<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Balaji SR</title>
    <description>The latest articles on Forem by Balaji SR (@sr_balaji).</description>
    <link>https://forem.com/sr_balaji</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F79463%2F9333ec29-c93c-42c2-a2a7-e221bd239933.png</url>
      <title>Forem: Balaji SR</title>
      <link>https://forem.com/sr_balaji</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sr_balaji"/>
    <language>en</language>
    <item>
      <title>DevOps tool-chain setup on Kubernetes cluster. Part - 3/3</title>
      <dc:creator>Balaji SR</dc:creator>
      <pubDate>Mon, 02 Jul 2018 21:38:34 +0000</pubDate>
      <link>https://forem.com/sr_balaji/devops-tool-chain-setup-on-kubernetes-cluster-part---33-506</link>
      <guid>https://forem.com/sr_balaji/devops-tool-chain-setup-on-kubernetes-cluster-part---33-506</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F298l0v54pjqkldy2j34e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F298l0v54pjqkldy2j34e.png" title="Kubernetes" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;This is the 3rd and final part in continuation with my previous articles on DevOps tool-chain setup on Kubernetes cluster.   In this article, I have explained how to  setup Nexus on the Kubernetes cluster.&lt;/p&gt;

&lt;h3&gt;
  
  
  Nexus setup on Kubernetes cluster
&lt;/h3&gt;

&lt;p&gt;Nexus is an artifact repository which plays an important role in the software development lifecycle especially in the age of Docker containers. I have created the below list of Kubernetes components to host Nexus artifact repository on the cluster.&lt;/p&gt;

&lt;h4&gt;
  
  
  Storage class for Nexus
&lt;/h4&gt;

&lt;p&gt;I have created the Storage Class for Nexus.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;StorageClass&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;storage.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexus-storage-data&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexus-storage-data&lt;/span&gt;
&lt;span class="na"&gt;provisioner&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;kubernetes.io/aws-ebs&lt;/span&gt;
&lt;span class="na"&gt;parameters&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gp2&lt;/span&gt;
  &lt;span class="na"&gt;zone&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;eu-west-2a&lt;/span&gt;
&lt;span class="na"&gt;allowVolumeExpansion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Persistence Volume for Nexus
&lt;/h4&gt;

&lt;p&gt;I have created Persistence Volume for Nexus with Storage space of 2GB on the Kubernetes Cluster.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PersistentVolumeClaim&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexus-storage&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexus-storage&lt;/span&gt;
  &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;volume.beta.kubernetes.io/storage-class&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;nexus-storage-data"&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;accessModes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ReadWriteOnce&lt;/span&gt;
  &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;storage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;2Gi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Deployment for Nexus
&lt;/h4&gt;

&lt;p&gt;I have created a deployment script which pulls the Nexus image if not persent in the Kubernetes cluster and configured on port 8081. I have configured user group for Nexus user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;extensions/v1beta1&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexus&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexus&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexus&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;securityContext&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;fsGroup&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2000&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexus&lt;/span&gt;
          &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonatype/nexus3:3.8.0&lt;/span&gt;
          &lt;span class="na"&gt;imagePullPolicy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;IfNotPresent&lt;/span&gt;
          &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8081&lt;/span&gt;
              &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexusport&lt;/span&gt;
          &lt;span class="na"&gt;volumeMounts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexus-data&lt;/span&gt;
              &lt;span class="na"&gt;mountPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/nexus-data&lt;/span&gt;
      &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexus-data&lt;/span&gt;
          &lt;span class="na"&gt;persistentVolumeClaim&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;claimName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexus-storage&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Service for Nexus
&lt;/h4&gt;

&lt;p&gt;I have created service for Nexus on port 8081&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Service&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexus&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexus-svc&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;NodePort&lt;/span&gt;
  &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8081&lt;/span&gt;
      &lt;span class="na"&gt;targetPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8081&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexusport&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nexus&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;LoadBalancer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By now I have created storage class, persistent volume, deployment, and service for Nexus and it is up &amp;amp; running.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$kubectl&lt;/span&gt; get deployment
&lt;span class="nv"&gt;$kubectl&lt;/span&gt; get pod
&lt;span class="nv"&gt;$kubectl&lt;/span&gt; get svc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By now all Kubernetes components are created for the CI/CD pipeline and it can be verified either by executing a command or by using the Kubernetes dashboard. In the below section, I am going to use the Kubernetes dashboard to verify the components that I have created.&lt;/p&gt;

&lt;h3&gt;
  
  
  Kubernetes cluster components
&lt;/h3&gt;

&lt;p&gt;Kubernetes dashboard with details of components that are created as a part of this cluster setup are available below.&lt;/p&gt;

&lt;h4&gt;
  
  
  Persistent Volumes
&lt;/h4&gt;

