From 08b62ba77639f1a64c098a836577e4145706e136 Mon Sep 17 00:00:00 2001 From: Pankaj Date: Thu, 15 Aug 2024 00:40:46 +0530 Subject: [PATCH] local working version --- dev/Dockerfile.postgres_profile_docker_k8s | 2 +- dev/dags/dbt/jaffle_shop/profiles.yml | 4 ++-- scripts/test/kubernetes-setup.sh | 4 ++-- scripts/test/postgres-deployment.yaml | 10 ++++++---- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/dev/Dockerfile.postgres_profile_docker_k8s b/dev/Dockerfile.postgres_profile_docker_k8s index c369f144b..1634616c5 100644 --- a/dev/Dockerfile.postgres_profile_docker_k8s +++ b/dev/Dockerfile.postgres_profile_docker_k8s @@ -3,7 +3,7 @@ FROM python:3.9 RUN pip install dbt-postgres==1.8.2 psycopg2==2.9.3 pytz ENV POSTGRES_DATABASE=postgres -ENV POSTGRES_HOST=127.0.0.1 +ENV POSTGRES_HOST=postgres.default.svc.cluster.local ENV POSTGRES_PASSWORD= ENV POSTGRES_PORT=5432 ENV POSTGRES_SCHEMA=public diff --git a/dev/dags/dbt/jaffle_shop/profiles.yml b/dev/dags/dbt/jaffle_shop/profiles.yml index b5fa5caa2..db1f34acd 100644 --- a/dev/dags/dbt/jaffle_shop/profiles.yml +++ b/dev/dags/dbt/jaffle_shop/profiles.yml @@ -17,8 +17,8 @@ postgres_profile: dev: type: postgres dbname: postgres #'{{ env_var(''POSTGRES_DATABASE'') }}' - host: "0.0.0.0" #'{{ env_var(''POSTGRES_HOST'') }}' + host: postgres.default.svc.cluster.local #'{{ env_var(''POSTGRES_HOST'') }}' pass: postgres #'{{ env_var(''POSTGRES_PASSWORD'') }}' port: 5432 #'{{ env_var(''POSTGRES_PORT'') | as_number }}' schema: postgres # '{{ env_var(''POSTGRES_SCHEMA'') }}' - user: "postgres" #'{{ env_var(''POSTGRES_USER'') }}' + user: postgres #'{{ env_var(''POSTGRES_USER'') }}' diff --git a/scripts/test/kubernetes-setup.sh b/scripts/test/kubernetes-setup.sh index 76f489244..ce5899d72 100644 --- a/scripts/test/kubernetes-setup.sh +++ b/scripts/test/kubernetes-setup.sh @@ -77,7 +77,7 @@ set -e #kubectl describe pod postgres-postgresql-0 -kubectl create secret generic postgres-secrets --from-literal=host=0.0.0.0 --from-literal=password=postgres +kubectl create secret generic postgres-secrets --from-literal=host=postgres-postgresql.default.svc.cluster.local --from-literal=password=postgres kubectl apply -f scripts/test/postgres-deployment.yaml @@ -90,4 +90,4 @@ echo "$POD_NAME" kubectl port-forward --namespace default "$POD_NAME" 5432:5432 & -kubectl get pod \ No newline at end of file +kubectl get pod diff --git a/scripts/test/postgres-deployment.yaml b/scripts/test/postgres-deployment.yaml index 473439cff..8939d7f36 100644 --- a/scripts/test/postgres-deployment.yaml +++ b/scripts/test/postgres-deployment.yaml @@ -23,7 +23,7 @@ spec: valueFrom: secretKeyRef: name: postgres-secrets - key: host # Adjust according to your secret's key + key: host - name: POSTGRES_PASSWORD valueFrom: secretKeyRef: @@ -39,7 +39,7 @@ metadata: name: postgres-secrets type: Opaque data: - host: MC4wLjAuMA== + host: cG9zdGdyZXMuZGVmYXVsdC5zdmMuY2x1c3Rlci5sb2NhbA== password: cG9zdGdyZXM= --- @@ -47,11 +47,13 @@ apiVersion: v1 kind: Service metadata: name: postgres - namespace: default # Ensure this matches the namespace of the Deployment + namespace: default spec: - type: LoadBalancer + type: NodePort ports: - port: 5432 targetPort: 5432 + protocol: TCP + nodePort: 32583 selector: app: postgres