From 5273f4e53022064ceeefe3828a0a58d5d27484b4 Mon Sep 17 00:00:00 2001 From: kfox1111 Date: Fri, 1 Sep 2023 12:25:07 -0700 Subject: [PATCH] Switch mysql and postgresql tests to HA Production configs (#471) Signed-off-by: Kevin Fox --- .github/kind/conf/kind-config.yaml | 2 ++ examples/external-mysql/run-tests.sh | 30 +++++++++------- examples/external-mysql/values.yaml | 3 +- examples/external-postgresql/run-tests.sh | 34 +++++++++++-------- examples/external-postgresql/values.yaml | 3 +- .../values-node-pod-antiaffinity.yaml | 11 ++++++ 6 files changed, 53 insertions(+), 30 deletions(-) create mode 100644 examples/production/values-node-pod-antiaffinity.yaml diff --git a/.github/kind/conf/kind-config.yaml b/.github/kind/conf/kind-config.yaml index 7c0cd3f..536dbcb 100644 --- a/.github/kind/conf/kind-config.yaml +++ b/.github/kind/conf/kind-config.yaml @@ -16,3 +16,5 @@ kubeadmConfigPatches: nodes: - role: control-plane - role: worker + - role: worker + - role: worker diff --git a/examples/external-mysql/run-tests.sh b/examples/external-mysql/run-tests.sh index b6b5ee5..76d6c1b 100755 --- a/examples/external-mysql/run-tests.sh +++ b/examples/external-mysql/run-tests.sh @@ -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 diff --git a/examples/external-mysql/values.yaml b/examples/external-mysql/values.yaml index 129ee27..c6354a4 100644 --- a/examples/external-mysql/values.yaml +++ b/examples/external-mysql/values.yaml @@ -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 diff --git a/examples/external-postgresql/run-tests.sh b/examples/external-postgresql/run-tests.sh index 1ffe1f6..fdb310d 100755 --- a/examples/external-postgresql/run-tests.sh +++ b/examples/external-postgresql/run-tests.sh @@ -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 diff --git a/examples/external-postgresql/values.yaml b/examples/external-postgresql/values.yaml index 8972e87..4d191a2 100644 --- a/examples/external-postgresql/values.yaml +++ b/examples/external-postgresql/values.yaml @@ -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 diff --git a/examples/production/values-node-pod-antiaffinity.yaml b/examples/production/values-node-pod-antiaffinity.yaml new file mode 100644 index 0000000..4fad729 --- /dev/null +++ b/examples/production/values-node-pod-antiaffinity.yaml @@ -0,0 +1,11 @@ +spire-server: + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - labelSelector: + matchExpressions: + - key: app.kubernetes.io/component + operator: In + values: + - server + topologyKey: kubernetes.io/hostname