&lt;p&gt;Below is the screenshot that contains list of Persistent Volumes&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fio9fmoge2y2h3cbot53e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fio9fmoge2y2h3cbot53e.png" title="Persistence Volumes" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Storage Classes – Below is the list of Storage Classes&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fgoimsgrhxan82ww4t08d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fgoimsgrhxan82ww4t08d.png" title="Storage Classes" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Deployments – Below is the list of Deployments&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F35dol31hs59crz8fch9c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F35dol31hs59crz8fch9c.png" title="Deployments" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Services – Below is the list of services&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fgejiin3vxkdvyw8fd4vy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fgejiin3vxkdvyw8fd4vy.png" title="Services" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;By now, I have covered the entire CI/CD toolset - Jenkins, sonarqube with PostgreSQL and nexus set up with the single replica on the kubernetes cluster.  This can be used to establish a DevOps pipeline on the kubernetes cluster.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>DevOps tool-chain setup on Kubernetes cluster. Part - 2/3</title>
      <dc:creator>Balaji SR</dc:creator>
      <pubDate>Wed, 27 Jun 2018 05:57:20 +0000</pubDate>
      <link>https://forem.com/sr_balaji/devops-tool-chain-setup-on-kubernetes-cluster-part---23-3job</link>
      <guid>https://forem.com/sr_balaji/devops-tool-chain-setup-on-kubernetes-cluster-part---23-3job</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F298l0v54pjqkldy2j34e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F298l0v54pjqkldy2j34e.png" title="Kubernetes" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction
&lt;/h3&gt;

&lt;p&gt;This is in continuation of my previous article - DevOps tool-chain setup on Kubernetes cluster. Part - 1/3. In this article, I have covered on how to setup the SonarQube and PostgreSQL on the Kubernetes cluster.&lt;/p&gt;

&lt;h3&gt;
  
  
  SonarQube setup on Kubernetes cluster
&lt;/h3&gt;

&lt;p&gt;SonarQube is a web-based open source platform used to measure and analyse the source code quality. Code quality analysis makes your code more reliable and readable. It can analyse and manage code of more than 20 programming languages.&lt;/p&gt;

&lt;p&gt;SonarQube needs a database and it supports databases like MySQL, PostgreSQL, MSSQL, etc. In this article I have used PostgreSQL as the database for SonarQube. I have followed a sequence of creating  PostgreSQL DB kubernetes components followed by SonarQube Kubernetes components.&lt;/p&gt;

&lt;p&gt;Let me configure PostgreSQL and SonarQube on the Kubernetes cluster by using the below scripts.&lt;/p&gt;

&lt;h3&gt;
  
  
  PostgreSQL setup on Kubernetes cluster
&lt;/h3&gt;

&lt;p&gt;In this section, I have setup PostSQL on Kubernetes cluster by using the below scripts.&lt;/p&gt;

&lt;h4&gt;
  
  
  Storage class for PostgreSQL
&lt;/h4&gt;

&lt;p&gt;I have created the Storage Class for PostgreSQL Database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;StorageClass&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;storage.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonar-storage&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonar-storage&lt;/span&gt;
&lt;span class="na"&gt;provisioner&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;kubernetes.io/aws-ebs&lt;/span&gt;
&lt;span class="na"&gt;parameters&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gp2&lt;/span&gt;
  &lt;span class="na"&gt;zone&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;eu-west-2a&lt;/span&gt;
&lt;span class="na"&gt;allowVolumeExpansion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Persistent Volume for PostgreSQL
&lt;/h4&gt;

&lt;p&gt;I have created Persistent Volume and allocated 4GB as the storage space for PostgreSQL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PersistentVolumeClaim&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonar-postgres-data&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Sonar-Postgres-Data&lt;/span&gt;
  &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;volume.beta.kubernetes.io/storage-class&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;sonar-storage"&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;accessModes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ReadWriteOnce&lt;/span&gt;
  &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
      &lt;span class="na"&gt;storage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;4Gi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Deployment for PostgreSQL
&lt;/h4&gt;

&lt;p&gt;I have created a deployment script which pulls the PostgreSQL image, if the image is not persent in the Kubernetes cluster. I have configured PostgreSQL with the port 5432. Its data are persisted on the persistent volume which is created in the previous step. This deployment is created with single Replica. PostgreSQL Database credentials (user name &amp;amp; password) are mentioned in clear text. In production environment it is not advisable to have password in clear text.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;extensions/v1beta1&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgresql-sonar&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgresql-sonar&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgresql-sonar&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgreqsl-sonar&lt;/span&gt;
          &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres:9.6&lt;/span&gt;
          &lt;span class="na"&gt;imagePullPolicy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;IfNotPresent&lt;/span&gt;
          &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5432&lt;/span&gt;
              &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgresql-port&lt;/span&gt;
          &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;POSTGRES_USER&lt;/span&gt;
              &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonar&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;POSTGRES_PASSWORD&lt;/span&gt;
              &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;password&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PGDATA&lt;/span&gt;
              &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/var/lib/postgresql/data/pgdata&lt;/span&gt;
          &lt;span class="na"&gt;volumeMounts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;db-data&lt;/span&gt;
              &lt;span class="na"&gt;mountPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/var/lib/postgresql/data&lt;/span&gt;
      &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;db-data&lt;/span&gt;
          &lt;span class="na"&gt;persistentVolumeClaim&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;claimName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonar-postgres-data&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Service for PostgreSQL
