From 915e5cf4468d316e89dbf9d124bb59c44a10c1f9 Mon Sep 17 00:00:00 2001 From: jurabek Date: Tue, 2 Jan 2024 13:18:16 +0100 Subject: [PATCH] k8s deploys changing separate env mappings from ConfigMap into envFrom->configMapRef --- .../services/basket-api/base/config.env | 6 +-- .../services/basket-api/base/deployment.yaml | 46 ++++++------------- .../services/basket-api/dev/config.env | 2 +- .../services/catalog-api/base/.env.secret | 8 ++-- .../services/catalog-api/base/config.env | 6 +-- .../services/catalog-api/base/deployment.yaml | 31 +++---------- .../services/catalog-api/base/menu-pgsql.yaml | 18 ++------ .../services/catalog-api/dev/config.env | 2 +- 8 files changed, 35 insertions(+), 84 deletions(-) diff --git a/k8s-kustomize/services/basket-api/base/config.env b/k8s-kustomize/services/basket-api/base/config.env index 746e9ff32..c50ab1d80 100644 --- a/k8s-kustomize/services/basket-api/base/config.env +++ b/k8s-kustomize/services/basket-api/base/config.env @@ -1,3 +1,3 @@ -auth.authority=http://identity-api -redis.host=redis-data:6379 -base.path=/basket \ No newline at end of file +AUTH_AUTHORITY=http://identity-api +REDIS_HOST=redis-data:6379 +BASE_PATH=/basket \ No newline at end of file diff --git a/k8s-kustomize/services/basket-api/base/deployment.yaml b/k8s-kustomize/services/basket-api/base/deployment.yaml index 804695b0b..25722f52b 100644 --- a/k8s-kustomize/services/basket-api/base/deployment.yaml +++ b/k8s-kustomize/services/basket-api/base/deployment.yaml @@ -13,36 +13,18 @@ spec: app: basket-api spec: containers: - - image: basket-api # must much from ./kustomization.yaml -> images[0].name - imagePullPolicy: IfNotPresent - name: basket-api - ports: - - containerPort: 5200 - env: - - name: AUTH_AUTHORITY - valueFrom: - configMapKeyRef: + - image: basket-api # must much from ./kustomization.yaml -> images[0].name + imagePullPolicy: IfNotPresent + name: basket-api + ports: + - containerPort: 5200 + envFrom: + - configMapKeyRef: name: basket-api - key: auth.authority - - name: AUTH_URL - valueFrom: - configMapKeyRef: - name: basket-api - key: auth.url - - name: REDIS_HOST - valueFrom: - configMapKeyRef: - name: basket-api - key: redis.host - - name: BASE_PATH - valueFrom: - configMapKeyRef: - name: basket-api - key: base.path - resources: - requests: - memory: "32Mi" - cpu: "60m" - limits: - memory: "128Mi" - cpu: "100m" \ No newline at end of file + resources: + requests: + memory: "32Mi" + cpu: "60m" + limits: + memory: "128Mi" + cpu: "100m" diff --git a/k8s-kustomize/services/basket-api/dev/config.env b/k8s-kustomize/services/basket-api/dev/config.env index 85f3eda97..79293e488 100644 --- a/k8s-kustomize/services/basket-api/dev/config.env +++ b/k8s-kustomize/services/basket-api/dev/config.env @@ -1 +1 @@ -auth.url=http://api-dev.restaurant.io/identity \ No newline at end of file +AUTH_URL=http://api-dev.restaurant.io/identity \ No newline at end of file diff --git a/k8s-kustomize/services/catalog-api/base/.env.secret b/k8s-kustomize/services/catalog-api/base/.env.secret index 3c147efbe..d6090ae53 100644 --- a/k8s-kustomize/services/catalog-api/base/.env.secret +++ b/k8s-kustomize/services/catalog-api/base/.env.secret @@ -1,4 +1,4 @@ -db.url=postgres://admin:Passw0rd!@catalog-pgsql-database:5432/catalog_database -db.name=catalog_database -db.password=Passw0rd! -db.username=admin \ No newline at end of file +DATABASE_URL=postgres://admin:Passw0rd!@catalog-pgsql-database:5432/catalog_database +POSTGRES_DB=catalog_database +POSTGRES_PASSWORD=Passw0rd! +POSTGRES_USER=admin \ No newline at end of file diff --git a/k8s-kustomize/services/catalog-api/base/config.env b/k8s-kustomize/services/catalog-api/base/config.env index 3c4864d6b..25c75ca37 100644 --- a/k8s-kustomize/services/catalog-api/base/config.env +++ b/k8s-kustomize/services/catalog-api/base/config.env @@ -1,3 +1,3 @@ -auth.authority=http://identity-api -env=Development -base.path=/catalog \ No newline at end of file +AUTH_AUTHORITY=http://identity-api +ENV=Development +BASE_URL=/catalog \ No newline at end of file diff --git a/k8s-kustomize/services/catalog-api/base/deployment.yaml b/k8s-kustomize/services/catalog-api/base/deployment.yaml index 944bd3f27..80a6cd1ad 100644 --- a/k8s-kustomize/services/catalog-api/base/deployment.yaml +++ b/k8s-kustomize/services/catalog-api/base/deployment.yaml @@ -18,36 +18,17 @@ spec: imagePullPolicy: Always ports: - containerPort: 8000 + envFrom: + - configMapRef: + name: catalog-api + - secretRef: + name: catalog-api env: - name: ROCKET_PORT value: "8000" - name: ROCKET_ADDRESS value: "0.0.0.0" - - name: ENV - valueFrom: - configMapKeyRef: - name: catalog-api - key: env - - name: BASE_URL - valueFrom: - configMapKeyRef: - name: catalog-api - key: base.path - - name: DATABASE_URL - valueFrom: - secretKeyRef: - name: catalog-api - key: db.url - - name: AUTH_URL - valueFrom: - configMapKeyRef: - name: catalog-api - key: auth.url - - name: AUTH_AUTHORITY - valueFrom: - configMapKeyRef: - name: catalog-api - key: auth.authority + readinessProbe: httpGet: path: /health/ready diff --git a/k8s-kustomize/services/catalog-api/base/menu-pgsql.yaml b/k8s-kustomize/services/catalog-api/base/menu-pgsql.yaml index 57085c85a..0fe62e8fb 100644 --- a/k8s-kustomize/services/catalog-api/base/menu-pgsql.yaml +++ b/k8s-kustomize/services/catalog-api/base/menu-pgsql.yaml @@ -18,24 +18,12 @@ spec: containers: - name: catalog-pgsql-database image: postgres:alpine + envFrom: + - secretRef: + name: catalog-api env: - name: PGDATA value: /var/lib/postgresql/data/pgdata - - name: POSTGRES_DB - valueFrom: - secretKeyRef: - name: catalog-api - key: db.name - - name: POSTGRES_PASSWORD - valueFrom: - secretKeyRef: - name: catalog-api - key: db.password - - name: POSTGRES_USER - valueFrom: - secretKeyRef: - name: catalog-api - key: db.username volumeMounts: - mountPath: /var/lib/postgresql/data name: order-database-data diff --git a/k8s-kustomize/services/catalog-api/dev/config.env b/k8s-kustomize/services/catalog-api/dev/config.env index 85f3eda97..79293e488 100644 --- a/k8s-kustomize/services/catalog-api/dev/config.env +++ b/k8s-kustomize/services/catalog-api/dev/config.env @@ -1 +1 @@ -auth.url=http://api-dev.restaurant.io/identity \ No newline at end of file +AUTH_URL=http://api-dev.restaurant.io/identity \ No newline at end of file