-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (127 loc) · 4.88 KB
/
Copy pathhelm-posgresql.yml
File metadata and controls
160 lines (127 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: helm-postgresql
on:
workflow_dispatch:
env:
K8S_NAMESPACE: helm
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
java-version: [ 21 ]
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{matrix.java-version}}
check-latest: true
cache: 'maven'
#- name: Install jbang
# run: |
# curl -Ls https://sh.jbang.dev | bash -s - app setup
#- name: Kubernetes KinD Cluster
# uses: container-tools/kind-action@v1
# with:
# version: v0.11.1
# registry: true
- name: Kubernetes KinD Cluster
uses: helm/kind-action@v1
with:
registry: false
#registry_name: my-registry
#registry_port: 5001
- name: Wait for Cluster Readiness
run: |
echo "Waiting for nodes to be ready..."
kubectl wait --for=condition=Ready nodes --all --timeout=300s
echo "Waiting for system pods to be ready..."
kubectl wait --for=condition=Ready pods --all -n kube-system --timeout=300s
echo "Cluster is ready!"
echo "########### Cluster pods ##########"
kubectl get pods -A
echo "############ Wait for the pod to reach 'Ready' status ######"
kubectl wait --for=condition=ready pod -l app=local-path-provisioner -n local-path-storage --timeout=60s
echo "############ Check pods ######"
kubectl get pods -A
- name: Install helm 4
run: |
#sudo apt remove helm
which helm
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-4
chmod 700 get_helm.sh
./get_helm.sh
helm version
#- name: Change the storage class volumeBindingMode to immediate
# run: |
# kubectl get sc
# kubectl delete sc standard
# cat <<EOF | kubectl apply -f -
# apiVersion: storage.k8s.io/v1
# kind: StorageClass
# metadata:
# name: standard
# annotations:
# storageclass.kubernetes.io/is-default-class: "true"
# provisioner: rancher.io/local-path
# reclaimPolicy: Delete
# volumeBindingMode: Immediate
# EOF
# kubectl get sc
- name: Install Postgresql helm chart
run: |
CHARTS=$(pwd)/.github/charts
kubectl create namespace $K8S_NAMESPACE
RELEASE_NAME=postgresql-db
MAX_ATTEMPTS=20
SLEEP_TIME=5
cat <<EOF > values.yml
postgresql:
enabled: true
global:
postgresql:
auth:
database: my_db_name
key: value
postgresPassword: secret
primary:
containerSecurityContext:
enabled: false
podSecurityContext:
enabled: false
volumePermissions:
enabled: true
EOF
helm install $RELEASE_NAME $CHARTS/postgresql-18.2.4 -n $K8S_NAMESPACE -f values.yml
helm status $RELEASE_NAME -n $K8S_NAMESPACE
echo "Waiting for Helm release '$RELEASE_NAME' to be 'deployed'..."
for ((i=1; i<=MAX_ATTEMPTS; i++)); do
# -o json allows us to parse the status accurately with jq
STATUS=$(helm status $RELEASE_NAME -n $K8S_NAMESPACE -o json | jq -r '.info.status')
if [ "$STATUS" == "deployed" ]; then
echo "✅ Success: Release is deployed."
exit 0
fi
echo "Attempt $i/$MAX_ATTEMPTS: Current status is '$STATUS'. Waiting..."
sleep $SLEEP_TIME
done
echo "::error::Timed out waiting for Helm release to deploy."
helm status $RELEASE_NAME -n $K8S_NAMESPACE
kubectl get events -n $K8S_NAMESPACE --sort-by='.lastTimestamp' | tail -n 10
exit 1
- name: Check postgresql pod
run: |
echo "########## Wait till Pod is running #########"
kubectl wait -n $K8S_NAMESPACE --for=condition=ready pod/postgresql-db-0 --timeout=90s
kubectl -n $K8S_NAMESPACE get pod/postgresql-db-0
echo "########## Get PV #########"
kubectl get pv
echo "########## Get PVC #########"
kubectl -n $K8S_NAMESPACE get pvc
kubectl -n $K8S_NAMESPACE describe pvc/data-postgresql-db-0
echo "########## Get Events #########"
kubectl events -A
echo "########## Get log #########"
kubectl -n $K8S_NAMESPACE logs pod/postgresql-db-0