&lt;/h4&gt;

&lt;p&gt;I have created service for PostgreSQL on port 5432.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Service&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgresql-db&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgresql-db&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;NodePort&lt;/span&gt;
  &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5432&lt;/span&gt;
    &lt;span class="na"&gt;targetPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5432&lt;/span&gt;
    &lt;span class="na"&gt;protocol&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;TCP&lt;/span&gt;
    &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgresql-db-port&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgresql-sonar&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  SonarQube Configuration
&lt;/h4&gt;

&lt;p&gt;I have created all the required Kubernetes components for the SonarQube Database in the previous sections. Now, I am going to create Kubernetes components for SonarQube which will use all the Database components. &lt;/p&gt;

&lt;h4&gt;
  
  
  Deployment for SonarQube
&lt;/h4&gt;

&lt;p&gt;I have created a deployment script which pulls the SonarQube image, if not persent in the Kubernetes cluster and configured on port 9000. I have configured SonarQube to connect with the PostgreSQL DB which is exposed on port 5432 by providing the user credentials.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;extensions/v1beta1&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonar&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonar&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonar&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonar&lt;/span&gt;
        &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonarqube:6.7&lt;/span&gt;
        &lt;span class="na"&gt;imagePullPolicy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;IfNotPresent&lt;/span&gt;
        &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;9000&lt;/span&gt;
          &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonarport&lt;/span&gt;
        &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SONARQUBE_JDBC_USERNAME&lt;/span&gt;
            &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonar&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SONARQUBE_JDBC_PASSWORD&lt;/span&gt;
            &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;password&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;SONARQUBE_JDBC_URL&lt;/span&gt;
            &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jdbc:postgresql://postgresql-db:5432/sonar&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Service for SonarQube
&lt;/h4&gt;

&lt;p&gt;I have created a service for SoanrQube on its default port 9000.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Service&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonar&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonar&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;NodePort&lt;/span&gt;
  &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;9200&lt;/span&gt;
      &lt;span class="na"&gt;targetPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;9000&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonarport&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sonar&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;LoadBalancer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By now I have created storage class, persistent volume, deployment, and service for SonarQube and PostgreSQL DB and it is up &amp;amp; running.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$kubectl&lt;/span&gt; get deployment
&lt;span class="nv"&gt;$kubectl&lt;/span&gt; get pod
&lt;span class="nv"&gt;$kubectl&lt;/span&gt; get svc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;By now I have covered how to setup SonarQube and PostgreSQL with single Replicaset on a Kubernetes cluster. I will discuss the Nexus setup in the final article.&lt;/p&gt;

&lt;p&gt;Note:&lt;br&gt;
yaml files are space sensitive and the scripts that are available in this article might have tab spaces instead of whitespace. These scripts will fail, if you copy and paste without changing the tab to whitespace.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
    </item>
    <item>
      <title>Blockchain - Hyperledger fabric - a high level overview </title>
      <dc:creator>Balaji SR</dc:creator>
      <pubDate>Sun, 24 Jun 2018 12:04:43 +0000</pubDate>
      <link>https://forem.com/sr_balaji/blockchain---hyperledger-fabric---a-high-level-overview--22g4</link>
      <guid>https://forem.com/sr_balaji/blockchain---hyperledger-fabric---a-high-level-overview--22g4</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzbgmg51cjdc0ka21k8is.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fzbgmg51cjdc0ka21k8is.png" title="Hyperledger fabric" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction:
&lt;/h3&gt;

&lt;p&gt;In the recent times, Blockchain has become the talk of the town. In this article, I have tried to cover a very high-level overview of Blockchain/Distributed Ledger and how it can help us. I have also given an overview of Hyperledger fabric Blockchain components.  &lt;/p&gt;

&lt;h3&gt;
  
  
  What is Blockchain?
&lt;/h3&gt;

&lt;p&gt;There is no single definition for Blockchain. According to me, Blockchain is an immutable distributed ledger that records the transactions in a decentralized environment. It’s an ordered list of all the transactions since inception. There are different type of Blockchain like public(permissionless) &amp;amp; permission. In this article, I have discussed the permission Blockchain – Hyperledger Fabric.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is distributed ledger?
&lt;/h3&gt;

&lt;p&gt;It is a set of records that are shared, replicated and synchronized among the participants in a network. It records all the transactions like the exchange of data or assets among the participants in the network.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fgqujhnb98uv3mhp6s8y5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fgqujhnb98uv3mhp6s8y5.png" title="current state of transaction" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Problem statement:
&lt;/h3&gt;

