Terraform kubernetes provider on minikube. Creating namespaces and running nginx deployment
2021, May 04
How to runn Nginx deployment in Minikube with Terraform in own namespace
Prerequisites :
- terraform
- minikube
What we will complete by the end of this exercise :
- Create 2 namespaces
- Deploy Nginx deployment
- Create a service with type NodePort to access it
Nodeport exposes the service on every node on a fixed port. In our case, will expose it on our minikube ip and fixed , dedicated port
Which makes it easy to access in combination with minikube ip
1) Start minikube :
2) Clone this article GIT repo :
Edit main.tf file, and edit appropiately to point to your kubeconfig file location :
3) Initialize terraform
4) Plan
5) Terraform apply
Enter : Yes
6) Verify Namespaces get created
Should show :
6) Verify Nginx pods are created
Expected output :
7) Access Nginx deployment via NodePort IP
Use the port , from the output and “minikube ip”
Taking into account my output :
Port : 30201
Minikube ip : 192.168.64.2
Nginx service will be accessible on :
8) You will see “Welcome to nginx!” page