Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Switch mysql and postgresql tests to HA Production configs (#471)
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Fox <Kevin.Fox@pnnl.gov>
  • Loading branch information
kfox1111 committed Sep 1, 2023
1 parent e81a59a commit 5273f4e
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .github/kind/conf/kind-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ kubeadmConfigPatches:
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker
30 changes: 17 additions & 13 deletions examples/external-mysql/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,35 @@ source "${SCRIPTPATH}/../../.github/scripts/parse-versions.sh"
# shellcheck source=/dev/null
source "${TESTDIR}/common.sh"

helm_install=(helm upgrade --install --create-namespace)
ns=spire-system

teardown() {
helm uninstall --namespace "${ns}" spire 2>/dev/null || true
kubectl delete ns "${ns}" 2>/dev/null || true

helm uninstall --namespace "spire-server" spire 2>/dev/null || true
helm uninstall --namespace mysql mysql 2>/dev/null || true
kubectl delete ns mysql 2>/dev/null || true
kubectl delete ns spire-server 2>/dev/null || true
kubectl delete ns spire-system 2>/dev/null || true
}

trap 'trap - SIGTERM && teardown' SIGINT SIGTERM EXIT

"${helm_install[@]}" mysql mysql --version "$VERSION_MYSQL" --repo "$HELM_REPO_MYSQL" \
--namespace mysql \
kubectl create namespace spire-system --dry-run=client -o yaml | kubectl apply -f -
kubectl label namespace spire-system pod-security.kubernetes.io/enforce=privileged || true
kubectl create namespace spire-server --dry-run=client -o yaml | kubectl apply -f -
kubectl label namespace spire-server pod-security.kubernetes.io/enforce=restricted || true

helm upgrade --install mysql mysql --version "$VERSION_MYSQL" --repo "$HELM_REPO_MYSQL" \
--namespace spire-server \
--values "${DEPS}/mysql.yaml" \
--wait

"${helm_install[@]}" --namespace "${ns}" --values "${SCRIPTPATH}/values.yaml" \
helm upgrade --install --namespace "spire-server" \
--values "${SCRIPTPATH}/values.yaml,${SCRIPTPATH}/../production/values.yaml,${SCRIPTPATH}/../production/values-node-pod-antiaffinity.yaml" \
--set 'spire-server.dataStore.sql.password=sp1ff3Test' --wait spire charts/spire
helm test --namespace "${ns}" spire
helm test --namespace "spire-server" spire

print_helm_releases
print_spire_workload_status "${ns}"
print_spire_workload_status spire-server
print_spire_workload_status spire-system

if [[ "$1" -ne 0 ]]; then
get_namespace_details "${ns}"
get_namespace_details spire-server
get_namespace_details spire-system
fi
3 changes: 2 additions & 1 deletion examples/external-mysql/values.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
spire-server:
replicaCount: 2
dataStore:
sql:
databaseType: mysql
databaseName: spire-server
host: mysql.mysql
host: mysql
port: 3306
username: spire
# password: CHANGE_ME
34 changes: 19 additions & 15 deletions examples/external-postgresql/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,35 @@ source "${SCRIPTPATH}/../../.github/scripts/parse-versions.sh"
# shellcheck source=/dev/null
source "${TESTDIR}/common.sh"

helm_install=(helm upgrade --install --create-namespace)
ns=spire-system

teardown() {
helm uninstall --namespace "${ns}" spire 2>/dev/null || true
kubectl delete ns "${ns}" 2>/dev/null || true

helm uninstall --namespace postgresql postgresql 2>/dev/null || true
kubectl delete ns postgresql 2>/dev/null || true
helm uninstall --namespace "spire-server" spire 2>/dev/null || true
helm uninstall --namespace "spire-server" postgresql 2>/dev/null || true
kubectl delete ns spire-server 2>/dev/null || true
kubectl delete ns spire-system 2>/dev/null || true
}

trap 'trap - SIGTERM && teardown' SIGINT SIGTERM EXIT

"${helm_install[@]}" postgresql postgresql --version "$VERSION_POSTGRESQL" --repo "$HELM_REPO_POSTGRESQL" \
--namespace postgresql \
--values "${DEPS}/postgresql.yaml" \
kubectl create namespace spire-system --dry-run=client -o yaml | kubectl apply -f -
kubectl label namespace spire-system pod-security.kubernetes.io/enforce=privileged || true
kubectl create namespace spire-server --dry-run=client -o yaml | kubectl apply -f -
kubectl label namespace spire-server pod-security.kubernetes.io/enforce=restricted || true

helm upgrade --install postgresql postgresql --version "$VERSION_POSTGRESQL" --repo "$HELM_REPO_POSTGRESQL" \
--namespace spire-server \
--values "${DEPS}/postgresql.yaml,${SCRIPTPATH}/../production/values.yaml,${SCRIPTPATH}/../production/values-node-pod-antiaffinity.yaml" \
--wait

"${helm_install[@]}" --namespace "${ns}" --values "${SCRIPTPATH}/values.yaml" \
helm upgrade --install --namespace "spire-server" \
--values "${SCRIPTPATH}/values.yaml,${SCRIPTPATH}/../production/values.yaml,${SCRIPTPATH}/../production/values-node-pod-antiaffinity.yaml" \
--set 'spire-server.dataStore.sql.password=sp1ff3Test' --wait spire charts/spire
helm test --namespace "${ns}" spire
helm test --namespace "spire-server" spire

print_helm_releases
print_spire_workload_status "${ns}"
print_spire_workload_status spire-server
print_spire_workload_status spire-system

if [[ "$1" -ne 0 ]]; then
get_namespace_details "${ns}"
get_namespace_details spire-server
get_namespace_details spire-system
fi
3 changes: 2 additions & 1 deletion examples/external-postgresql/values.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
spire-server:
replicaCount: 2
dataStore:
sql:
databaseType: postgres
databaseName: spire-server
host: postgresql.postgresql
host: postgresql
port: 5432
username: spire
# password: CHANGE_ME
Expand Down
11 changes: 11 additions & 0 deletions examples/production/values-node-pod-antiaffinity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
spire-server:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app.kubernetes.io/component
operator: In
values:
- server
topologyKey: kubernetes.io/hostname

0 comments on commit 5273f4e

Please sign in to comment.