&lt;p&gt;There are different participants in a business and every participants keep their own ledger copy. Transactions are bilateral and each participant has to interact with each other and thus by creating a complex network. Transactions are governed by a central body which needs multiple approvals. This is a time &amp;amp; money consuming task.&lt;/p&gt;

&lt;h4&gt;
  
  
  Trust:
&lt;/h4&gt;

&lt;p&gt;Establishing trust in a network is very difficult and it’s a time consuming with the subject of reputation. The reputed and governing body takes time to create trust.&lt;/p&gt;

&lt;h4&gt;
  
  
  Transparency:
&lt;/h4&gt;

&lt;p&gt;As each participant in the network has its own ledger which is not shared and so there is no transparency in the network.&lt;/p&gt;

&lt;h4&gt;
  
  
  Accountability:
&lt;/h4&gt;

&lt;p&gt;Regulators like bank, clearinghouse, stock exchange, legal services are required as a middleman to ensure the accountability of the transaction.&lt;/p&gt;

&lt;h3&gt;
  
  
  How does Blockchain help?
&lt;/h3&gt;

&lt;p&gt;The Blockchain is a tamper-proof immutable distributed ledger which records all the transactions in a network. The ledger is maintained by all participants and it is distributed in a peer-to-peer network. Instead of trusting on the 3rd party or central governances, Blockchain uses consensus protocol to commit a transaction into the ledger. The integrity of the transactions are achieved by cryptographic hashes and digital signatures.&lt;/p&gt;

&lt;h3&gt;
  
  
  How does Blockchain works?
&lt;/h3&gt;

&lt;p&gt;In a distributed peer-to-peer network, transactions are stored in blocks which are linked together to form a chain and this is called as Blockchain. Each block contains a hash of the current block, timestamp of recent valid transaction and hash for the previous block. Previous block hash is used to link the block and prevents from altering the block or inserting between blocks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8gp3cx8mhaww98ylpv6m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8gp3cx8mhaww98ylpv6m.png" title="Blockchain state of transaction" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Hyperledger – Linux foundation project
&lt;/h3&gt;

&lt;p&gt;Hyperledger is an open source hosted by Linux foundation and openly governed by collaborative effort to advance the cross-industry blockchain technologies for business. Hyperledger Fabric is a blockchain framework implementation and it is one of the Hyperledger projects.&lt;/p&gt;

&lt;p&gt;Some key feature of Fabric: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No token -  Permissioned blockchain &lt;/li&gt;
&lt;li&gt;Based on consensus &lt;/li&gt;
&lt;li&gt;Endorsement policies for transactions approvals &lt;/li&gt;
&lt;li&gt;Private Channels for sharing confidential information&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Components of Hyperledger fabric
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Peers
&lt;/h5&gt;

&lt;p&gt;These are the network services that maintain the ledger. It receives ordered update messages for committing the new transaction to the ledger and to run the smart contacts.&lt;/p&gt;

&lt;h5&gt;
  
  
  Committing peers
&lt;/h5&gt;

&lt;p&gt;It commits transactions and maintains the ledger &amp;amp; state.&lt;/p&gt;

&lt;h5&gt;
  
  
  Endorsing peers
&lt;/h5&gt;

&lt;p&gt;It receives transactions for endorsement and it verifies whether the transaction fulfills all the necessary and sufficient conditions. Thereby the Endorsing peer responds by granting or denying the endorsement.&lt;/p&gt;

&lt;h5&gt;
  
  
  Ordering service or Orderers
&lt;/h5&gt;

&lt;p&gt;It approves the inclusion of blocks into the ledger. It communicates with peers and endorsing peers. It provides a shared communication channel to clients and peers over which the transaction can be broadcasted.&lt;/p&gt;

&lt;h5&gt;
  
  
  Channels
&lt;/h5&gt;

&lt;p&gt;These are subnets of the peer network which shares a single ledger. It is used to restrict access to the transaction with involved parties. It means clients only can see the messages and their associated transactions of the channels they are connected to and are unaware of other channels.&lt;/p&gt;

&lt;h5&gt;
  
  
  Certificate authorities
&lt;/h5&gt;

&lt;p&gt;It provides identity services to participants on the network. It manages different types of certificates required to run the blockchain.&lt;/p&gt;

&lt;h5&gt;
  
  
  Smart contracts
&lt;/h5&gt;

&lt;p&gt;It’s the transaction logic running on each invocation call. Transaction invocation results in updating or querying the ledger state.&lt;/p&gt;

&lt;h5&gt;
  
  
  Consensus
&lt;/h5&gt;

&lt;p&gt;It’s the process by which the agreement is obtained on the peer network. It is responsible for consistently replicating the ledger and for agreeing on new blocks.&lt;/p&gt;

