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
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 metadata: title: lb-service labels: app: lb-service spec: sort: LoadBalancer ports: - port: 80 targetPort: 5000 selector: 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
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.