git.iko.soy/typeable/octopod
on master help sign in
Helm3 chart fixes (#64)

* new generic utils * fix scheme in notes and ingresses + values for generic scripts * move migrations to init containers * new generic utils * fix scheme in notes and ingresses + values for generic scripts * move migrations to init containers * fix versions * update readme * emphasize some parts of readme * remove chart beta warning * add future version of octopod to the chart * Update charts/helm3/octopod/README.md Co-authored-by: iko <ilyakooo0@gmail.com> * Update charts/helm3/octopod/README.md Co-authored-by: iko <ilyakooo0@gmail.com> * add an ability to have a fixed secret for ui basic auth * dont ask for cliauth header if vault is enabled * add readme section about ui auth * Refined wording Co-authored-by: iko <ilyakooo0@gmail.com>

commite2c109213b3691434b147de24dbae57ba360f4a0 authorAlex-Sizov <45825279+Alex-Sizov@users.noreply.github.com> dateMon 23 Aug 2021, 16:42 (5 years ago) parent648e654
10 files changed+102−110
charts/helm3/octopod/Chart.yaml+2−2 charts/helm3/octopod/README.md+17−22 charts/helm3/octopod/templates/NOTES.txt+3−3 charts/helm3/octopod/templates/_helpers.tpl+8 charts/helm3/octopod/templates/deployment.yaml+56 charts/helm3/octopod/templates/ingress-app.yaml+1−1 charts/helm3/octopod/templates/ingress-powerapp.yaml+1−1 charts/helm3/octopod/templates/migration-job.yaml−77 charts/helm3/octopod/templates/nginx-configmap.yaml+1−1 charts/helm3/octopod/values.yaml+13−3
charts/helm3/octopod/Chart.yaml+2−2
@@ -2,8 +2,8 @@ apiVersion: v2
22name: octopod
33description: An opensource self-hosted solution for managing multiple deployments in a Kubernetes cluster.
44type: application
5−version: 0.4.0
6−appVersion: 1.3
5+version: 0.5.0
6+appVersion: 1.3.1
77keywords:
88 - kubernetes
99 - octopod
charts/helm3/octopod/README.md+17−22
@@ -1,14 +1,12 @@
11# Octopod
22
3−### This is beta version of a chart!
4−
53[Octopod](https://octopod.site/) is a fully open-source self-hosted solution for managing multiple deployments in a Kubernetes cluster with a user-friendly web interface. Managing deployments does not require any technical expertise.
64
75## TL;DR
86```console
9−helm repo add typeable https://typeable.github.io/octopod/
10−kubectl create ns octopod-deployment
11−helm install octopod typeable/octopod --set octopod.baseDomain="your-domain.com"
7+$ helm repo add typeable https://typeable.github.io/octopod/
8+$ kubectl create ns octopod-deployment
9+$ helm install octopod typeable/octopod --set octopod.baseDomain="your-domain.com"
1210```
1311
1412## Introduction
@@ -33,27 +31,12 @@ Second in which Octopod will deploy all it's deployments (configured in octopod.
3331```console
3432$ kubectl create namespace octopod-deployments
3533```
36−Also you need to generate certificates for octo client<->octopod server communication.
37−
38−Generate certificates
39−```bash
40−mkdir certs
41−cd certs && \
42−openssl req -x509 -newkey rsa:4096 -keyout server_key.pem -out server_cert.pem -nodes -subj "/CN=localhost/O=Server" && \
43−openssl req -newkey rsa:4096 -keyout client_key.pem -out client_csr.pem -nodes -subj "/CN=Client" && \
44−openssl x509 -req -in client_csr.pem -CA server_cert.pem -CAkey server_key.pem -out client_cert.pem -set_serial 01 -days 3650
45−
46−```
47−Create configmap from generated certificates
48−```console
49−kubectl create configmap octopod-certs -n octopod --from-file=./certs
50−```
51−Name for configmap is cofigured in octopod.certsConfigMapName
34+
5235To install the chart with the release name `my-release` from current directory execute:
5336
5437```console
5538$ helm repo add typeable https://typeable.github.io/octopod/
56−# helm -n octopod install my-release typeable/octopod
39+$ helm -n octopod install my-release typeable/octopod --set octopod.baseDomain="your-domain.com"
5740```
5841
5942The command deploys Octopod on the Kubernetes cluster in the default configuration inside octopod namespace. The [Parameters](#parameters) section lists the parameters that can be configured during installation.
@@ -68,6 +51,17 @@ $ helm -n octopod delete my-release
6851
6952The command removes all the Kubernetes components but PVC's associated with the postgres chart and deletes the release.
7053
54+## Note about generated values
55+Some values (such as passwords) in this chart (and its dependencies) are generated automatically, but due to [a limitation in helm](https://github.com/helm/charts/issues/5167) the values are changing on every upgrade. To prevent this you must fix these values by providing them via `--set` flags or in the [values file](https://helm.sh/docs/chart_template_guide/values_files/).
56+
57+These values are:
58+- `postgresql.postgresqlPassword` - main db password
59+- `postgresql.postgresqlPostgresPassword` - password for "postgres" user
60+- `octopod.cliAuthSecret` - auth header for octo cli tool
61+- `octopod.uiAuthSecret` - basic auth secret for ui->octopod communication
62+
63+Note: if these values are not provided, the `helm upgrade` command can fail or Octopod will not work after the upgrade.
64+
7165## Parameters
7266
7367The following tables lists the configurable parameters of the Octopod chart and their default values.
@@ -102,6 +96,7 @@ The following tables lists the configurable parameters of the Octopod chart and
10296| octopod.archiveRetention | int | `1209600` | |
10397| octopod.baseDomain | string | `""` | Domain that will be used as a ase for Octopod deploymets and ingress hosts|
10498| octopod.cliAuthSecret | string | `nil` | Auth Header for accessing octopod using octo CLI |
99+| octopod.uiAuthSecret | string | `nil` | Basic auth secret for securing communcation between octopod UI and backend API |
105100| octopod.deploymentNamespace | string | `"octopod-deployment"` | Name of a namespace which will be used for all Octopod deployments (you need to create it yourself) |
106101| octopod.env | object | `{}` | key value map for supplying additional environment variables for octopod or your control scripts |
107102| octopod.migrations.enabled | bool | `true` | Enable or not automatic DB schema migrations |
charts/helm3/octopod/templates/NOTES.txt+3−3
@@ -1,8 +1,8 @@
11Thank you for installing Octopod!
2−You can access UI here: https://{{ include "uiIngressHost" . }}
3−To access octopod via octo CLI you can use this url https://{{ include "powerAppIngressHost" . }}
2+You can access UI here: {{ include "httpScheme" . }}://{{ include "uiIngressHost" . }}
3+To access octopod via octo CLI you can use this url {{ include "httpScheme" . }}://{{ include "powerAppIngressHost" . }}
44To get you CLI secret you need to execute this command:
55 kubectl -n {{ .Release.Namespace }} get secret {{ include "octopodCliAuthSecretName" . }} -o jsonpath='{.data.cli-secret}' | base64 -d
6−{{ if and (not .Values.octopod.cliAuthSecret) .Release.IsUpgrade }}
6+{{ if and (not .Values.octopod.cliAuthSecret) (not .Values.vault.enabled) .Release.IsUpgrade }}
77{{ fail "To upgrade you need to set octopod.cliAuthSecret variable with your current secret" }}
88{{- end }}
charts/helm3/octopod/templates/_helpers.tpl+8
@@ -135,4 +135,12 @@ octopod-app.{{ .Values.octopod.baseDomain }}
135135{{- else }}
136136{{- randAlphaNum 32 }}
137137{{- end }}
138+{{- end }}
139+
140+{{- define "octopodUiAuthSecret" -}}
141+{{- if .Values.octopod.uiAuthSecret -}}
142+{{ .Values.octopod.uiAuthSecret }}
143+{{- else }}
144+{{- randAlphaNum 32 }}
145+{{- end }}
138146{{- end }}
charts/helm3/octopod/templates/deployment.yaml+56
@@ -45,6 +45,60 @@ spec:
4545 securityContext:
4646 {{- toYaml .Values.podSecurityContext | nindent 8 }}
4747 initContainers:
48+ - name: copy-migrations
49+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
50+ command:
51+ - "bash"
52+ - "-ec"
53+ - |
54+ set -ex
55+
56+ # copy migrations
57+ cp -av /migrations/* /mymigrations
58+
59+ # create sqitch.conf
60+ echo '[core]' > /mymigrations/sqitch.conf
61+ echo 'engine = pg' >> /mymigrations/sqitch.conf
62+ echo 'plan_file = sqitch.plan' >> /mymigrations/sqitch.conf
63+ echo 'top_dir = .' >> /mymigrations/sqitch.conf
64+ echo '[engine "pg"]' >> /mymigrations/sqitch.conf
65+ echo ' registry = sqitch' >> /mymigrations/sqitch.conf
66+ echo '[deploy]' >> /mymigrations/sqitch.conf
67+ echo ' verify = true' >> /mymigrations/sqitch.conf
68+ echo '[rebase]' >> /mymigrations/sqitch.conf
69+ echo ' verify = true' >> /mymigrations/sqitch.conf
70+ echo '[target "octopod"]' >> /mymigrations/sqitch.conf
71+ echo 'uri = db:pg://{{ .Values.postgresql.postgresqlUsername }}:$(PG_PASS)@{{ include "postgresqlHost" . }}/{{ .Values.postgresql.postgresqlDatabase }}' >> /mymigrations/sqitch.conf
72+ env:
73+ - name: PG_PASS
74+ valueFrom:
75+ secretKeyRef:
76+ name: {{ include "postgresqlSecretName" . }}
77+ key: postgresql-password
78+ volumeMounts:
79+ - name: migrations
80+ mountPath: /mymigrations
81+ - name: run-migrations
82+ image: "{{ .Values.sqitch.image.repository }}:{{ .Values.sqitch.image.tag }}"
83+ command:
84+ - "bash"
85+ - "-c"
86+ - |
87+ set -x
88+ echo 'checking connection to postgresql...'
89+ for i in $(seq 1 6); do psql "postgres://{{ .Values.postgresql.postgresqlUsername }}:$(PG_PASS)@{{ include "postgresqlHost" . }}/{{ .Values.postgresql.postgresqlDatabase }}" -c ''; if [ $? -eq 0 ]; then break; fi; sleep 10; done
90+ set -e
91+ echo 'run migrations...'
92+ cd /migrations && /usr/local/bin/sqitch deploy octopod
93+ env:
94+ - name: PG_PASS
95+ valueFrom:
96+ secretKeyRef:
97+ name: {{ include "postgresqlSecretName" . }}
98+ key: postgresql-password
99+ volumeMounts:
100+ - name: migrations
101+ mountPath: /migrations
48102 - name: copy-control-scripts
49103 image: "{{ .Values.controlScripts.image.repository }}:{{ .Values.controlScripts.image.tag }}"
50104 imagePullPolicy: {{ .Values.controlScripts.image.pullPolicy }}
@@ -179,6 +233,8 @@ spec:
179233 emptyDir: {}
180234 - name: www
181235 emptyDir: {}
236+ - name: migrations
237+ emptyDir: {}
182238 - name: nginx-config
183239 configMap:
184240 name: {{ include "octopod.fullname" . }}-nginx-config
charts/helm3/octopod/templates/ingress-app.yaml+1−1
@@ -24,7 +24,7 @@ metadata:
2424 nginx.ingress.kubernetes.io/auth-secret-type: auth-file
2525 nginx.ingress.kubernetes.io/auth-type: basic
2626 nginx.ingress.kubernetes.io/enable-cors: "true"
27− nginx.ingress.kubernetes.io/cors-allow-origin: {{ printf "%s://%s" (include "httpScheme" .) .Values.ingress.ui.host | quote }}
27+ nginx.ingress.kubernetes.io/cors-allow-origin: {{ printf "%s://%s" (include "httpScheme" .) (include "uiIngressHost" .) | quote }}
2828 nginx.ingress.kubernetes.io/cors-allow-methods: "GET, POST, PUT, DELETE, PATCH, OPTIONS"
2929 {{- with .Values.ingress.app.annotations }}
3030 {{- toYaml . | nindent 4 }}
charts/helm3/octopod/templates/ingress-powerapp.yaml+1−1
@@ -24,7 +24,7 @@ metadata:
2424 {{- toYaml . | nindent 4 }}
2525 {{- end }}
2626spec:
27− {{- if .Values.ingress.tls }}
27+ {{- if .Values.ingress.tls.enabled }}
2828 tls:
2929 - hosts:
3030 - {{ include "powerAppIngressHost" . }}
charts/helm3/octopod/templates/migration-job.yamldeleted−77
@@ -1,77 +0,0 @@
1−{{- if .Values.octopod.migrations.enabled }}
2−apiVersion: batch/v1
3−kind: Job
4−metadata:
5− name: {{ include "octopod.fullname" . }}-migrations
6− labels:
7− {{- include "octopod.labels" . | nindent 4 }}
8− annotations:
9− "helm.sh/hook": post-install,post-upgrade
10− "helm.sh/hook-delete-policy": hook-succeeded
11−spec:
12− activeDeadlineSeconds: 600
13− template:
14− spec:
15− initContainers:
16− - name: copy
17− image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
18− command:
19− - "bash"
20− - "-ec"
21− - |
22− set -ex
23−
24− # copy migrations
25− cp -av /migrations/* /mymigrations
26−
27− # create sqitch.conf
28− echo '[core]' > /mymigrations/sqitch.conf
29− echo 'engine = pg' >> /mymigrations/sqitch.conf
30− echo 'plan_file = sqitch.plan' >> /mymigrations/sqitch.conf
31− echo 'top_dir = .' >> /mymigrations/sqitch.conf
32− echo '[engine "pg"]' >> /mymigrations/sqitch.conf
33− echo ' registry = sqitch' >> /mymigrations/sqitch.conf
34− echo '[deploy]' >> /mymigrations/sqitch.conf
35− echo ' verify = true' >> /mymigrations/sqitch.conf
36− echo '[rebase]' >> /mymigrations/sqitch.conf
37− echo ' verify = true' >> /mymigrations/sqitch.conf
38− echo '[target "octopod"]' >> /mymigrations/sqitch.conf
39− echo 'uri = db:pg://{{ .Values.postgresql.postgresqlUsername }}:$(PG_PASS)@{{ include "postgresqlHost" . }}/{{ .Values.postgresql.postgresqlDatabase }}' >> /mymigrations/sqitch.conf
40− env:
41− - name: PG_PASS
42− valueFrom:
43− secretKeyRef:
44− name: {{ include "postgresqlSecretName" . }}
45− key: postgresql-password
46− volumeMounts:
47− - name: migrations
48− mountPath: /mymigrations
49− containers:
50− - name: migrations
51− image: "{{ .Values.sqitch.image.repository }}:{{ .Values.sqitch.image.tag }}"
52− command:
53− - "bash"
54− - "-c"
55− - |
56− set -x
57− echo 'checking connection to postgresql...'
58− for i in $(seq 1 6); do psql "postgres://{{ .Values.postgresql.postgresqlUsername }}:$(PG_PASS)@{{ include "postgresqlHost" . }}/{{ .Values.postgresql.postgresqlDatabase }}" -c ''; if [ $? -eq 0 ]; then break; fi; sleep 10; done
59− set -e
60− echo 'run migrations...'
61− cd /migrations && /usr/local/bin/sqitch deploy octopod
62− env:
63− - name: PG_PASS
64− valueFrom:
65− secretKeyRef:
66− name: {{ include "postgresqlSecretName" . }}
67− key: postgresql-password
68− volumeMounts:
69− - name: migrations
70− mountPath: /migrations
71−
72− volumes:
73− - name: migrations
74− emptyDir: {}
75− restartPolicy: Never
76− backoffLimit: 3
77−{{- end }}
charts/helm3/octopod/templates/nginx-configmap.yaml+1−1
@@ -1,4 +1,4 @@
1−{{- $octopodAppAuthPassword := randAlphaNum 32 -}}
1+{{- $octopodAppAuthPassword := include "octopodUiAuthSecret" . -}}
22apiVersion: v1
33kind: ConfigMap
44metadata:
charts/helm3/octopod/values.yaml+13−3
@@ -83,13 +83,23 @@ octopod:
8383 archiveRetention: 1209600
8484 migrations:
8585 enabled: true
86− env: {}
86+ env:
87+ HELM_BIN: "/utils/helm"
88+ KUBECTL_BIN: "/utils/kubectl"
89+ DEFAULTS: |
90+ {
91+ "chart_name": "wordpress",
92+ "chart_repo_name": "bitnami",
93+ "chart_repo_url": "https://charts.bitnami.com/bitnami",
94+ "chart_version": "12.0.0",
95+ "default_overrides": []
96+ }
8797 vaultEnv: {}
8898controlScripts:
8999 image:
90− repository: typeable/octopod-helm-example
100+ repository: typeable/octopod-generic-utils
91101 pullPolicy: IfNotPresent
92− tag: 1.1
102+ tag: 0.1.0
93103sqitch:
94104 image:
95105 repository: typeable/sqitch