Example - Deploy demochat to Kubernetes cluster
In this example we will deploy our
demochat application to Kubernetes.
demochat requires two services to run
demochatwebserver that is implemented in Node and can be found here
We will do the following steps:
- Build image for
- Deploy the
demochatservice to K8 cluster
- Access running
demochatdeployment using Codefresh pipeline
Demochat repository can be found and forked from here:
Build image for Demochat
- Add your forked
demochatrepo (use the url above to find the repo).
- Also, choose the branch for your first build (in this case
- Select how you would like to setup your repository. In this case, our repo has a Dockerfile, so we’ll select the middle option.
- Clicking on
Buildbutton will trigger a regular build.
- When the docker image will be created, go to the tab
Imagesto find the image
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
- Go to the
- And then add the cluster
- Go to the tab
Kubernetesand click on the button
Add New Service
demochatapplication uses the mongo, therefore we need to add
mongoservice with the following params (see the screenshots below).
- Then just click on the button
- The mongo service will appear on your kubernetes dashboard
- Click on the button
Add New Serviceto create a Demochat service
- Use the screenshot below to specify the parameters of Demochat service
|CLUSTER||choose one of your clusters|
|NAMESPACE||choose the namespace in the dropdown list|
Kubernetes tab you can see the
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.
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.
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.
In the next step, you need to configure the Deploy Script
- Choose the option Kubernetes (Beta)
- Choose the cluster on which will be deployed the service
- Choose the namespace
- Select the service that will be redeployed
- Select the branch as condition when the Deploy Script will be performed
Save and Build the pipeline.