Example - Deploy demochat to Kubernetes cluster

In this example we will deploy our demochat application to Kubernetes. demochat requires two services to run

  1. MongoDB
  2. demochat webserver that is implemented in Node and can be found here

We will do the following steps:

  1. Build image for demochat
  2. Deploy the demochat service to K8 cluster
  3. Access running demochat
  4. Automate demochat deployment using Codefresh pipeline
Demochat

Demochat repository can be found and forked from here:
https://github.com/containers101/demochat

Build image for Demochat

  1. Add your forked demochat repo (use the url above to find the repo).
  2. Also, choose the branch for your first build (in this case master).
  3. Select how you would like to setup your repository. In this case, our repo has a Dockerfile, so we’ll select the middle option.
  4. Clicking on Build button will trigger a regular build.
  5. When the docker image will be created, go to the tab Images to find the image containers101/demochat

More info about how to add, build and push docker image you can find in the readme of repository https://github.com/containers101/demochat

Deploy the Demochat service to K8 cluster

  1. Go to the ConfigurationIntegrationEnable Kubernetes
  1. And then add the cluster

Codefresh integrations

  1. Go to the tab Kubernetes and click on the button Add New Service
  1. The demochat application uses the mongo, therefore we need to add mongo service with the following params (see the screenshots below).

codefresh_mongo_service.png

  1. Then just click on the button Deploy
  1. The mongo service will appear on your kubernetes dashboard
  1. Click on the button Add New Service to create a Demochat service
  1. Use the screenshot below to specify the parameters of Demochat service
Parameter Value
CLUSTER choose one of your clusters
NAMESPACE choose the namespace in the dropdown list
SERVICE NAME Demochat
REPLICAS 1
EXPOSE PORT 5000
IMAGE containers101/demochat
INTERNAL PORTS 5000

codefresh_configure_kubernates_service.png

Access Demochat

On the Kubernetes tab you can see the demochat and mongo services.

codefresh_k8_services.png

Demochat was successfully deployed!

You can see the external endpoints of this service in the service view and access the application using its endpoint and port.

codefresh_external_endpoints.png

codefresh_demochat_endpoint.png

Automate Demochat deployment using Codefresh pipeline

To configure the Deploy Script in the pipeline you just need to go to the tab Repositories and click on the button Pipelines of the demochat service.

codefresh_demochat_repo.png

On the next screen, you need to enable the Push to Docker registry. Just integrate with the docker registry that you use for images on the Integration page and then select this docker registry in the dropdown list of the push step. This image will be used in the Deploy script.

codefresh_push_step.png

In the next step, you need to configure the Deploy Script

  1. Choose the option Kubernetes (Beta)
  1. Choose the cluster on which will be deployed the service
  1. Choose the namespace
  1. Select the service that will be redeployed
  1. Select the branch as condition when the Deploy Script will be performed

codefresh_deploy_script.png

Save and Build the pipeline.

codefresh_deploy_script_process.png