DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Security in the CI/CD Pipeline
  • CI/CD Pipelines for Kubernetes Using GitLab CI
  • Optimizing CI/CD Pipeline With Kubernetes, Jenkins, Docker, and Feature Flags
  • Securing Secrets: A Guide To Implementing Secrets Management in DevSecOps Pipelines

Trending

  • Monoliths, REST, and Spring Boot Sidecars: A Real Modernization Playbook
  • Creating a Web Project: Caching for Performance Optimization
  • Navigating Change Management: A Guide for Engineers
  • How to Introduce a New API Quickly Using Micronaut
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. DevOps and CI/CD
  4. Getting Started With Kubernetes-Native CI/CD Pipelines

Getting Started With Kubernetes-Native CI/CD Pipelines

Setting up CI/CD for Kubernetes is challenging. In this blog, the author walks through the process of creating k8s-native CI/CD pipelines using Devtron.

By 
Abhinav Dubey user avatar
Abhinav Dubey
·
May. 02, 23 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
6.0K Views

Join the DZone community and get the full member experience.

Join For Free

Setting up the CI/CD pipelines for Kubernetes is complex. Post setup, managing the CI/CD can become quite challenging when your team and infrastructure grow quickly. An efficient and fully automated CI/CD plays an important role in ensuring you ship your features faster.  By leveraging CI/CD, you can guarantee that the application teams ship features faster while ensuring best practices for the code base. 

In this micro-blog, we will see how easily one can create and manage the CI/CD pipelines with Devtron, but before doing that, let's do a quick refresher on CI/CD.

What Is CI/CD?

CI stands for “Continuous integration,” which is the stage where we validate and test the changes pushed by developers. It is where you run all your test cases, i.e., unit and integration tests. After we have validated and tested the codebase, we can build the software artifacts in this step; for e.g., we can build a container image, or it can be a binary executable.

CD stands for “Continuous delivery,” which is when you push your software artifacts to the production/staging environment in an automated process. In this context, after building a container image and pushing it to the container registry, we deploy the same image in the Kubernetes cluster with the help of Devtron.

What Is Kubernetes Native CI/CD?

The Kubernetes native CI/CD leverages the software delivery workflows by being part of the Kubernetes cluster. The benefit of using Kubernetes native CI/CD is that your build step will happen inside a pod, and you don’t need to provision or connect any other compute resources externally for your CI. From a security perspective, this method is recommended as all of our secrets & external credentials are within the cluster.

Kubernetes Native CI/CD With Devtron

When you're managing your pipelines with YAML, you need to write the workflow and update it repeatedly. Understanding YAML, examining the build process, learning different Linux commands, deploying code manually, and learning Kubernetes is hard for a developer. They need something intuitive, simple and doesn’t require domain expertise. Even if you don’t know much about Kubernetes, you should be able to develop, execute & trigger your builds & deployments. 

This is what we are trying to solve using Devtron. It gives you an intuitive dashboard to help you quickly set up and manage your CI/CD pipelines on Kubernetes. Let's install Devtron and set up some CI/CD pipelines for our applications.

For installing Devtron, refer to the installation documentation. After installing Devtron, we will port-forward the Devtron service to get the dashboard URL since we are installing it on a local machine.

kubectl -n devtroncd port-forward service/devtron-service 8000:80 &

After this, you should be able to access the Devtron dashboard on localhost port 8080.  

For demonstrating the CI/CD pipeline, let's use a nodejs demo application provided by Devtron on GitHub repository.

After getting this, you need to set the global configurations for your application. For setting global configuration refer to the documentation. 

Step 1: Enabling GitOps

To enable GitOps, go to global configuration and then use any Git provider for authentication. In our case, we have used GitHub. It is recommended to create a new GitHub organization of all your GitOps configs.

GitOps Configs

Step 2: Creating an Application

Now let’s move ahead and create our first application on Devtron. Provide the App Name i.e demo-application, assign it a project i.e. devtron-demo and then click on Create App.

Create App

Step 3: Adding GitHub Repository and Build Configuration

The next step is to add the Git Repo URL of your source code from where it is being hosted. If you want to deploy an application that is in a private repo, explore the Git Accounts Docs.

Adding Git Repository

Now once we have set up our repository, we need to set the build configuration. The build configuration is required to pull and push your container images. You can change the registry to use docker, ECR, GCR, etc, which can be configured from container registries under Global Configurations. 

We have now integrated Buildpacks with which you can build OCI-compliant container images directly from your code. 

Build Configurations

If you want to build a platform-specific image, then you can configure that in the advanced options in Build Configurations.

Buildx Multi-Platform Builds

Step 4: Configuring Base Deployment Template

