Terraform kubernetes provider on minikube. Creating kubernetes namespaes

2021, Mar 26    

Prerequisites :

  • terraform
  • minikube

1) Start minikube :

minikube start

2) Clone this article GIT repo :


cd namespaces

Edit main.tf file, and edit appropiately to point to your kubeconfig file location :

provider "kubernetes" {
  config_context_cluster   = "minikube"
  config_path = "~/.kube/config"

3) Initialize terraform

terraform init

4) Plan

terraform plan

5) Terraform apply

terraform apply

6) Verify Namespaces get created

kubectl get ns

Should show :

NAME                     STATUS   AGE
applications-namespace   Active   6s
monitoring-namespace     Active   6s
default                  Active   37d
kube-node-lease          Active   37d
kube-public              Active   37d
kube-system              Active   37d