diff --git a/deploy.sh b/deploy.sh index a223751..a00f946 100755 --- a/deploy.sh +++ b/deploy.sh @@ -32,17 +32,26 @@ function configure_cert_manager() { helm install cert-manager jetstack/cert-manager \ --namespace cert-manager \ --create-namespace \ - --version v1.14.2 + --version v1.13.3 } function configure_postgres() { - helm install --create-namespace \ - --namespace portfolio stackgres-operator \ - --set-string adminui.service.type=ClusterIP \ - https://stackgres.io/downloads/stackgres-k8s/stackgres/latest/helm/stackgres-operator.tgz + helm repo add cnpg https://cloudnative-pg.github.io/charts + helm upgrade --install cnpg \ + --namespace portfolio \ + --create-namespace \ + cnpg/cloudnative-pg - kubectl wait deployment -l group=stackgres.io --for=condition=Available -n portfolio - kubectl apply -f ./deployment/postgres/sgcluster.yaml + kubectl wait --for=condition=available \ + --timeout=600s \ + deployment.apps/cnpg-cloudnative-pg \ + -n portfolio + + kubectl apply -f ./deployment/postgres/cn-cluster.yaml + kubectl wait --for=condition=Ready \ + --timeout=600s \ + cluster/postgres-cn-cluster \ + -n portfolio } function application_deploy() { @@ -100,7 +109,7 @@ function main() { minikube kubectl -- $@ } - minikube start --driver kvm2 --cpus 4 --memory 3Gib + minikube start --driver kvm2 --cpus 4 --memory 4Gib minikube addons enable ingress-dns minikube addons enable ingress @@ -127,10 +136,8 @@ function main() { ./deployment/cert-manager/cert-manager-certificate.yaml echo "http://$(/usr/bin/minikube ip)" - - else - configure_nginx_ingress + else kubectl apply -f \ ./deployment/cert-manager/cert-manager-issuer.yaml diff --git a/deployment/backend/backend-config.yaml b/deployment/backend/backend-config.yaml index ce0be2d..f8b54f6 100644 --- a/deployment/backend/backend-config.yaml +++ b/deployment/backend/backend-config.yaml @@ -5,4 +5,5 @@ metadata: name: backend-config data: backend_url: backend-service - backend_port: "8070" \ No newline at end of file + backend_port: "8070" + backend_db_name: portfolio \ No newline at end of file diff --git a/deployment/backend/backend.yaml b/deployment/backend/backend.yaml index e54b742..d1aa878 100644 --- a/deployment/backend/backend.yaml +++ b/deployment/backend/backend.yaml @@ -18,12 +18,12 @@ spec: image: yoshiunfriendly/backend-hideyoshi.com imagePullPolicy: Always resources: - requests: - memory: "256Mi" - cpu: "250m" - limits: - memory: "256Mi" - cpu: "250m" + requests: + memory: "256Mi" + cpu: "250m" + limits: + memory: "256Mi" + cpu: "250m" ports: - containerPort: 8070 env: @@ -119,15 +119,15 @@ spec: - name: POSTGRES_URL valueFrom: - configMapKeyRef: - name: postgres-config - key: postgres_url + secretKeyRef: + name: postgres-cn-cluster-app + key: host - name: POSTGRES_DB valueFrom: secretKeyRef: - name: postgres-secret - key: postgresDatabase + name: postgres-cn-cluster-app + key: dbname - name: DATABASE_URL value: "postgresql://$(POSTGRES_URL):5432/$(POSTGRES_DB)" @@ -135,14 +135,14 @@ spec: - name: DATABASE_USERNAME valueFrom: secretKeyRef: - name: postgres-secret - key: postgresUser + name: postgres-cn-cluster-app + key: user - name: DATABASE_PASSWORD valueFrom: secretKeyRef: - name: postgres-secret - key: postgresPassword + name: postgres-cn-cluster-app + key: password - name: REDIS_URL valueFrom: diff --git a/deployment/postgres/cn-cluster.yaml b/deployment/postgres/cn-cluster.yaml new file mode 100644 index 0000000..8480dab --- /dev/null +++ b/deployment/postgres/cn-cluster.yaml @@ -0,0 +1,23 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: postgres-cn-cluster + namespace: portfolio +spec: + instances: 3 + primaryUpdateStrategy: unsupervised + imageName: ghcr.io/cloudnative-pg/postgresql:14.10-18 + + storage: + size: 5Gi + + resources: + requests: + memory: "32Mi" + cpu: "50m" + limits: + memory: "128Mi" + cpu: "100m" + + monitoring: + enablePodMonitor: true diff --git a/deployment/postgres/sgcluster.yaml b/deployment/postgres/sgcluster.yaml deleted file mode 100644 index 576c420..0000000 --- a/deployment/postgres/sgcluster.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: stackgres.io/v1 -kind: SGInstanceProfile -metadata: - namespace: portfolio - name: postgres-portfolio-profile -spec: - cpu: "250m" - memory: "512Mi" - containers: - pg-main-container: - cpu: "250m" - memory: "512Mi" - ---- -apiVersion: stackgres.io/v1 -kind: SGCluster -metadata: - namespace: portfolio - name: postgres-cluster -spec: - instances: 1 - postgres: - version: "latest" - pods: - persistentVolume: - size: "5Gi" - sgInstanceProfile: postgres-portfolio-profile