&lt;h5&gt;
  
  
  Shared ledger
&lt;/h5&gt;

&lt;p&gt;It is an immutable record of all transactions on the network. It’s a collection of records that all participants on the network can access.&lt;/p&gt;

&lt;h5&gt;
  
  
  Client
&lt;/h5&gt;

&lt;p&gt;It is an End-user application which must be connected to the Blockchain through a peer.&lt;/p&gt;

&lt;h4&gt;
  
  
  Architecture of Hyperledger Fabric v1
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1m5f3tpu0dkpuluvirh6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1m5f3tpu0dkpuluvirh6.png" title="Hypeledger fabric architecture" alt="alt here"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  How does it works?
&lt;/h4&gt;

&lt;p&gt;Client application / SDK submits a transaction proposal for a chaincode by targeting the required peers. All the Endorser peers will execute the transactions. These transactions will not be updated in the ledger as it is only to endorse. Once endorsement is completed, it is signed by the endorser and returned to the client. The client then submits the transaction to the Orderer. It is then the Ordering service collects the transaction in blocks and distributes to the committing peers. These committing peers then deliver to other peers using gossip. There are different ordering algorithms are available such as SOLO (single node, development), Kafka, SBFT.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5c6c1fm5zkevo9vpnc9s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5c6c1fm5zkevo9vpnc9s.png" title="Hyperledger fabric - transaction processing" alt="alt here"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Committing peers validate the transactions against the endorsement policy and also check whether the transactions are valid for the current state. After all these processes the transactions are written into the ledger. Client applications are notified when the transactions are succeeded or failed and also when the blocks are added into the ledger if they are registered for the notification. The client application will also be notified by each peer to which they are connected to.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;I have given an overview of what Blockchain is and high-level view of Hyperledger fabric. This approach can be used across various business areas like finance, supply chain, trade, etcs.&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>hyperledgerfabric</category>
    </item>
    <item>
      <title>DevOps tool-chain setup on Kubernetes cluster. Part - 1/3</title>
      <dc:creator>Balaji SR</dc:creator>
      <pubDate>Sat, 23 Jun 2018 20:25:00 +0000</pubDate>
      <link>https://forem.com/sr_balaji/devops-tool-chain-setup-on-kubernetes-cluster-59cn</link>
      <guid>https://forem.com/sr_balaji/devops-tool-chain-setup-on-kubernetes-cluster-59cn</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F298l0v54pjqkldy2j34e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F298l0v54pjqkldy2j34e.png" title="Kubernetes" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;DevOps has become a part of the software lifecycle management with CI/CD pipeline to deliver a change to production in an automated way.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8ko3m7l823612pap65zd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F8ko3m7l823612pap65zd.png" title="DevOps" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In CI/CD pipeline the popular open source tools are Github for source code repository, Jenkins for Continuous Integration, build, test &amp;amp; deployment orchestration, SonarQube for static code analysis and Nexus for artifacts repository. There are many open source tools available for testing too. This article is not much about DevOps or CI/CD pipline rather it will describe how to create the CI/CD pipeline on Kubernetes cluster environment using kubectl. &lt;/p&gt;

&lt;h3&gt;
  
  
  Containers:
&lt;/h3&gt;

&lt;p&gt;These are methods of operating system virtualization that allows us to run an application and its dependencies in resource-isolated processes. Containers allows a developer to package an application with parts it needs, such as libraries and other dependencies, and ship it all out as one package. There are many container options that are available and Docker is one such open source container which is very widely used.&lt;/p&gt;

&lt;h3&gt;
  
  
  Kubernetes:
&lt;/h3&gt;

&lt;p&gt;It is a portable open-source platform for managing containerised workloads and services that facilitates both declarative configuration and automation. Kubernetes has become the default tool to manage the containers in most of the public, private &amp;amp; hybrid cloud and also on the bare metal systems.&lt;/p&gt;

&lt;p&gt;This write-up describes on how to create Kubernetes cluster with Jenkins, Sonar, Nexus as pods on AWS cloud. It doesnt includes details about functionality of Jenkins, SonarQube, Nexus.&lt;/p&gt;

&lt;p&gt;I have already write an article on setting up a Kubernetes cluster on AWS Cloud with one master and two worker nodes. For futher details refer the link - &lt;a href="https://dev.to/sr_balaji/kubernetes-cluster-setup-on-aws-13m6"&gt;https://dev.to/sr_balaji/kubernetes-cluster-setup-on-aws-13m6&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F739ut1xpewm555pf418f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F739ut1xpewm555pf418f.png" title="Kubernetes node details" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Kubernetes components
&lt;/h3&gt;

