Skip to content

Commit d0a911f

Browse files
♻️ k8s: Introduce Namespaces + Cleanups (#836)
* wip * wip * wip * wip * Update charts/Makefile Co-authored-by: Yury Hrytsuk <[email protected]> * fix typo * Change suggestions @YuryHrytsuk * Add web entrypoint again --------- Co-authored-by: Dustin Kaiser <[email protected]> Co-authored-by: Yury Hrytsuk <[email protected]>
1 parent a3977a4 commit d0a911f

File tree

7 files changed

+62
-25
lines changed

7 files changed

+62
-25
lines changed

charts/Makefile

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,67 @@ CONFIG_DIR := $(shell dirname $(REPO_CONFIG_LOCATION))
77
CHART_DIRS := $(wildcard $(REPO_BASE_DIR)/charts/*/)
88

99
.PHONY: .check-helmfile-installed
10-
.check-helmfile-installed:
10+
.check-helmfile-installed: ## Checks if helmfile is installed
1111
@if ! command -v helmfile >/dev/null 2>&1; then \
1212
echo "'helmfile' is not installed. Install it to continue ...";\
1313
fi
1414

15-
helmfile.yaml: simcore-charts/helmfile.yaml
15+
helmfile.yaml: simcore-charts/helmfile.yaml ## Copies the helmfile.yaml to the charts directory
1616
cp $(CONFIG_DIR)/$@ $(REPO_BASE_DIR)/charts/helmfile.yaml
1717

18-
simcore-charts/helmfile.yaml:
18+
simcore-charts/helmfile.yaml: ## Copies the simcore helmfile to the charts directory
1919
cp $(CONFIG_DIR)/helmfile.simcore.yaml $(REPO_BASE_DIR)/charts/$@
2020

2121
.PHONY: helmfile-lint
22-
helmfile-lint: .check-helmfile-installed helmfile.yaml
22+
helmfile-lint: .check-helmfile-installed helmfile.yaml ## Lints the helmfile
2323
set -a; source $(REPO_CONFIG_LOCATION); set +a; \
2424
helmfile lint
2525

2626
.PHONY: .helmfile-local-post-install
27-
.helmfile-local-post-install:
27+
.helmfile-local-post-install: ## Post install steps for local helmfile deployment
2828
@$(MAKE) -s configure-local-hosts
2929
@echo "";
30-
@echo "Cluster has been deployed locally: http://$(MACHINE_FQDN)";
30+
@echo "Cluster has been deployed locally: https://$(MACHINE_FQDN)";
3131
@echo " For secure connections self-signed certificates are used.";
32-
@echo " Install their root-ca certificate in your system for smooth experience.";
33-
@echo " For insecure connections make sure to disable automatic https redirects in your browser.";
32+
@echo "";
3433

3534
.PHONY: helmfile-apply
36-
helmfile-apply: .check-helmfile-installed helmfile.yaml
35+
helmfile-apply: .check-helmfile-installed helmfile.yaml ## Applies the helmfile configuration
3736
set -a; source $(REPO_CONFIG_LOCATION); set +a; \
3837
helmfile -f $(REPO_BASE_DIR)/charts/helmfile.yaml apply
3938

4039
@if [ "$(MACHINE_FQDN)" = "osparc.local" ]; then \
4140
$(MAKE) -s .helmfile-local-post-install; \
4241
fi
4342

43+
.PHONY: helmfile-sync
44+
helmfile-sync: .check-helmfile-installed helmfile.yaml ## Syncs the helmfile configuration (use `helmfile-apply` to deploy the app)
45+
set -a; source $(REPO_CONFIG_LOCATION); set +a; \
46+
helmfile -f $(REPO_BASE_DIR)/charts/helmfile.yaml sync
47+
48+
@if [ "$(MACHINE_FQDN)" = "osparc.local" ]; then \
49+
$(MAKE) -s .helmfile-local-post-install; \
50+
fi
51+
52+
4453
.PHONY: configure-local-hosts
45-
configure-local-hosts:
46-
@echo "Addings $(MACHINE_FQDN) hosts to /etc/hosts ..."
54+
configure-local-hosts: ## Adds local hosts entries for the machine
55+
@echo "Adding $(MACHINE_FQDN) hosts to /etc/hosts ..."
4756
@grep -q '127.0.0.1 k8s.monitoring.$(MACHINE_FQDN)' /etc/hosts || echo '127.0.0.1 k8s.monitoring.$(MACHINE_FQDN)' | sudo tee -a /etc/hosts
4857

4958
.PHONY: helmfile-diff
50-
helmfile-diff: .check-helmfile-installed helmfile.yaml
59+
helmfile-diff: .check-helmfile-installed helmfile.yaml ## Shows the differences that would be applied by helmfile
5160
@set -a; source $(REPO_CONFIG_LOCATION); set +a; \
5261
helmfile -f $(REPO_BASE_DIR)/charts/helmfile.yaml diff
5362

5463
.PHONY: helmfile-delete
55-
helmfile-delete: .check-helmfile-installed helmfile.yaml
64+
helmfile-delete: .check-helmfile-installed helmfile.yaml ## Deletes the helmfile configuration
5665
@set -a; source $(REPO_CONFIG_LOCATION); set +a; \
5766
helmfile -f $(REPO_BASE_DIR)/charts/helmfile.yaml delete
67+
68+
.PHONY: up
69+
up: helmfile-apply ## Start the stack
70+
71+
.PHONY: leave
72+
leave: ## Leaves kind cluster
73+
kind delete clusters kind

charts/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ source: https://kind.sigs.k8s.io/docs/user/quick-start
2323

2424
Follow the instructions here: https://helm.sh/docs/intro/install/
2525

26+
Install the helm-diff plugin: `helm plugin install https://github.com/databus23/helm-diff`
27+
28+
`via https://doc.traefik.io/traefik/user-guides/crd-acme/#ingressroute-definition`
29+
Install traefik-v3 CRDs: `kubectl apply -f https://raw.githubusercontent.com/traefik/traefik/v3.1/docs/content/reference/dynamic-configuration/kubernetes-crd-definition-v1.yml`
30+
31+
`via https://doc.traefik.io/traefik/user-guides/crd-acme/#ingressroute-definition`
32+
Install traefik-v3 RBAC: `kubectl apply -f https://raw.githubusercontent.com/traefik/traefik/v3.1/docs/content/reference/dynamic-configuration/kubernetes-crd-rbac.yml`
33+
2634
#### helmfile
2735

2836
If you have a different OS / architecture, pick a different link from [release artifacts](https://github.com/helmfile/helmfile/releases)

charts/adminer/values.yaml.gotmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ ingress:
4949
enabled: true
5050
className: ""
5151
annotations:
52+
namespace: {{ .Release.Namespace }}
5253
cert-manager.io/cluster-issuer: "cert-issuer"
5354
traefik.ingress.kubernetes.io/router.entrypoints: websecure
5455
tls:

charts/cert-manager/values.selfsigned.yaml.gotmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ extraObjects:
2222
"helm.sh/hook": post-install,post-upgrade
2323
"helm.sh/hook-weight": "1"
2424
spec:
25+
secretTemplate:
26+
annotations:
27+
reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
28+
reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "" # Control destination namespaces: emptystring means all
29+
reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true" # Auto create reflection for matching namespaces
30+
reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "" # Control auto-reflection namespaces
2531
isCA: true
2632
commonName: local-ca
2733
subject:

charts/traefik/values.insecure.yaml.gotmpl

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ extraObjects:
33
kind: Service
44
metadata:
55
name: traefik-api
6+
namespace: {{.Release.Namespace}}
67
spec:
78
type: ClusterIP
89
selector:
910
app.kubernetes.io/name: traefik
10-
app.kubernetes.io/instance: traefik-default
11+
app.kubernetes.io/instance: {{.Release.Namespace}}-traefik
1112
ports:
1213
- port: 8080
1314
name: traefik
@@ -17,7 +18,7 @@ extraObjects:
1718
kind: Secret
1819
metadata:
1920
name: traefik-authorized-users
20-
namespace: default
21+
namespace: {{.Release.Namespace}}
2122
data:
2223
users: |2
2324
{{ requiredEnv "TRAEFIK_K8S_AUTHORIZED_USER" }}
@@ -32,16 +33,18 @@ extraObjects:
3233
kind: Ingress
3334
metadata:
3435
name: traefik-dashboard
36+
namespace: {{.Release.Namespace}}
3537
annotations:
3638
traefik.ingress.kubernetes.io/router.entrypoints: web,websecure # allow http(s) for local deployment
37-
traefik.ingress.kubernetes.io/router.middlewares: default-traefik-basic-auth@kubernetescrd # namespace + middleware name
39+
traefik.ingress.kubernetes.io/router.middlewares: {{.Release.Namespace}}-traefik-basic-auth@kubernetescrd # namespace + middleware name
40+
cert-manager.io/cluster-issuer: "cert-issuer"
3841
spec:
3942
tls:
40-
- hosts:
41-
- k8s.monitoring.{{ requiredEnv "MACHINE_FQDN" }}
42-
secretName: monitoring-tls
43+
- hosts:
44+
- {{ requiredEnv "K8S_MONITORING_FQDN" }}
45+
secretName: monitoring-tls
4346
rules:
44-
- host: k8s.monitoring.{{ requiredEnv "MACHINE_FQDN" }}
47+
- host: {{ requiredEnv "K8S_MONITORING_FQDN" }}
4548
http:
4649
paths:
4750
- path: /dashboard
@@ -51,7 +54,7 @@ extraObjects:
5154
name: traefik-api
5255
port:
5356
name: traefik
54-
- host: k8s.monitoring.{{ requiredEnv "MACHINE_FQDN" }}
57+
- host: {{ requiredEnv "K8S_MONITORING_FQDN" }}
5558
http:
5659
paths:
5760
- path: /api

charts/traefik/values.secure.yaml.gotmpl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ extraObjects:
1010
kind: Service
1111
metadata:
1212
name: traefik-api
13+
namespace: {{.Release.Namespace}}
1314
spec:
1415
type: ClusterIP
1516
selector:
1617
app.kubernetes.io/name: traefik
17-
app.kubernetes.io/instance: traefik-default
18+
app.kubernetes.io/instance: {{.Release.Namespace}}-traefik
1819
ports:
1920
- port: 8080
2021
name: traefik
@@ -25,7 +26,7 @@ extraObjects:
2526
kind: Secret
2627
metadata:
2728
name: traefik-authorized-users
28-
namespace: default
29+
namespace: {{.Release.Namespace}}
2930
data:
3031
users: |2
3132
{{ requiredEnv "TRAEFIK_K8S_AUTHORIZED_USER" }}
@@ -53,9 +54,11 @@ extraObjects:
5354
kind: Ingress
5455
metadata:
5556
name: traefik-dashboard
57+
namespace: {{.Release.Namespace}}
5658
annotations:
5759
traefik.ingress.kubernetes.io/router.entrypoints: websecure
58-
traefik.ingress.kubernetes.io/router.middlewares: default-traefik-basic-auth@kubernetescrd
60+
traefik.ingress.kubernetes.io/router.middlewares: {{.Release.Namespace}}-traefik-basic-auth@kubernetescrd # namespace + middleware name
61+
cert-manager.io/cluster-issuer: "cert-issuer"
5962
spec:
6063
tls:
6164
- hosts:

charts/traefik/values.webinternal.yaml.gotmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ ports:
99
http3:
1010
enabled: false
1111
middlewares:
12-
- default-internal-ipallowlist@kubernetescrd
12+
- {{.Release.Namespace}}-internal-ipallowlist@kubernetescrd

0 commit comments

Comments
 (0)