Selaa lähdekoodia

cm-and-secret

xcad2k 4 vuotta sitten
vanhempi
commit
8f62f0c812

+ 30 - 0
kubernetes/templates/cm-and-secrets/mysql-deploy.yml

@@ -0,0 +1,30 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: mysql
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      app: mysql
+  template:
+    metadata:
+      labels:
+        app: mysql
+    spec:
+      containers:
+      - image: mysql:5.6
+        name: mysql
+        env:
+        - name: MYSQL_ROOT_PASSWORD
+          value: "password-in-cleartext"
+        ports:
+        - name: mysql
+          containerPort: 3306
+#         volumeMounts:
+#         - name: mysql-vol
+#           mountPath: /var/lib/mysql
+#       volumes:
+#       - name: mysql-vol
+#         hostPath:
+#           path: /var/mysql-data

+ 7 - 0
kubernetes/templates/cm-and-secrets/mysql-secret.yml

@@ -0,0 +1,7 @@
+apiVersion: v1
+kind: Secret
+metadata:
+  name: mysql-secret
+type: Opaque
+stringData:
+  root-pass: test123

+ 21 - 0
kubernetes/templates/cm-and-secrets/nginx-http-cm.yml

@@ -0,0 +1,21 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: nginx-http-cm
+data:
+  nginx.conf: |
+    user nginx;
+    worker_processes 1;
+    events {
+      worker_connections  10240;
+    }
+    http {
+      server {
+        listen       80;
+        server_name  _;
+        location / {
+            root   /usr/share/nginx/html;
+            index  index.html index.htm;
+        }
+      }
+    }

+ 32 - 0
kubernetes/templates/cm-and-secrets/nginx-http-deploy.yml

@@ -0,0 +1,32 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: nginx-http
+spec:
+  replicas: 1
+  selector:
+    matchLabels: 
+      app: nginx-http
+  template:
+    metadata:
+      labels:
+        app: nginx-http
+    spec:
+      containers:
+      - name: nginx-http
+        image: nginx
+        ports:
+        - name: web
+          containerPort: 80
+        volumeMounts:
+        - name: nginx-http-cm
+          mountPath: /etc/nginx
+        - name: nginx-http-vol
+          mountPath: /usr/share/nginx/html
+      volumes:
+      - name: nginx-http-cm
+        configMap:
+          name: nginx-http-cm
+      - name: nginx-http-vol
+        hostPath:
+          path: /var/nginxserver

+ 15 - 0
kubernetes/templates/cm-and-secrets/nginx-http-svc.yml

@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: nginx-http-svc
+  labels:
+    app: nginx-http
+spec:
+  type: LoadBalancer
+  ports:
+  - port: 30080
+    targetPort: 80
+    protocol: TCP
+    name: http
+  selector:
+    app: nginx-http

+ 27 - 0
kubernetes/templates/cm-and-secrets/nginx-https-cm.yml

@@ -0,0 +1,27 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: nginx-https-cm
+data:
+  nginx.conf: |
+    user nginx;
+    worker_processes 1;
+    events {
+      worker_connections  10240;
+    }
+    http {
+      server {
+        listen       80;
+        listen       443 ssl;
+
+        server_name  _;
+
+        ssl_certificate     /etc/nginx/ssl/server-cert.pem;
+        ssl_certificate_key /etc/nginx/ssl/server-key.pem;
+
+        location / {
+            root   /usr/share/nginx/html;
+            index  index.html index.htm;
+        }
+      }
+    }

+ 38 - 0
kubernetes/templates/cm-and-secrets/nginx-https-deploy.yml

@@ -0,0 +1,38 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: nginx-https
+spec:
+  replicas: 1
+  selector:
+    matchLabels: 
+      app: nginx-https
+  template:
+    metadata:
+      labels:
+        app: nginx-https
+    spec:
+      containers:
+      - name: nginx-https
+        image: nginx
+        ports:
+        - name: secureweb
+          containerPort: 443
+        volumeMounts:
+        - name: nginx-https-cm
+          mountPath: /etc/nginx
+        - name: nginx-https-secret
+          mountPath: /etc/nginx/ssl
+          readOnly: true
+        - name: nginx-https-vol
+          mountPath: /usr/share/nginx/html
+      volumes:
+      - name: nginx-https-cm
+        configMap:
+          name: nginx-https-cm
+      - name: nginx-https-secret
+        secret:
+          secretName: nginx-https-secret
+      - name: nginx-https-vol
+        hostPath:
+          path: /var/nginxserver

+ 12 - 0
kubernetes/templates/cm-and-secrets/nginx-https-secret-blank.yml

@@ -0,0 +1,12 @@
+apiVersion: v1
+kind: Secret
+metadata:
+  name: nginx-https-secret
+type: Opaque
+stringData:
+  server-cert.pem: |
+    -----BEGIN CERTIFICATE-----
+    ...
+    -----END CERTIFICATE-----
+  server-key.pem: |
+    

+ 19 - 0
kubernetes/templates/cm-and-secrets/nginx-https-svc.yml

@@ -0,0 +1,19 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: nginx-https-svc
+  labels:
+    app: nginx-https
+spec:
+  type: LoadBalancer
+  ports:
+  - port: 31080
+    targetPort: 80
+    protocol: TCP
+    name: http
+  - port: 31443
+    targetPort: 443
+    protocol: TCP
+    name: https
+  selector:
+    app: nginx-https

+ 1 - 1
kubernetes/templates/pv-and-pvc/local-web.yml

@@ -24,4 +24,4 @@ spec:
       volumes:
       - name: local
         hostPath:
-          path: /usr/share/nginx/html
+          path: /var/nginxserver