&lt;p&gt;The list of Kubernetes components that is used in this cluster are detalied below. I have provided a very high-level details on the Kubernetes components. For further details please refer &lt;a href="https://kubernetes.io" rel="noopener noreferrer"&gt;https://kubernetes.io&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Cluster: It is set of a physical or virtual machine and, in Kubernetes, all machine are managed as a cluster.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Node: It is a worker machine in Kubernetes. It may be a Virtual or physical machine. (In this article I have used EC2 instance to provision the Kubernetes Cluster)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pod: It is a group of one or more containers (such as Docker containers), with shared storage/network, and a set of specifications to run the containers. A pod’s contents are always co-located, co-scheduled and runs in a shared context.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deployment: It provides declarative updates for Pods and ReplicaSets.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Persistent Volume: It is a piece of storage in the cluster that has been provisioned by an administrator. It is a node in cluster resource.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Persistent Volume Claim: It is a request for storage by an user.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Service: It is an abstraction that defines a logical set of Pod(s)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Storageclass: It provides a way for administrators to describe the “classes” of storage they offer.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Kubernetes Cluster environment
&lt;/h3&gt;

&lt;p&gt;In this Kubernetes cluster, I have created a single instance of the Jenkins, SonarQube &amp;amp; Nexus and configured in such a way that one instance of these servers is always available. The data of these servers are persisted, and even in the event of these servers getting crashed, it rebuilds automatically with the data that are preserved.&lt;/p&gt;

&lt;p&gt;I have created separate storage class for Jenkins, SonarQube &amp;amp; Nexus with data persistence. Each of the servers are available as a separate pod with their ports exposed as a service. I have used deployment to create pods for individual tools.&lt;/p&gt;

&lt;h3&gt;
  
  
  Jenkins Setup on the Kubernetes cluster
&lt;/h3&gt;

&lt;p&gt;Jenkins is an open source  Continuous Integration (CI)/Continuous Delivery (CD) orchestration tool. It offers a simple way to set up a CI/CD environment for any languages &amp;amp; source code repositories. I have created the following list of Kubernetes components to host Jenkins server on the cluster.&lt;/p&gt;

&lt;h4&gt;
  
  
  Storage class for Jenkins
&lt;/h4&gt;

&lt;p&gt;I have created the storage class on the cluster for Jenkins data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;StorageClass&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;storage.k8s.io/v1&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jenkins-storage&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; 
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jenkins-storage&lt;/span&gt;
&lt;span class="na"&gt;provisioner&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;kubernetes.io/aws-ebs&lt;/span&gt;
&lt;span class="na"&gt;parameters&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gp2&lt;/span&gt;
  &lt;span class="na"&gt;zone&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;eu-west-2a&lt;/span&gt;
&lt;span class="na"&gt;allowVolumeExpansion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Persistent Volume for Jenkins
&lt;/h4&gt;

&lt;p&gt;I have created a Persistent Volume claim and allocated 2GB as the storage space to presist Jenkins data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PersistentVolumeClaim&lt;/span&gt;
&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jenkins-data&lt;/span&gt;
  &lt;span class="na"&gt;annotations&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;volume.beta.kubernetes.io/storage-class&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;jenkins-storage"&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;accessModes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ReadWriteOnce&lt;/span&gt;
  &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;requests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;storage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;2Gi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Deployment for Jenkins
&lt;/h4&gt;

&lt;p&gt;I have created a deployment script which pulls the Jenkins official image from internet and I have configured Jenkins with the default port 8080. Its data are persisted on the persistent volume which is created in the previous step. This deployment is created with single Replica which means Kubernetes will make sure that one instance of Jenkins is always up &amp;amp; running. In this configuration the port is not exposed to the cluster which will be covered in the next section.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;extensions/v1beta1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deployment&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jenkins&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;replicas&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jenkins&lt;/span&gt;
    &lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;securityContext&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;runAsUser&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;
        &lt;span class="na"&gt;fsGroup&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;
      &lt;span class="na"&gt;containers&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jenkins&lt;/span&gt;
        &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jenkins:2.60.3&lt;/span&gt;
        &lt;span class="na"&gt;imagePullPolicy&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;IfNotPresent&lt;/span&gt;
        &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;containerPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
        &lt;span class="na"&gt;volumeMounts&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jenkins-home&lt;/span&gt;
            &lt;span class="na"&gt;mountPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/var/jenkins_home&lt;/span&gt;
      &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jenkins-home&lt;/span&gt;
          &lt;span class="na"&gt;persistentVolumeClaim&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
            &lt;span class="na"&gt;claimName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jenkins-data&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Service for Jenkins
&lt;/h4&gt;

&lt;p&gt;I have created a Service to expose Jenkins on port 9500 rather than on its default port.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;apiVersion&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1&lt;/span&gt;
&lt;span class="na"&gt;kind&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Service&lt;/span&gt;
&lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jenkins&lt;/span&gt;
  &lt;span class="na"&gt;labels&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jenkins&lt;/span&gt;
