Thursday, February 29, 2024
HomeSoftware EngineeringThe right way to Deploy a Docker Container to Kubernetes

The right way to Deploy a Docker Container to Kubernetes

After you have a Docker container, it’s actually easy to deploy it to Kubernetes.

Generate a Deployment YAML

kubectl gives a incredible means to assist generate deployment yamls.

kubectl create deployment <app_name> --image=<some/picture> --dry-run=shopper -o yaml > <deployment_file_name>.yaml

Carry out the Deployment

Now that we’ve a deployment yaml, we are able to merely run:

kubectl apply -f <deployment_file_name>.yaml

What subsequent?

Subsequent you would possibly need to add a Service in order that the deployment is out there to the world.

Open up the deployment yaml file generated and add the next:

apiVersion: v1
variety: Service
  title: lb-service
    app: lb-service
  sort: LoadBalancer
  - port: 80
     targetPort: 5000
    app: <app_name>

Be aware that the above Service makes use of a LoadBalancer sort, listens for requests on port 80, forwards them onto port 5000 to the app specified within the selector label.

We referred to as this <app_name> above, which it’s best to swap out with no matter appname you selected earlier than. That is specified by the label used within the unique yaml.



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments