In this tutorial, we will see how you can deploy a Docker image to a Kubernetes cluster.
In this case, we will use the Kubernetes cluster we’ve set up in the previous tutorial Set up a Kubernetes cluster. You can also attach your existing cluster hosted on AWS, GCP, Azure, or on-premise. You will get the same CI/CD experience regardless of which cloud provider you decide to use.
We will cover two different deployment options:
- Deploying a Docker image manually
- Automating Kubernetes deployments
#Prerequisites
To follow along with this tutorial you will first need to provision a new Kubernetes cluster or connect to an existing one.
Microtica provides a native integration with Kubernetes, so that you don’t have to worry about integration and writing custom scripts at all.
#Deploying a Docker image manually
In this example we will cover a manual deployment of a public image hosted on Docker Hub on an existing Kubernetes cluster.
Before we deploy the image we need to first create a Service in Microtica. To create a new service choose Services from the left side menu under Kubernetes.
The next screen that appears is the Service list. To create new service click on the Create Service button on the top right.
Choose a name and description of your choice.
Next, you need to specify the source of the Docker image. For the purpose of this example we will choose Public Docker Image as a source and under image name type nginx.

Click on Create Service button. The next screen that appears is the service details page.
To deploy on Kubernetes click on Add To Cluster. A new modal appears with the list of available Kubernetes clusters.

Choose the appropriate cluster and hit Add To Cluster button.
Finally, we are ready to deploy on Kubernetes. Configure auto-scaling configuration if needed and click on Deploy button.

Default Kubernetes specMicrotica will automatically apply a default Kubernetes spec for the service. The default spec includes deployment config and autoscaling.
If you need more control over what and how resources are being provisioned in Kubernetes, place kube.config file in your source code root dir.
To see the status of deployed service choose Clusters from the left side menu under Kubernetes.

If you choose the cluster, the Microtica Kubernetes Dashboard will appear. Click on the service you’ve created to observe the service logs and events.

And that’s it! You now have a running Nginx server without writing any custom script, YAML files or dealing with a Kubernetes integration.
#Automating Kubernetes deployments
In the previous example we’ve deployed an existing public Docker image from Docker Hub.
Now, we’ll go further and automate the entire Kubernetes deployment. To achieve this, you need to connect your Git account with Microtica.
Connect a Git Account
To connect your Git account (GitHub or Bitbucket) go to Settings from the left menu, select Git Accounts tab and click on Connect Account button. For the account type choose GitHub or Bitbucket. You will be redirected to the provider’s authorization page. After successful authorization you will be redirected to Microtica with connected account enlisted.

Authorizing MicroticaAuthorizing with GitHub will give Microtica access to your private and public repos.
Microtica will only access your repositories during pipeline execution.
Create a new pipeline
Let’s now create a new Pipeline and connect the Git repository you’ve already connected as a source.

Choose a name and description of your choice and select the Git account and repository from the dropdown.
Click on the Create Pipeline button at the bottom to create the pipeline. You will be redirected to the pipeline details page.

Copy and past the following pipeline spec into the pipeline editor and hit on Save button.
YAML
steps:
Clone:
title: Clone the app source code from Git
type: git-clone
BuildNodeApp:
title: Build My NodeJS Application
image: node:alpine3.12
commands:
- npm install
PushDockerImage:
type: docker-push
image_name: microtica/demo-service
tag: "{{MIC_PIPELINE_EXECUTION_ID}}"
registry: dockerhub
DeployToCluster:
type: deploy
target: kubernetes
cluster: my-kubernetes-cluster
service: demo-service
tag: "{{MIC_PIPELINE_EXECUTION_ID}}"
Note that in PushDockerImage step we specified dockerhub as a name of the Docker registry which is already connected in Microtica portal.
Docker registryDocker images produced by the pipeline will be stored on your remote Docker registry as specified in the pipeline spec.
Now click on Trigger Pipeline button at the top right and choose a branch to pull the source code from.
Create a Kubernetes Service
Let’s now create a new Kubernetes Service. To do that, click on Services button from the left menu under Kubernetes and click on Create Service.
Choose a name and description of your choice.
Next thing we need to do is to specified the Docker image that will be used when deploying the service on Kubernetes. Choose the Docker registry which is already connected in Microtica portal. The registry should be the same specified in the pipeline spec. For image enter the name of the image as specified in the pipeline spec.

Click on Create Service button at the bottom.
Deploy the Service on Kubernetes
Once the pipeline is completed, go to the service details and click on Add To Cluster button.
A new modal appears with the list of available Kubernetes clusters.

Choose the appropriate cluster and hit Add To Cluster button.
Finally, we are ready to deploy on Kubernetes. Configure auto-scaling configuration if needed and click on Deploy button

To see the status of the deployed service choose Clusters from the left side menu under Kubernetes.

If you choose the cluster, the Microtica Kubernetes Dashboard will appear. Click on the service you’ve created to observe the service logs and events.

And that’s it! You now have your service running on Kubernetes with enabled CI/CD without writing any custom script or dealing with a Kubernetes integration.