Automating Cloud Native Application Delivery
local graph
Chapter 11 — Automating Cloud Native Application Delivery
Section titled “Chapter 11 — Automating Cloud Native Application Delivery”In this chapter we will focus on Cloud Native application lifecycle. We’ll learn about best practices for development and delivery of Cloud Native apps and see how automation helps to develop better and ship faster.
This chapter covers everything you need to know about Cloud Native Application Delivery domain of KCNA exam that makes up 8% of the total exam questions. The following topics we’re about to cover:
- Delivery of Cloud Native applications
- CI/CD and GitOps
- Infrastructure as a Code (IaC)
This is the last technically packed chapter of the book. You’re almost ready to take the exam and become Kubernetes and Cloud Native associate. Carry on!
Delivery of Cloud Native applications
Section titled “Delivery of Cloud Native applications”Modern applications are often developed at a high velocity which requires efficient and robust delivery processes. That is why Cloud Native applications delivery is a rather complex, but highly automated process consisting of multiple stages.
First, developers write code and commit it to a Version Control System (VCS) such as Git, Mercurial or Subversion with Git being de-facto standard today. The code is then built, tested and released. Automating those stages makes it possible to speed up the whole process of software delivery and make small, frequent, and well-tested software releases.
Release
Is a version of software including the changes (new features, enhancements, bugfixes, etc.) to be delivered to the users. Each release has semantic versioning where v1.0.0 commonly stands for the first stable release (More about semantic versioning can be found in Further Reading section).
To release (as a verb) is also commonly used for describing the process of deploying to a production environment, e.g., making new software version available to the end users.
Strictly speaking, the application delivered doesn’t have to be Cloud Native. However, with Cloud Native architectures that are often based on microservices, it is pretty much impossible to do all the build-test-release stages manually. Imagine for a moment you’d have to do it 30 times for 30 different microservices – slow, error prone, and tedious work. That is why automation became an essential part of modern application lifecycle and brought us many benefits including the following:
- Faster delivery times and more frequent updates
- More stable releases with automated processes
- More productivity as manual work minimized
- Fewer bugs with automated test runs
- Repeatable results
Obviously, there is more to it than just build-test-release as every service should also be deployed, operated and monitored as suggested on Figure 11*.1* below:

Figure 11.1 – modern application lifecycle.
This loop is infinite, and automation of the stages makes it possible to release the changes and updates even multiple times per day. In fact, it also saves a lot of developer’s time so that they could focus on developing new features and fixing bugs. It should also be possible to roll back the changes easily and fast in case of any issues (one example of how to do it with Kubernetes and Helm was discussed previously in Chapter 8).
Now that we know about the basics of Cloud Native application delivery, let’s dive into CI/CD and GitOps.
CI/CD and GitOps
Section titled “CI/CD and GitOps”You might have heard it before, CI stands for Continuous Integration and CD for Continuous Delivery or sometimes Continuous Deployment.
Continuous Integration
Is a practice and process automation targeting developers. With CI, code changes are regularly built, tested and integrated into a shared repository (branch/trunk/etc.)
CI is viewed as a solution to the problem of having too many changes in development at once that might conflict with each other and being hard to merge. The ultimate goal is to ensure that the software is always in the working state and in case automated tests fail, the team has to fix the problem first, before continuing with development.
Continuous Delivery
Usually refers to an automation in the pipeline where the tested code changes mark a release that is uploaded to a package repository or container image. From there on, the image or a package can be deployed after approval.
Continuous Delivery can be seen as a way to align development and business teams and its purpose is to ensure that it would take minimum time and effort to deploy new code. In Continuous Delivery, there is normally an approval that should be done by a human before the release can be deployed to a production environment.
Continuous Deployment
Is a further automation for deploying changes from the source repository to a development, testing or production environments. It is essentially Continuous Delivery except deployment happens automatically when all the tests and checks have passed.
Schematically, this can be seen as follows in Figure 11*.2*:

