Example of running echoserver on minikube using pure terraform
Prerequisites
Steps:
- Start minikube:
minikube start
- Clone repo:
git clone git@github.com:jhole89/terraform-k8s-example.git
- Change to this directory:
cd minikube-echoserver
- Initialise terraform:
terraform init
- Apply terraform plan:
tf apply --auto-approve
- you should see the following outputkubernetes_namespace.example_namespace: Creating... kubernetes_namespace.example_namespace: Creation complete after 0s [id=example-app-namespace] kubernetes_deployment.example_deployment: Creating... kubernetes_deployment.example_deployment: Creation complete after 5s [id=example-app-namespace/example-app-deployment] kubernetes_service.example_service: Creating... kubernetes_service.example_service: Creation complete after 1s [id=example-app-namespace/example-app-service] Apply complete! Resources: 3 added, 0 changed, 0 destroyed. Outputs: node_port = 31740
- The plan outputs the
node_port
exposed through the kubernetes service (here it was 31740). You can now hit the endpoint using curl:curl $(minikube ip):31740
- Once no longer required you can remove all resources:
terraform destroy --auto-approve
- Stop minikube:
minikube stop