Skip to content
Homelab

Installation

Prerequisites

  • git must be installed
  • terraform-cli must be installed
  • clster should be configured in you ~/.kube/config file

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/tap
brew install hashicorp/tap/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/tap
brew install hashicorp/tap/terraform

Create Kubernetes Cluster

The following variables are required as input to the module:

Oracle Cloud Infrastructure Provider

VariableDescription
tenancy_ocid10.0.1.0/24
user_ocid10.0.2.0/24
private_key_encoded10.0.3.0/24
fingerprint10.0.3.0/24

Cloudflare Provider

VariableDescription
cloudflare_api_key10.0.0.0/28

Grafana Cloud Provider

VariableDescription
grafana_cloud_api_key10.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.

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.