Implements CloudNativePG
This commit is contained in:
29
deploy.sh
29
deploy.sh
@@ -32,17 +32,26 @@ function configure_cert_manager() {
|
|||||||
helm install cert-manager jetstack/cert-manager \
|
helm install cert-manager jetstack/cert-manager \
|
||||||
--namespace cert-manager \
|
--namespace cert-manager \
|
||||||
--create-namespace \
|
--create-namespace \
|
||||||
--version v1.14.2
|
--version v1.13.3
|
||||||
}
|
}
|
||||||
|
|
||||||
function configure_postgres() {
|
function configure_postgres() {
|
||||||
helm install --create-namespace \
|
helm repo add cnpg https://cloudnative-pg.github.io/charts
|
||||||
--namespace portfolio stackgres-operator \
|
helm upgrade --install cnpg \
|
||||||
--set-string adminui.service.type=ClusterIP \
|
--namespace portfolio \
|
||||||
https://stackgres.io/downloads/stackgres-k8s/stackgres/latest/helm/stackgres-operator.tgz
|
--create-namespace \
|
||||||
|
cnpg/cloudnative-pg
|
||||||
|
|
||||||
kubectl wait deployment -l group=stackgres.io --for=condition=Available -n portfolio
|
kubectl wait --for=condition=available \
|
||||||
kubectl apply -f ./deployment/postgres/sgcluster.yaml
|
--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() {
|
function application_deploy() {
|
||||||
@@ -100,7 +109,7 @@ function main() {
|
|||||||
minikube kubectl -- $@
|
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-dns
|
||||||
minikube addons enable ingress
|
minikube addons enable ingress
|
||||||
|
|
||||||
@@ -127,10 +136,8 @@ function main() {
|
|||||||
./deployment/cert-manager/cert-manager-certificate.yaml
|
./deployment/cert-manager/cert-manager-certificate.yaml
|
||||||
|
|
||||||
echo "http://$(/usr/bin/minikube ip)"
|
echo "http://$(/usr/bin/minikube ip)"
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
configure_nginx_ingress
|
else
|
||||||
|
|
||||||
kubectl apply -f \
|
kubectl apply -f \
|
||||||
./deployment/cert-manager/cert-manager-issuer.yaml
|
./deployment/cert-manager/cert-manager-issuer.yaml
|
||||||
|
|||||||
@@ -5,4 +5,5 @@ metadata:
|
|||||||
name: backend-config
|
name: backend-config
|
||||||
data:
|
data:
|
||||||
backend_url: backend-service
|
backend_url: backend-service
|
||||||
backend_port: "8070"
|
backend_port: "8070"
|
||||||
|
backend_db_name: portfolio
|
||||||
@@ -18,12 +18,12 @@ spec:
|
|||||||
image: yoshiunfriendly/backend-hideyoshi.com
|
image: yoshiunfriendly/backend-hideyoshi.com
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
memory: "256Mi"
|
memory: "256Mi"
|
||||||
cpu: "250m"
|
cpu: "250m"
|
||||||
limits:
|
limits:
|
||||||
memory: "256Mi"
|
memory: "256Mi"
|
||||||
cpu: "250m"
|
cpu: "250m"
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8070
|
- containerPort: 8070
|
||||||
env:
|
env:
|
||||||
@@ -119,15 +119,15 @@ spec:
|
|||||||
|
|
||||||
- name: POSTGRES_URL
|
- name: POSTGRES_URL
|
||||||
valueFrom:
|
valueFrom:
|
||||||
configMapKeyRef:
|
secretKeyRef:
|
||||||
name: postgres-config
|
name: postgres-cn-cluster-app
|
||||||
key: postgres_url
|
key: host
|
||||||
|
|
||||||
- name: POSTGRES_DB
|
- name: POSTGRES_DB
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: postgres-secret
|
name: postgres-cn-cluster-app
|
||||||
key: postgresDatabase
|
key: dbname
|
||||||
|
|
||||||
- name: DATABASE_URL
|
- name: DATABASE_URL
|
||||||
value: "postgresql://$(POSTGRES_URL):5432/$(POSTGRES_DB)"
|
value: "postgresql://$(POSTGRES_URL):5432/$(POSTGRES_DB)"
|
||||||
@@ -135,14 +135,14 @@ spec:
|
|||||||
- name: DATABASE_USERNAME
|
- name: DATABASE_USERNAME
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: postgres-secret
|
name: postgres-cn-cluster-app
|
||||||
key: postgresUser
|
key: user
|
||||||
|
|
||||||
- name: DATABASE_PASSWORD
|
- name: DATABASE_PASSWORD
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: postgres-secret
|
name: postgres-cn-cluster-app
|
||||||
key: postgresPassword
|
key: password
|
||||||
|
|
||||||
- name: REDIS_URL
|
- name: REDIS_URL
|
||||||
valueFrom:
|
valueFrom:
|
||||||
|
|||||||
23
deployment/postgres/cn-cluster.yaml
Normal file
23
deployment/postgres/cn-cluster.yaml
Normal file
@@ -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
|
||||||
@@ -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
|
|
||||||
Reference in New Issue
Block a user