Base Deployment Template is where all magic happens. Devtron displays a fined-grained configuration, abstracting out all the Kubernetes config complexities and packages the template in a helm chart. The deployment template consists of almost all major configurations that would be required for a production-grade microservice, and it comes with two display options — Basic (GUI Mode) & Advanced (YAML Configs).

Deployment Template GUI Mode

You can configure ContainerPort, set Requests & Limits for your deployment, provide Environment Variables, etc. There’s also an advanced option from which you can get the detailed YAML configurations that Devtron will use during deployment and overwrite the same. Here’s a glimpse of how the deployment template looks. 

Base Deployment Template

You can configure Horizontal Pod Autoscaling, Ingress, Security Context, Keda Autoscaling, Volume Mountsand many more Kubernetes configurations just with a few tweaks in the predefined template. With Devtron’s deployment template, you don’t have to worry about writings tons of YAML file for your Kubernetes configurations.

Step 5: Creating and Triggering a CI/CD Pipeline

Once you have configured the deployment template, you are ready to build your CI/CD Workflow. Let us go ahead and configure continuous integration. To know more about different ways of creating pipelines, feel free to read workflow editor documentation. In this example, we will build & deploy from Devtron Dashb

Workflow Editor - Build & Deploy from Devtron

Now, let's create our CI Build Pipeline and configure the pipeline details. In CI pipeline, you can configure vulnerabilities scanning, pre/ post build stages, give the source type i.e, Branch Fixed, Regex, Pull Request or Tag Creation for building images, and a lot more.

Build Stage - CI Pipeline

Now after the creating build pipeline, let’s create the Deployment Pipeline. Use the + icon on the same page to add your deployment pipeline. With Devtron, you can create as many pipelines as you want, be it sequential pipelines or deploy to multiple environments from the same build. 

In Deployment Pipeline you can configure pre/ post deployment stages, out-of-the-box integrations of deployment strategies i.e., Rolling, Recreate, Blue-Green, and Canary. It also allows you to choose different deployment strategies for different environments in the same application. The default deployment strategy is Rolling as you can see in the below image.

In this blog, we will proceed with Blue-Green deployment strategy. You can check out the deployment strategy configurations and make changes depending on your use case. This configuration change is an application for all other deployment strategies.

Blue-Green Deployment Strategy

After configuring the CI & CD pipelines, here’s what the entire pipeline looks like. We can create multiple workflows with different configs for different environments and build types in the same application. 

Isn't it interesting!!
Build & Deploy Workflow

Now that pipelines are created, we need to trigger our pipelines and for that we have to go to the Build & Deploy section.

To build an image, click on Select Material -> Select the Commit for which you want to build -> Click on Start Build. 

Start Build

Once the build is initiated, we can check the logs of the build process and when the build is successful then we can verify the image built in the artifacts section. It also allows you to check the previous builds, and all necessary audit info required in the dashboard as you can see in the image below.

Build History for CI Pipeline

Let’s trigger the deployment pipeline. After the build pipeline is successful, there will be an option to select image in Build & Deploy page. Select the image and then click on Deploy. We can also check the commit and security details against which deployment is being initiated. Once deployment is started, Devtron gives you details of all stages along with K8s Configurations against each deployment. In CD pipelines as well, we get all the audit info regarding the deployment as you can see in the image below.

Deployment History for CD Pipeline

Step 6: App Details 

Once your application is deployed, you can view detailed information about your application in the App Details. All the health-related information about your workloads and application metrics can be easily monitored from App Details tab.

After the application is successfully deployed, it gives you a 360-degree view of all info regarding the application and allows you to perform different pod operations such as view logs, exec into terminal, check manifests, events and also comes with Logs Analyzer that allows grep on multi-container logs. It also shows all the Kubernetes resources associated with particular applications in a grouped manner that comes very handy for debugging and observability.

App Details of deployed application

Conclusion

In this blog, we have learned about Kubernetes CI/CD and how easily it can be set up using Devtron in just 3 minutes with all the best practices and GitOps. One of the main benefits of a quick Kubernetes CI/CD setup is that it can speed up the whole release process by automating your build and continuously testing the codebase. Developers don’t need to build and test manually. A fast, reliable, and efficient Kubernetes CI/CD will lead to better products and happier users.

Contextual design Kubernetes Pipeline (software)

Published at DZone with permission of Abhinav Dubey. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Security in the CI/CD Pipeline
  • CI/CD Pipelines for Kubernetes Using GitLab CI
  • Optimizing CI/CD Pipeline With Kubernetes, Jenkins, Docker, and Feature Flags
  • Securing Secrets: A Guide To Implementing Secrets Management in DevSecOps Pipelines

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!