When deploying docker into Kubernetes, it is a step by step processing setting it up. If you miss a single step, it will give strange errors. I suggest to go through your process for your environment and not miss a step. You may have to do this multiple time to get it right.
Having said that let’s say that you have deployed Kubenetes cluster and you have setup your kubectl correctly and now you can see Kubernetes cluster description through kubectl. For example you can run following commands:
kubectl describe pod kubectl get deployment kubectl get services
Now you are ready to deploy your docker. If you are using Container Registry in any of the cloud, you will need to follow their tagging system to be able to deploy in the Kubernetes. Once you have properly install your docker in in ECR, now you are ready to deploy.
You need to create a deployment YAML that describes the docker deployment. Once you have your YAML, deploy the docker as follows:
kubectl apply -f deployment-file.yaml
Check your deployment status with
kubectl get deployments #check your docker status kubectl describe pod kubectl get deployment kubectl get services
Now you are getting **BackOff*** error, what to do? There is no issue in deployment YAML and you can run the docker in the interactive mode. It works just fine.
The reason you get this error is that if you do not have EntryPoint in docker or if you have not described in the YAML, then Kubernetes basically does not know what to do. Thus gives this error.
To resolve, add either exec command in deployment YAML or add entry point in the docker. The easiest way to test is to add exec command section in YAML and deploy. This will deploy and run the docker. If you add “Sleep Infinity”, you will be login and run your process.
- Kubernetes Deployment https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
- Docker deployment example in Oracle Cloud, https://docs.oracle.com/en-us/iaas/developer-tutorials/tutorials/spring-on-k8s/01oci-spring-k8s-summary.htm