Deploying a Docker image to Kubernetes using Bitbucket Pipelines
A potential next step after building the Docker image is to deploy it to a Kubernetes cluster. By taking advantage of the redundancy capabilities in a cluster, we can perform application upgrades without a service outage occurring.
Getting ready
The instructions in this recipe assume that you have an existing Kubernetes cluster or minikube environment that was created manually.
In addition, you must manually define a deployment that runs the application in Kubernetes. So, let’s learn how to create a deployment.
Ensure the application name and the Docker registry username are available for easy reference. Execute the kubectl
command, including the necessary flags, as shown in the following code snippet. These will include the application name and Docker registry name as part of the image name:
kubectl run <my.app> --labels="app=<my.app>" --image=<my.dockerhub.username>...