- A demonstration project that uses Terraform to provision Google Kubernetes Engine [GKE] cluster(s) and installs Ondat - a software-defined, cloud native storage platform for Kubernetes.
- The goal of this project is to automate the process of creating, managing and destroying a GKE cluster with
terraform
. During the creation of a cluster, Ondat is installed using thekubectl-storageos
plugin.
- The goal of this project is to automate the process of creating, managing and destroying a GKE cluster with
- For information on resource requirements required to run Ondat, refer to the official Ondat prerequisites documentation.
- Required utilities to ensure that deployments are executed successfully.
terraform
,gcloud
,kubectl
,kubectl-storageos
- Tested on;
UBUNTU
,UBUNTU_CONTAINERD
- Ensure that the
gcloud
CLI is installed on your local machine and is in your path.- Initialise
gcloud
CLI.
- Initialise
- Set the project property for
gcloud
. - Authorise
gcloud
CLI to access Google Cloud using your user account. - Ensure that the Kubernetes Engine API and Compute Engine API are enabled.
- Ensure that the
terraform
CLI is installed on your local machine and is in your path. - Apple M1 users may get the following error message when they run
terraform init
on their machine.
Error: Incompatible provider version
│
│ Provider registry.terraform.io/hashicorp/template v2.2.0 does not have a package available for your current platform, darwin_arm64.
│
│ Provider releases are separate from Terraform CLI releases, so not all providers are available for all platforms. Other versions of this provider may have different platforms supported.
╵
- This is due to the
hashicorp/template
provider being deprecated, but some providers still depend on it. To address this issue, apply the following workaround solution.
# clone the template provider repository.
$ git clone [email protected]:hashicorp/terraform-provider-template.git
# navigate into the directory.
$ cd terraform-provider-template/
# build the template provider from source (requires Golang to be installed).
$ go build
# make the generated binary executable.
$ chmod -v +x terraform-provider-template
# create the following directory and move the binary into `darwin_arm64/`.
$ mkdir -v ~/.terraform.d/plugins/registry.terraform.io/hashicorp/template/2.2.0/darwin_arm64/
$ mv -v terraform-provider-template ~/.terraform.d/plugins/registry.terraform.io/hashicorp/template/2.2.0/darwin_arm64/
# go back to the `terraform-gke-ondat-demo/` directory containing
# the configuration files and initialise again.
$ terraform init
- Ensure that the
kubectl
CLI is installed on your local machine and is in your path. - Ensure that the
kubectl-storageos
plugin CLI is installed on your local machine and is in your path. - Ensure that the
storageos
CLI is installed on your local machine and is in your path.
# clone the repository.
$ git clone [email protected]:hubvu/terraform-kubernetes-ondat-demo.git
# navigate into the `aks/` directory.
$ cd terraform-kubernetes-ondat-demo/gke/
# initialise the working directory containing the configuration files.
$ terraform init
# validate the configuration files in the working directory.
$ terraform validate
# create an execution plan first.
$ terraform plan
# execute the actions proposed in a plan and enter your PROJECT_ID.
$ terraform apply
# after the cluster has been provisioned, inspect the pods with
# kubectl and the generated kubeconfig file.
$ export KUBECONFIG="${PWD}/kubeconfig-ondat-demo"
# or use `gcloud` to get the cluster credentials automatically added
# to your `$HOME/.kube/config`.
$ gcloud container clusters get-credentials terraform-gke-cluster-ondat-demo --region="europe-west1"
$ kubectl get pods --all-namespaces
# destroy the environment created with terraform once you
# are finished testing out GKE & Ondat.
$ terraform destroy
- Review the Ondat Demo README.md for an overview of Ondat and its usage.