diff --git a/manifests/prod/postgres-secret.yaml b/manifests/prod/postgres-secret.yaml new file mode 100644 index 0000000..853ed57 --- /dev/null +++ b/manifests/prod/postgres-secret.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Secret +metadata: + name: postgres-secret + namespace: prod +type: Opaque +stringData: + POSTGRES_DB: appdb + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password diff --git a/manifests/prod/postgres.yaml b/manifests/prod/postgres.yaml new file mode 100644 index 0000000..3b9cf54 --- /dev/null +++ b/manifests/prod/postgres.yaml @@ -0,0 +1,36 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: postgres + namespace: prod +spec: + replicas: 1 + selector: + matchLabels: + app: postgres + template: + metadata: + labels: + app: postgres + spec: + containers: + - name: postgres + image: postgres:16 + ports: + - containerPort: 5432 + envFrom: + - secretRef: + name: postgres-secret + +--- +apiVersion: v1 +kind: Service +metadata: + name: postgres + namespace: prod +spec: + selector: + app: postgres-service + ports: + - port: 5432 + targetPort: 5432 diff --git a/manifests/stage/deployment.yaml b/manifests/stage/deployment.yaml index b8a6d0d..10c75ed 100644 --- a/manifests/stage/deployment.yaml +++ b/manifests/stage/deployment.yaml @@ -18,5 +18,11 @@ spec: image: registry.internal.uia.no/ikt206-g-26v-devops/group23/flask:latest ports: - containerPort: 5000 + env: + - name: FLASK_ENV + value: staging + + - name: DATABASE_URL + value: postgresql://postgres:password@postgres-service:5432/appdb imagePullSecrets: - name: gitlab-registry-secret diff --git a/manifests/stage/postgres-secret.yaml b/manifests/stage/postgres-secret.yaml new file mode 100644 index 0000000..5c02f84 --- /dev/null +++ b/manifests/stage/postgres-secret.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Secret +metadata: + name: postgres-secret + namespace: stage +type: Opaque +stringData: + POSTGRES_DB: appdb + POSTGRES_USER: postgres + POSTGRES_PASSWORD: password diff --git a/manifests/stage/postgres.yaml b/manifests/stage/postgres.yaml new file mode 100644 index 0000000..ee86b6a --- /dev/null +++ b/manifests/stage/postgres.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: postgres + namespace: stage +spec: + replicas: 1 + selector: + matchLabels: + app: postgres + template: + metadata: + labels: + app: postgres + spec: + containers: + - name: postgres + image: postgres:16 + ports: + - containerPort: 5432 + envFrom: + - secretRef: + name: postgres-secret +--- +apiVersion: v1 +kind: Service +metadata: + name: postgres-service + namespace: stage +spec: + selector: + app: postgres + ports: + - port: 5432 + targetPort: 5432