&lt;span class="na"&gt;spec&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;NodePort&lt;/span&gt;
  &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;9500&lt;/span&gt;
      &lt;span class="na"&gt;targetPort&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8080&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jenkinsport&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;jenkins&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;LoadBalancer&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I have created storage class, persistent volume, deployment, and service for Jenkins so far. All the components for Jenkins are created and it is up running.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$kubectl&lt;/span&gt; get deployment
&lt;span class="nv"&gt;$kubectl&lt;/span&gt; get pod
&lt;span class="nv"&gt;$kubectl&lt;/span&gt; get svc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In this article, I have covered on how to setup Jenkins with single Replicaset on a Kubernetes cluster. I will cover the setup of SonarQube and Nexus in the next articles.&lt;/p&gt;

&lt;h5&gt;
  
  
  Note:
&lt;/h5&gt;

&lt;p&gt;yaml files are space sensitive and the scripts that are available in this article  might have tab spaces instead of whitespace. These scripts will fail, if you copy and paste without changing the tab to whitespace.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
    </item>
    <item>
      <title>Kubernetes cluster setup on AWS</title>
      <dc:creator>Balaji SR</dc:creator>
      <pubDate>Fri, 22 Jun 2018 15:21:27 +0000</pubDate>
      <link>https://forem.com/sr_balaji/kubernetes-cluster-setup-on-aws-13m6</link>
      <guid>https://forem.com/sr_balaji/kubernetes-cluster-setup-on-aws-13m6</guid>
      <description>&lt;h1&gt;
  
  
  Kubernetes
&lt;/h1&gt;

&lt;p&gt;It is an open source system for managing containerized applications across multiple hosts, providing basic mechanisms for deployment, maintenance, and scaling of applications.&lt;/p&gt;

&lt;p&gt;In this article, I am going to setup a Kubernetes cluster on AWS cloud environment up for which I am going to use a tool called KOPS.&lt;/p&gt;

&lt;p&gt;What is KOPS? kops is an opinionated provisioning system with&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fully automated installation&lt;/li&gt;
&lt;li&gt;Uses DNS to identify clusters&lt;/li&gt;
&lt;li&gt;Self-healing: everything runs in Auto-Scaling Groups&lt;/li&gt;
&lt;li&gt;Limited OS support (Debian preferred, Ubuntu 16.04 supported, early support for CentOS &amp;amp; RHEL)&lt;/li&gt;
&lt;li&gt;High-Availability support&lt;/li&gt;
&lt;li&gt;Direct provision or  terraform manifest generation&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Pre-requisite
&lt;/h3&gt;

&lt;p&gt;As a part of the setup, I would need an Ubuntu or Debian instance with latest updates and other supporting utility/tools like AWS-CLI, S3 bucket, Hosted Zone on Route 53 and a registered domain. In this article, I am going to use Ubuntu instance to launch my cluster.&lt;/p&gt;

&lt;h4&gt;
  
  
  Ubuntu EC2-instance
&lt;/h4&gt;

&lt;p&gt;Let me launch an AWS EC2 Ubuntu instance and update with the latest packages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$sudo&lt;/span&gt; apt-get update

&lt;span class="nv"&gt;$sudo&lt;/span&gt; apt-get &lt;span class="nt"&gt;-y&lt;/span&gt; upgrade
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  kops installation
&lt;/h4&gt;

&lt;p&gt;I have downloaded the latest version of kops and changed the permission before moving it to /usr/local/bin&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;wget &lt;span class="nt"&gt;-O&lt;/span&gt; kops https://github.com/kubernetes/kops/releases/download/&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; https://api.github.com/repos/kubernetes/kops/releases/latest | &lt;span class="nb"&gt;grep &lt;/span&gt;tag_name | &lt;span class="nb"&gt;cut&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'"'&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; 4&lt;span class="si"&gt;)&lt;/span&gt;/kops-linux-amd64

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x kops

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo mv &lt;/span&gt;kops /usr/local/bin/

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  kubectl installation
&lt;/h4&gt;

&lt;p&gt;I have downloaded the latest version of the kubectl and changed the permission before moving it to /usr/local/bin&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;curl &lt;span class="nt"&gt;-LO&lt;/span&gt; https://storage.googleapis.com/kubernetes-release/release/&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; https://storage.googleapis.com/kubernetes-release/release/stable.txt&lt;span class="si"&gt;)&lt;/span&gt;/bin/linux/amd64/kubectl
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x kubectl
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo mv &lt;/span&gt;kubectl /usr/local/bin/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  AWS CLI
&lt;/h4&gt;

&lt;p&gt;I have installed AWS CLI to access the AWS instance from the command line to create Kubernetes cluster.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nb"&gt;install &lt;/span&gt;python-pip
&lt;span class="nv"&gt;$ &lt;/span&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--upgrade&lt;/span&gt; pip
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;awscli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  IAM user creation
&lt;/h4&gt;

