From 5e5309d9e5ad2c83fc5f5d6120adf88ccffc86b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ondrej=20Ladomirj=C3=A1k?= Date: Sat, 14 May 2022 11:55:46 +0000 Subject: [PATCH] Upload files to 'sk1' --- sk1/mongo-configmap.yaml | 7 +++++ sk1/mongo-deployment.yaml | 34 +++++++++++++++++++++++ sk1/mongo-express-deployment.yaml | 38 ++++++++++++++++++++++++++ sk1/mongo-express-service.yaml | 14 ++++++++++ sk1/mongo-secret.yaml | 9 +++++++ sk1/mongo-service.yaml | 13 +++++++++ sk1/mongo-stateful-set.yaml | 45 +++++++++++++++++++++++++++++++ sk1/namespace.yaml | 4 +++ sk1/pv.yaml | 15 +++++++++++ sk1/remove-app.sh | 4 ++- sk1/start-app.sh | 9 +++++++ sk1/stop-app.sh | 8 ++++++ 12 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 sk1/mongo-configmap.yaml create mode 100644 sk1/mongo-deployment.yaml create mode 100644 sk1/mongo-express-deployment.yaml create mode 100644 sk1/mongo-express-service.yaml create mode 100644 sk1/mongo-secret.yaml create mode 100644 sk1/mongo-service.yaml create mode 100644 sk1/mongo-stateful-set.yaml create mode 100644 sk1/namespace.yaml create mode 100644 sk1/pv.yaml create mode 100644 sk1/start-app.sh create mode 100644 sk1/stop-app.sh diff --git a/sk1/mongo-configmap.yaml b/sk1/mongo-configmap.yaml new file mode 100644 index 0000000..046854d --- /dev/null +++ b/sk1/mongo-configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: mongo-configmap + namespace: z2 +data: + database-url: mongo-service \ No newline at end of file diff --git a/sk1/mongo-deployment.yaml b/sk1/mongo-deployment.yaml new file mode 100644 index 0000000..24c47ac --- /dev/null +++ b/sk1/mongo-deployment.yaml @@ -0,0 +1,34 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mongo-deployment + namespace: z2 + labels: + app: mongodb +spec: + replicas: 1 + selector: + matchLabels: + app: mongodb + template: + metadata: + labels: + app: mongodb + spec: + containers: + - name: mongodb + image: mongo:latest + ports: + - containerPort: 27017 + env: + #mongo-secret.yaml poskytne meno a heslo, bezpecnejsie base64 + - name: MONGO_INITDB_ROOT_USERNAME + valueFrom: + secretKeyRef: + name: mongo-secret + key: mongo-username + - name: MONGO_INITDB_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mongo-secret + key: mongo-password diff --git a/sk1/mongo-express-deployment.yaml b/sk1/mongo-express-deployment.yaml new file mode 100644 index 0000000..c592d49 --- /dev/null +++ b/sk1/mongo-express-deployment.yaml @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mongo-express-deployment + namespace: z2 + labels: + app: mongo-express +spec: + replicas: 1 + selector: + matchLabels: + app: mongo-express + template: + metadata: + labels: + app: mongo-express + spec: + containers: + - name: mongo-express + image: mongo-express:latest + ports: + - containerPort: 8081 + env: + - name: ME_CONFIG_MONGODB_ADMINUSERNAME + valueFrom: + secretKeyRef: + name: mongo-secret + key: mongo-username + - name: ME_CONFIG_MONGODB_ADMINPASSWORD + valueFrom: + secretKeyRef: + name: mongo-secret + key: mongo-password + - name: ME_CONFIG_MONGODB_SERVER + valueFrom: + configMapKeyRef: + name: mongo-configmap + key: database-url diff --git a/sk1/mongo-express-service.yaml b/sk1/mongo-express-service.yaml new file mode 100644 index 0000000..6fb3e9d --- /dev/null +++ b/sk1/mongo-express-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: mongo-express-service + namespace: z2 +spec: + selector: + app: mongo-express + type: LoadBalancer + ports: + - protocol: TCP + port: 8081 + targetPort: 8081 + nodePort: 30001 \ No newline at end of file diff --git a/sk1/mongo-secret.yaml b/sk1/mongo-secret.yaml new file mode 100644 index 0000000..dfcc29e --- /dev/null +++ b/sk1/mongo-secret.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: mongo-secret + namespace: z2 +type: Opaque +data: + mongo-username: YWRtaW4= + mongo-password: YWRtaW4= \ No newline at end of file diff --git a/sk1/mongo-service.yaml b/sk1/mongo-service.yaml new file mode 100644 index 0000000..6a57d32 --- /dev/null +++ b/sk1/mongo-service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: mongo-service + namespace: z2 +spec: + selector: + app: mongodb + type: ClusterIP + ports: + - protocol: TCP + port: 27017 + targetPort: 27017 \ No newline at end of file diff --git a/sk1/mongo-stateful-set.yaml b/sk1/mongo-stateful-set.yaml new file mode 100644 index 0000000..4727b56 --- /dev/null +++ b/sk1/mongo-stateful-set.yaml @@ -0,0 +1,45 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: mongodb +spec: + selector: + matchLabels: + app: mongodb + serviceName: mongo-service + replicas: 1 + template: + metadata: + labels: + app: mongodb + spec: + containers: + - name: mongodb + image: mongo:latest + ports: + - name: mongodb + containerPort: 27017 + protocol: TCP + env: + - name: MONGO_INITDB_ROOT_USERNAME + valueFrom: + secretKeyRef: + name: mongo-secret + key: mongo-username + - name: MONGO_INITDB_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mongo-secret + key: mongo-password + volumeMounts: + - mountPath: /data/db + name: mongopvc + volumeClaimTemplates: + - metadata: + name: mongopvc + spec: + accessModes: ["ReadWriteMany"] + storageClassName: "local" + resources: + requests: + storage: 500Mi \ No newline at end of file diff --git a/sk1/namespace.yaml b/sk1/namespace.yaml new file mode 100644 index 0000000..151a8f8 --- /dev/null +++ b/sk1/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: z2 diff --git a/sk1/pv.yaml b/sk1/pv.yaml new file mode 100644 index 0000000..e35b58b --- /dev/null +++ b/sk1/pv.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: pv-mongo + labels: + type: local +spec: + storageClassName: local + capacity: + storage: 500Mi + accessModes: + - ReadWriteMany + persistentVolumeReclaimPolicy: Delete + hostPath: + path: "/zkt22/z2/pv" \ No newline at end of file diff --git a/sk1/remove-app.sh b/sk1/remove-app.sh index f7cae96..92a9baf 100644 --- a/sk1/remove-app.sh +++ b/sk1/remove-app.sh @@ -3,4 +3,6 @@ set -e az group delete -n skuskaZKT -y az group delete -n NetworkWatcherRG -y -az group delete -n DefaultResourceGroup-EA -y \ No newline at end of file +az group delete -n DefaultResourceGroup-EA -y + +printf 'Sicko vymazane' \ No newline at end of file diff --git a/sk1/start-app.sh b/sk1/start-app.sh new file mode 100644 index 0000000..4a25a21 --- /dev/null +++ b/sk1/start-app.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e + +kubectl apply -f mongo-configmap.yaml +kubectl apply -f mongo-secret.yaml +kubectl apply -f mongo-service.yaml +kubectl apply -f mongo-stateful-set.yaml -n z2 +kubectl apply -f mongo-express-deployment.yaml +kubectl apply -f mongo-express-service.yaml diff --git a/sk1/stop-app.sh b/sk1/stop-app.sh new file mode 100644 index 0000000..31016d0 --- /dev/null +++ b/sk1/stop-app.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +kubectl delete statefulset.apps/mongodb -n z2 +kubectl delete deployment.apps/mongo-express-deployment -n z2 +kubectl delete service/mongo-express-service -n z2 +kubectl delete service/mongo-service -n z2 +kubectl delete configmap/mongo-configmap -n z2