Figure 11.2 – the CI/CD/CD pipelines.
Needless to say, there are many ways how to implement CI or CD automation in any organization, and there is no single right way of doing it. We can use different tools, introduce custom checks or deployment schedules, involve various stakeholders for approval, etc. However, one thing that will always be present is a Pipeline.
Ci/CD Pipeline
Is a top-level component which implements automation processes. Pipeline typically consists of multiple jobs and stages where output of one job or stage can be used as an input for the next job/stage. Pipeline might invoke multiple tools to compile the code, run unit tests, perform code analysis, create binaries, package code into container and so on.
Why we often refer to pipelines when talking about CI/CD is because many processes in software delivery have sequential steps that are executed one after another. You can think of it as a pipe where the source code comes in on one side and built and tested package come out on another side. Or, possibly, the package is being deployed on the other end. And this process repeats all over again as previously shown on Figure 11*.1*.
Speaking about the packages and change sets, it is considered best to release and deploy small changes often, rather than infrequently do big changes, especially when implementing Continuous Deployment. When the change set is small, there is much lower risk of things going wrong, so it is recommended to release and deploy small, tested changes regularly instead of deploying many changes together as big bang once in a while.
Now that we’ve covered the concept, let’s mention few tools that can help us to implement CI/CD automation. There are many tools available today and despite different feature sets, they all can be used to build and run CI/CD pipelines. Some might be a better fit for your tech stack with better support for one or another VCS, some provide Kubernetes and various IaaS/PaaS integrations, and some are only available as a service. CI/CD system offered as a service means provider will take care of its maintenance, updates, scaling and so on for a monthly fee. Make sure to conduct some research before picking one for your team.
Listed here are a few popular CI/CD systems that you might want to check out:
- ArgoCD
- Jenkins
- Gitlab CI
- Tekton
- GitHub Actions
- Spinnaker
- FluxCD
- GoCD
- CircleCI
- TravisCI
Note
The presence of CI or CD in the names does not mean you can only implement CI or CD with that tool. Some of the tools could be used for implementing both CI and CD and some not.
GitOps
Section titled “GitOps”Previously, we’ve learned about DevOps, DevSecOps, FinOps, and now there is one more Ops to go – GitOps. Introduced in 2017, it is a further evolution of industry best practices and CI/CD applied for modern infrastructure and Cloud Native application delivery.
GitOps
Is an operational framework combining DevOps practices such as Git version control, collaboration, compliance, declarative configuration, and CI/CD.

Figure 11.3 – overview of GitOps.
GitOps based upon three core elements:
Merge Requests (MR) + Infrastructure as a Code (IaC) + CI/CD
- Merge Requests are the change mechanism offered by Git version control system. MR is where the team collaborates and does code reviews and leaves comments. When a MR is approved, the changes are typically merged into the main (
master) branch and commit messages along with comments serve as an audit log. - IaC is the topic of the upcoming section, but at a high-level, it is a practice of describing desired infrastructure configuration and setup as a code that is kept in Git repository. IaC is an example of declarative configuration that serves as the source of truth for your infrastructure.
- CI/CD is an essential part of GitOps and its purpose is not just to automate the delivery stages described in the previous section, but also to avoid manual changes and eliminate infrastructure drift. Manual changes are not tolerated with GitOps.
Infrastructure (configuration) drift
Is when the real-time state of the infrastructure does not match what has been defined in your IaC configuration. Drift can be caused by manual human actions, applications making unintended changes, software bugs and other reasons.
Drift can cause uncertainty, application failures, and even introduce security holes. That is why eliminating infrastructure drift is very important and GitOps does this job well if implemented right. If someone did manual changes, then latest on the next MR being accepted and merged into the source of truth Git repository those manual changes will be overwritten and drift will be eliminated.
Furthermore, some advanced GitOps tools such as ArgoCD, FluxCD and Jenkins X have the capability to constantly watch the changes in Git repository and propagate those to a connected live environment. The system will resync and bring environment to the desired state automatically – any manual change on the live environment will be overwritten in a matter of seconds. New changes coming from code merged in Git will be deployed automatically and fast.
One thing to keep in mind is that ArgoCD, FluxCD and Jenkins X require Kubernetes cluster to run on. That does not mean it is impossible to implement GitOps without Kubernetes, but implementing it with Kubernetes is much easier due to developed ecosystem and its ultimate reconciliation loop functionality that brings cluster resources to the desired state (see Chapter 5 in case you’ve forgotten).
Let’s consider the following example to see how GitOps and K8s can complement each other. Imagine your team operates microservices on Kubernetes and specification definitions are stored in Git repository which acts as the source of truth. You use ArgoCD for GitOps that deploys K8s manifests to the target Kubernetes clusters. A new colleague has recently started in your team and got the task to decommission a microservice that is no longer needed.
Unfortunately, the new colleague was not fully onboarded with the processes and started deleting Kubernetes resources manually with kubectl which is a GitOps anti-pattern. By mistake, he/she has deleted wrong K8 Deployment which belonged to another microservice in production environment. Kubernetes controller loop kicked in and started terminating Pods managed by that Deployment, bringing wrong microservice down. Luckily, ArgoCD had auto-sync turned on and detected that the state of both affected microservices has drifted away from the definition located in Git repository. ArgoCD kicked in and quickly created missing Deployment and other manually deleted resources. The service quickly came back online. A colleague has opened a MR to change the desired state in Git correctly which got approved by the teammates and merged. In an event of wrong changes been merged into Git, it is just as easy to roll them back by simply reverting the respective commit.
Figure 11*.4* demonstrates an example GitOps process:

