From 3752df60bdb51db26d8c46733a281f93ef7c0afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Karcewicz?= Date: Sun, 27 Mar 2022 23:02:36 +0200 Subject: [PATCH] . --- Configmaps_Secrets_K3S/mysql-deploy.yml | 33 ++++++ Configmaps_Secrets_K3S/mysql-secret.yml | 7 ++ Configmaps_Secrets_K3S/nginx-cm.yml | 28 +++++ Configmaps_Secrets_K3S/nginx-deploy.yml | 64 +++++++++++ Configmaps_Secrets_K3S/nginx-https-deploy.yml | 104 ++++++++++++++++++ Configmaps_Secrets_K3S/nginx-https-secret.yml | 14 +++ K3S-NFS/nfs-pv.yml | 13 +++ K3S-NFS/nfs-pvc.yml | 11 ++ K3S-NFS/nginx-deployment.yml | 71 ++++++++++++ 9 files changed, 345 insertions(+) create mode 100644 Configmaps_Secrets_K3S/mysql-deploy.yml create mode 100644 Configmaps_Secrets_K3S/mysql-secret.yml create mode 100644 Configmaps_Secrets_K3S/nginx-cm.yml create mode 100644 Configmaps_Secrets_K3S/nginx-deploy.yml create mode 100644 Configmaps_Secrets_K3S/nginx-https-deploy.yml create mode 100644 Configmaps_Secrets_K3S/nginx-https-secret.yml create mode 100644 K3S-NFS/nfs-pv.yml create mode 100644 K3S-NFS/nfs-pvc.yml create mode 100644 K3S-NFS/nginx-deployment.yml diff --git a/Configmaps_Secrets_K3S/mysql-deploy.yml b/Configmaps_Secrets_K3S/mysql-deploy.yml new file mode 100644 index 0000000..6a17086 --- /dev/null +++ b/Configmaps_Secrets_K3S/mysql-deploy.yml @@ -0,0 +1,33 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mysql +spec: + replicas: 1 + selector: + matchLabels: + app: mysql + template: + metadata: + labels: + app: mysql + spec: + containers: + - image: tobi312/rpi-mariadb:10.5 + name: mysql + env: + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mysql-secret + key: roota-haslo + ports: + - name: mysql + containerPort: 3306 +# volumeMounts: +# - name: mysql-vol +# mountPath: /var/lib/mysql +# volumes: +# - name: mysql-vol +# hostPath: +# path: /var/mysql-data \ No newline at end of file diff --git a/Configmaps_Secrets_K3S/mysql-secret.yml b/Configmaps_Secrets_K3S/mysql-secret.yml new file mode 100644 index 0000000..a1991da --- /dev/null +++ b/Configmaps_Secrets_K3S/mysql-secret.yml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: mysql-secret +type: Opaque +stringData: + roota-haslo: Zaq12wsx \ No newline at end of file diff --git a/Configmaps_Secrets_K3S/nginx-cm.yml b/Configmaps_Secrets_K3S/nginx-cm.yml new file mode 100644 index 0000000..7f69288 --- /dev/null +++ b/Configmaps_Secrets_K3S/nginx-cm.yml @@ -0,0 +1,28 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: nginx-cm +data: + # key: value + # file: | + # content + # --- + nginx.conf: | + user nginx; + worker_processes 1; + events { + worker_connections 1024; + } + http { + server { + listen 80; + server_name example.com; + location / { + root /usr/share/nginx/html; + index index.html index.htm index.php; + } + location /test { + return 401; + } + } + } \ No newline at end of file diff --git a/Configmaps_Secrets_K3S/nginx-deploy.yml b/Configmaps_Secrets_K3S/nginx-deploy.yml new file mode 100644 index 0000000..a72c3f6 --- /dev/null +++ b/Configmaps_Secrets_K3S/nginx-deploy.yml @@ -0,0 +1,64 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx +spec: + replicas: 1 + selector: + matchLabels:. + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx + ports: + - name: web + containerPort: 80 + volumeMounts: + - name: nginx-cm + mountPath: /etc/nginx + - name: wolumin1 + mountPath: /usr/share/nginx/html + volumes: + - name: nginx-cm + configMap: + name: nginx-cm + - name: wolumin1 + hostPath: + path: /var/nginx + type: DirectoryOrCreate + + +--- +apiVersion: v1 +kind: Service +metadata: + name: nginx + labels: + app: nginx +spec: + type: LoadBalancer + ports: + - port: 8880 + targetPort: 80 + protocol: TCP + selector: + app: nginx + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: metallb-system + name: config +data: + config: | + address-pools: + - name: default + protocol: layer2 + addresses: + - 192.168.100.230-192.168.100.235 \ No newline at end of file diff --git a/Configmaps_Secrets_K3S/nginx-https-deploy.yml b/Configmaps_Secrets_K3S/nginx-https-deploy.yml new file mode 100644 index 0000000..54b6daa --- /dev/null +++ b/Configmaps_Secrets_K3S/nginx-https-deploy.yml @@ -0,0 +1,104 @@ +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: web + containerPort: 80 + ports: + - name: sslweb + containerPort: 443 + volumeMounts: + - name: nginx-cm + mountPath: /etc/nginx + - name: nginx-secret + mountPath: /etc/nginx/ssl + readOnly: true + - name: wolumin1 + mountPath: /usr/share/nginx/html + volumes: + - name: nginx-cm + configMap: + name: nginx-cm + - name: nginx-secret + configMap: + name: nginx-secret + - name: wolumin1 + hostPath: + path: /var/nginx + type: DirectoryOrCreate + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: nginx-cm +data: + nginx.conf: | + user nginx; + worker_processes 1; + events { + worker_connections 1024; + } + http { + server { + listen 80; + listen 443 ssl; + server_name example.com; + 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 index.php; + } + } + } + + +--- +apiVersion: v1 +kind: Service +metadata: + name: nginx-https + labels: + app: nginx-https +spec: + type: LoadBalancer + ports: + - port: 8880 + targetPort: 80 + protocol: TCP + name: http + - port: 8443 + targetPort: 443 + protocol: TCP + name: https + selector: + app: nginx-https + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: metallb-system + name: config +data: + config: | + address-pools: + - name: default + protocol: layer2 + addresses: + - 192.168.100.230-192.168.100.235 \ No newline at end of file diff --git a/Configmaps_Secrets_K3S/nginx-https-secret.yml b/Configmaps_Secrets_K3S/nginx-https-secret.yml new file mode 100644 index 0000000..a0960aa --- /dev/null +++ b/Configmaps_Secrets_K3S/nginx-https-secret.yml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Secret +metadata: + name: nginx-secret +type: Opaque +stringData: + server-cert.pem: | + -----BEGIN CERTIFICATE----- + ... + -----END CERTIFICATE----- + server-key.pem: | + -----BEGIN PRIVATE KEY----- + ... + -----END PRIVATE KEY \ No newline at end of file diff --git a/K3S-NFS/nfs-pv.yml b/K3S-NFS/nfs-pv.yml new file mode 100644 index 0000000..3999ad9 --- /dev/null +++ b/K3S-NFS/nfs-pv.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: nfs +spec: + capacity: + storage: 500Mi + accessModes: + - ReadWriteMany + storageClassName: nfs + nfs: + server: 192.168.100.185 + path: "/volume1/nginx" \ No newline at end of file diff --git a/K3S-NFS/nfs-pvc.yml b/K3S-NFS/nfs-pvc.yml new file mode 100644 index 0000000..7e8cb5e --- /dev/null +++ b/K3S-NFS/nfs-pvc.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: nfs +spec: + accessModes: + - ReadWriteMany + storageClassName: nfs + resources: + requests: + storage: 100Mi \ No newline at end of file diff --git a/K3S-NFS/nginx-deployment.yml b/K3S-NFS/nginx-deployment.yml new file mode 100644 index 0000000..a132848 --- /dev/null +++ b/K3S-NFS/nginx-deployment.yml @@ -0,0 +1,71 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx + ports: + - containerPort: 80 + volumeMounts: + - name: wolumin1 + mountPath: /usr/share/nginx/html + volumes: + - name: wolumin1 + persistentVolumeClaim: + claimName: nfs + +#--- +#apiVersion: v1 +#kind: PersistentVolumeClaim +#metadata: +# name: nfs +#spec: +# accessModes: +# - ReadWriteMany +# storageClassName: nfs +# resources: +# requests: +# storage: 100Mi + + + +--- +apiVersion: v1 +kind: Service +metadata: + name: nginx + labels: + app: nginx +spec: + type: LoadBalancer + ports: + - port: 8088 + targetPort: 80 + protocol: TCP + selector: + app: nginx + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: metallb-system + name: config +data: + config: | + address-pools: + - name: default + protocol: layer2 + addresses: + - 192.168.100.230-192.168.100.235 \ No newline at end of file