<?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 Amit Gujar on Medium]]></title>
        <description><![CDATA[Stories by Amit Gujar on Medium]]></description>
        <link>https://medium.com/@amitgujar15?source=rss-142fc40d2bc8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oglYx86hVFoYpn8UWzDVHA.jpeg</url>
            <title>Stories by Amit Gujar on Medium</title>
            <link>https://medium.com/@amitgujar15?source=rss-142fc40d2bc8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 00:38:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amitgujar15/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[Kafka Simplified: Your Fast Track to Remote Server Configuration]]></title>
            <link>https://amitgujar15.medium.com/kafka-simplified-your-fast-track-to-remote-server-configuration-fe1c07ef58ed?source=rss-142fc40d2bc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe1c07ef58ed</guid>
            <category><![CDATA[ansible]]></category>
            <category><![CDATA[speed]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[configuration]]></category>
            <category><![CDATA[production]]></category>
            <dc:creator><![CDATA[Amit Gujar]]></dc:creator>
            <pubDate>Mon, 27 May 2024 09:57:47 GMT</pubDate>
            <atom:updated>2024-05-27T12:39:20.422Z</atom:updated>
            <content:encoded><![CDATA[<p>Deploying Apache Kafka on remote servers can be a breeze or a bit challenging depending on your approach. This tutorial will showcase how to leverage the power of Ansible to make the process super easy and lightning-fast. Additionally, we’ll delve into creating topics, producing, and consuming messages on the newly deployed Kafka setup. Assuming a foundational understanding of Kafka, I will also provide a brief overview for those who may require it.</p><p><strong>Apache Kafka is a distributed event store and stream-processing platform. It is an open-source system developed by the Apache Software Foundation and written in Java and Scala.</strong></p><h3>Requirements:</h3><ul><li>Root access to the remote servers.</li><li>An ansible controller machine.</li><li>Refer to my previous blog to get basic knowledge about <a href="https://amitgujar15.medium.com/an-introduction-to-ansible-install-deployment-ab51d9bf383b"><strong>Ansible.</strong></a></li><li>Ports 9092, 2181, 2888, 8001, 3888, 22.</li></ul><h3>Let’s Start 🤩:</h3><p><strong>Step 1: </strong>Download the collection for kafka deployment from ansible-galaxy.</p><pre>ansible-galaxy collection install amitgujar.kafkaninja</pre><p><strong>Step 2:</strong> Create an inventory file in the given format. Increase the machine count if you have more than 3 remote servers.</p><pre>[machine1]<br>35.154.183.177<br><br>[machine2]<br>13.233.93.60<br><br>[machine3]<br>13.232.209.6<br><br>[all:vars]<br>ansible_user=ubuntu<br>ansible_python_interpreter=/usr/bin/python3<br><br>[machine1:vars]<br>value=1<br><br>[machine2:vars]<br>value=2<br><br>[machine3:vars]<br>value=3</pre><p><strong>Step 3:</strong> Create a file named zookeeper.yml</p><pre>- name: Zookeeper Install<br>  hosts: all<br>  become: true<br><br>  vars_prompt:<br>    - name: username<br>      prompt: &quot;Enter the username &quot;<br>      private: false<br><br>    - name: servers<br>      prompt: &quot;Enter private ipv4s in comma seperated values &quot;<br>      private: false<br><br>    - name: server_count<br>      prompt: &quot;How many servers you want to configure &quot;<br>      private: false<br><br>    - name: zookeeper.properties<br>      prompt: &quot;Specify the location for zookeeper properties (optional) &quot;<br>      private: false<br><br>  roles:<br>    - amitgujar.kafkaninja.zookeeper</pre><p>Let’s clarify our objectives. This playbook involves deploying Zookeeper on remote servers. While a single server suffices, this role is fully capable of establishing a zookeeper quorum setup as well.</p><p><strong>ZooKeeper</strong> plays a critical role in a <strong>Kafka cluster</strong> by providing distributed coordination and synchronization services. It maintains the cluster’s metadata, manages leader elections, and enables consumers to track their consumption progress. It also stores offsets, ensures fault tolerance, and assists in broker discovery and dynamic configuration updates. Therefore it is highly important to set the zookeeper correctly before performing the kafka cluster setup.</p><p>Let’s discuss the variable values:</p><ul><li><strong>username:</strong> server username, it’s recommended to keep the same username on all servers. If you are using ec2 then enter ubuntu.</li><li><strong>servers:</strong> private ipv4 of all 3 servers, separated by a comma.</li><li><strong>server_count:</strong> total no. of machines that you want to configure.</li><li><strong>zookeeper.properties:</strong> leave this blank if you don’t want to add any custom values to zookeeper servers. default config can be found in my GitHub repo, link will be provided at the end of this blog.</li></ul><p><strong>Step 4</strong>: Execute the playbook</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lJRglxOqqSc01-i4iNYGcA.png" /><figcaption>Playbook execution</figcaption></figure><p>Upon successful execution, you should get this output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9uKUmsmBzchK65rmOW0lpA.png" /><figcaption>Playbook completion</figcaption></figure><p><strong><em>This setup allows you to install Zoonavigator as well. Zoonavigator is a GUI client to interact with the zookeeper cluster.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mPEsKcTobxNXbvkZSl0TDQ.png" /><figcaption>Zoonavigator Login</figcaption></figure><p><strong>Step 5:</strong> Add these values as a connection string (zookeeper1:2181, zookeeper2:2181, zookeeper:2181) Each zookeeper represents a single instance of the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J9HdSHDGh6jIeaxFEJ8nfQ.png" /><figcaption>Zoonavigator shows zookeeper node.</figcaption></figure><p>You should get this window upon successful connection.</p><h3><strong>Time to install Kafka 🙂:</strong></h3><p><strong>Step 6:</strong> Create a new playbook.</p><pre>- name: Kafka Install<br>  hosts: all<br>  become: true<br><br>  vars_prompt:<br>    - name: username<br>      prompt: &quot;Enter the username &quot;<br>      private: false<br><br>    - name: server_properties<br>      prompt: &quot;Specify the custom server.properties file (optional) &quot;<br>      private: false<br><br>    - name: partition_size<br>      prompt: &quot;Enter the partition size to create (e.g 2GB) &quot;<br>      private: false<br><br>  roles:<br>    - amitgujar.kafkaninja.kafka</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*URbRVDJ3CBew0n5i8B48uw.png" /><figcaption>Kafka playbook</figcaption></figure><p><strong>Let’s discuss the variable&#39;s values:</strong></p><ul><li><strong>username:</strong> explained above 😅</li><li><strong>server_properties:</strong> Customize the given file according to your requirements but <strong>keep broker.id and listeners, zookeeper config in a given format,</strong> Ansible will do the rest of the work for you.</li><li><strong>partition_size:</strong> specify the size of the external disk that you have attached to the remote server.</li></ul><pre># Keep broker id as 1 here, the ansible role will do all the magic<br>broker.id=1<br># Keep the listener value as defined here, ansible role will do all the magic<br>advertised.listeners=PLAINTEXT://kafka1:9092<br>delete.topic.enable=true<br>log.dirs=/data/kafka<br>num.partitions=8<br># keep this 3 only if you have 3 servers.<br>default.replication.factor=3<br>min.insync.replicas=2<br>log.retention.hours=168<br>log.segment.bytes=1073741824<br>log.retention.check.interval.ms=300000<br>############################# Zookeeper #############################<br># root directory for all kafka znodes.<br>zookeeper.connect=zookeeper1:2181,zookeeper2:2181,zookeeper3:2181/kafka<br>zookeeper.connection.timeout.ms=6000<br>auto.create.topics.enable=true</pre><p>Step 7: If you get this response on all three servers, then you have configured Kafka correctly.</p><pre>nc -vz kafka1 9092<br>nc -vz kafka2 9092<br>nc -vz kafka3 9092</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*pn3n0LzJrqiS4vkERvo9NA.png" /><figcaption>Kafka connection check</figcaption></figure><p>Step 8: In Zoonavigator you should see a new node named Kafka created automatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*664XoBXJ-vxY_lk9F1eTSw.png" /><figcaption>Zoonavigator shows new kafka node</figcaption></figure><p><strong>Yes, that’s it, It’s all you need for the overall setup. Isn’t that great 😎. In only 8 steps, and 10 minutes &amp; your production-grade Kafka cluster is ready.</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F25420589&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fyess-yes-gif-25420589&amp;image=https%3A%2F%2Fmedia.tenor.com%2FUVmpVqlpVhQAAAAN%2Fyess-yes.png&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf8810723fa676620eb70e400226c148/href">https://medium.com/media/cf8810723fa676620eb70e400226c148/href</a></iframe><p><strong>If you need more brokers, create a group in the inventory file and only execute the Kafka playbook. A Zookeeper quorum with 3 servers is enough for most of the workloads but if you need more I suggest keeping them up to 5 only.</strong></p><h3><strong>Keywords:</strong></h3><p>Before we move forward with the so-called ACTION 😅, Let’s look at the basic terminologies.</p><ul><li><strong>Server:</strong> This is the remote server on which the Kafka is deployed.</li><li><strong>Events:</strong> Messages or records.</li><li><strong>Producer:</strong> Client application that writes events to the Kafka cluster.</li><li><strong>Consumer:</strong> Client application that reads events written by the producer.</li><li><strong>Broker:</strong> Single node/server in Kafka cluster.</li><li><strong>Topic:</strong> A category/collection of events.</li><li><strong>Offset: </strong>Unique ID of the message.</li><li><strong>Partitions: </strong>Subsets of messages in a topic.</li></ul><h3>And Action…….</h3><p>Now that we have the cluster ready let’s perform some actions on it. We will be starting with topic creation first.</p><pre>cd $USER/kafka/bin<br>./kafka-topics.sh --create --topic logs --partitions 3 --bootstrap-server kafka1:9092</pre><p><strong>Describe Topic:</strong></p><pre>./kafka-topics.sh --describe --topic logs --bootstrap-server kafka1:9092</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XfizxXmlHlnkkAymNxZfmA.png" /><figcaption>Kafka&#39;s topic creation &amp; describe</figcaption></figure><p><strong>Write events:</strong></p><p>This command will open the producer which allows you to write events.</p><pre>./kafka-console-producer.sh --topic logs --bootstrap-server kafka1:9092</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fwfhY2u-lLv7pxQtDzJycg.png" /><figcaption>Kafka producer writing the streams</figcaption></figure><p><strong>Consume events:</strong></p><p>This command will open the consumer and display the live events that the producer is writing.</p><pre>./kafka-console-consumer.sh --topic logs --bootstrap-server kafka1:9092 --from-beginning</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R-L05vf57CvAzKDUK5FOOw.png" /><figcaption>Kafka consumer reading the streams</figcaption></figure><p><strong>Note: I have utilized a producer on server1 and a consumer on server2 to illustrate the successful operation of the Kafka cluster. It is important to note that executing both actions on separate servers is not a requirement.</strong></p><p>Just a quick reminder that we use the hostname of broker1 on server2, and for security reasons, these servers communicate with private IPv4 addresses for real-time use cases. In our case, hostnames are kafka1/zookeeper1 as follows where the number denotes the number of remote servers.</p><h4>Remember Zoonavigator..?</h4><p>Use the following path, you will see the newly created topic here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r13EPOlOkk4Ob9YvJ6V2ew.png" /><figcaption>Zoonavigator shows kafka topic entry</figcaption></figure><h3><strong>Conclusion 😎:</strong></h3><p>The “kafkaNinja” Ansible collection simplifies the process, allowing for quick deployment and robust configuration of Apache Kafka in just a few minutes. By following the steps outlined in this guide, you can establish a production-grade Kafka setup that is both resilient and scalable. Additionally, we also explored operations such as topic creation, message read/write on the cluster, and the use of ZooNavigator, which provides a nice dashboard for our Kafka cluster. I hope this guide has given you the insights and confidence to optimize your Kafka deployments on remote servers. Happy streaming!</p><p>Here is the GitHub link for those who want to contribute/explore behind the scenes.</p><p><a href="https://github.com/AmitGujar/kafkaNinja">GitHub - AmitGujar/kafkaNinja: Ansible collection which allows you to configure kafka cluster on remote servers.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe1c07ef58ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy Neo4j on AKS with TLS and reverse proxy.]]></title>
            <link>https://amitgujar15.medium.com/deploy-neo4j-on-aks-with-tls-and-reverse-proxy-39b003e74ac2?source=rss-142fc40d2bc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/39b003e74ac2</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[neo4j]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Amit Gujar]]></dc:creator>
            <pubDate>Thu, 28 Dec 2023 11:54:19 GMT</pubDate>
            <atom:updated>2023-12-29T06:43:21.425Z</atom:updated>
            <content:encoded><![CDATA[<p>Before we continue, let me explain the situation. I wanted to deploy Neo4j on Azure and initially tried using the Azure Container Instance. While everything was working perfectly, it didn&#39;t support HTTPS connections, which was a deal-breaker for me. I considered using the application gateway, but it didn&#39;t support the bolt protocol. After some research, I found that the only viable option was to use AKS. In this tutorial, we will take a detailed look at the steps involved in deploying Neo4j on Azure using AKS. However, before you dive into the tutorial, make sure you have all the necessary prerequisites.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zFXUSoe41dVOlTUikz_U5Q.jpeg" /></figure><h3>What do you need?</h3><ul><li>An AKS cluster.</li><li>Helm and Kubectl.</li><li>Basic knowledge of k8s.</li><li>Custom domain name.</li></ul><p><strong><em>If you want to accelerate the process of creating an AKS cluster, you can use my modules from the Terraform Registry.</em></strong></p><p>Terraform module: <a href="https://registry.terraform.io/modules/AmitGujar/aksacr/azure/latest"><strong>AKS</strong></a><strong>.</strong></p><h3>Let’s Start 🤩.</h3><p>Step 1: Create a file named values.yml</p><pre>neo4j:<br>  name: my-standalone<br>  resources:<br>    cpu: &quot;0.5&quot;<br>    memory: &quot;4Gi&quot;<br><br>  password: &quot;test1234&quot;<br><br>volumes:<br>  data:<br>    mode: &quot;dynamic&quot;<br>    dynamic:<br>      storageClassName: managed-csi</pre><p>Step 2: Install neo4j through the helm.</p><pre>helm repo add neo4j https://helm.neo4j.com/neo4j<br>helm repo update<br>helm install my-neo4j-release neo4j/neo4j -f values.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vK3vFDXo5PJsufnp4NoFNw.png" /><figcaption>Installation of Neo4j status</figcaption></figure><p>Step 3: Verify that neo4 installation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Me1G7_iaPPDn0LPQwiufkw.png" /><figcaption>Neo4j app status</figcaption></figure><p>Step 4: Install nginx-ingress-controller through the helm.</p><pre>kubectl create namespace public-ingress<br><br>helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx<br>helm repo update<br><br>helm upgrade --install ingress-nginx ingress-nginx \<br>      --repo https://kubernetes.github.io/ingress-nginx \<br>      --namespace public-ingress \<br>      --set controller.service.externalTrafficPolicy=Local </pre><p>Step 5: Copy the external address of the ingress-controller and paste it into the DNS record of your custom domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eJM_Wl-JvVM8QG-l3rv5RQ.png" /><figcaption>Details of ingress-controller</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7LzuuN4UADoqq5erdHtjHQ.png" /><figcaption>DNS record update</figcaption></figure><p>Step 6: Install cert-manager in your cluster.</p><pre>helm repo add jetstack https://charts.jetstack.io<br>helm repo update<br># Install CRDs with kubectl<br>kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.crds.yaml<br># Install the cert-manager Helm chart<br>helm install cert-manager jetstack/cert-manager \<br>  --version v1.11.0</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RfVAspTAISZQELi4FimrgA.png" /><figcaption>Pod status of cert-manager</figcaption></figure><p>Step 7: Create an issuer</p><pre># Cluster Issuer<br>apiVersion: cert-manager.io/v1<br>kind: ClusterIssuer<br>metadata:<br>  name: letsencrypt-production<br>spec:<br>  acme:<br>    server: https://acme-v02.api.letsencrypt.org/directory<br>    email: enter your email id here<br>    privateKeySecretRef:<br>      name: letsencrypt-production<br>    solvers:<br>      - http01:<br>          ingress:<br>            class: nginx</pre><p>Step 8: Apply the issuer through the Kubectl command</p><pre>kubectl apply -f issuer.yaml</pre><p>Step 9: Create an ingress route configuration</p><p>We are creating this ingress just to set up a certificate for our domain. <strong>We won’t use</strong> <strong>this ingress</strong> to access the neo4j application from outside the cluster.</p><p>Here is why:</p><p><strong><em>Ingress cannot be used because Neo4j’s driver protocol communicates at the TCP level and most Ingress only support HTTP communication. Node Port services cannot be associated with a static IP address, making setting up DNS and SSL very difficult. Using NodePort can additionally create configuration challenges for some Neo4j applications that expect to use port 7687</em></strong></p><pre>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  name: neo4j-ingress<br>  annotations:<br>    cert-manager.io/cluster-issuer: letsencrypt-production<br>spec:<br>  ingressClassName: nginx<br>  tls:<br>  - hosts:<br>    - ct.akstest.tech<br>    secretName: tls-secret<br>  rules:<br>  - host: ct.akstest.tech<br>    http:<br>      paths:<br>      - pathType: Prefix<br>        path: /<br>        backend:<br>          service:<br>            name: my-neo4j-admin<br>            port:<br>              number: 7474</pre><p>Step 10: Apply the configuration.</p><pre>kubectl apply -f ingress.yaml</pre><p>Step 11: Verify that the certificate is applied to your custom domain.</p><pre>kubectl get certificate</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Crhgw_5_2nxRxVkp3uyPrQ.png" /><figcaption>Certificate status</figcaption></figure><p>As we cannot communicate with the ingress directly, we will be using a Helm chart named neo4j/neo4j-reverse-proxy to access Neo4j on either port 80 or port 443 through a Kubernetes Ingress. This Helm chart is available on the Neo4j Helm repository.</p><p>This Helm chart creates a reverse proxy that is configured to route traffic to the Neo4j service URL using the serviceName, namespace, and domain values.</p><p>Step 12: Create a new file named ingress-values. yml.</p><pre>reverseProxy:<br>    image: neo4j/helm-charts-reverse-proxy:5.12.0<br>    serviceName: &quot;my-neo4j-admin&quot;<br>    ingress:<br>        enabled: true<br>        className: nginx<br>        annotations:<br>          cert-manager.io/cluster-issuer: letsencrypt-production<br>        tls:<br>            enabled: true<br>            config:<br>                - secretName: tls-secret<br>                  hosts:<br>                    - ct.akstest.tech</pre><pre>helm install rp neo4j/neo4j-reverse-proxy -f ingress-values.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8DdjPmHirzgbektIKEi-Qw.png" /><figcaption>Neo4j installation</figcaption></figure><pre>watch -n1 kubectl get ing #use this command to see status of ingress</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K6H7fTDNpnGA1PJaMPuLvA.png" /><figcaption>Reverse proxy and ingress status</figcaption></figure><p>Step 13: To improve traffic routing and add extra features like request rewriting, rate limiting, or authentication, we will delete the current ingress. This means that instead of going straight to the my-neo4j-admin service, traffic for <strong>ct.akstest.tech</strong> will now be directed to the reverse proxy.</p><pre>kubectl delete -f ingress.yaml</pre><p>Step 14: Check your domain to see neo4j deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8RaHkQz0iNO9ZEtUL3CJoQ.png" /><figcaption>Neo4j dashboard</figcaption></figure><p>Step 15: Double-check if you can access the database with either the neo4j+s:// or bolt+s:// protocol.</p><pre>username = neo4j<br>password = test1234</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kr19c955Zp6VvpPZS79lBg.png" /><figcaption>Connection using neo4j+s</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l4wjXKt_JB9IeF6JL8xULQ.png" /><figcaption>Connection using bolt+s</figcaption></figure><h3>Conclusion😎:</h3><p><em>If you’re too lazy to read the entire blog, clone this repo </em><a href="https://github.com/AmitGujar/k8s-neo4j-deployment"><strong><em>AmitGujar/k8s-neo4j-deployment </em></strong></a><em>and run the command “run.sh”.</em></p><p>Throughout this tutorial, we covered all the necessary steps involved in deploying Neo4j on an AKS cluster. By following these steps, you can efficiently deploy and utilize Neo4j on your AKS cluster with an TLS certificate, enabling you to take full advantage of its powerful graph database capabilities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39b003e74ac2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Comprehensive Guide to Ansible Vault for Beginners.]]></title>
            <link>https://amitgujar15.medium.com/a-comprehensive-guide-to-ansible-vault-for-beginners-6818e1d618d3?source=rss-142fc40d2bc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/6818e1d618d3</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[secrets]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[Amit Gujar]]></dc:creator>
            <pubDate>Sat, 16 Sep 2023 13:42:48 GMT</pubDate>
            <atom:updated>2023-09-17T10:48:33.548Z</atom:updated>
            <content:encoded><![CDATA[<p>In my previous tutorial, we learned how to set up Ansible on our control node and perform bare deployments by writing playbooks and inventory files. Now we will take a step forward in our Ansible journey and introduce the Ansible-Vault.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i_Pp9cjRq7NwDYfPg-IGGw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@isthatbrock?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Brock Wegner</a> on <a href="https://unsplash.com/photos/3ROwc3JSjCk?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>What is an Ansible vault?</h3><p>This tool allows you to securely store sensitive information in an encrypted format like any other vault. In today’s blog post, we will discuss the details of this vault and perform several operations such as encryption and decryption.</p><p><strong><em>Note: Before reading this blog, I recommend reading my previous one Introduction to Ansible.</em></strong></p><h3>What will you learn:</h3><ol><li>Create encrypted variable files for playbooks.</li><li>Perform operations on encrypted files.</li><li>Link encrypted files in playbooks.</li></ol><h3>Requirements:</h3><ol><li>Refer to my last blog.</li></ol><h3>Let’s Start 🤩:</h3><p><strong>Step 1:</strong> Set your ansible editor if you don’t want to use Vim. Add the following line in your .bashrc.</p><pre>export EDITOR=nano</pre><p>The main interface for managing encrypted content within Ansible is the &quot;ansible-vault&quot; command. It can encrypt, view, edit, or decrypt data.</p><p><strong>Step 2:</strong> Create your first encrypted file.</p><pre>ansible-vault create file.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-kE4YV5UCvN8sI2Q2xbb2A.png" /></figure><p><strong>Step 3:</strong> View the contents of the encrypted file.</p><pre>cat file.yml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9bminCakzNTGoD0m2By7NQ.png" /></figure><p><strong>Step 4:</strong> Edit the encrypted file. You will get a prompt to enter the password in order to edit. Once editing is done the will get encrypted again.</p><pre>ansible-vault edit file.yml</pre><p><strong>Step 5:</strong> To view the file content temporarily, use this command.</p><pre>ansible-vault view file.yml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gZEf0AKGljSvLl4q6IxTUQ.png" /></figure><p><strong>Step 6:</strong> You can also change the password of an encrypted file using the rekey command.</p><pre>ansible-vault rekey file.yml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J8MacONS7FH2ulg6zLtA6w.png" /></figure><p><strong>Step 7: </strong>You can also encrypt existing files using the encrypt command</p><pre>ansible-vault encrypt another_file.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r401JBXntYbVU32_mJbYVg.png" /></figure><p><strong>Step 8: </strong>Decrypt an encrypted file permanently.</p><pre>ansible-vault decrypt another_file.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V3_DhbYcuBoAh4gLP5Qndg.png" /></figure><p><strong>Step 9:</strong> Avoid the hassle of entering the password every time. Create a file named password.txt/py and type your password in it. Make sure to mention this file in .gitignore.</p><pre>ansible-vault view file.yml --vault-password-file=password.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GwN89_X8spqyhaIYLs5j7A.png" /></figure><p><strong>Step 10: </strong>Simplify this by adding the ANSIBLE_VAULT_PASSWORD_FILE variable to the .bashrc file. This automatically catches the password file, eliminating the need for the --vault-password-file flag.</p><pre>export ANSIBLE_VAULT_PASSWORD_FILE=~/myPlaybooks/vault/password.py</pre><h3><strong>Implementing Vault in Playbook:</strong></h3><p>As we move forward, it&#39;s important to note that what we&#39;ve learned so far may not be something you&#39;ll use frequently. However, there is one task that you&#39;ll likely perform more often - providing secret values within a playbook. To demonstrate this, we&#39;ll be using the vm_linux.yml playbook from our previous blog.</p><p><strong>Step 1:</strong> Create a folder, and create a file named values.yml. This file will contain our all variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ynWhFJtNBwfNHskICPponQ.png" /></figure><p><strong>Step 2:</strong> Encrypt this file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ig3NaDT6EJfP89v4YRAx9g.png" /></figure><p><strong><em>Note: I have already added the password file path to the .bashrc file. You may need to perform this step.</em></strong></p><p><strong>Step 3:</strong> To make necessary changes, please edit the vm_linux.yaml file by indicating the exact location of the encrypted file that contains our variables.</p><pre>- name: Creating a VM in Azure<br>  hosts: localhost<br>  vars_files:<br>    - vault/values.yml<br><br>  tasks:<br>  # creating a resource group<br>    - name: Creating a resource group<br>      azure.azcollection.azure_rm_resourcegroup:<br>        name: &quot;{{ resource_name }}&quot;<br>        location: &quot;{{ location }}&quot;<br>        tags:<br>          Exp: &quot;2&quot;<br><br>  # creating a virtual network<br>    - name: Creating virtual network<br>      azure.azcollection.azure_rm_virtualnetwork:<br>        name: &quot;{{ virtual_network_name }}&quot;<br>        resource_group: &quot;{{ resource_name }}&quot;<br>        location: &quot;{{ location }}&quot;<br>        address_prefixes_cidr:<br>          - &quot;10.0.0.0/16&quot;<br>  # creating a subnet<br>    - name: Adding subnet<br>      azure.azcollection.azure_rm_subnet:<br>        name: &quot;{{ subnet_name }}&quot;<br>        resource_group: &quot;{{ resource_name }}&quot;<br>        virtual_network: &quot;{{ virtual_network_name }}&quot;<br>        address_prefix_cidr: &quot;10.0.1.0/24&quot;<br>  # creating a public ip<br>    - name: Creating public ip<br>      azure.azcollection.azure_rm_publicipaddress:<br>        name: &quot;{{ public_ip_name }}&quot;<br>        resource_group: &quot;{{ resource_name }}&quot;<br>        allocation_method: Static<br>      register: output_public_ip<br><br>  # creating a network security group<br>    - name: Creating NSG<br>      azure.azcollection.azure_rm_securitygroup:<br>        name: &quot;{{ nsg_name }}&quot;<br>        resource_group: &quot;{{ resource_name }}&quot;<br>        rules:<br>          - name: &#39;Allow_SSH&#39;<br>            protocol: Tcp<br>            destination_port_range: 22<br>            access: Allow<br>            priority: 100<br>            direction: Inbound<br>          - name: &#39;Allow_web_traffic&#39;<br>            protocol: Tcp<br>            destination_port_range:<br>              - 80<br>              - 443<br>            access: Allow<br>            priority: 101<br>            direction: Inbound<br><br>  # creating a network interface<br>    - name: Creating NIC with public ip<br>      azure.azcollection.azure_rm_networkinterface:<br>        name: &quot;{{ nic_name }}&quot;<br>        resource_group: &quot;{{ resource_name }}&quot;<br>        virtual_network: &quot;{{ virtual_network_name }}&quot;<br>        subnet_name: &quot;{{ subnet_name }}&quot;<br>        security_group: &quot;{{ nsg_name }}&quot;<br>        ip_configurations:<br>          - name: deafult<br>            public_ip_address_name: &quot;{{ public_ip_name }}&quot;<br>            primary: true<br><br>  # creating virtual machines<br>    - name: Finally creating a VM<br>      azure.azcollection.azure_rm_virtualmachine:<br>        name: vm-ansiblemanaged<br>        resource_group: &quot;{{ resource_name }}&quot;<br>        vm_size: Standard_B1s<br>        admin_username: amit<br>        ssh_password_enabled: false<br>        ssh_public_keys:<br>          - path: /home/amit/.ssh/authorized_keys<br>            key_data: &quot;{{ lookup(&#39;file&#39;, &#39;~/.ssh/id_rsa.pub&#39;) }}&quot;<br>        network_interfaces:<br>          - name: &quot;{{ nic_name }}&quot;<br>        image:<br>          offer: 0001-com-ubuntu-server-jammy<br>          publisher: Canonical<br>          sku: &#39;22_04-lts&#39;<br>          version: latest<br><br>  # connection string<br>    - name: Connect to machine using this string<br>      ansible.builtin.debug:<br>        msg: &quot;ssh amit@{{ output_public_ip.state.ip_address }}&quot;</pre><p>Our playbook is now more organized and clean. Let&#39;s execute it to verify if it works as expected.</p><pre>ansible-playbook vm_linux.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tiLuT9-dvd9Lgyp2DebMOA.png" /></figure><h3>Wrapping up 😎:</h3><p>In this tutorial, Ansible Vault and its fundamental functionalities were explained. The tutorial covered various operations that can be performed on Ansible Vault and how to incorporate encrypted files into the playbook.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6818e1d618d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An introduction to Ansible: Install & Deployment.]]></title>
            <link>https://amitgujar15.medium.com/an-introduction-to-ansible-install-deployment-ab51d9bf383b?source=rss-142fc40d2bc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab51d9bf383b</guid>
            <category><![CDATA[ansible]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[ansible-playbook]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Amit Gujar]]></dc:creator>
            <pubDate>Tue, 12 Sep 2023 20:31:33 GMT</pubDate>
            <atom:updated>2023-09-16T08:15:41.528Z</atom:updated>
            <content:encoded><![CDATA[<p>It has been a while since I wrote about the IaaC tool; previously, I focused on the provisioning tool. Today, I’m going to show you how to effortlessly install a cutting-edge configuration management tool that will empower you to easily set up and manage remote servers like a pro! Yes, This tutorial is all about Ansible. Before we dive into the details let’s take a quick look at some of the prerequisites for the tutorial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vW4t7Mt1nho1AA1XhfjGQg.jpeg" /><figcaption>Ansible Illustration</figcaption></figure><h3><strong>Requirements:</strong></h3><ol><li>Linux machines with root access.</li><li>Azure subscription.</li></ol><p><strong><em>Note: You can use docker for Linux machines as well.</em></strong></p><h3>What you will learn 🤩:</h3><ol><li>How to install and configure Ansible on the controller node.</li><li>Writing inventory and playbooks.</li><li>Installing packages on managed nodes.</li><li>Deploying virtual machine on Azure using playbooks.</li><li>Bonus commands.</li></ol><p>Ansible needs 1 controller node and other managed nodes. I will be using WSL as a controller node &amp; VMS in Azure as a managed node.</p><p>I have written a shell script to create virtual machines on Azure. This script will also automatically configure the public key of your local machine to the cloud instances. <strong><em>(Script execution may take time, Ignore all the warnings)</em></strong></p><p><strong>Note: If you are creating the machines on the portal via GUI then you need to add the public key of a local machine.</strong></p><h3>Let’s Start 😎:</h3><p><strong>Note: Perform all the steps on the local machine/controller node only.</strong></p><p><strong>Step 1</strong>: Run the following script to create multiple machines on the cloud.</p><p>(2 is recommended, 1 is enough as well 😅)</p><p>The script will show you the public addresses of the virtual machines on completion. We will be using these to test connections and include them in the inventory file later on.</p><pre>group=ansibleNodesRG<br>size=$1<br><br>read -p &quot;How many machines you want to create? = &quot; instance<br><br>if [ -z $instance ] || [ $instance -eq 0 ]; then <br>    echo &quot;\nNo size is provided, Please specify the size and Try Again.&quot;<br>    exit 1<br>fi<br><br>generate_keys() {<br>    if [ -f ~/.ssh/id_rsa ]; then<br>        echo &quot;SSH keys already exist, Deleting....&quot;<br>        rm -rf ~/.ssh<br>    fi<br>    <br>    echo &quot;\n Generating new ssh keys.\n&quot;<br>    yes &quot;&quot; | ssh-keygen -t rsa -b 4096 -N &quot;&quot; -f ~/.ssh/id_rsa<br>}<br>generate_keys<br><br>echo &quot;\nInitializing VM Creation Process.\n&quot;<br><br>az group create -g $group -l centralindia 2&gt; /dev/null<br>if [ $? -ne 0 ]; then<br>    az group create -g group -l centralindia<br>fi<br><br>az network vnet create \<br>    -n vm-net \<br>    -g $group \<br>    -l centralindia \<br>    --address-prefixes &#39;192.168.0.0/16&#39; \<br>    --subnet-name subnet \<br>    --subnet-prefixes &#39;192.168.0.0/24&#39;<br><br>if [ -z $size ]; then <br> echo &quot;\nNo size is provided, Using default size Standard_B1s for machine&quot;<br> size=B1s<br>fi<br><br>vm_create() {<br>for i in $(seq 1 $instance);<br>do <br>    az vm create \<br>        -n Machine$i \<br>        -g $group \<br>        -l centralindia \<br>        --size Standard_$size \<br>        --image Ubuntu2204 \<br>        --admin-username amitgujar \<br>        --vnet-name vm-net \<br>        --subnet subnet \<br>        --public-ip-sku Standard \<br>        --generate-ssh-keys \<br>        --ssh-key-values ~/.ssh/id_rsa.pub <br>    <br>    az vm open-port -g $group -n Machine$i --port 80<br>done<br>}<br>vm_create<br><br>update_vm() {<br>for i in $(seq 1 $instance);<br>do <br>    az vm run-command invoke \<br>        -g $group \<br>        -n Machine$i \<br>        --command-id RunShellScript \<br>        --script &quot;sudo apt update -y&quot; <br><br>done<br>}<br><br>update_vm<br><br>vm_listIpAddress() {<br>for i in $(seq 1 $instance);<br>do<br>    az vm list-ip-addresses \<br>    -n Machine$i \<br>    -g $group | grep ipAddress | cut -d&#39;:&#39; -f2<br>done<br>}<br><br>vm_listIpAddress</pre><p><strong>Step 2:</strong> Install Ansible and Python3 on the local machine.</p><pre>sudo apt install python3.10 -y<br>sudo apt-add-repository ppa:ansible/ansible<br>sudo apt update -y<br>sudo apt install ansible -y</pre><p><strong>Step 3:</strong> Verify the ansible installation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M1fk_TZkOQAbLMrojNlzlg.png" /></figure><p><strong>Step 4:</strong> Verify the ssh connection of the cloud machines. Use the public IPs from Step 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BPJzggSTJffdVZg94oY91w.png" /><figcaption>Machine 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v855mS26TJtgf5kZ1QiUGA.png" /><figcaption>Machine 2</figcaption></figure><p>We need to write our first inventory file. We can directly change the main inventory file located in /etc/ansible/hosts. However, it is a good practice to create a per-project inventory.</p><p>Inventory is a file that contains information about the management nodes that Ansible controls.</p><p><strong>Step 5: </strong>Create the inventory file and add the following lines.</p><pre>[azure]<br>ip address of the machine 1<br>ip address of the machine 2 <br><br>[azure:vars]<br>ansible_user=amitgujar<br>ansible_python_interpreter=/usr/bin/python3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0TDaczosltBbtytUI_1osg.png" /><figcaption>inventory file</figcaption></figure><p>It’s time to test the connection of managed nodes and master node.</p><p><strong>Step 6:</strong> Enter the following command.</p><pre>ansible all -i inventory -m ping</pre><p>(If you get the success message then a connection is successful)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gZoDh_qKjlZQYo8Vo4TB7A.png" /><figcaption>Connection status</figcaption></figure><p>After writing the inventory file, the next step is to create a playbook.</p><p>A playbook is a file containing a series of tasks to be executed on a remote server.</p><p><strong>Step 7:</strong> Create the playbook.yaml file and add the following lines.</p><pre>- name: Installing packages<br>  hosts: azure<br>  become: true<br>  tasks:<br>    - name: Installing nginx<br>      ansible.builtin.package:<br>        name: nginx<br>        state: present</pre><p><strong>Step 8:</strong> Enter the following command to execute the playbook against the managed nodes.</p><pre>ansible-playbook -i inventory playbook.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iv4JadTKWu7X3ySx8vN0vA.png" /><figcaption>Playbook execution</figcaption></figure><p>To check if nginx is installed, use the curl command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tHTa40LTZ9j0rpt-2YteQw.png" /><figcaption>nginx status</figcaption></figure><p>We have successfully installed the nginx package on the managed nodes. By using the same steps you can install different packages as well.</p><h3><strong>Deployment on Azure:</strong></h3><p><strong>Step 1:</strong> Install Azure CLI</p><pre>curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash</pre><p><strong>Step 2: </strong>Install pip3 &amp; azure packages.</p><pre>sudo apt install python3-pip<br>pip3 install -r /usr/lib/python3/dist-packages/ansible_collections/azure/azcollection/requirements-azure.txt</pre><p><strong>Step 3:</strong> Create the service principle for the subscription. Enter the following command.</p><pre>az ad sp create-for-rbac --role=&quot;Contributor&quot; --scopes=&quot;/subscriptions/&lt;SUBSCRIPTION_ID&gt;&quot;</pre><p>Note down the following details.</p><pre>{<br>  &quot;appId&quot;: &quot;xxxxxx-xxx-xxxx-xxxx-xxxxxxxxxx&quot;,<br>  &quot;displayName&quot;: &quot;azure-cli-2023-xxxx&quot;,<br>  &quot;password&quot;: &quot;xxxxxx~xxxxxx~xxxxx&quot;,<br>  &quot;tenant&quot;: &quot;xxxxx-xxxx-xxxxx-xxxx-xxxxx&quot;<br>}</pre><p><strong>Step 4:</strong> Add these details into the ~/.bashrc for the authentication.</p><pre>export AZURE_SUBSCRIPTION_ID=&lt;SUBSCRIPTION_ID&gt;<br>export AZURE_CLIENT_ID=&lt;CLIENT_ID&gt;<br>export AZURE_SECRET=&lt;CLIENT_SECRET&gt;<br>export AZURE_TENANT=&lt;TENANT_ID&gt;</pre><p>Restart the terminal instance.</p><p><strong>Step 5:</strong> Create the playbook to deploy the resource group &amp; virtual network on the Azure portal.</p><pre>- name: Creation of virtual machine<br>  hosts: localhost<br>  vars:<br>    resource_name: rg-ansiblemanaged<br>    location: centralindia<br>    virtual_network_name: vnet-ansiblemanaged<br>    public_ip_name: pip_ansiblemanaged<br>    nsg_name: nsg-ansiblemanaged<br>    subnet_name: subnet-ansiblemanaged<br>    nic_name: nic-ansiblemanaged<br><br>  tasks:<br>  # creating a resource group<br>    - name: Creating a resource group<br>      azure.azcollection.azure_rm_resourcegroup:<br>        name: &quot;{{ resource_name }}&quot;<br>        location: &quot;{{ location }}&quot;<br><br>  # creating a virtual network<br>    - name: Creating virtual network<br>      azure.azcollection.azure_rm_virtualnetwork:<br>        name: &quot;{{ virtual_network_name }}&quot;<br>        resource_group: &quot;{{ resource_name }}&quot;<br>        location: &quot;{{ location }}&quot;<br>        address_prefixes_cidr:<br>          - &quot;10.0.0.0/16&quot;<br>  # creating a subnet<br>    - name: Adding subnet<br>      azure.azcollection.azure_rm_subnet:<br>        name: &quot;{{ subnet_name }}&quot;<br>        resource_group: &quot;{{ resource_name }}&quot;<br>        virtual_network: &quot;{{ virtual_network_name }}&quot;<br>        address_prefix_cidr: &quot;10.0.1.0/24&quot;<br>  # creating a public ip<br>    - name: Creating public ip<br>      azure.azcollection.azure_rm_publicipaddress:<br>        name: &quot;{{ public_ip_name }}&quot;<br>        resource_group: &quot;{{ resource_name }}&quot;<br>        allocation_method: Static<br>      register: output_public_ip<br><br>  # creating a network security group<br>    - name: Creating NSG<br>      azure.azcollection.azure_rm_securitygroup:<br>        name: &quot;{{ nsg_name }}&quot;<br>        resource_group: &quot;{{ resource_name }}&quot;<br>        rules:<br>          - name: &#39;Allow_SSH&#39;<br>            protocol: Tcp<br>            destination_port_range: 22<br>            access: Allow<br>            priority: 100<br>            direction: Inbound<br>          - name: &#39;Allow_web_traffic&#39;<br>            protocol: Tcp<br>            destination_port_range:<br>              - 80<br>              - 443<br>            access: Allow<br>            priority: 101<br>            direction: Inbound<br><br>  # creating a network interface<br>    - name: Creating NIC with public ip<br>      azure.azcollection.azure_rm_networkinterface:<br>        name: &quot;{{ nic_name }}&quot;<br>        resource_group: &quot;{{ resource_name }}&quot;<br>        virtual_network: &quot;{{ virtual_network_name }}&quot;<br>        subnet_name: &quot;{{ subnet_name }}&quot;<br>        security_group: &quot;{{ nsg_name }}&quot;<br>        ip_configurations:<br>          - name: deafult<br>            public_ip_address_name: &quot;{{ public_ip_name }}&quot;<br>            primary: true<br><br>  # creating virtual machines<br>    - name: Finally creating a VM<br>      azure.azcollection.azure_rm_virtualmachine:<br>        name: vm-ansiblemanaged<br>        resource_group: &quot;{{ resource_name }}&quot;<br>        vm_size: Standard_B1s<br>        admin_username: amit<br>        ssh_password_enabled: false<br>        ssh_public_keys:<br>          - path: /home/amit/.ssh/authorized_keys<br>            key_data: &quot;{{ lookup(&#39;file&#39;, &#39;~/.ssh/id_rsa.pub&#39;) }}&quot;<br>        network_interfaces:<br>          - name: &quot;{{ nic_name }}&quot;<br>        image:<br>          offer: 0001-com-ubuntu-server-jammy<br>          publisher: Canonical<br>          sku: &#39;22_04-lts&#39;<br>          version: latest<br><br>  # connection string<br>    - name: Connect to machine using this string<br>      ansible.builtin.debug:<br>        msg: &quot;ssh amit@{{ output_public_ip.state.ip_address }}&quot;</pre><p><strong>Step 6:</strong> Execute the playbook on localhost</p><pre>ansible-playbook vm_linux.yaml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fyzm8C9vjeeBUYkGuE3cEw.png" /></figure><p><strong>Step 7:</strong> Check if the deployment is successful.</p><pre>ssh amit@ip_address_displayed_in_terminal</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Cs-mzRh3eyG6DWfkCFnHg.png" /></figure><p><strong><em>Note: As you can notice we don’t need managed nodes for the resource group deployment, localhost is enough.</em></strong></p><h3>Bonus 😉:</h3><h3>Ad hoc commands :</h3><p>Ad hoc commands are powerful single-line commands in Ansible. They are very useful to execute singular tasks on managed nodes.</p><p><strong>Command 1:</strong> Harness the power of SCP to transfer files.</p><pre>ansible azure -i inventory -m ansible.builtin.copy -a &quot;src=/path of controller dest=/path to target machines&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-9R1VXjCOD0hq3bnI-omVA.png" /><figcaption>Working of ansible. builtin.copy</figcaption></figure><p><strong>Command 2: </strong>Changing file permissions on remote machines.</p><pre>ansible azure -i inventory -m ansible.builtin.file -a &quot;dest=/home/amitgujar/playbook.yaml mode=777&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fqOPj6Pm003kWXiq5LhFnw.png" /></figure><p><strong>Command 3:</strong> Checking os-release</p><pre>ansible all -i inventory -a &quot;cat /etc/os-release&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ew_p4ayW3_ekkpvLsezebA.png" /></figure><h3><strong>Wrapping up:</strong></h3><p>Today we have covered several concepts of Ansible including installation, configuration, playbooks, and inventory files. Working with deployment on Azure &amp; some ad hoc commands.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab51d9bf383b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building CI/CD pipeline for Terraform in Azure DevOps: A Step-by-Step Guide.]]></title>
            <link>https://amitgujar15.medium.com/building-ci-cd-pipeline-for-terraform-in-azure-devops-a-step-by-step-guide-34eaad16fee5?source=rss-142fc40d2bc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/34eaad16fee5</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[azure-devops]]></category>
            <dc:creator><![CDATA[Amit Gujar]]></dc:creator>
            <pubDate>Fri, 14 Apr 2023 00:21:04 GMT</pubDate>
            <atom:updated>2023-04-14T10:19:29.160Z</atom:updated>
            <content:encoded><![CDATA[<p>Being able to build a CI/CD pipeline for your project is a really important practice in DevOps. This pipeline can save a lot of time by automating the workflow of tasks. Today we will learn, how to create Pipeline for terraform scripts. We will be using Azure DevOps for creating pipelines. This pipeline will automatically deploy terraform code and create resources accordingly on Azure Portal. This tutorial only consists of terraform code as of now but you can use the same steps to deploy other Azure services as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4I3dnmMhRAbbdD5SDzx6bQ.jpeg" /></figure><h3>Requirements</h3><ul><li>Microsoft Azure account.</li><li>Azure DevOps account with parallel jobs permit.</li><li>Git should be installed on your system.</li><li>Terraform, Replace token extension for your organization.</li></ul><p><strong><em>NOTE: I have already written terraform code for this pipeline tutorial. Feel free to create your own. We will be using Azure Repos for version control in this tutorial.</em></strong></p><h3>Let’s Start……🤩</h3><p>Step 1: Open the Azure DevOps portal and create a new project.</p><p><strong><em>Note: If you are not able to select the public visibility option then go for the private.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*laa7Qdqu5PbHsbstrL1jkw.png" /><figcaption>Project creation</figcaption></figure><p>Step 2: Click on Repos to clone my GitHub repository. Now that you are cloning your copy, you can make changes here directly as your own repository.</p><p><strong><em>Update: I have changed the URL of the git repo. Make changes in the path accordingly while adding terraform tasks.</em></strong></p><pre>https://amitgujar3342@dev.azure.com/amitgujar3342/AKS-Migration/_git/AKS-Migration</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EciupjqFdgYmeHFlK6UCxQ.png" /><figcaption>Importing GitHub repository into the Azure Repos</figcaption></figure><p>Step 3: Click on pipelines to create a new pipeline. Select Azure Repos as a source and select that cloned repository. Click on the run button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-xFOv-xvQxM763lMHjsiAA.png" /><figcaption>Pipeline review</figcaption></figure><p><strong><em>Note: This task will copy our Terraform files into the Terraform folder of the agent and it will generate it as an artifact. We will be using this artifact to create a release pipeline.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hAYne_uzo9SKn2pbMicAwQ.png" /><figcaption>Pipeline in action</figcaption></figure><p>Step 4: Now click on Releases to create a new release pipeline. Select an empty job. We will be adding all the terraform commands inside this release pipeline as tasks. Once this pipeline gets deployed our resources should get deployed on the portal automatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TMA5g8e8EHu4_mjF1Pfqeg.png" /><figcaption>Creating release pipeline</figcaption></figure><p>Step 5: Click on add artifact and enter the following details. It will automatically get the latest version of the artifact to create a release and deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*modPf3UctBYIXFTuLngQDw.png" /><figcaption>Adding artifact</figcaption></figure><p>Step 6: Enable continuous deployment trigger by clicking on the flash symbol on the artifact.</p><p><strong><em>Optional: You can also set a schedule to automatically run the pipeline at a specific time</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ijMF3D6rF1G1hVVxeYZS6g.png" /><figcaption>Creating deployment trigger</figcaption></figure><p>Step 7: Click on the Stage 1 area to add tasks for our deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZeVoe_KOH22v0YeiJRJ4Rg.png" /><figcaption>Task Initialization</figcaption></figure><p>Step 8: Add a task for our agent, select the Azure CLI task, and enter the following details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nSsjg5kUgPmgXtJINhKYDg.png" /><figcaption>Az CLI</figcaption></figure><p>Add the following code in the Inline script section and click on save. This script will create a resource group, storage account, and container named terraform to store state files.</p><pre># Creating a resource group for our storage account <br>az group create -l westus -n $(resourcegroup)<br><br># Create an storage account inside the resource group<br>az storage account create -n $(storageaccount) -g $(resourcegroup) -l westus --sku Standard_LRS<br><br># Create a container inside storage account<br>az storage container create -n terraform --account-name $(storageaccount)<br><br>az storage account keys list -g $(resourcegroup) --account-name $(storageaccount)<br><br># Get the storage account keys<br>storageKeys=$(az storage account keys list --account-name $(storageaccount) --resource-group $(resourcegroup) --query &quot;[?keyName==&#39;key1&#39;].value&quot; --output tsv)<br><br>echo &quot;$storageKeys&quot;</pre><p>I have created a backend block to store Terraform.state file inside the Azure blob storage. I have initialized certain values which need to be replaced with the pipeline variables including the storage access key.</p><p>Add another task to replace values inside terraform script with variables of the pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*27e_tRhNMzSyhzSh0Lt5Qw.png" /><figcaption>Token Replacement</figcaption></figure><p>Step 9: Now we will create another task to install Terraform on our agent.</p><p>Step 10: Add terraform init task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lMiLft1141pLaiNRS_Ojeg.png" /><figcaption>Terraform Init</figcaption></figure><p>Step 11: Add terraform validate task. (optional)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gSB_83Y8BUSgzawH-RFS4g.png" /><figcaption>Terraform validate</figcaption></figure><p>Step 12: Add terraform plan task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7mrZKy9uf5usb2ADWbeWww.png" /><figcaption>Terraform plan</figcaption></figure><p>Step 13: Add terraform apply task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5M7gCEpWOB19rkL9_0jLiw.png" /><figcaption>Terraform apply</figcaption></figure><p><strong><em>Note: You can also add destroy task after this task, if you just want to use this pipeline for testing purposes, make sure to add a lock=false argument for the command to avoid errors.</em></strong></p><p>Step 14: Add variables for our release pipeline. Click on the variables tab beside Tasks &amp; then click on Save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NnzxUPSR4i-sbTx8fuYXwA.png" /><figcaption>Initialize variables for the pipeline</figcaption></figure><p>Step 15: Create a release for our stage 1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ekHM21w6bMCXgPTmNGnfQ.png" /><figcaption>Creating the first release</figcaption></figure><p>Step 16: And…..ACTION………</p><p>Deploy the release pipeline. This will be our first manual deployment. Next time if you make any changes in the code, it will create a new release and deployment automatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OvAPYHsy6nnaXds6wZb2CA.png" /><figcaption>Deploying release pipeline</figcaption></figure><p>You can click on logs to see details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VCKBvgVrYf3-mqbYHSHNTA.png" /><figcaption>Deployment logs</figcaption></figure><p>Step 17: Verify your resource deployment on Azure Portal.</p><h3><strong>Conclusion 😊:</strong></h3><p>We used the Azure DevOps portal to create CI/CD for our terraform code to automate the resource creation process.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34eaad16fee5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Terraform to set up the AKS cluster.]]></title>
            <link>https://amitgujar15.medium.com/using-terraform-to-set-up-the-aks-cluster-bf2daadee804?source=rss-142fc40d2bc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf2daadee804</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[powershell]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Amit Gujar]]></dc:creator>
            <pubDate>Mon, 03 Apr 2023 03:31:46 GMT</pubDate>
            <atom:updated>2023-04-03T12:34:54.420Z</atom:updated>
            <content:encoded><![CDATA[<p>In my last blog, I wrote about creating the k8s cluster and deploying an image on the Linode platform. Today we will be doing the same thing BUT using a different technique &amp; different platform. You see, the last time we did everything by ourselves &amp; yes it took a little bit of extra time. Well, this time we will hire someone to do that job for us and that guy is Terraform.</p><p>Just like last time, I will be breaking down this tutorial into various steps so, it will get easy to understand for beginners. I have provided certain requirements, make sure to have those before starting the tutorial.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yGPTvKPLbixo7ZLMQGfwXg.png" /></figure><h3>Tutorial Requirements :</h3><ol><li>An Azure subscription.</li><li>Azure CLI client.</li><li>Terraform configured with Az Cli.</li><li>Kubectl should be installed on your pc.</li></ol><h3>What will you learn :</h3><ol><li>How to create an AKS cluster using terraform.</li><li>How to deploy an application image on it.</li><li>Browse your deployment.</li></ol><h3>Let’s Begin 🤩</h3><p>Make a folder, it will contain all your terraform code.</p><p>Before proceeding make sure you have generated ssh-keys.</p><p>Step 1: Create a file named providers. tf and add the following code to it.</p><pre>terraform {<br>  required_version = &quot;&gt;= 1.0&quot;<br><br>  required_providers {<br>    azurerm = {<br>      source  = &quot;hashicorp/azurerm&quot;<br>      version = &quot;&gt;= 3.0&quot;<br>    }<br>  }<br>}<br><br>provider &quot;azurerm&quot; {<br>  features {<br>    resource_group {<br>      prevent_deletion_if_contains_resources = false<br>    }<br>  }<br>}</pre><p>Step 2: Create a file named main. tf</p><p><strong><em>NOTE: You can alter the image size according to your need.</em></strong></p><pre>resource &quot;azurerm_resource_group&quot; &quot;rg&quot; {<br>  name     = var.resource_group_name<br>  location = var.resource_group_location<br>}<br><br>resource &quot;azurerm_kubernetes_cluster&quot; &quot;k8s&quot; {<br>  location            = azurerm_resource_group.rg.location<br>  name                = var.cluster_name<br>  resource_group_name = azurerm_resource_group.rg.name<br>  dns_prefix          = var.dns_prefix<br><br>  default_node_pool {<br>    name       = &quot;workernode&quot;<br>    vm_size    = &quot;Standard_D2_v2&quot;<br>    node_count = var.agent_count<br>  }<br>  linux_profile {<br>    admin_username = &quot;amitgujar&quot;<br><br>    ssh_key {<br>      key_data = file(var.ssh_public_key)<br>    }<br>  }<br>  network_profile {<br>    network_plugin    = &quot;kubenet&quot;<br>    load_balancer_sku = &quot;standard&quot;<br>  }<br>  service_principal {<br>    client_id     = var.aks_service_principal_app_id<br>    client_secret = var.aks_service_principal_client_secret<br>  }<br>}</pre><p>Step 3: Create a file named variables. tf</p><pre>variable &quot;resource_group_name&quot; {<br>  default = &quot;k8s-demo-rg&quot;<br>}<br><br>variable &quot;resource_group_location&quot; {<br>  default     = &quot;centralindia&quot;<br>  description = &quot;Location of the resource group.&quot;<br>}<br><br>variable &quot;resource_group_name_prefix&quot; {<br>  default     = &quot;rg&quot;<br>  description = &quot;Prefix of the resource group name&quot;<br>}<br><br>variable &quot;agent_count&quot; {<br>  default = 2<br>}<br><br>variable &quot;aks_service_principal_app_id&quot; {<br>  default = &quot;&quot;<br>}<br><br>variable &quot;aks_service_principal_client_secret&quot; {<br>  default = &quot;&quot;<br>}<br><br>variable &quot;cluster_name&quot; {<br>  default = &quot;myCluster&quot;<br>}<br><br>variable &quot;dns_prefix&quot; {<br>  default = &quot;myCluster&quot;<br>}<br><br>variable &quot;ssh_public_key&quot; {<br>  default = &quot;~/.ssh/id_rsa.pub&quot;<br>}</pre><p>Our terraform script is successfully created, it’s time to run them.</p><p>Step 4: Type the following command to initialize terraform</p><pre>terraform init -upgrade</pre><p>Once it’s done, you will see a prompt like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3sgwYJPLusm8_iHjiv8J0A.png" /><figcaption>Terraform Init</figcaption></figure><p>Step 5: Make a plan of your terraform config.</p><pre>terraform plan -out main.tfplan</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n0ccejNQSJEVtp3KaNee_g.png" /><figcaption>Terraform Apply</figcaption></figure><p>Step 6: Type the following command to create resources as per the plan.</p><pre>terraform apply main.tfplan</pre><p>You will see a success message once everything is created.</p><p>Step 7: It’s time for us to verify the resource group. Enter the following command</p><pre>echo &quot;$(terraform output resource_group_name)&quot;</pre><p>Step 8: Master Node Time.</p><pre>az aks get-credentials -g k8s-demo-rg -n myCluster</pre><p>Step 9: Verify if our worker nodes are ready or not.</p><pre>kubectl get nodes</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0RLpf_Rgs8pNv7MUV_-QwA.png" /><figcaption>kubectl get nodes</figcaption></figure><p>Now we can conclude that our aks cluster is ready to do some action.</p><p>Step 10: Create another folder named deployment. This folder will contain the deployment code.</p><p>Step 11: Make deployment.yaml file inside the folder and add this code to it.</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: demopods-deployment<br>  labels:<br>    app: demopods<br>spec:<br>  replicas: 3<br>  selector:<br>    matchLabels:<br>      app: demopods<br>  template:<br>    metadata:<br>      labels:<br>        app: demopods<br>    spec:<br>      containers:<br>      - name: static-site<br>        image: amitgujar/static-app:latest<br>        imagePullPolicy: Always<br>        ports:<br>        - containerPort: 80</pre><p>This code will pull the docker image of my basic node application and it will deploy that image on myCluster.</p><p>Step 12: Create a PowerShell file named deploy.ps1 to auto-deploy and assign a public IP to our deployment so, we can access our deployment through that IP.</p><p><strong><em>NOTE: It is not important to add sleep in the script. I added that for my convenience, you can totally ignore that.</em></strong></p><pre>Write-Output &quot;Deployment is started....!!!&quot;<br><br>Start-Sleep -Seconds 3<br><br>kubectl apply -f deployment.yaml<br><br>Write-Output &quot;Getting more information about the deployment&quot;<br><br>kubectl describe deployment demopods-deployment<br><br>Write-Output &quot;Listing the number of pods created by deployment&quot;<br><br>kubectl get pods -o wide<br><br>Write-Output &quot;Exposing the deployment...!!!&quot;<br><br>Start-Sleep -Seconds 7<br><br>kubectl expose deployment demopods-deployment --type=LoadBalancer --port=80 --name=expose-service<br><br>Write-Output &quot;Listing the service&quot;<br><br>kubectl get svc</pre><p>Now, before executing this check the execution policy in PowerShell. If it is restricted then you will need to change it for the script to run.</p><pre>Get-ExecutionPolicy</pre><p>Step 13: And action…. (run deploy.ps1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BCyseSLjETMNonSvy3nGvg.png" /><figcaption>Deploying docker image</figcaption></figure><p>Your output should look like this. Run the following command to check the Public IP of LB.</p><pre>kubectl get svc</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gkpm95mQTSEgFXXwon0E_g.png" /><figcaption>Exposing Deployment</figcaption></figure><p>Step 14: Note down this external IP. Enter the following command to see if your deployment is working successfully.</p><pre>curl http://20.219.224.183</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BGJLpJ7fkUEQ5viQeHrQsQ.png" /><figcaption>Successful Deployment on Terminal</figcaption></figure><p>Yes, If you need some fancy page then you can enter this address in the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C7cEtQW21flMiLofTOFPzQ.png" /><figcaption>Successful Deployment</figcaption></figure><p>Step 15: Clean up your resources….</p><pre>terraform destroy</pre><h3>Cheers 😎</h3><p>Let’s summarize what we have done here.</p><p>First, we created some terraform configuration files. Then we applied that configuration to create resources. Once our cluster is created, we get connected to that cluster from our machine. Then we deployed a docker image of my sample project. We exposed our deployment to verify deployment on our machine.</p><p>The entire code is available on my <a href="https://github.com/AmitGujar/Terraform-Test">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf2daadee804" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup your K8s Cluster with Linode]]></title>
            <link>https://amitgujar15.medium.com/setup-your-k8s-cluster-with-linode-38befb4e365f?source=rss-142fc40d2bc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/38befb4e365f</guid>
            <category><![CDATA[linode]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[wsl]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Amit Gujar]]></dc:creator>
            <pubDate>Wed, 15 Mar 2023 02:41:24 GMT</pubDate>
            <atom:updated>2023-03-15T02:41:24.046Z</atom:updated>
            <content:encoded><![CDATA[<p>It all started yesterday, I was playing with azure services and reading through their documentation, and literally out of nowhere, my friend told me about Linode on a phone call. I thought it might be worth giving a shot on this cloud platform (and it was 😉).</p><p>I went ahead and created an account on Linode, and saw their various offerings but one service caught my eye and that was Kubernetes. I realized how much effort it took for me to set up the k8s cluster on my local Linux VM on Vmware. Believe me, Setting up your own Kubernetes cluster can be a little bit of extra work depending on which platform you use (it is a bit of work if you plan to do it on a local VM). It is very easy to set up a cluster on cloud platforms.</p><p>Today in this tutorial we will talk about Linode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oD9O5w8ee51hqzHzSl9dfQ.png" /></figure><p>THIS TUTORIAL IS NOT FOR LINODE PROMOTION.</p><h3>Why Linode?</h3><ul><li>It is cheaper than other big bois (AWS, Azure).</li><li>It is very easy.</li><li>Beginner friendly if you want to see k8s in action.</li></ul><h3>Tutorial Requirement</h3><ul><li>Create a Linode account from <a href="https://login.linode.com/signup"><strong>here</strong></a><strong>.</strong></li><li>Basic knowledge about k8s.</li><li>A Linux machine (you can use WSL).</li></ul><h3>What will you learn?</h3><ul><li>Create worker nodes on Linode.</li><li>Make your local Linux machine the master node.</li><li>Deploy a sample nginx image on all nodes.</li><li>Use the Nodeport service to access port 80.</li><li>Watch your deployment.</li></ul><h3>Let’s Start….(shall we?)</h3><p>Step 1: Open your Linode dashboard, find Kubernetes service, and click on create a cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V_58hcjpf3Qoe7nQsgTyqg.png" /></figure><p>Step 2: Enter the details and select the shared CPU, and add the minimal plan to save some money 😅.</p><p>Click on Create Cluster.</p><p>Step 3: Wait for your 3 worker nodes to get up and running.</p><p>You see, We only have worker nodes here. You might ask where is the master node and yeah that’s right. But no worries Linode will come to the rescue by providing us with a FREE Master node.</p><p>That master node will be our local Linux machine. I will be using WSL for this tutorial but you can use whatever you want.</p><p>Step 4: Click on view beside your kube_cluster_config.yaml &amp; yes you can download this file right away to avoid extra work. If you did this then skip to step 7.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G2ML_ZKRrS3CuKVZznJvxQ.png" /></figure><p>Step 5: Copy the contents of the yaml file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_meEZmHRMNrhJuGyotIBqQ.png" /></figure><p>Step 6: Open your local Linux machine &amp; create a yaml file and copy this code into it.</p><p>Step 7: Time to install kubectl on your local machine by this command.</p><pre>curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl</pre><p>Step 8: Make this downloaded kubectl an executable.</p><pre>sudo chmod 700 kubectl</pre><p>Step 9: Move this command to your path so you can access it from anywhere.</p><pre>sudo mv ./kubectl /usr/local/bin/kubectl</pre><p>Step 10: Remember step 6? now you need to give the path of your config.yaml to set an environment variable. Add this line to your terminal ./bashrc if you using bash or ./zshrc</p><p>After this step, your local machine will act as Master Node.</p><pre>export KUBECONFIG=~/kubeconfig/kubeconfig.yaml</pre><p>Step 11: Type the following command to see if your worker nodes are successfully connected to your master node.</p><pre>kubectl get nodes</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OaCTFYLKK4N2-KQLNwIpFQ.png" /></figure><p>It’s time for us to deploy some images on it.</p><p>Step 12: Create a new file named deployment.yaml and add the following code to it.</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: nginx-deployment<br>  labels:<br>    app: demopods<br>spec:<br>  replicas: 3<br>  selector:<br>    matchLabels:<br>      app: demopods<br>  template:<br>    metadata:<br>      labels:<br>        app: demopods<br>    spec:<br>      containers:<br>      - name: static-site<br>        image: nginx:latest<br>        imagePullPolicy: Always<br>        ports:<br>        - containerPort: 80</pre><p>Step 13: Create a deployment.sh, file to automate the process of deployment and node port. Add the following code to it.</p><pre>#! /bin/bash<br>kubectl apply -f deployment.yaml<br><br>echo &quot;\nGetting more info on deployment.yaml&quot;<br><br>kubectl describe deployment demopods-deployment<br><br>echo &quot;\nListing the number of pods created by this deployment.\n&quot;<br><br>kubectl get pods -o wide<br><br>echo &quot;\nExposing deployment.\n&quot;<br><br>kubectl expose deployment demopods-deployment --type=NodePort --name=expose-service<br><br>echo &quot;\nGetting Services&quot;<br><br>kubectl get svc</pre><p>Now either give execute permission to this file or simply type “sh deployment. sh” on the terminal to execute this file. It will deploy an nginx image and expose port number 80.</p><p>Your output should look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g4pbRLQMK8JQC-DVuvYNkw.png" /></figure><p>Step 14: Note down the Port number beside the 80, In my case that is 32563.</p><p>Type the following command to check if your pods are up and running.</p><pre>kubectl get pods</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xPfASvUAFUdYbjlWsZ_e_w.png" /></figure><p>Step 15: Login into one of your worker nodes and type ifconfig in the terminal.</p><p>Step 16: Note down the eth0 IP address. In my case, it is 170.187.251.190</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Ypn_4yo0C8jL7db6tAg0w.png" /></figure><p>Step 17: Type the following command along with the IP address from step 16 and the port number from step 14 to if your deployment is working successfully.</p><pre>curl 170.187.251.190:32563</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hz_F8S3Ebe8eKBnqpH8p3w.png" /></figure><p>Step 17: You can also type that IP address and port number in your browser &amp; you will see the nginx page is working.</p><h3>Wrapping Up</h3><p>Well… we successfully created a Kubernetes cluster and deployed a sample nginx image on it. We will talk about AKS clusters next time 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38befb4e365f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Customize your Git bash like this]]></title>
            <link>https://amitgujar15.medium.com/customize-your-git-bash-like-this-d969c68abfdb?source=rss-142fc40d2bc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/d969c68abfdb</guid>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[zsh]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[customization]]></category>
            <category><![CDATA[windows-10]]></category>
            <dc:creator><![CDATA[Amit Gujar]]></dc:creator>
            <pubDate>Mon, 08 Mar 2021 01:20:16 GMT</pubDate>
            <atom:updated>2021-03-08T01:20:16.852Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s spice up our default git bash terminal into a good-looking modern terminal. The final version of our git bash is gonna look something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HdsKB9UbyvCLc6nEVFYDig.png" /></figure><h3>Requirements</h3><p>Before getting started, make sure you have downloaded all these required files.</p><p><a href="https://git-scm.com/download/win">Git bash</a></p><p><a href="https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701">Windows terminal</a></p><p><a href="https://packages.msys2.org/package/zsh?repo=msys&amp;variant=x86_64">Zsh package</a></p><p><a href="https://peazip.github.io/index.html">Peazip</a></p><p><a href="https://www.nerdfonts.com/font-downloads">Nerd Fonts</a> (download and install your favorite font)</p><h3>Add git bash in windows terminal</h3><p>Copy following code in settings.json</p><pre>&quot;guid&quot;: &quot;{00000000-0000-0000-ba54-000000000002}&quot;,</pre><pre>&quot;commandline&quot;: &quot;%PROGRAMFILES%/git/usr/bin/bash.exe -i -l&quot;,</pre><pre>&quot;icon&quot;: &quot;%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico&quot;,</pre><pre>&quot;name&quot; : &quot;Bash&quot;,</pre><pre>&quot;startingDirectory&quot; : &quot;%USERPROFILE%&quot;</pre><p>If you want then you can make this terminal as default in the windows terminal.</p><h3>Add zsh package</h3><p>Extract the content to your git bash installation dir: Usually C:\Program Files\Git using PeaZip.</p><p>Now open git bash and type zsh, if it starts zsh then you are good to go.</p><h3>Install oh-my-zsh</h3><pre>sh -c &quot;$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)&quot;</pre><p>You need to edit ~/.bashrc file to make zsh the default shell. Add the following lines at the end of the file.</p><pre># Launch Zsh<br>if [ -t 1 ]; then<br>exec zsh<br>fi</pre><h3>Install powerlevel10k</h3><pre>git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k</pre><p>After install, you need to add powerlevel10k as zsh theme for that you need to edit ~/.zshrc to following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*Z44QknUX7j-0meiDD5j6MA.png" /></figure><p>Now open another instance of git terminal in a windows terminal, you should see something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_h0dXszQ4DwqV79EXQvVBg.png" /></figure><p>Now choose options as per your desire and finish the configuration.</p><h3>Time to change colors</h3><p>Your terminal may not look like mine because you need to change your color scheme in the windows terminal, Open settings.json, and paste this scheme.</p><pre>&quot;name&quot;: &quot;MyScheme&quot;,</pre><pre>&quot;black&quot;: &quot;#070707&quot;,</pre><pre>&quot;red&quot;: &quot;#fc0744&quot;,</pre><pre>&quot;green&quot;: &quot;#bbbbbb&quot;,</pre><pre>&quot;yellow&quot;: &quot;#ffdb8e&quot;,</pre><pre>&quot;blue&quot;: &quot;#b3007d&quot;,</pre><pre>&quot;purple&quot;: &quot;#d57bff&quot;,</pre><pre>&quot;cyan&quot;: &quot;#76c1ff&quot;,</pre><pre>&quot;white&quot;: &quot;#c7c7c7&quot;,</pre><pre>&quot;brightBlack&quot;: &quot;#686868&quot;,</pre><pre>&quot;brightRed&quot;: &quot;#ff6e67&quot;,</pre><pre>&quot;brightGreen&quot;: &quot;#00ff88&quot;,</pre><pre>&quot;brightYellow&quot;: &quot;#ffe600&quot;,</pre><pre>&quot;brightBlue&quot;: &quot;#ff9900&quot;,</pre><pre>&quot;brightPurple&quot;: &quot;#00b0ff&quot;,</pre><pre>&quot;brightCyan&quot;: &quot;#00aeff&quot;,</pre><pre>&quot;brightWhite&quot;: &quot;#ffffff&quot;,</pre><pre>&quot;background&quot;: &quot;#24283f&quot;,</pre><pre>&quot;foreground&quot;: &quot;#d6c9ff&quot;</pre><p>To enable the acrylic effect copy these lines and paste them into the git bash profile.</p><pre>&quot;acrylicOpacity&quot;: 0.8,</pre><pre>&quot;useAcrylic&quot;: true</pre><p>Bonus,</p><p>To enable Autosuggestions, Git Clone the zsh-autocomplete plugin in the .oh-my-zsh plugin folder.</p><pre>git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions</pre><p>Now, add the plugin in the ~/.zshrc file&#39;s plugin list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*RlIt4LsHGIqmv10_LfBIVA.png" /></figure><p>Now your git bash should look like mine.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d969c68abfdb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Best browser extension that everyone should use.]]></title>
            <link>https://amitgujar15.medium.com/5-best-browser-extension-of-2020-that-everyone-should-use-44d8d9cc18b3?source=rss-142fc40d2bc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/44d8d9cc18b3</guid>
            <category><![CDATA[browsers]]></category>
            <category><![CDATA[chrome-extension]]></category>
            <category><![CDATA[best]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[2020]]></category>
            <dc:creator><![CDATA[Amit Gujar]]></dc:creator>
            <pubDate>Wed, 16 Dec 2020 17:24:25 GMT</pubDate>
            <atom:updated>2020-12-16T17:30:10.005Z</atom:updated>
            <content:encoded><![CDATA[<p>It doesn&#39;t matter what kind of user you are especially if you are using the internet, there are some great extension which will help you to boost your browsing experience and enhance the utility for your daily browser. In this article, we are going to look at the 5 browser extension that anyone can use on regular basis.</p><h3>Lastpass</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_NeKxPahcQywCEuAPL2gaA.jpeg" /></figure><p>Lastpass is a free password manager that will help you to manage your all passwords, secure notes, payment cards, bank accounts. This can even help you to generate strong passwords and the cool thing is you don’t have to remember them, it will fill them automatically whenever requires. You can also get a premium version if you need any additional features.</p><p><a href="https://chrome.google.com/webstore/detail/lastpass-free-password-ma/hdokiejnpimakedhajhdlcegeplioahd">Download</a></p><h3>IDM</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-sr-KhHRjrS-ZpTAWc892A.png" /></figure><p>Internet Download Manager is a very useful tool with which you will be able to duplicate the download speed, the remaining times will be reduced. Internet Download Manager includes all the necessary features to make easier and faster the download process for users. All you have to do is to set the URL of the file you want to download or include a shortcut in your web browser. Once you have inserted the URL you can choose the kind of file (general, document, music, video, programs, or compressed file), You can even schedule multiple downloads.</p><p><a href="https://www.internetdownloadmanager.com/">Download</a></p><h3>Grammarly</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*8EakkWOs0AO3DxBnptmk8w.jpeg" /></figure><p>Grammarly is one of the popular extensions in the chrome web store and it does a really handy job. Grammarly helps you eliminate writing errors and find the perfect words to express yourself. You’ll get real-time feedback from Grammarly almost all over the internet where you have to type any sentence or paragraph. I also use Grammarly while writing blogs here ;)</p><p><a href="https://chrome.google.com/webstore/detail/grammarly-for-chrome/kbfnbcaeplbcioakkpcpgfkobkghlhen">Download</a></p><h3>The Great Suspender</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JJGPR0-5fBvcmVq57YYHpg.jpeg" /></figure><p>If you open lots of tabs on a browser and often end working on a specific one? and while doing so all of those tabs can result in a memory hog. Well, there is one extension named The great suspender that is just for you. The great suspender will suspend those tabs that you are not using currently. You can also whitelist some sites from getting suspended.</p><p><a href="https://chrome.google.com/webstore/detail/the-great-suspender/klbibkeccnjlkjkiokjodocebajanakg">Download</a></p><h3>Bink (Personal dashboard for chrome)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zdIBMW-993jh0DK8mr60gw.png" /></figure><p>Default dashboard of browsers can be so boring, it will just show you your top sites or bookmarks and nothing else or you can say it “good looking”. Now I know there are many dashboard extensions available in the web store but do you really use all the features of them?. Bink is an exception to this because it’s so simple and it will make your default tab into a beautiful looking productive tab. It will show your top sites, precise weather, time, motivational quotes, high-quality wallpapers which will change daily and of course todo for your daily tasks, and everything is just under 397 Kb. If you want then you can also contribute to this project. (Plus this extension is created by me ;) )</p><p><a href="https://chrome.google.com/webstore/detail/bink-personal-dashboard-f/hobnhcjgdhdcmgcjlidgcladgdlbpgba">Download</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44d8d9cc18b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Change Spotify themes on Desktop]]></title>
            <link>https://amitgujar15.medium.com/change-spotify-themes-on-desktop-e8a34f339f83?source=rss-142fc40d2bc8------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8a34f339f83</guid>
            <category><![CDATA[windows-10]]></category>
            <category><![CDATA[desktop]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[themes]]></category>
            <category><![CDATA[spotify]]></category>
            <dc:creator><![CDATA[Amit Gujar]]></dc:creator>
            <pubDate>Sat, 12 Sep 2020 08:46:57 GMT</pubDate>
            <atom:updated>2020-09-12T09:00:10.005Z</atom:updated>
            <content:encoded><![CDATA[<h3>Changing theme of the Spotify app on desktop</h3><p>Bored from default Spotify dark theme on its desktop application? wanna try out new themes or wanna built some new themes for it on your own, well it’s possible and in this blog, I am gonna guide you through all process. When we talk about UI of desktop application it mainly consists of Js, CSS, HTML and here we will be changing themes by injecting our custom CSS.</p><p>This thing is possible because of an application named <a href="https://github.com/khanhas/spicetify-cli"><strong>Spicetify</strong>-<strong>Cli</strong></a> created by <a href="https://github.com/khanhas/"><strong>Khanhas</strong></a>.</p><p>It’s recommended that don’t use Spotify from the windows store because your changes will get vanished after the application closes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ncPvAzcoBrAPPCpHrHHBFQ.jpeg" /><figcaption>Theme Name —BlueContrast by Amit Gujar</figcaption></figure><p>I am gonna tell you the installation on windows but if you have Linux or Mac then you can check the installation info <a href="https://github.com/khanhas/spicetify-cli/wiki/Installation"><strong>here</strong></a>.</p><p>Open Powershell as admin and type the following line.</p><pre>Invoke-WebRequest -UseBasicParsing &quot;https://raw.githubusercontent.com/khanhas/spicetify-cli/master/install_curl.ps1&quot; | Invoke-Expression</pre><p>Now, wait until it finishes the installation.</p><p>Now type commands in PowerShell again</p><pre>spicetify //to generate config file<br>spicetify backup apply enable-devtool // to enable developer tools</pre><p><strong>NOTE — “C:\Users\Username\spicetify-cli” this is the default path of application on Windows.</strong></p><p>Now it’s time to choose a theme, Spicetify Users created a variety of themes you can find them <a href="https://github.com/morpheusthewhite/spicetify-themes"><strong>here</strong></a><strong> </strong>(you can clone this entire folder).</p><p>Choose any theme you like then open that folder and copy color.ini and user.css</p><p>Now it’s time to apply some themes, follow this path <strong>C:\Users\Username\spicetify-cli\Themes\SpicetifyDefault</strong></p><p>You will see two files like this, Now replace these two files with your copied color.ini and user.css</p><p>Then open PowerShell/Cmd and type</p><pre>spicetify update<br>spicetify restart</pre><p>You will find that your default theme has been applied to Spotify Application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4pxs3Pvki5z8v0o9TaQdYA.png" /><figcaption>Theme Name — Dribbblish (Horizon) by morpheusthewhite</figcaption></figure><p>NOTE — If want to make your own theme then you can change the user.css and color.ini accordingly.</p><p><strong>You can also add some </strong><a href="https://github.com/khanhas/spicetify-cli/wiki/Extensions"><strong>extensions</strong></a><strong> to your Spotify Application. </strong>For Demo, I have installed this extension named New Releases (shows newly released songs in the past 30 days).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-OTpFEM8Cxu4jEJmhUXwhg.jpeg" /></figure><p>To install extensions type the following command in Powershell/CMD</p><pre>spicetify config extensions newReleases.js<br>spicetify apply</pre><p>To see the list of available extensions you can check <strong>C:\Users\Username\spicetify-cli\Extensions </strong>or <a href="https://github.com/khanhas/spicetify-cli/wiki/Extensions"><strong>Here</strong></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8a34f339f83" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>