Skip to content

Manual & Automatic Deployments with CNO Deploy

Your teams are on deck, and your environments are running at full speed.

Finally, it's time to deploy your applications.

CNO built several advanced deployment strategies to let you deploy with all confidence in production, with templatized frameworks.

This section will show you how to use CNO to manage the deployment of your applications.
We will show you how to scale up/down applications, manually deploy new versions (continuous delivery), and detect and auto-deploy new versions pushed on your docker registry (continuous deployment).

Prerequisites

Before Starting

You must have created a project with a few environments at this point.

Let's make sure you can deploy with docker first.

Create and push an image to your docker registry

First, clone the version-printer repo

git clone https://github.com/beopencloud/version-printer.git
cd version-printer

Then, build and push version 1.0.0 of CNO to your docker registry.

git checkout 1.0.0
docker build . -t <your username>/version-printer:1.0.0
docker push <your username>/version-printer:1.0.0

Finally, build and push version 2.0.0 of CNO to your docker registry.

git checkout 2.0.0
docker build . -t <your username>/version-printer:2.0.0
docker push <your username>/version-printer:2.0.0

Connect to the cno-cd-lab environment

cnoctl use env -e <environmentName> --project <projectName>

This command allows you to get a kubeconfig to access your environment.

Now, you can apply kubectl commands.

Deploy the version-printer application to your environment

kubectl create deployment version-printer --image <your username>/version-printer:1.0.0
kubectl create service clusterip version-printer --tcp 8080:8080

Port-forward and check if the application responds correctly

First, open a new terminal and run the following command

kubectl port-forward service/version-printer 8080:8080

On another terminal, run the following command to test if the application responds correctly:

curl -w "\n" http://localhost:8080
Result example:
version 1.0.0

A CD operator on the CNO data-plane monitors Kubernetes objects such as deployments, StatefulSets, DaemonSets, Services, and Ingress.

It's, therefore, possible to retrieve the list of all workloads (applications) currently in an environment. In addition, the operator also monitors the docker registry to detect new versions of applications.

You can use CD functionality from CNO's U.I. or cnoctl.
For example, we can get the list of workloads deployed in a namespace with the following command.

cnoctl get workload --project <projectName> --env <environmentName>

Scaling your applications

You can scale up/down an application directly from CNO without accessing the cluster API-server where you deployed the application.
Instead, you can do it through CNO's UI, or CNO's CLI, cnoctl.

Scaling your applications

  1. Go to Deploy > Continuous Deploy

On this board, you will find all the applications for your project. You can only edit these applications.

  1. Choose the number of replicas for your applications

  1. Define the number of replicas to your app.

  2. Press Update

You can get the list of workloads deployed in a namespace with the following command:

cnoctl get workload --project <projectName> --env <environmentName>

It should return a list in this format:

NAME STRATEGY REPLICAS IMAGE AUTO-DEPLOY LIVE STAGING STAGING-TRAFFIC HEADERS
workload Name canary replicas Number username/workloadName true/false V1.0.0 0

You can increase or decrease the number of replicas of the version-printer application by adjusting the number of replicas you want with the following command:

cnoctl deploy workload version-printer --replicas <numberReplicas>  --project <projectName> --env <environmentName>

Yay, you scaled your application! 💪

Continuous Delivery with CNO

Delivery deployment is a manual method where you will have to manually select the application's version to release to the market.

From CNO's API, it is easy to update the version of an application manually. Furthermore, it prevents you from detecting the Kubernetes cluster on which you deployed the application to retrieve a kubeconfig, allowing us to access it and type kubectl commands to update the app version.

You can do it from the CNO user interface or the command line with cnoctl.

Info

Continuous delivery is the default strategy applied for each onboarded application.
You can apply this strategy to deployment, Statefulset, and Deamonset applications.

Continuous Delivery

a) Go to Deploy > Continuous Deploy On this board, you will find all the applications for your project. You can only edit these applications.

b) Apply continuous deployment to your environment

1. Scale up or down your application if needed

  1. Select the Default strategy

  2. Select the version you want to deploy

  3. Don't push the Auto Deploy button

  4. Press Update

c) Check your app in "Go to live."

You will find on this board all the applications deployed according to the chosen strategies, in the example « Default.»

You can find below the command to choose the version of the version-printer to apply to your workload:

cnoctl deploy workload version-printer 
--version <versionNumber> --project lab --env cno-cd-lab

You can verify if the deployment is effective with this command:

cnoctl get workload --project <projectName> --env <environmentName>

And finally, you can see that the live version of the version-printer app with:

curl -w "\n" http://localhost:8080

Yay, you've deployed your application! 🥳

If you deploy a new image, CNO will identify it.
To deploy a new image, select the new version that should automatically appear. After that, you will have to re-edit your application.

Automatic strategy for Continuous Deployment

Continuous deployment is an automatic method where CNO will deploy each new onboarded version of your applications without your intervention.

CNO's CD operator can monitor your docker registry and detect any new versions of your applications. It is possible to activate the auto-deployment functionality so that each time a new version of your application is pushed on your docker registry, CNO will automatically deploy it. We can also apply filters on the name of the versions to be deployed.

You can do it through CNO's UI or CNOCTL.

Info

You can apply this strategy to deployment, statefulset, and deamonset applications.

Continuous Delivery

a) Go to Deploy > Continuous Deploy

b) Let's activate auto-deployment

1. Scale up or down your application following your needs

  1. Select the Default strategy

  2. Select the version you want to deploy

  3. Push the Auto deploy button

  4. Press Update

Your application will be automatically deployed as soon as a new version is added. So if you want to change the strategy for this one or scale your application, you will have to re-edit your application.

c) Check "Go to live."

You will find on this board all the applications deployed according to the chosen strategies, in the example « Default.»

Run the following command to activate the auto-deploy functionality for the version-printer app:

cnoctl deploy workload version-printer --auto-deploy=true --project <projectName> --env <environmentName>

By assigning the actual value to auto-deploy, you allow the version-printer to point to the last created version of the Nginx image. Each time a new version is made, the app will automatically be deployed.

By typing the following "get workload" command, you'll notice that an auto-deploy variable now appears:

cnoctl get workload --project <projectName> --env <environmentName>

Let’s build and push version 3.0.0 to your docker registry.

git checkout 3.0.0
docker build . -t <your username>/version-printer:3.0.0
docker push <your username>/version-printer:3.0.0

After this, CNO will automatically deploy version 3.0.0.

To verify if it worked, you can use the "get workload" command again:

cnoctl get workload --project <projectName> --env <environmentName>

Then, we can test with the following command.

curl -w "\n" http://localhost:8080
Result example
version 3.0.0

Run the following command to disable auto-deploy

cnoctl deploy workload version-printer --auto-deploy=false --project <projectName> --env <environmentName>

Last update: 2022-12-02