Skip to content

Commit d09bad8

Browse files
feat: Waypoint on new IaaS (#2)
* moved project an setup next IaaS : Contabo * new packer * started CD/CI for packer * use terraform import to recover instance * nginx ingress enabled (traefik still available) * metallb * ready and functionnal waypoint in prod
1 parent 5b5337d commit d09bad8

File tree

90 files changed

+1460
-4053
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1460
-4053
lines changed

.editorconfig

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
[*]
7+
indent_style = space
8+
indent_size = 4
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = false
12+
insert_final_newline = false
13+
14+
[*.{yml,yaml,yml.*,yaml.*}]
15+
indent_size = 2
16+
17+
[*.sh]
18+
end_of_line = lf
19+
20+
[Makefile]
21+
indent_style = tab

.github/workflows/release.yml .github/workflows/release-helm.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- main
77
paths:
88
- 'charts/**'
9-
- .github/workflows/release.yml
9+
- .github/workflows/release-helm.yml
1010

1111
permissions:
1212
contents: write

.github/workflows/release-packer.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: hcp-packer
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- 'playbook/**'
8+
- 'packer/**'
9+
- .github/workflows/release-packer.yml
10+
jobs:
11+
gh-release-packer:
12+
runs-on: ubuntu-latest
13+
name: Run Packer
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
- name: Setup `packer`
18+
uses: hashicorp/setup-packer@main
19+
id: setup
20+
with:
21+
version: "1.8.6"
22+
23+
- name: Set outputs
24+
id: vars
25+
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
26+
27+
- name: Run `packer init`
28+
id: init
29+
run: "packer init ubuntu.pkr.hcl"
30+
working-directory: packer
31+
env:
32+
PKR_VAR_ssh_password: ${{ secrets.PKR_VAR_SSH_PASSWORD }}
33+
PKR_VAR_ssh_password_hash: ${{ secrets.PKR_VAR_SSH_PASSWORD_HASH }}
34+
35+
- name: Run `packer validate`
36+
id: validate
37+
run: >-
38+
packer validate \
39+
-var-file "$(uname -ms | tr ' ' '-')-host.hcl" \
40+
-var-file=secrets.pkrvars.hcl ubuntu.pkr.hcl
41+
working-directory: packer
42+
env:
43+
PKR_VAR_ssh_password: ${{ secrets.PKR_VAR_SSH_PASSWORD }}
44+
PKR_VAR_ssh_password_hash: ${{ secrets.PKR_VAR_SSH_PASSWORD_HASH }}
45+
46+
- name: Build Artifact
47+
run: >-
48+
packer build \
49+
-var-file "$(uname -ms | tr ' ' '-')-host.hcl" \
50+
ubuntu.pkr.hcl
51+
working-directory: packer
52+
env:
53+
PKR_VAR_ssh_password: ${{ secrets.PKR_VAR_SSH_PASSWORD }}
54+
PKR_VAR_ssh_password_hash: ${{ secrets.PKR_VAR_SSH_PASSWORD_HASH }}
55+
56+
- uses: "marvinpinto/action-automatic-releases@latest"
57+
with:
58+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
59+
automatic_release_tag: ubuntu-jammy-${{ steps.vars.outputs.sha_short }}
60+
prerelease: true
61+
files: |
62+
packer/.qemu-vm/ubuntu-jammy-22.04.2.qcow2
63+
packer/.qemu-vm/SHA256SUMS

.github/workflows/test-packer.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: test-packer
2+
on:
3+
pull_request:
4+
paths:
5+
- 'playbook/**'
6+
- 'packer/**'
7+
- .github/workflows/test-packer.yml
8+
jobs:
9+
gh-release-packer:
10+
runs-on: ubuntu-latest
11+
name: Run Packer
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
- name: Setup `packer`
16+
uses: hashicorp/setup-packer@main
17+
id: setup
18+
with:
19+
version: "1.8.6"
20+
21+
- name: Set outputs
22+
id: vars
23+
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
24+
25+
- name: Run `packer init`
26+
id: init
27+
run: "packer init ubuntu.pkr.hcl"
28+
working-directory: packer
29+
env:
30+
PKR_VAR_ssh_password: ${{ secrets.PKR_VAR_SSH_PASSWORD }}
31+
PKR_VAR_ssh_password_hash: ${{ secrets.PKR_VAR_SSH_PASSWORD_HASH }}
32+
33+
- name: Run `packer validate`
34+
id: validate
35+
run: >-
36+
packer validate \
37+
-var-file "$(uname -ms | tr ' ' '-')-host.hcl" \
38+
ubuntu.pkr.hcl
39+
working-directory: packer
40+
env:
41+
PKR_VAR_ssh_password: ${{ secrets.PKR_VAR_SSH_PASSWORD }}
42+
PKR_VAR_ssh_password_hash: ${{ secrets.PKR_VAR_SSH_PASSWORD_HASH }}

.vscode/extensions.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
"szTheory.vscode-packer-powertools",
88
"ms-azuretools.vscode-azureterraform",
99
"HashiCorp.terraform",
10-
"valentjn.vscode-ltex"
10+
"valentjn.vscode-ltex",
11+
"ms-python.python",
12+
"4ops.packer"
1113
]
1214
}

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
# Paas Tutorial
1+
# K3s PaaS
22

