diff --git a/.gitignore b/.gitignore index 769e3a7..748794d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -/kubernetes/config/ +/kubernetes/custom/config/ diff --git a/kubernetes/config/.gitkeep b/kubernetes/custom/config/.gitkeep similarity index 100% rename from kubernetes/config/.gitkeep rename to kubernetes/custom/config/.gitkeep diff --git a/custom/options/label/Default b/kubernetes/custom/options/label/Default similarity index 100% rename from custom/options/label/Default rename to kubernetes/custom/options/label/Default diff --git a/custom/options/label/Kosmos b/kubernetes/custom/options/label/Kosmos similarity index 100% rename from custom/options/label/Kosmos rename to kubernetes/custom/options/label/Kosmos diff --git a/kubernetes/gitea-server.yaml b/kubernetes/gitea-server.yaml index 61ad820..90eb3d5 100644 --- a/kubernetes/gitea-server.yaml +++ b/kubernetes/gitea-server.yaml @@ -15,16 +15,21 @@ spec: initContainers: - name: init-config image: busybox - command: ['sh', '-c', 'mkdir -p /data/gitea/conf && mkdir -p /data/gitea/https && cp /root/conf/app.ini /data/gitea/conf/app.ini && chown 1000:1000 /data/gitea/conf/app.ini && chmod 660 /data/gitea/conf/app.ini && cp /root/conf/*.pem /data/gitea/https && chmod 600 /data/gitea/https/*.pem && chown -R 1000:1000 /data/gitea'] + command: [ + 'sh', '-c', + 'mkdir -p /data/gitea/conf && mkdir -p /data/gitea/https && mkdir -p /data/gitea/options/label && cp /root/conf/app.ini /data/gitea/conf/app.ini && chown 1000:1000 /data/gitea/conf/app.ini && chmod 660 /data/gitea/conf/app.ini && cp /root/conf/*.pem /data/gitea/https && chmod 600 /data/gitea/https/*.pem && cp /root/options/label/* /data/gitea/options/label/ && chown -R 1000:1000 /data/gitea' + ] volumeMounts: - mountPath: /data name: gitea-server-data - mountPath: /root/conf name: config + # The labels have been created as a ConfigMap from local files using this command: + # + # kubectl create configmap gitea-options-label --from-file=custom/options/label/ + - mountPath: /root/options/label + name: label containers: - # This is only used for the initial setup, it does nothing once a app.ini - # file exists in the conf/ directory of the data directory - # (/data/gitea/conf in our case) - name: gitea-server image: gitea/gitea:1.7.1 ports: @@ -52,6 +57,9 @@ spec: - key: key.pem path: key.pem mode: 256 + - name: label + configMap: + name: gitea-options-label --- apiVersion: v1 kind: PersistentVolumeClaim diff --git a/script/get_secrets b/script/get_secrets index 0a7dcc2..310929c 100755 --- a/script/get_secrets +++ b/script/get_secrets @@ -7,7 +7,7 @@ secret = `kubectl get secret gitea-config -o yaml` yaml = YAML.load(secret) yaml['data'].each do |key, data| - filename = File.join('kubernetes', 'config', key) + filename = File.join('kubernetes', 'custom', 'config', key) File.open(filename, "w+") do |f| puts "Writing #{filename}" f.write Base64.decode64(data) diff --git a/script/replace_secrets b/script/replace_secrets index 2a3de09..c2ef0cf 100755 --- a/script/replace_secrets +++ b/script/replace_secrets @@ -2,8 +2,8 @@ # Delete the gitea-config secrets kubectl delete secret gitea-config -# Replace it from the local files in kubernetes/config/* (acquired by running +# Replace it from the local files in kubernetes/custom/config/* (acquired by running # ./script/get_secrets) -kubectl create secret generic gitea-config --from-file=cert.pem=kubernetes/config/cert.pem --from-file=key.pem=kubernetes/config/key.pem --from-file=app.ini=kubernetes/config/app.ini +kubectl create secret generic gitea-config --from-file=cert.pem=kubernetes/custom/config/cert.pem --from-file=key.pem=kubernetes/custom/config/key.pem --from-file=app.ini=kubernetes/custom/config/app.ini # Force the pod to restart by patching the deployment resource kubectl patch deployment gitea-server -p "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"date\":\"`date +'%s'`\"}}}}}"