From 26c677085f91690d9f2f5816324ffc78e8b10e92 Mon Sep 17 00:00:00 2001 From: Alexander Dejanovski Date: Wed, 29 Sep 2021 16:37:05 +0200 Subject: [PATCH] Sanitize client config object names and create a script to deploy on GKE multi cluster [K8SSAND-931] (#158) * Sanitize client config object names and create a script to deploy on GKE multi cluster * Remove the reliance on kubectx and remove the k8ssandra cluster creation from the script --- api/v1alpha1/zz_generated.deepcopy.go | 1 + .../default/cass-operator/kustomization.yaml | 2 +- docs/install/deploy-gke-multi.sh | 84 +++++++++++++++++++ scripts/create-clientconfig.sh | 5 +- 4 files changed, 89 insertions(+), 3 deletions(-) create mode 100755 docs/install/deploy-gke-multi.sh diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 6f05d4676..b30d409ff 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* diff --git a/aux-config/default/cass-operator/kustomization.yaml b/aux-config/default/cass-operator/kustomization.yaml index 719637597..34050a42b 100644 --- a/aux-config/default/cass-operator/kustomization.yaml +++ b/aux-config/default/cass-operator/kustomization.yaml @@ -1,4 +1,4 @@ namespace: default resources: -- github.com/k8ssandra/cass-operator/config/default?ref=v1.8.0-rc.1 +- github.com/k8ssandra/cass-operator/config/default?ref=v1.8.0-rc.2 # namePrefix: cass-operator- # Can be removed in this case because cass-operator already has a namePrefix defined in the repo. \ No newline at end of file diff --git a/docs/install/deploy-gke-multi.sh b/docs/install/deploy-gke-multi.sh new file mode 100755 index 000000000..fa25dc6fb --- /dev/null +++ b/docs/install/deploy-gke-multi.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +# +# As a prerequisite, cluster1 and cluster2 need to have a firewall rules allowing +# communications between their Pods CIDRs on ports 7000/7001 (Gossip) and 8080 (management API) +# +# Change the following variables to match your setup +# cluster1=k8ssandra-testing-dc1 +# zone1=us-central1-c +# cluster2=k8ssandra-testing-dc2 +# zone2=us-west1-a +# gcp_project=community-ecosystem + + +# Add kubeconfig entries for both clusters +gcloud container clusters get-credentials $cluster1 --zone $zone1 --project $gcp_project +gcloud container clusters get-credentials $cluster2 --zone $zone2 --project $gcp_project + +# Install cert manager on both clusters +kubectl config use-context gke_${gcp_project}_${zone1}_${cluster1} +kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.3.1/cert-manager.yaml +kubectl config use-context gke_${gcp_project}_${zone2}_${cluster2} +kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.3.1/cert-manager.yaml + +# Install the k8ssandra control plane +kubectl config use-context gke_${gcp_project}_${zone1}_${cluster1} +kustomize build aux-config/control_plane | kubectl apply -f - + +# Install the k8ssandra data plane +kubectl config use-context gke_${gcp_project}_${zone2}_${cluster2} +kustomize build aux-config/data_plane | kubectl apply -f - + +# Create the client config +export KUBECONFIG=./build/kubeconfigs/${cluster1}.yaml +gcloud container clusters get-credentials ${cluster1} --zone ${zone1} --project ${gcp_project} +export KUBECONFIG=./build/kubeconfigs/${cluster2}.yaml +gcloud container clusters get-credentials ${cluster2} --zone ${zone2} --project ${gcp_project} +unset KUBECONFIG + +scripts/create-clientconfig.sh --src-kubeconfig build/kubeconfigs/${cluster2}.yaml --dest-kubeconfig build/kubeconfigs/${cluster1}.yaml --in-cluster-kubeconfig build/kubeconfigs/${cluster2}.yaml --output-dir clientconfig + +# Restart the k8ssandra-operator pod on the control-plane +kubectl config use-context gke_${gcp_project}_${zone1}_${cluster1} +kubectl delete pod -l control-plane=k8ssandra-operator + +# Create a K8ssandraCluster +echo "You can create a K8ssandra cluster by running the following command, after adjusting it to match your requirements: + +cat < "$clientconfig_path" <