3-
[Documentation](https://esgi-lyon.github.io/paas-tutorial)
3+
> Taken From [original tutorial](https://esgi-lyon.github.io/paas-tutorial/)
4+
5+
[Documentation](docs/index.md)

charts/microservice/values.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ ingress:
6868
enabled: false
6969
className: ""
7070
annotations:
71-
kubernetes.io/ingress.class: traefik
71+
kubernetes.io/ingress.class: nginx
7272
cert-manager.io/cluster-issuer: letsencrypt-acme-issuer
7373
hosts:
74-
- host: client.k3s.local
74+
- host: client.k3s.test
7575
paths:
7676
- path: /
7777
pathType: ImplementationSpecific
7878
tls: []
79-
# - secretName: client.k3s.local-tls
79+
# - secretName: client.k3s.test-tls
8080
# hosts:
81-
# - client.k3s.local
81+
# - client.k3s.test
8282

8383
resources: {}
8484
# We usually recommend not to specify default resources and to leave this as a conscious

infra/.gitignore contabo/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ override.tf.json
3131

3232
# Ignore CLI configuration files
3333
.terraformrc
34-
terraform.rc
34+
terraform.rc

infra/.terraform.lock.hcl contabo/.terraform.lock.hcl

+35-52
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contabo/Makefile

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
VAR_FILE?=prod.tfvars
2+
SHELL:=/bin/bash
3+
4+
read_tfvar=$(shell grep $1 prod.tfvars | cut -d'=' -f2 | tr -d ' ' | tr -d \")
5+
6+
CLIENT_ID:=$(call read_tfvar,oauth2_client_id)
7+
CLIENT_SECRET:=$(call read_tfvar,oauth2_client_secret)
8+
API_USER:=$(call read_tfvar,oauth2_user)
9+
API_PASSWORD:=$(call read_tfvar,oauth2_pass)
10+
INSTANCE_ID:=$(call read_tfvar,contabo_instance)
11+
12+
.DEFAULT_GOAL := help
13+
14+
help:
15+
@echo "Contabo tf simple helpers"
16+
@echo "Instance setup $(INSTANCE_ID)"
17+
18+
setup_cntb:
19+
cntb config set-credentials --oauth2-clientid="$(CLIENT_ID)" \
20+
--oauth2-client-secret="$(CLIENT_SECRET)" --oauth2-user="$(API_USER)" \
21+
--oauth2-password="$(API_PASSWORD)"
22+
23+
destroy:
24+
terraform destroy -var-file=$(VAR_FILE) -auto-approve
25+
26+
# Run it if starting from empty infra
27+
apply:
28+
terraform import -var-file=$(VAR_FILE) contabo_instance.paas_instance $(INSTANCE_ID)
29+
terraform apply -var-file=$(VAR_FILE) -auto-approve
30+
31+
read_tfvar:
32+
$(call read_tfvar contabo_instance)

infra/data.tf contabo/data.tf

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
data "azurerm_resource_group" "paas" {
2-
name = "kubeapps-group"
3-
}
4-
5-
data "azurerm_image" "search" {
6-
name = "k3s-pre-paas-az-arm"
7-
resource_group_name = data.azurerm_resource_group.paas.name
8-
}
9-
10-
data "azurerm_client_config" "current" {}
11-
data "azurerm_subscription" "primary" {}
12-
131
data "github_organization" "org" {
142
name = var.github_organization
153
}
@@ -26,3 +14,7 @@ data "github_membership" "all_admin" {
2614
}
2715
username = each.value.username
2816
}
17+
18+
data "contabo_instance" "paas_instance" {
19+
id = var.contabo_instance
20+
}

infra/exemple.tfvars.dist contabo/exemple.tfvars.dist

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
tenant_id="00000000-0000-0000-0000-000000000000"
21
github_organization = "github-team"
32
github_team = "ops-team"
43
domain = "paas-esgi-tutorial.live"
54
namedotcom_username = "username"
65
namedotcom_token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa"
76
github_token = "ghp_aaaaaaaaaaaaaaaaaaxxxxxxxxxxxx"
87

8+
contabo_instance = "XXXXXXXXX"
9+
oauth2_client_id = "INT-XXXXX"
10+
oauth2_client_secret = "XXXXXXX-xXXX-XXXX-XXX-XXXXXXXXX"
11+
oauth2_user = "[email protected]"
12+
oauth2_pass = "password"
13+
914
secrets = {
1015
dex_github_client_id = "dex-github-oauth2-app-client-id"
1116
dex_github_client_secret = "dex-github-oauth2-app-client-secret"

0 commit comments

Comments
 (0)