&lt;p&gt;On AWS console, I have created a new IAM user (for example kops) with full access and saved the access keys as it would be used to configure the AWS CLI. Then I have copied both AWS access key ID and AWS secret access key for later usage.&lt;/p&gt;

&lt;p&gt;On the EC2 instance, I have configured the newly created AWS IAM user with following commands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$aws&lt;/span&gt; configure

AWS Access Key ID &lt;span class="o"&gt;[&lt;/span&gt;None]:  AWS Secret Access Key &lt;span class="o"&gt;[&lt;/span&gt;None]: Default region name &lt;span class="o"&gt;[&lt;/span&gt;None]: &amp;lt; Optional : Please enter the region or blank &lt;span class="k"&gt;for &lt;/span&gt;default&amp;gt;
Default output format &lt;span class="o"&gt;[&lt;/span&gt;None]: &amp;lt; Optional : Please enter the output format or blank &lt;span class="k"&gt;for &lt;/span&gt;default&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the same the EC2 instance, I have generated a key pair for AWS EC2 user. It will be used to connect to the kubernetes cluster which I am going to create. In my case, as it is Ubuntu user the ssh keys by default are stored in .ssh folder of the user home directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ssh-keygen
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Domain creation
&lt;/h4&gt;

&lt;p&gt;I have created a domain for the cluster user "kops" and DNS for discovery which will be used inside the cluster and to reach the kubernetes API server from the client. It should have a valid DNS name. I recommend using a subdomain for the cluster configuration.&lt;/p&gt;

&lt;p&gt;An existing domain or a new domain can be used. In this example, I have created a new domain and hosted it on dot.tk which is a free domain provider.&lt;/p&gt;

&lt;h5&gt;
  
  
  Domain registration on dot.tk / freenom.com:
&lt;/h5&gt;

&lt;p&gt;I have registered a new domain on freenom.com with the name k8sclustersetup.tk which I going to use for my Kubernetes cluster.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fec6chd6us2ozi4963xrb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fec6chd6us2ozi4963xrb.png" title="Domain registration" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Create Hosted Zone
&lt;/h4&gt;

&lt;p&gt;On AWS console, I have created a new Hosted zone on router 53. I have logged into AWS console, navigate to router53 DNS management and created new Hosted Zone. It's advisable to create a subdomain. This creates a set of name servers which can be copied for later usage. I have copied the name server details which starts with ns-xxx.awsdns-xx.com, ns-xxx.awsdns-xx.co.uk, ns-xxx.awsdns-xx.org, ns-xxx.awsdns-xx.net.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fu25buxcbudxxqzd83x8l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fu25buxcbudxxqzd83x8l.png" title="AWS Route 53 Hosted Zone" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These NameServer (NS) values should be updated on the domain service provider. In this setup, I have updated the NS details on freenom.com.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5dppiy652bd4a5w7sqtq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F5dppiy652bd4a5w7sqtq.png" title="Update the Name Server details for the domain" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  S3 bucket creation
&lt;/h4&gt;

&lt;p&gt;I have created a new S3 bucket with a meaningful name (for example "kopsclusterdemo") which is used to store the cluster state. Kubernetes uses S3 to store the cluster details like configuration, keys, etc.&lt;/p&gt;

&lt;p&gt;With this, all the pre-requisite has been setup and the environment is ready to create and launch the Kubernetes cluster.&lt;/p&gt;

&lt;h4&gt;
  
  
  Kubernetes cluster creation
&lt;/h4&gt;

&lt;p&gt;For learning purpose, I have chosen the t2.micro which is a free EC2 instance. I have executed the below command to create the kubernetes cluster with one master and 2 worker nodes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kops create cluster &lt;span class="nt"&gt;--name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;k8sclustersetup.tk &lt;span class="nt"&gt;--state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;s3://kopsclusterdemo &lt;span class="nt"&gt;--zones&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;eu-west-2a &lt;span class="nt"&gt;--node-count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2 &lt;span class="nt"&gt;--node-size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;t2.micro &lt;span class="nt"&gt;--master-size&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;t2.micro &lt;span class="nt"&gt;--dns-zone&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;k8sclustersetup.tk

&lt;span class="nv"&gt;$kops&lt;/span&gt; update cluster k8sclustersetup.tk &lt;span class="nt"&gt;--yes&lt;/span&gt; &lt;span class="nt"&gt;--state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;s3://kopsclusterdemo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It takes a couple of minutes for the Kubernetes cluster to get created. To confirm whether the Kubernetes cluster got created I have used the below command to list the cluster details.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$kops&lt;/span&gt; get cluster &lt;span class="nt"&gt;--state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;s3://kopsclusterdemo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cluster node details can be listed by issuing the below command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$kubectl&lt;/span&gt; get node
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In this article, the details to install and configure Kubernets cluster on AWS has been provided.&lt;/p&gt;

</description>
      <category>kubernetes</category>
    </item>
  </channel>
</rss>
