penguin/AstroJS

Javascript framework for my blog

commit a74f588640143e103fbde3e99b3c09b3f1b7bff3

author斟酌 鵬兄 <tgckpg@gmail.com>
date2024-10-31T21:08:49Z
subjectUse configmap instead of secrets
commit a74f588640143e103fbde3e99b3c09b3f1b7bff3
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2024-10-31T21:08:49Z

    Use configmap instead of secrets
---
 .gitignore                                  |  1 +
 concourse/prepare-deployment-resources.yaml |  2 ++
 k8s/configmap.yaml                          | 25 +++++++++++++++++++++++++
 k8s/deployments.yaml                        |  4 ++--
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index fff347a..7ff9941 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+.DS_Store
 *~
 *.swp
 *.pyc
diff --git a/concourse/prepare-deployment-resources.yaml b/concourse/prepare-deployment-resources.yaml
index ab371da..49b63fa 100644
--- a/concourse/prepare-deployment-resources.yaml
+++ b/concourse/prepare-deployment-resources.yaml
@@ -18,4 +18,6 @@ run:
     - -exc
     - |
       VERSION=$( cat commit.sha )
+      cat k8s/configmap.yaml >> deploy-confs/prod.yaml
+      echo "---"
       sed "s/IMAGE_TAG/$VERSION/g" k8s/deployments.yaml >> deploy-confs/prod.yaml
diff --git a/k8s/configmap.yaml b/k8s/configmap.yaml
new file mode 100644
index 0000000..bed48fc
--- /dev/null
+++ b/k8s/configmap.yaml
@@ -0,0 +1,25 @@
+kind: ConfigMap
+apiVersion: v1
+metadata:
+  name: astrojs-nginx-ctmpls
+  namespace: default
+data:
+  default.conf.template: |
+    server {
+        listen       80;
+        listen  [::]:80;
+        server_name  localhost;
+
+        expires 10d;
+        add_header Cache-Control "public";
+
+        location / {
+            root   /usr/share/nginx/html;
+            index  index.html index.htm;
+        }
+
+        error_page   500 502 503 504  /50x.html;
+        location = /50x.html {
+            root   /usr/share/nginx/html;
+        }
+    }
diff --git a/k8s/deployments.yaml b/k8s/deployments.yaml
index fbdaf1d..5ea0e7d 100644
--- a/k8s/deployments.yaml
+++ b/k8s/deployments.yaml
@@ -71,8 +71,8 @@ spec:
           persistentVolumeClaim:
             claimName: astrojs-cache
         - name: nginx-conf-templates
-          secret:
-            secretName: nginx-conf-templates
+          configMap:
+            name: astrojs-nginx-ctmpls
 
 ---