Figure 11.4 – CI/CD and GitOps example with ArgoCD and Kubernetes.
If you decide to implement similar process in your team or organization, consider the fact that ArgoCD is suitable for GitOps and CD, but for implementing CI, you’ll need an additional tool. That could be, for example, Argo Workflows or Gitlab CI or similar.
To wrap it up, GitOps is a very powerful framework that primarily focuses on CD and CI. It allows to deliver software at a very fast pace, maximize stability, increase productivity and free up productive time for the team as manual operations are automated. All configurations are transparent, auditable and reviewable. For best results and maximum efficiency, you also need to implement CI to automate testing and building of the applications.
Finally, let’s talk about IaC in more detail.
Infrastructure as a Code (IaC)
Section titled “Infrastructure as a Code (IaC)”IaC is the practice of managing and provisioning infrastructure in a declarative way via definition files. You describe the desired state in definition files and let a tool apply the configuration to your environment.
Don’t worry, despite the presence of the word Code that does not mean you’ll need to learn how to code in C++ or Java or other advanced programming language. Most IaC tools allow configuration to be defined in YAML or a similar human-readable markup language.
IaC automates and replaces manual operations for infrastructure configuration and provisioning. Essentially, all actions that can be done using your cloud provider UI or CLI manually can be done with an IaC tool. Instead of clicking through the dashboard to configure and provision VM every time you need one, you could describe the desired number and type of VMs you need in IaC and keep that configuration in Git or other version control. Invoking an IaC tool with desired configuration will establish communication with cloud provider API and create described resources. If resources were there before and configured correctly, IaC tool won’t do any further changes. Resources that IaC can provision include VMs, load balancers, network attached storage, firewall rules, object storage buckets and much-much more.
Today, Terraform is one of the most popular IaC tools on the market. It supports major public and private cloud providers and most of their IaaS/PaaS/SaaS/FaaS offerings.
Terraform accepts JSON as well as own .tf definition file format and here is a small example to give you an idea what it looks like:
terraform { required_providers { aws = { source = "hashicorp/aws" version = "~> 4.16" } } required_version = ">= 1.2.0"}provider "aws" { region = "eu-central-1"}resource "aws_instance" "kcna_demo_vm" { ami = "ami-051835d754b74795c" instance_type = „t3.medium" tags = { Name = "KCNAExampleInstance" }}If applied, this definition file will provision a t3.medium type VM tagged KCNAExampleInstance in AWS public cloud in eu-central-1 region. This VM can also be referenced again in other definition files, for example, if you’d like to attach a storage block device to it.
For the scope of KCNA, you don’t need to memorize the format or .tf specifics, but you need to remember the advantages of IaC which were already mentioned in the previous section since IaC is an essential part of GitOps:
- Faster setup and reproducible results.
- Human-readable and reviewable configuration that can be stored in VCS.
- Elimination of infrastructure drift with desired state definition.
Worth mentioning that some cloud providers have their own, vendor specific IaC tools that might offer better support for their cloud services, but obviously won’t be compatible with any other providers. CloudFormation – an IaC made by AWS only for AWS would be such an example.
If you remember the exercises we did in Chapters 5 and 6, we basically used IaC with Kubernetes. Kubernetes uses declarative resource definitions to describe workloads but can also be used to provision load balancers (with LoadBalancer Service type) and persistent storage (as PV and PVC). When you run it in a public cloud environment and apply the specification, Kubernetes cloud controller manager will interact with provider APIs and ensure that resources are provisioned and in the desired state.
Summary
Section titled “Summary”In this chapter we’ve learned about the delivery of Cloud Native applications. Modern applications require CI/CD to automate all stages of software delivery.
Where CI focuses on the first build-test-release stages, Continuous Delivery focuses on packaging software in container images or installable software packages and uploading them into container registry or package repositories respectively.
Another CD – Continuous Deployment focuses on automatic deployment of the tested and packaged releases into various live environments.
Next, we’ve seen how GitOps evolved on top of CI/CD by adding reviewable merge (or pull) requests together with IaC. This has led to an ultimate, highly automated, and powerful process that works especially well with Kubernetes. Some of the popular tools that help implementing GitOps are ArgoCD, FluxCD and Jenkins X.
IaC is the practice of managing and provisioning infrastructure in a declarative way with definition files. Using IaC allows to eliminate Infrastructure Drift and have reviewable and reproducible infrastructure configuration. Terraform is one of the most popular IaC tools today.
Going with IaC and GitOps means no manual changes, no manual deployments or live reconfiguration is allowed. The whole team should be aware and follow the process. Git repositories act as a source of truth and CI/CD systems ensure that this desired state is reached and maintained.
And with that we’ve finished the last technical chapter! Congratulations and well done! In the next two chapters you’ll find a mock exam to evaluate your readiness as well as tips on how to pass the exam and what to do after.
Questions
Section titled “Questions”Correct answers can be found at __TBD__
- What does CI mean?
- Continuous Interaction 2. Continuous Improvement 3. Continuous Integration 4. Continuous Inspection
- Which of the following stages are the focus of CI automation (pick multiple)?
- Release 2. Build, Test 3. Deploy 4. Package
- Which of the following definitions are correct for CD (pick multiple)?
- Continuous Debugging 2. Continuous Delivery 3. Continuous Destruction 4. Continuous Deployment
- Which of the following is considered a CI/CD practice?
- Frequent, large releases done by the whole team together 2. Frequent, small, and fully automated releases 3. Frequent, small, well tested, and automated releases 4. Infrequent, large, and automated releases
- Which of the following tools are suitable for GitOps (pick multiple)?
- Jenkins X 2. FluxCD 3. TravisCI 4. ArgoCD
- Which of the following elements are a part of GitOps (pick multiple)?
- Kubernetes 2. CI/CD 3. IaC 4. Merge (or pull) Requests
- Which VCS is used with GitOps?
- Bitbucket 2. Subversion 3. Git 4. Mercurial
- What is infrastructure drift?
- When the infrastructure is fully automated and can drift on autopilot 2. When the number of VMs in cloud has increased due to autoscaling events 3. When the performance of VMs varies during the day depending on demand 4. When the real infrastructure state is different from what is desired and defined by IaC
- What should NOT be done with established GitOps process in team?
- Monitoring the system state 2. Opening (pull) merge requests 3. Manual changes in the live environment 4. Reviewing teammate’s code as tests are automated
- What is normally defined with IaC (pick multiple)?
- System architecture 2. VMs and load balancers 3. Database migrations 4. Firewall rules
- What are the benefits of GitOps (pick multiple)?
- Faster and more stable software delivery 2. No need to monitor live environments anymore 3. More free time for the team due to high degree of automation 4. All Kubernetes operations are handled by CI/CD
- What are the benefits of CI (pick multiple)?
- Automatic deployment of tested code 2. Automatic packaging of tested code 3. No developer time spent for running builds or tests 4. Issue detection with automated tests
- What is a correct definition of a release?
- A version of software to be delivered to the users 2. A current state of application in K8s cluster 3. A decision to stop further development 4. A complete CI/CD pipeline run
- Which of the following is a CI/CD tool?
- CloudFormation 2. Terraform 3. GitlabCI 4. Subversion
- What normally triggers a deployment in GitOps?
- Push into any Git branch 2. An event of infrastructure drift 3. Approved and merged MR (PR) 4. Manual rebase in Git
- Which of the following is true about GitOps (pick multiple)?
- Overwrite of manual changes 2. It is only possible with Kubernetes 3. Uses declarative configuration 4. Can only be used with a few popular programming languages
- Which of the following stages are NOT a part of CI/CD (pick multiple)?
- Monitor 2. Build 3. Plan 4. Code