Installation
Prerequisites
- git must be installed
- terraform-cli must be installed
- clster should be configured in you
~/.kube/configfile
Install Git
Homebrew is a package manager for macOS which you can use to install Terraform. If you don’t already have Homebrew installed, you can install it now.
brew tap hashicorp/tapbrew install hashicorp/tap/terraform
pnpm astro add starlight
Chocolatey is a package manager for Windows which you can use to install Terraform. If you don’t already have Chocolatey installed, you can install it now.
choco install terraform
Install Terraform
Homebrew is a package manager for macOS which you can use to install Terraform. If you don’t already have Homebrew installed, you can install it now.
brew tap hashicorp/tapbrew install hashicorp/tap/terraform
pnpm astro add starlight
Chocolatey is a package manager for Windows which you can use to install Terraform. If you don’t already have Chocolatey installed, you can install it now.
choco install terraform
Create Kubernetes Cluster
The following variables are required as input to the module:
Oracle Cloud Infrastructure Provider
| Variable | Description |
|---|---|
| tenancy_ocid | 10.0.1.0/24 |
| user_ocid | 10.0.2.0/24 |
| private_key_encoded | 10.0.3.0/24 |
| fingerprint | 10.0.3.0/24 |
Cloudflare Provider
| Variable | Description |
|---|---|
| cloudflare_api_key | 10.0.0.0/28 |
Grafana Cloud Provider
| Variable | Description |
|---|---|
| grafana_cloud_api_key | 10.0.0.0/28 |
leverage Terraform Cloud to manage our state files remotely Loging into Terraform Cloud and create a new organization. For our purposes we can use the free tier.The main reason for using Terraform Cloud is that we can store our state files in a secure way. However, you can also use a local state file if you prefer to do so. Connect your VCS provider to Terraform Cloud, in my case Github. Select this repository and create a new workspace. Now you can start to configure your workspace.
In the VCS settings set the directory to src/infra.
Create a commit and push the changes to your repository to trigger a plan in Terraform Cloud.
Create a new file terraform.tfvars and add the following variables
Change working directory to src/infra and initialize terraform.
terraform initIf everything looks good you can apply the changes
terraform apply -auto-approve
Populate the Cluster
First we need to set up the kubectl context to point to our new cluster.
terraform output kubeconfig > ~/.kube/config
Change working directory to src/cluster and initialize terraform.
terraform init
If everything looks good you can apply the changes
terraform apply -auto-approve
That’s it! You have now a fully functional Kubernetes cluster running the services we will see in more detail in the next sections.