I am trying to run terraform as a container in minikube but the container is getting crash loop back

5/7/2021

I am trying to run terraform as a container in minikube but the container is getting crash loop back This is the cmdlet i am using kubectl create deployment terraform --image=hashicorp/terraform:light please suggest how to resolve this

-- Abhishek Singh
kubernetes
kubernetes-pod
minikube
terraform

1 Answer

5/7/2021

The hashicorp/terraform:light container's entrypoint is terraform. Thus you must provide a valid argument when starting the container.

(You could find if you check the logs of crashed pod.)

You can override the docker ENTRYPOINT in command line to keep the pod running.

kubectl create deployment terraform --image=hashicorp/terraform:light -n test -- sleep 3600

$ kubectl get po -n test
NAME                         READY   STATUS             RESTARTS   AGE
terraform-5f7bfdc955-95pt6   1/1     Running            0          25s

$ kubectl exec -it terraform-5f7bfdc955-95pt6 -n test sh  
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
/ # terraform -version
Terraform v0.15.3
on linux_amd64
-- hariK
Source: StackOverflow