Skip to content

jphaugla/cockroachK8sTerraformAnsible

Repository files navigation

cockroachTerraformAnsible Deploy CockroachDB on kubernetes using terraform and ansible

Purpose

Demo deployments of CockroachDB with kubernetes using terraform and ansible. Has GKE (Google), EKS (AWS) and AKS (Azure) terraform deployments. The Ansible code is deployed from a terraform provisioner subdirectory for each cloud provider. Ansible code differences between cloud providers are minimal. The ansible code could also be used in on-premise situations.

Outline

Useful Links

k8s ansible on mac

Prior to Mac OS 14, using a global python3 worked with ansible. It no longer works well-using venv instead. easiest to install ansible with brew install ansible

python3 -m venv ansible-venv
source ansible-venv/bin/activate
pip3 install requests
pip3 install google-auth
pip3 install kubernetes
pip3 install psycopg2
brew install ansible

Make sure to run terraform and ansible with this environment sourced

Single Region

GKE

  • set the parameters in the main terraform job file
    • main.tf file includes version information such as gke_release_channel, gcp credentials, region and zone
    • no need to set the variables in main parameter file
    • this parameter file is only needed for reruns to disable parts of the operation

Terraform creation GKE

kick off terraform creation-the gke creation takes a very long time-over 10 minutes

source ansible-venv/bin/activate
cd terraform/test
terraform init
terraform apply --auto-approve

Terraform creation EKS

kick off terraform creation-the eks creation takes a long time-over 10 minutes

source ansible-venv/bin/activate
cd terraform/test
terraform init
terraform apply --auto-approve
  • The terraform and ansible will deploy using the steps referenced in this cockroachDB documentation
  • To connect with the GCP need to run gcloud container clusters get-credentials
    • The appropriate parameters for this are available in the GCP cloud interface by selecting the cluster and clicking on the connect link near the top of the UI
    • Set the context to the cockroach namespace with kubectl config set-context --current --namespace=cockroach
  • To finish the steps referenced above, continue at Step 5

EKS

  • set the parameters in the main terraform job file
    • main.tf file includes version information such as cluster_prefix, credentials, IP addresses, region, vm_size, versions
    • no need to set the variables in main parameter file
    • this parameter file is only needed for reruns to disable parts of the operation

Terraform creation AKS

kick off terraform creation but must re-initialize aks if a cluster t

source ansible-venv/bin/activate
cd terraform-azure/test
terraform init
terraform apply --auto-approve

Multi-region

GKE multi-cluster

  • set the parameters in the main terraform job file
    • main.tf file includes version information such as gke_release_channel, gcp credentials, region and zone
    • no need to set the variables in main parameter file
    • this parameter file is only needed for reruns to disable parts of the operation

Ansible documentation

About

cockroach with k8s using terraform and ansible

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published