|
26 | 26 | set -eux |
27 | 27 |
|
28 | 28 | git_repo_root=$(git rev-parse --show-toplevel) |
| 29 | + |
| 30 | +# Source the common setup script |
| 31 | +source ${git_repo_root}/scripts/common.sh |
| 32 | + |
29 | 33 | kube_config_path=${git_repo_root}/k8s/kube-config.yaml |
30 | 34 | demo_yaml_path=${git_repo_root}/demo/yaml |
31 | 35 |
|
@@ -61,63 +65,65 @@ export KUBECONFIG=${kube_config_path} |
61 | 65 | # Begin deployment, one region at a time |
62 | 66 | for region in eu us; do |
63 | 67 |
|
| 68 | + CONTEXT_NAME=$(get_cluster_context "${region}") |
| 69 | + |
64 | 70 | if [ $trunk -eq 1 ] |
65 | 71 | then |
66 | 72 | # Deploy CloudNativePG operator (trunk - main branch) |
67 | 73 | curl -sSfL \ |
68 | 74 | https://raw.githubusercontent.com/cloudnative-pg/artifacts/main/manifests/operator-manifest.yaml | \ |
69 | | - kubectl --context kind-k8s-${region} apply -f - --server-side |
| 75 | + kubectl --context ${CONTEXT_NAME} apply -f - --server-side |
70 | 76 | else |
71 | 77 | # Deploy CloudNativePG operator (latest version, through the plugin) |
72 | 78 | kubectl cnpg install generate --control-plane | \ |
73 | | - kubectl --context kind-k8s-${region} apply -f - --server-side |
| 79 | + kubectl --context ${CONTEXT_NAME} apply -f - --server-side |
74 | 80 | fi |
75 | 81 |
|
76 | 82 | # Wait for CNPG deployment to complete |
77 | | - kubectl --context kind-k8s-${region} rollout status deployment \ |
| 83 | + kubectl --context ${CONTEXT_NAME} rollout status deployment \ |
78 | 84 | -n cnpg-system cnpg-controller-manager |
79 | 85 |
|
80 | 86 | # Deploy cert-manager |
81 | | - kubectl apply --context kind-k8s-${region} -f \ |
| 87 | + kubectl apply --context ${CONTEXT_NAME} -f \ |
82 | 88 | https://github.com/cert-manager/cert-manager/releases/latest/download/cert-manager.yaml |
83 | 89 |
|
84 | 90 | # Wait for cert-manager deployment to complete |
85 | | - kubectl rollout --context kind-k8s-${region} status deployment \ |
| 91 | + kubectl rollout --context ${CONTEXT_NAME} status deployment \ |
86 | 92 | -n cert-manager |
87 | | - cmctl check api --wait=2m --context kind-k8s-${region} |
| 93 | + cmctl check api --wait=2m --context ${CONTEXT_NAME} |
88 | 94 |
|
89 | 95 | if [ $trunk -eq 1 ] |
90 | 96 | then |
91 | 97 | # Deploy Barman Cloud Plugin (trunk) |
92 | | - kubectl apply --context kind-k8s-${region} -f \ |
| 98 | + kubectl apply --context ${CONTEXT_NAME} -f \ |
93 | 99 | https://raw.githubusercontent.com/cloudnative-pg/plugin-barman-cloud/refs/heads/main/manifest.yaml |
94 | 100 | else |
95 | 101 | # Deploy Barman Cloud Plugin (latest stable) |
96 | | - kubectl apply --context kind-k8s-${region} -f \ |
| 102 | + kubectl apply --context ${CONTEXT_NAME} -f \ |
97 | 103 | https://github.com/cloudnative-pg/plugin-barman-cloud/releases/latest/download/manifest.yaml |
98 | 104 | fi |
99 | 105 |
|
100 | 106 | # Wait for Barman Cloud Plugin deployment to complete |
101 | | - kubectl rollout --context kind-k8s-${region} status deployment \ |
| 107 | + kubectl rollout --context ${CONTEXT_NAME} status deployment \ |
102 | 108 | -n cnpg-system barman-cloud |
103 | 109 |
|
104 | 110 | # Create Barman object stores |
105 | | - kubectl apply --context kind-k8s-${region} -f \ |
| 111 | + kubectl apply --context ${CONTEXT_NAME} -f \ |
106 | 112 | ${demo_yaml_path}/object-stores |
107 | 113 |
|
108 | 114 | # Create the Postgres cluster |
109 | | - kubectl apply --context kind-k8s-${region} -f \ |
| 115 | + kubectl apply --context ${CONTEXT_NAME} -f \ |
110 | 116 | ${demo_yaml_path}/${region}/pg-${region}${legacy}.yaml |
111 | 117 |
|
112 | 118 | # Create the PodMonitor if Prometheus has been installed |
113 | 119 | if check_crd_existence podmonitors.monitoring.coreos.com |
114 | 120 | then |
115 | | - kubectl apply --context kind-k8s-${region} -f \ |
| 121 | + kubectl apply --context ${CONTEXT_NAME} -f \ |
116 | 122 | ${demo_yaml_path}/${region}/pg-${region}-podmonitor.yaml |
117 | 123 | fi |
118 | 124 |
|
119 | 125 | # Wait for the cluster to be ready |
120 | | - kubectl wait --context kind-k8s-${region} \ |
| 126 | + kubectl wait --context ${CONTEXT_NAME} \ |
121 | 127 | --timeout 30m \ |
122 | 128 | --for=condition=Ready cluster/pg-${region} |
123 | 129 |
|
|
0 commit comments