diff --git a/k8s/db-deployment.yaml b/k8s/db-deployment.yaml new file mode 100644 index 0000000..85d2579 --- /dev/null +++ b/k8s/db-deployment.yaml @@ -0,0 +1,55 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: db + name: db +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: db + strategy: + type: Recreate + template: + metadata: + annotations: + kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: db + spec: + containers: + - env: + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + key: POSTGRES_DB + name: env-prod-db + - name: POSTGRES_PASSWORD + valueFrom: + configMapKeyRef: + key: POSTGRES_PASSWORD + name: env-prod-db + - name: POSTGRES_USER + valueFrom: + configMapKeyRef: + key: POSTGRES_USER + name: env-prod-db + image: postgres:14.5-alpine + name: db + resources: {} + volumeMounts: + - mountPath: /var/lib/postgresql/data/ + name: postgres-data-prod + restartPolicy: Always + volumes: + - name: postgres-data-prod + persistentVolumeClaim: + claimName: postgres-data-prod +status: {} diff --git a/k8s/env-prod-configmap.yaml b/k8s/env-prod-configmap.yaml new file mode 100644 index 0000000..a3fdbd1 --- /dev/null +++ b/k8s/env-prod-configmap.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +data: + DATABASE: postgres + DEBUG: "0" + DJANGO_ALLOWED_HOSTS: localhost 127.0.0.1 [::1] + SECRET_KEY: django-insecure-9+ + SOME_ENV_VAR: VALUE_OF_SOME_ENV_VAR + SQL_DATABASE: django_prod + SQL_ENGINE: django.db.backends.postgresql + SQL_HOST: db + SQL_PASSWORD: pwddjango + SQL_PORT: "5432" + SQL_USER: django +kind: ConfigMap +metadata: + creationTimestamp: null + labels: + io.kompose.service: web-env-prod + name: env-prod diff --git a/k8s/env-prod-db-configmap.yaml b/k8s/env-prod-db-configmap.yaml new file mode 100644 index 0000000..18fadf4 --- /dev/null +++ b/k8s/env-prod-db-configmap.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +data: + POSTGRES_DB: django_prod + POSTGRES_PASSWORD: pwddjango + POSTGRES_USER: django +kind: ConfigMap +metadata: + creationTimestamp: null + labels: + io.kompose.service: db-env-prod-db + name: env-prod-db diff --git a/k8s/media-volume-persistentvolumeclaim.yaml b/k8s/media-volume-persistentvolumeclaim.yaml new file mode 100644 index 0000000..2747eb8 --- /dev/null +++ b/k8s/media-volume-persistentvolumeclaim.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + creationTimestamp: null + labels: + io.kompose.service: media-volume + name: media-volume +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Mi +status: {} diff --git a/k8s/nginx-deployment.yaml b/k8s/nginx-deployment.yaml new file mode 100644 index 0000000..8c77a1a --- /dev/null +++ b/k8s/nginx-deployment.yaml @@ -0,0 +1,41 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: nginx + name: nginx +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: nginx + strategy: + type: Recreate + template: + metadata: + annotations: + kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: nginx + spec: + containers: + - image: nginx + name: nginx + ports: + - containerPort: 80 + resources: {} + volumeMounts: + - mountPath: /home/app/staticfiles + name: static-volume + restartPolicy: Always + volumes: + - name: static-volume + persistentVolumeClaim: + claimName: static-volume +status: {} diff --git a/k8s/nginx-service.yaml b/k8s/nginx-service.yaml new file mode 100644 index 0000000..08371fb --- /dev/null +++ b/k8s/nginx-service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: nginx + name: nginx +spec: + ports: + - name: "1337" + port: 1337 + targetPort: 80 + selector: + io.kompose.service: nginx +status: + loadBalancer: {} diff --git a/k8s/postgres-data-prod-persistentvolumeclaim.yaml b/k8s/postgres-data-prod-persistentvolumeclaim.yaml new file mode 100644 index 0000000..596475f --- /dev/null +++ b/k8s/postgres-data-prod-persistentvolumeclaim.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + creationTimestamp: null + labels: + io.kompose.service: postgres-data-prod + name: postgres-data-prod +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Mi +status: {} diff --git a/k8s/static-volume-persistentvolumeclaim.yaml b/k8s/static-volume-persistentvolumeclaim.yaml new file mode 100644 index 0000000..87acc47 --- /dev/null +++ b/k8s/static-volume-persistentvolumeclaim.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + creationTimestamp: null + labels: + io.kompose.service: static-volume + name: static-volume +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Mi +status: {} diff --git a/k8s/web-deployment.yaml b/k8s/web-deployment.yaml new file mode 100644 index 0000000..a34f5eb --- /dev/null +++ b/k8s/web-deployment.yaml @@ -0,0 +1,107 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: web + name: web +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: web + strategy: + type: Recreate + template: + metadata: + annotations: + kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: web + spec: + containers: + - args: + - gunicorn + - example.wsgi:application + - --bind + - 0.0.0.0:8000 + env: + - name: DATABASE + valueFrom: + configMapKeyRef: + key: DATABASE + name: env-prod + - name: DEBUG + valueFrom: + configMapKeyRef: + key: DEBUG + name: env-prod + - name: DJANGO_ALLOWED_HOSTS + valueFrom: + configMapKeyRef: + key: DJANGO_ALLOWED_HOSTS + name: env-prod + - name: SECRET_KEY + valueFrom: + configMapKeyRef: + key: SECRET_KEY + name: env-prod + - name: SOME_ENV_VAR + valueFrom: + configMapKeyRef: + key: SOME_ENV_VAR + name: env-prod + - name: SQL_DATABASE + valueFrom: + configMapKeyRef: + key: SQL_DATABASE + name: env-prod + - name: SQL_ENGINE + valueFrom: + configMapKeyRef: + key: SQL_ENGINE + name: env-prod + - name: SQL_HOST + valueFrom: + configMapKeyRef: + key: SQL_HOST + name: env-prod + - name: SQL_PASSWORD + valueFrom: + configMapKeyRef: + key: SQL_PASSWORD + name: env-prod + - name: SQL_PORT + valueFrom: + configMapKeyRef: + key: SQL_PORT + name: env-prod + - name: SQL_USER + valueFrom: + configMapKeyRef: + key: SQL_USER + name: env-prod + image: web + name: web + ports: + - containerPort: 8000 + resources: {} + volumeMounts: + - mountPath: /home/app/staticfiles + name: static-volume + - mountPath: /home/app/mediafiles + name: media-volume + restartPolicy: Always + volumes: + - name: static-volume + persistentVolumeClaim: + claimName: static-volume + - name: media-volume + persistentVolumeClaim: + claimName: media-volume +status: {} diff --git a/k8s/web-service.yaml b/k8s/web-service.yaml new file mode 100644 index 0000000..3c5c392 --- /dev/null +++ b/k8s/web-service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose convert -f ../docker-compose.prod.yaml -v + kompose.version: 1.26.1 (a9d05d509) + creationTimestamp: null + labels: + io.kompose.service: web + name: web +spec: + ports: + - name: "8000" + port: 8000 + targetPort: 8000 + selector: + io.kompose.service: web +status: + loadBalancer: {}