<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ashok Kadian on Medium]]></title>
        <description><![CDATA[Stories by Ashok Kadian on Medium]]></description>
        <link>https://medium.com/@ashokkadian?source=rss-ca41c97e91e0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*izanhO12WbxmG4ub3SsGZg.jpeg</url>
            <title>Stories by Ashok Kadian on Medium</title>
            <link>https://medium.com/@ashokkadian?source=rss-ca41c97e91e0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 09:13:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ashokkadian/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building an Efficient CI/CD Pipeline for Kubernetes — Deutsche Telekom Gurgaon]]></title>
            <link>https://blog.dtdl.in/building-an-efficient-ci-cd-pipeline-for-kubernetes-deutche-telekom-gurgaon-6c1ef7c51899?source=rss-ca41c97e91e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c1ef7c51899</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[sre]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Ashok Kadian]]></dc:creator>
            <pubDate>Wed, 13 Nov 2019 06:46:10 GMT</pubDate>
            <atom:updated>2019-11-13T09:51:01.934Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building an Efficient CI/CD Pipeline for Kubernetes — Deutsche Telekom Gurgaon</h3><h3><strong>CI/CD pipeline to manage and deploy build for 9 Countries in different namespace of Kubernetes.</strong></h3><p>Deutsche Telekom Gurgaon have multi micro-service environment. So we need a cost effective solution for managing these micro-service at scale. Our environment have 9 countries and 10–15 micro-service for each country on our e-commerce platform. We decided to go with cost effective Kubernetes to maintain the environment consistency between multiple countries. We have some shared namespace between countries for common micro-service across platform.</p><p>Now the biggest challenge is to maintain CI/CD pipeline on such ecosystem. We already using gitlab CI/CD in other project but for this one we decided to go with Jenkins CI/CD pipeline. Jenkins CI-CD is one key components through which we ensure delivering continuous quality and zero downtime deployment along with automated unit/integration test cases and sonar quality gateway. Readiness and liveness probe ensure the newly deployed Kubernetes container will not impacted the existing running pods.</p><p>Automated monitoring by Open Source Elastic APM, JVM level deep tracing with Prometheus , Node/Pod’s resources monitoring with Grafana, automatic node autoscaling on amazon, pod autoscaling ( Horizontal and Vertical ) , GC logs helps business pace up to the agility with quality.</p><h3>At a Glance :</h3><ul><li>What is Jenkins Pipeline?</li><li>What is a JenkinsFile?</li><li>JenkinsFile syntax types.</li><li>Why Use Jenkins Pipeline?</li><li>Types of CICD deployment</li><li>Best Practices using Jenkins Pipeline</li></ul><h3>What is Jenkins Pipeline?</h3><p>In Jenkins, a pipeline is a group of events or jobs which are interlinked with one another in a sequence.</p><p>In simple words, Jenkins Pipeline is a combination of plugins and stages that helps you to automate steps in your software delivery process, such as initiating code builds, running automated tests, and deploying to a staging or production environment. Automated pipelines remove manual errors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*idGgZWsP2vrYQlrlIxyCTw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q8rJPlGt8wieTLLDC-EBrQ.png" /></figure><h3>What is a JenkinsFile?</h3><p>Jenkinsfiles, using a domain specific language based on the Groovy programming language, are persistent <strong>files</strong> that model delivery pipelines “as code”, containing the complete set of encoded steps (steps, nodes, and stages) necessary to define the entire application life-cycle. JenkinsFile can be defined by either Web UI or with a JenkinsFile. You can also use custom name (MyCustomJenkinFileName) of Jenkins file, like as in below screenshot. The “MyCustomJenkinFileName” file should be in your git repo and used as custom jenkinsFile name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w4htEgfJRCUFMlySEee3Jg.png" /></figure><h3>JenkinsFile syntax types?</h3><ol><li>Declarative:</li><li>Scripted</li></ol><blockquote>Declarative pipeline is a relatively new feature that supports the pipeline as code concept. It makes the pipeline code easier to read and write. This code is written in a Jenkinsfile which can be checked into a source control management system such as Git.</blockquote><blockquote>Declarative pipeline syntax offers an easy way to create pipelines. It contains a predefined hierarchy to create Jenkins pipelines. It gives you the ability to control all aspects of a pipeline execution in a simple, straight-forward manner.</blockquote><blockquote>The declarative pipeline is defined within a block labelled ‘pipeline’.</blockquote><p><strong>Structure and syntax of the Declarative pipeline:</strong></p><pre>pipeline {<br> agent {<br>        label {<br>            label &quot;DT&quot;<br>            customWorkspace &quot;/var/lib/jenkins/workspace/${env.JOB_NAME}&quot;<br>        }<br> }<br> options {<br>     skipDefaultCheckout()<br>    }<br> parameters {<br>  choice(<br>   name: &#39;Deploy_Through&#39;,<br>   choices:&quot;Branch\nImage&quot;,<br>   description: &quot;You wanna deploy through Branch / Image!&quot;)<br>  string (<br>   name: &#39;BRANCH&#39;,<br>   defaultValue: &#39;dev&#39;,<br>   description: &#39;git branch want to deploy&#39;)<br>  string (<br>   name: &#39;image_version&#39;,<br>   defaultValue: &#39;${BUILD_DISPLAY_NAME}&#39;,<br>   description: &#39;Please left as default or pass image&#39;)<br>  choice(<br>   name: &#39;Run_Sonar&#39;,<br>   choices:&quot;Yes\nNo&quot;,<br>   description: &quot;Check sonar qualitygate!&quot;)<br>    }<br>    tools {<br>        maven &quot;mvn-DT&quot;<br>        nodejs &quot;node-DT&quot;<br>    }<br> stages {<br>  stage(&#39;Git checkout source code&#39;) {<br>    steps {<br>     checkout([$class: &#39;GitSCM&#39;,<br>     branches: [[name: &#39;$BRANCH&#39;]],<br>     doGenerateSubmoduleConfigurations: false,<br>     extensions: [[$class: &#39;CleanBeforeCheckout&#39;]],<br>     submoduleCfg: [],<br>     userRemoteConfigs: [[credentialsId: &#39;DT&#39;, url: &#39;<a href="https://git.yo-digital.com/eshop/eshop-bff.git&#39;">DT&#39;</a>]]<br>    ])<br>    script {<br>     commit_id = sh(returnStdout: true, script: &#39;git rev-parse --short HEAD&#39;)<br>     commit_id = commit_id.replaceAll(/\s*$/, &#39;&#39;)<br>    }<br>        }<br>  }</pre><pre>stage(&quot;set build name&quot;){<br>            steps {<br>                script {<br>      currentBuild.displayName = &quot;${COUNTRY}-${ENVIRONMENT}-${BUILD_NUMBER}-${commit_id}-${RUN_SONAR}&quot;<br>      currentBuild.description = &quot;${COUNTRY}-${ENVIRONMENT}-${BUILD_NUMBER}-${commit_id}-${RUN_SONAR}&quot;<br>                }<br>            }<br>  }</pre><pre>stage(&#39;Git checkout K8s code&#39;) {<br>            steps {<br>                checkout([$class: &#39;GitSCM&#39;,<br>     branches: [[name: &#39;*/master&#39;]],<br>     doGenerateSubmoduleConfigurations: false,<br>     extensions: [[$class: &#39;CleanCheckout&#39;, $class: &#39;RelativeTargetDirectory&#39;, relativeTargetDir: &#39;devops&#39;]],<br>     submoduleCfg: [],<br>     userRemoteConfigs: [[credentialsId: &#39;DT&#39;, url: &#39;<a href="https://git.yo-digital.com/eshop/eshop-eks-docker-code.git&#39;">DT&#39;</a>]]<br>    ])<br>            }<br>        }</pre><pre>stage (&#39;Build &amp; Run Test&#39;) {<br>   when {<br>                expression { params.Deploy_Through == &#39;Branch&#39; }<br>            }<br>   steps {<br>    sh &quot;mvn -Dmaven.repo.local=/var/lib/jenkins/.m2/repository/DT clean install -f assembly&quot;<br>   }<br>  }</pre><pre>stage(&#39;Sonarqube analysis&#39;) {<br>   when {<br>    allOf {<br>     expression { params.Run_Sonar == &#39;Yes&#39; }<br>     expression { params.Deploy_Through == &#39;Branch&#39; }<br>    }<br>            }<br>   environment {<br>    scannerHome = tool &#39;sonar&#39;<br>   }<br>   steps {<br>    withSonarQubeEnv(&#39;sonar&#39;) {<br>     sh &quot;${scannerHome}/bin/sonar-scanner \<br>      -Dsonar.projectKey=DT \<br>      -Dsonar.projectName=DT \<br>      -Dsonar.projectVersion=DT \<br>      -Dsonar.sources=. \<br>      -Dsonar.java.libraries=DT \<br>      -Dsonar.java.binaries=DT \<br>      -Dsonar.exclusions=DT \<br>      &quot;<br>    }<br>    timeout(time: 10, unit: &#39;MINUTES&#39;) {<br>     waitForQualityGate abortPipeline: true<br>    }<br>   }<br>  }</pre><pre>stage(&#39;jacoco code coverage&#39;) {<br>   when {<br>                expression { params.Deploy_Through == &#39;Branch&#39; }<br>            }<br>            steps {<br>    jacoco(<br>     execPattern: &#39;**/**.exec&#39;,<br>     classPattern: &#39;**/classes&#39;,<br>     sourcePattern: &#39;src/main/java&#39;,<br>     exclusionPattern: &#39;src/test*&#39;<br>    )<br>            }<br>        }</pre><pre>stage(&#39;Image Build and upload to nexus&#39;) {<br>   when {<br>                expression { params.Deploy_Through == &#39;Branch&#39; }<br>            }<br>   steps {<br>    sh &#39;&#39;&#39;<br>    imagename=DT<br>    ./devops/make_image.sh ${imagename} ${image_version}<br>    &#39;&#39;&#39;<br>   }<br>  }</pre><pre>stage(&#39;Deploy Dev?&#39;) {<br>   steps {<br>    timeout(time: 5, unit: &#39;MINUTES&#39;) {<br>     input &quot;Do you Want to deploy on dev env?&quot;<br>     sh &#39;&#39;&#39;<br>     K8sENV=dev<br>     imagename=DT<br>     AWS_PROFILE=DT kubectl apply -f devops/pl/${K8sENV}/${imagename}-${K8sENV}.yml<br>     &#39;&#39;&#39;<br>    }<br>   }<br>  }</pre><pre>stage(&#39;API Health Check&#39;) {<br>   steps {<br>    timeout(time: 5, unit: &#39;MINUTES&#39;) {<br>     sh &#39;&#39;&#39;<br>####################<br>     &#39;&#39;&#39;<br>    }<br>   }<br>  }</pre><pre>stage(&#39;Rollback Dev?&#39;) {<br>   steps {<br>    timeout(time: 5, unit: &#39;MINUTES&#39;) {<br>     script {<br>      env.DT_ROLL_BACK_DEV = input message: &#39;User input required&#39;,<br>       parameters: [choice(name: &#39;Rollback&#39;, choices: &#39;no\nyes&#39;, description: &#39;Choose &quot;yes&quot; if you want to Rollback&#39;)]<br>     }<br>    }<br>   }<br>  }</pre><pre>stage(&#39;RollingBack Dev&#39;) {<br>   when {<br>   environment(name: &#39;DT_ROLL_BACK_DEV&#39;, value: &#39;yes&#39;)<br>   }<br>            steps {<br>    script {<br>     skipRemainingStages = true<br>     println &quot;skipRemainingStages = ${skipRemainingStages}&quot;<br>    }<br>    sh &#39;&#39;&#39;<br>    K8sENV=dev<br>    imagename=DT<br>    AWS_PROFILE=DT kubectl rollout undo deployment ${imagename} --namespace eshop-poland-${K8sENV}<br>    &#39;&#39;&#39;<br>            }<br>        }</pre><pre>}</pre><pre>post {<br>        success {<br>            mail to:&quot;<a href="/service/mailto:ashok@telekom-digital.com">ashok@D</a>T.com&quot;, subject:&quot;SUCCESS: ####&quot;, body: &quot;#############&quot;<br>        }<br>        failure {<br>            mail to:&quot;<a href="/service/mailto:ashok@telekom-digital.com">ashok@DT.com</a>&quot;, subject:&quot;FAILURE: ####&quot;, body: &quot;################&quot;<br>        }<br>    }</pre><pre>}</pre><blockquote>Whereas, the scripted pipeline is a traditional way of writing the code. In this pipeline, the Jenkinsfile is written on the Jenkins UI instance.</blockquote><blockquote>The scripted pipeline is defined within a ‘node’.</blockquote><p><strong>Structure and syntax of the scripted pipeline:</strong></p><pre>node (&#39;node-1&#39;) {<br>  stage(&#39;Source&#39;) {<br>    git &#39;<a href="https://github.com/digitalvarys/jenkins-tutorials.git&#39;&#39;">https://github.com/ashok/#####.git&#39;&#39;</a><br>  }<br>  stage(&#39;Compile&#39;) {<br>    def gradle_home = tool &#39;gradle4&#39;<br>    sh &quot;&#39;${gradle_home}/bin/gradle&#39; clean compileJava test&quot;<br>  }<br>}</pre><h3>Why use Jenkin’s pipeline?</h3><p><strong>The benefits of using JenkinsFile are:<br>Contributors:</strong> This is the singular source for your pipeline and can be modified by multiple users.<br><strong>Easiness:</strong> Easy to review and audit your code on the pipeline<br>Security: No one can able to directly edit pipeline stages by Jenkins GUI.<br><strong>Version Control:</strong> A Jenkinsfile lives with the code in github. Therefore, like any production code, it can be peer-reviewed, commented and approved before being merged into master and built.<br><strong>Visualization of Stages:</strong> Jenkinsfiles allow visualization of stages, enabling developers to quickly spot which stages are failing more quickly and intuitively.<br><strong>Save time and money:</strong> Once you have written one JenkinsFile then you will save time and effort for writing other Jenkinsfile.</p><h3>Deployment strategies:</h3><p>There are several different types of deployment strategies you can take advantage of depending on your goal. For example, you may need to roll out changes to a specific environment for more testing, or a subset of users/customers or you may want to do some user testing before making a feature ‘Generally Available’.</p><h4><strong>1) Rolling Deployment: </strong>Cost effective with zero downtime</h4><p>The rolling deployment is the standard deployment to Kubernetes. It works by slowly, one by one, replacing pods of the previous version of your application with pods of the new version without any cluster downtime.</p><p>Below image indicate how different version of code live over group of pods during deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cu9ziBdQV7ZFgHfJVIHPag.png" /></figure><p>A rolling update waits for new pods to become ready via your readiness probe, liveness probe and before it starts scaling down the old ones but maxUnavailable should be 0. If there is a problem, the rolling update or deployment can be aborted without bringing the whole cluster down.</p><pre>apiVersion: extensions/v1beta1<br>kind: Deployment<br>metadata:<br>  name: DT<br>  namespace: DT-$ENV<br>spec:<br>  replicas: 2<br>  strategy:<br>    type: RollingUpdate<br>    rollingUpdate:<br>      maxSurge: 1<br><strong>      maxUnavailable: 0<br></strong>  revisionHistoryLimit: 2<br>  selector:<br>    matchLabels:<br>      app: DT</pre><p>Rolling updates can be further refined by adjusting the parameters in the manifest file:</p><pre>readinessProbe:<br>  httpGet:<br>    path: /actuator/health<br>    port: 8050<br>  initialDelaySeconds: 30<br>  timeoutSeconds: 5<br>  periodSeconds: 10<br>  failureThreshold: 10<br>livenessProbe:<br>  httpGet:<br>    path: /actuator/health<br>    port: 8050<br>  initialDelaySeconds: 30<br>  timeoutSeconds: 5<br>  periodSeconds: 10<br>  failureThreshold: 15</pre><h4>2) Recreate:</h4><p>In this type of very simple deployment, all of the old pods are killed all at once and get replaced all at once with the new ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mqL-UjOYESm-IIEACs5rYA.png" /></figure><p>This manifest looks something like this:</p><pre>apiVersion: extensions/v1beta1<br>kind: Deployment<br>metadata:<br>  name: DT<br>  namespace: DT-$ENV<br>spec:<br>  replicas: 2<br>  strategy:<br>    type: Recreate<strong><br></strong>  revisionHistoryLimit: 2<br>  selector:8f<br>    matchLabels:<br>      app: DT</pre><h4>3) Blue/ Green (or Red / Black) deployments:</h4><p>A blue/green deployment is a change management strategy for releasing software code. Blue/green deployments, which may also be referred to as A/B deployments require two identical hardware environments that are configured exactly the same way. While one environment is active and serving end users, the other environment remains idle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uoTDRK-BW9RpFLuYhXB-SA.png" /></figure><h4>4) Canary:</h4><p>Canary deployments are a bit like blue/green deployments, but are more controlled and use a more phased-in delivery approach. A canary is used for when you want to test some new functionality, typically on the backend of your application. Traditionally, you may have had two almost identical servers: one that goes to all users and another with the new features that gets rolled out to a subset of users and then compared. When no errors are reported, the new version can gradually roll out to the rest of the infrastructure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3CUfBrJmRGY_WG1AChYEjw.png" /></figure><h3>Final touch on how does it work here at T :-</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*90-Sk7tBpSlpWd1MtFxnXw.png" /></figure><p>we have two options i.e branch and Docker images to deploy code. When we trigger, jenkins build various stages of build process which is displayed on Jenkins GUI. On top of the UI historical code coverage trend is displayed. Docker image name is generated dynamically using commit ID for tracking. Status and logs of various stages can be seen in Jenkin console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pFW2nn_wxjWmm5PPuQkL4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*idGgZWsP2vrYQlrlIxyCTw.png" /></figure><p>On sonarqube analysis stage, code quality check is invoked. Sonarqube UI gives complete information regarding the code quality. Using sonar console, we can define various quality gateway. Quality gateway defines the criteria for code quality acceptance like Vulnerabilities, Code coverage etc. Threshold for any of the mentioned property can be configured.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T5k5c5vBofdsfKg4-2Y9mg.png" /></figure><p>If the configured threshold is violated, The quality gateway will fail the build. After successful code quality check pass, The build process creates docker image and upload the same to nexus repository for historical artifacts. Then build process deploy the image to target kubernetes cluster, on separate pods without impacting existing deployments.</p><p>After deployment, the api health check (Readiness / Liveness probe) has been done on deployed micro-service . If the api health check failed, then the deployment exit with non successful code and alerts triggers automatically to the team. The Kubernetes dashboard provide easy management of containers and 360 view of deployed micro-services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v-w65Tg-EG-T-VxSrnzkvw.png" /></figure><p>Interactive dashboard are build on grafana for monitoring purpose, using metrics collected by prometheus. The grafana dashboard is also used to perform RCA of past incidents. You will get the resource utilisation like CPU, Network, JVM level resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QU0Fu8WiluyP8G8vLbM7vg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*De65sLGmL00H7VB4oDWPYQ.png" /></figure><p>All application logs are automatically available in kibana for real time alerting and analytics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x2USUrrU459NHXXrE8GX3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LKahwPPqk1HODKTvLNj3GQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c1ef7c51899" width="1" height="1" alt=""><hr><p><a href="https://blog.dtdl.in/building-an-efficient-ci-cd-pipeline-for-kubernetes-deutche-telekom-gurgaon-6c1ef7c51899">Building an Efficient CI/CD Pipeline for Kubernetes — Deutsche Telekom Gurgaon</a> was originally published in <a href="https://blog.dtdl.in/">Deutsche Telekom Digital Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>