<?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>DEV Community: Aditya Kanekar</title>
    <description>The latest articles on DEV Community by Aditya Kanekar (@adityakanekar).</description>
    <link>https://dev.to/adityakanekar</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%2F476877%2F797821e4-34a8-4308-b2ec-85403b5ffd32.png</url>
      <title>DEV Community: Aditya Kanekar</title>
      <link>https://dev.to/adityakanekar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adityakanekar"/>
    <language>en</language>
    <item>
      <title>Installing SciSpacy on Apple M1 Laptops</title>
      <dc:creator>Aditya Kanekar</dc:creator>
      <pubDate>Mon, 11 Jul 2022 03:09:39 +0000</pubDate>
      <link>https://dev.to/adityakanekar/installing-scispacy-on-apple-m1-laptops-3cn6</link>
      <guid>https://dev.to/adityakanekar/installing-scispacy-on-apple-m1-laptops-3cn6</guid>
      <description>&lt;h1&gt;
  
  
  Background
&lt;/h1&gt;

&lt;p&gt;I was working on developing a API based on SciSpacy to search for medical terms. Looking at the slow performance of loading the model and entity linker on the Intel i5 chip on my Lenovo laptop, I was curious to check how the Apple M1 chip would perform since I own a MacBook Air with M1 chip with following specifications,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;RAM - 16GB&lt;/li&gt;
&lt;li&gt;Storage - 512GB SSD&lt;/li&gt;
&lt;li&gt;Apple M1 chip

&lt;ul&gt;
&lt;li&gt;8-core CPU with 4 perform­ance cores and 4 efficiency cores&lt;/li&gt;
&lt;li&gt;8-core GPU&lt;/li&gt;
&lt;li&gt;16-core Neural Engine&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  The Process
&lt;/h1&gt;

&lt;p&gt;Following are the dependencies from &lt;strong&gt;requirement.txt&lt;/strong&gt; file for SciSpacy and the en_core_sci_lg model,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;scispacy==0.5.0
https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.5.0/en_core_sci_lg-0.5.0.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The ** pip install -r requirement.txt ** failed with lot of errors while installing a dependency ** nmslib ** with an error ** clang compiler does not support '-march=native' **. Since I already had the Xcode installed on my Mac the version of C was 11 but somehow the mentioned command was failing, since the said argument was not supported on the C version. With a lot of digging around I finally found a solution mentioned on &lt;a href="https://github.com/allenai/scispacy/issues/372"&gt;SciSpacy GitHub page&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Install the nmslib using following command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CFLAGS="-mavx -DWARN(a)=(a)" pip install nmslib
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running this command all the packages got installed as expected and I was able to load and run the queries on SciSpacy model. &lt;/p&gt;

&lt;p&gt;Next I will be coming up with the performance comparison on Apple M1 vs Intel i5 chip. I understand the comparison isn't fair but it just shows how much improved the M1 Chip is over the Intel processors.&lt;/p&gt;

</description>
      <category>scispacy</category>
      <category>ner</category>
      <category>nlp</category>
    </item>
    <item>
      <title>Tips for CKAD Exam</title>
      <dc:creator>Aditya Kanekar</dc:creator>
      <pubDate>Sun, 15 Aug 2021 18:22:27 +0000</pubDate>
      <link>https://dev.to/adityakanekar/tips-for-ckad-exam-58gn</link>
      <guid>https://dev.to/adityakanekar/tips-for-ckad-exam-58gn</guid>
      <description>&lt;p&gt;In the last post I talked about &lt;a href="https://dev.to/adityakanekar/how-to-prepare-for-ckad-exam-3a85"&gt;How to prepare for CKAD exam&lt;/a&gt;. In this post we will talk about tips and tricks for passing the CKAD exam.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup your Kubernetes environment
&lt;/h2&gt;

&lt;p&gt;Before starting the exam, spend few mins to setup the environment which will help you save time later. &lt;/p&gt;

&lt;h3&gt;
  
  
  Setup autocompletion
&lt;/h3&gt;

&lt;p&gt;Ref - &lt;a href="https://kubernetes.io/docs/reference/kubectl/cheatsheet/"&gt;https://kubernetes.io/docs/reference/kubectl/cheatsheet/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run following statements on the shell to setup autocompletion for kubectl commands,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source &amp;lt;(kubectl completion bash) 

# Only if you want to add this to your bashrc profile
echo "source &amp;lt;(kubectl completion bash)" &amp;gt;&amp;gt; ~/.bashrc

alias k=kubectl
complete -F __start_kubectl k
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can execute commands on shell using alias &lt;strong&gt;k&lt;/strong&gt; instead of &lt;strong&gt;kubectl&lt;/strong&gt; e.g.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k get pods
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also you can now press tab after writing first 2-3 letters of your sub commands to complete the command. This will save you sometime in the exam, remember the time is limited and saving time typing each command will add up to a significant saving in time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup alias for frequently used commands
&lt;/h3&gt;

&lt;p&gt;Setup alias or environment variables for frequently used commands, I personally used following alias's and environment variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias kg='k get po -o wide --show-labels'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Environment variables&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dr='--dry-run=client -o yaml'
fd='--force --grace-period=0'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first command can be used with &lt;strong&gt;k run&lt;/strong&gt; command to generate yaml definition like,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k run nginx --image=nginx $dr &amp;gt; nginx.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second command can be used with &lt;strong&gt;k delete po&lt;/strong&gt; to delete pod's quickly. As part of the exams, there will be lot of questions which will require to create/delete pods. To delete pod quickly you can use the second environment variable like,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k delete po nginx $fd 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Use imperative commands
&lt;/h2&gt;

&lt;p&gt;It's difficult to create the YAML definition files required for deploying resources like PODs, Deployments, ReplicaSets etc. by creating YAML definition files manually. Copying the files manually from the Kubernetes documentation is one way, but its time consuming and exam time is limited. &lt;/p&gt;

&lt;p&gt;There is a better way for creating these complex YAML definition files using kubectl imperative commands. I am listing down few commands for creating resources like POD, Deployments, Service etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create POD
&lt;/h3&gt;

&lt;p&gt;Ref - &lt;a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#run"&gt;https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#run&lt;/a&gt;&lt;br&gt;
Use the below command to generate the Pod definition file,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k run &amp;lt;pod-name&amp;gt; --image=&amp;lt;image-name&amp;gt; --dry-run=client -o yaml &amp;gt; &amp;lt;file-name&amp;gt;.yaml

#or if you setup the environment variable simply run

k run &amp;lt;pod-name&amp;gt; --image=&amp;lt;image-name&amp;gt; $dr &amp;gt; &amp;lt;file-name&amp;gt;.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following command demonstrates how you can use different option to quickly create a Pod or YAML definition file without creating the YAML file at all,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k run nginx --image=nginx --labels tier=webserver --env="key=value" --port=8080 --requests="cpu=200m,memory=256Mi" --limits="cpu=250m,memory=512Mi" --command -- echo "test" 

# If you want to save the definition to a file then use
k run nginx --image=nginx --dry-run=client -o yaml --labels tier=webserver --env="key=value" --port=8080 --requests="cpu=200m,memory=256Mi" --limits="cpu=250m,memory=512Mi" --command -- echo "test" &amp;gt; nginx.yaml

k apply -f nginx.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure to use '--dry-run=client -o yaml' before command, also you can use the environment variable $dr with this command. Also if you want to expose the pod as a service you can suffix &lt;strong&gt;--expose&lt;/strong&gt; to expose the Pod as a service.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create Deployment
&lt;/h3&gt;

&lt;p&gt;To create deployment definition or deployment run command below,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k create deploy &amp;lt;deployment-name&amp;gt; --image=&amp;lt;image&amp;gt; --replicas=4  $dr &amp;gt; &amp;lt;filename&amp;gt;.yaml

# Nginx deployment sample
k create deploy nginx --image=nginx --replicas=4 $dr &amp;gt; nginx.yaml

k apply -f nginx.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Exposing Service
&lt;/h3&gt;

&lt;p&gt;To expose the deployment as a service run below command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k expose deployment nginx --image=nginx --replicas=4 --port=8080 --target-port=8080 --name=nginx-service --type=ClusterIP $dr &amp;gt; service.yaml

# for pod
k expose pod nginx --image=nginx --replicas=4 --port=8080 --target-port=8080 --name=nginx-service --type=ClusterIP $dr &amp;gt; service.yaml

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

&lt;/div&gt;



&lt;p&gt;To create a NodePort service however you will have to run the above command and add nodePort in the YAML file. &lt;/p&gt;

&lt;h2&gt;
  
  
  Small but significant things
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Testing your deployments
&lt;/h3&gt;

&lt;p&gt;Always make sure to test the deployments, to be sure to not miss on any requirements. To test the deployments you can run temporary pods by running below command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k run temp --image=nginx:alpine --restart=Never --rm -i -- curl -m 5 nginx-service:8080

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

&lt;/div&gt;



&lt;p&gt;If the service is in a different namespace you can specify namespace like,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k run temp --image=nginx:alpine --restart=Never --rm -i -- curl -m 5 nginx-service:8080 -n 
&amp;lt;namespace&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or specify the name as . like,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k run temp --image=nginx:alpine --restart=Never --rm -i -- curl -m 5 nginx-service.&amp;lt;namespace&amp;gt;:8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Get CPU/Memory usage for node/pod
&lt;/h3&gt;

&lt;p&gt;To get the CPU/Memory usage by node/pod run,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k top node

#for pods run
k top pod
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Using Init Containers
&lt;/h3&gt;

&lt;p&gt;Init containers run un before the app containers are started. You can learn more about Init Containers &lt;a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Multi-Container Pod or Sidecar
&lt;/h3&gt;

&lt;p&gt;Multi-container POD is simply a mode with more than one containers. Following YAML shows example of a multi-container POD also called as Sidecar,&lt;br&gt;
Ref - &lt;a href="https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/"&gt;https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Pod
metadata:
  name: two-containers
spec:

  restartPolicy: Never

  volumes:
  - name: shared-data
    emptyDir: {}

  containers:

  - name: nginx-container
    image: nginx
    volumeMounts:
    - name: shared-data
      mountPath: /usr/share/nginx/html

  - name: debian-container
    image: debian
    volumeMounts:
    - name: shared-data
      mountPath: /pod-data
    command: ["/bin/sh"]
    args: ["-c", "echo Hello from the debian container &amp;gt; /pod-data/index.html"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Reading logs from Pod
&lt;/h2&gt;

&lt;p&gt;To read logs from POD run,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k logs &amp;lt;pod_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To see running logs run,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k logs -f &amp;lt;pod_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To read logs from multi-container Pod,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k logs -f &amp;lt;pod_name&amp;gt; -c &amp;lt;container_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Making changes to the existing deployments
&lt;/h2&gt;

&lt;p&gt;You can make changes to the existing deployments by simply editing them like,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k edit pod &amp;lt;pod_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will open the Pod definition (YAML) in Vim editor. Some changes can be done without recreating the pod but changes like changing the image name for example, requires you to delete and recreate the Pod. The trick to make such changes are to edit the Pod and try to save the changes, this will prompt you to create a new temporary file, just hit ':wq' to save the changes to the file. You can then delete the old pod and use this temporary file to apply the changes. The trick here is to save as much time as possible to cover all the questions.&lt;/p&gt;

&lt;p&gt;So thats it for this post, I will keep updating this post with more information. Till then, happy practicing!&lt;/p&gt;

</description>
      <category>ckad</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>Preparing for CKAD exam</title>
      <dc:creator>Aditya Kanekar</dc:creator>
      <pubDate>Tue, 03 Aug 2021 20:31:09 +0000</pubDate>
      <link>https://dev.to/adityakanekar/how-to-prepare-for-ckad-exam-3a85</link>
      <guid>https://dev.to/adityakanekar/how-to-prepare-for-ckad-exam-3a85</guid>
      <description>&lt;h1&gt;
  
  
  Background
&lt;/h1&gt;

&lt;p&gt;I was planning for my next certification and I was thinking of either taking cloud certification like AWS or GCP, but then I recollected my discussion with one of my colleague who just passed CKAD exam and he also suggested me to go for it. Since, we were already working on Kubernetes, it would be a little easy to get certified. Also, Kubernetes has no dependency on one specific cloud platform. Every cloud platform has its own version of managed Kubernetes platform e.g. Azure offers AKS, AWS offers EKS and GCP offers GKE. So the certification is independent of the cloud providers, that means this certification will still hold value against the majority of cloud platforms.&lt;/p&gt;

&lt;p&gt;I recently passed my CKAD certification and I am sharing my experience in this post.&lt;/p&gt;

&lt;p&gt;The certification has been developed by the Cloud Native Computing Foundation (CNCF), in collaboration with The Linux Foundation.&lt;/p&gt;

&lt;h1&gt;
  
  
  Prepare for the exam
&lt;/h1&gt;

&lt;p&gt;In this section we will look at what it takes to prepare for the exam.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get trained for the certification
&lt;/h2&gt;

&lt;p&gt;If you have basic understanding of Kubernetes look no further start with Mumshad Mannambeth's course (KodeKloud) on Udemy,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.udemy.com/course/certified-kubernetes-application-developer/"&gt;Certified Kubernetes Application Developer - By KodeKloud&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This exam curriculum includes these general domains and their weights on the exam:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;13% – Core Concepts&lt;/li&gt;
&lt;li&gt;18% – Configuration&lt;/li&gt;
&lt;li&gt;10% – Multi-Container Pods&lt;/li&gt;
&lt;li&gt;18% – Observability&lt;/li&gt;
&lt;li&gt;20% – Pod Design&lt;/li&gt;
&lt;li&gt;13% – Services &amp;amp; Networking&lt;/li&gt;
&lt;li&gt;8% – State Persistence&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This course covers all the topics required by the exam in detail with hands-on lab, lightning labs and mock exams. You will get access to labs on Kode Kloud after you purchase the course and you can practice as many times as you like for the exam.&lt;/p&gt;

&lt;p&gt;However if you are at beginner level and want to get comfortable with Kubernetes you can start with,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.udemy.com/course/learn-kubernetes/"&gt;Kubernetes for the Absolute Beginners - Hands-on&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Practice Exams/Labs
&lt;/h2&gt;

&lt;p&gt;KodeKloud provides you with hands-on labs, lightning labs and 2 mock exams (2 parts with 10 questions each). You can take the labs as many times as you like. The labs simulates all real life scenarios you will face while working with Kubernetes and that's what the exam is all about. &lt;/p&gt;

&lt;p&gt;In addition to the mock exams you should practice &lt;a href="https://github.com/dgkanatsios/CKAD-exercises"&gt;CKAD-Excercises&lt;/a&gt;. This one is pretty extensive and covers all the topic in details. The good thing about this lab is that it provides you alternate approaches to implement the same problem. The lab also covers how to validate the answers (implementation) which is one important aspect of the exam. You should be able to test what you implemented.&lt;/p&gt;

&lt;p&gt;Along with this you can also practice on &lt;a href="https://killer.sh"&gt;killer.sh&lt;/a&gt; its a paid lab and it will cost you around 29.99 €, you do normally get 10% discount after you register with them (Register and wait for a day :p). However I will advice you not to buy this exam separately as it comes complementary as a exam simulator with CKAD Certification Exam. Killer.sh will provide you 2 sessions, each session will be valid for 36 hours once you start the session. The session gives you a mock exam with 20 questions with a timer of 120 mins to pass the mock exam. You can restart your session as many times as you like in the 36 hours, at the end of the exam you will get answers with explanations. &lt;/p&gt;

&lt;p&gt;Each of the practice labs I suggested above will help you learn smart ways of implementing and validating your answers. &lt;/p&gt;

&lt;h1&gt;
  
  
  Exam Tips
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Practice, practice and practice
&lt;/h2&gt;

&lt;p&gt;This is a hands-on exam, you have to solve 19 questions in 120 minutes. The time just flies when you are giving the exam, so there is no time to relax. The only way to get around this exam is to practice every day and make sure you complete the mock exams from Kode Kloud in half time, once you reach there you are ready for the exam. &lt;/p&gt;

&lt;h2&gt;
  
  
  Don't rely on the Kubernetes documentation
&lt;/h2&gt;

&lt;p&gt;This is a open book exam. You are allowed to open one extra tabs with following sites,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://kubernetes.io/docs/"&gt;https://kubernetes.io/docs/&lt;/a&gt; and their subdomains&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/kubernetes/"&gt;https://github.com/kubernetes/&lt;/a&gt; and their subdomains&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://kubernetes.io/blog/"&gt;https://kubernetes.io/blog/&lt;/a&gt; and their subdomains&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If he documentation is allowed then why I am saying don't rely on it? No, the documentation is not wrong, the time is short. You can't be searching for documentation on Kubernetes documentation site while in the exam. Its too time consuming and you will loose time quickly.&lt;/p&gt;

&lt;p&gt;So what's the best way?&lt;br&gt;
The easiest thing to do is to use imperative commands as much as possible. However resources like Persistent Volumes, Network policies or Ingress is not available as imperative commands. So, its best to rely on documentation in this case.  &lt;/p&gt;
&lt;h2&gt;
  
  
  Always check the weightage for the question
&lt;/h2&gt;

&lt;p&gt;Some of the questions might carry lower weightage and can have multiple things to do like create persistent volume, create volume claim and mount it to a pod. Asses the complexity of the question against weightage, if it takes more time to execute flag it and move to next question and come back to it later. The trick here is to cover maximum questions in less time and then come back to the flagged questions.&lt;/p&gt;

&lt;p&gt;I had a similar problem where one question had a weightage of 2% but I was not sure how to answer it. So I flagged it and came back to it later, searched for the documentation and answered the same. &lt;/p&gt;
&lt;h2&gt;
  
  
  Don't spend too much time on one question
&lt;/h2&gt;

&lt;p&gt;Remember this you should not spend too much time on one question, if you are stuck on a question and you are not sure don't panic just move to the next question. Yes, I know everybody wants high score but you need to pass the certification as well, so just move ahead flag the question, move ahead and then come back to the flagged questions.&lt;/p&gt;
&lt;h2&gt;
  
  
  Bookmark important links
&lt;/h2&gt;

&lt;p&gt;When you are practicing make sure you bookmark the links you are referring for solving the question. The best place to bookmark is on the bookmark bar create a folder and start bookmarking all the documentation links there. This makes it easy to access during the exam. &lt;/p&gt;

&lt;p&gt;You can import bookmarks from &lt;a href="https://github.com/reetasingh/CKAD-Bookmarks"&gt;Kubernetes&lt;/a&gt;. However you should also create your own version of the bookmarks, it helps you in locating the required documents faster.&lt;/p&gt;

&lt;p&gt;Also, bookmark documentation which has all things you require to complete a solution in one place e.g. Create persistent volume, volume claim, mount in pod. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/"&gt;https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This link has all the things required to solve such scenario in one place.&lt;/p&gt;
&lt;h2&gt;
  
  
  Use one YAML file with multiple definitions
&lt;/h2&gt;

&lt;p&gt;Try to use one YAML files separated by --- to store different definitions related to the solution e.g.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: PersistentVolume
metadata:
  name: task-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data"
---
apiVersion: v1
kind: Pod
metadata:
  name: task-pv-pod
spec:
  volumes:
    - name: task-pv-storage
      persistentVolumeClaim:
        claimName: task-pv-claim
  containers:
    - name: task-pv-container
      image: nginx
      ports:
        - containerPort: 80
          name: "http-server"
      volumeMounts:
        - mountPath: "/usr/share/nginx/html"
          name: task-pv-storage
---
apiVersion: v1
kind: Pod
metadata:
  name: task-pv-pod
spec:
  volumes:
    - name: task-pv-storage
      persistentVolumeClaim:
        claimName: task-pv-claim
  containers:
    - name: task-pv-container
      image: nginx
      ports:
        - containerPort: 80
          name: "http-server"
      volumeMounts:
        - mountPath: "/usr/share/nginx/html"
          name: task-pv-storage
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Practice your Vim skills
&lt;/h2&gt;

&lt;p&gt;Vim is the default editor for editing Kubernetes definitions. Make sure you learn the shortcuts to implement the solution faster. You can refer &lt;a href="https://www.youtube.com/watch?v=knyJt8d6C_8"&gt;Vim Crash Course&lt;/a&gt; to learn more about the shortcuts.&lt;/p&gt;

&lt;p&gt;This is a pretty long post, read my next post for &lt;a href="https://dev.to/adityakanekar/tips-for-ckad-exam-58gn"&gt;Tips for CKAD exam&lt;/a&gt;. Till then, happy learning!&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>ckad</category>
      <category>certification</category>
    </item>
    <item>
      <title>Look ma, no Zookeeper</title>
      <dc:creator>Aditya Kanekar</dc:creator>
      <pubDate>Mon, 03 May 2021 20:08:13 +0000</pubDate>
      <link>https://dev.to/adityakanekar/look-ma-no-zookeeper-3noe</link>
      <guid>https://dev.to/adityakanekar/look-ma-no-zookeeper-3noe</guid>
      <description>&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;Kafka always had dependency on Kafka since its inception for managing topics, managing ACLs, partitions, leader elections etc. While this is not a big issue you still need to maintain a quorum of Zookeeper (3 servers - recommended) for making sure Kafka runs smoothly in a clustered environment. That means maintaining a Zookeeper quorum which translates into running 3 instances of Zookeeper which adds to infrastructure cost as well as one more thing to maintain for DevOps.&lt;/p&gt;

&lt;p&gt;Also Zookeeper had its share of limitations w.r.t. how much data you can store on each ZNode which is important if you are using ACLs on Kafka (details coming soon on this issue). Ever since &lt;a href="https://issues.apache.org/jira/browse/KAFKA-9119"&gt;KIP-500&lt;/a&gt; was added to Kafka backlog, everyone was waiting for Kafka version which gets rid of Zookeeper. Kafka team had started moving in this direction from quite sometime now, with the new Kafka Admin API introduced in 2.1.0 version, it featured features like topic crating, adding/removing ACLs, deleting topics through Kafka without connecting to Zookeeper. &lt;/p&gt;

&lt;p&gt;The day has now come with the introduction of Kafka 2.8 which gives us preview of Kafka without Zookeeper. *Please be aware that this feature is not intended to be used in production, Kafka team is still working on putting some &lt;a href="https://github.com/apache/kafka/blob/6d1d68617ecd023b787f54aafc24a4232663428d/config/kraft/README.md#missing-features"&gt;missing pieces&lt;/a&gt; of the puzzle. &lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;

&lt;p&gt;Before getting started download Kafka binaries,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wget https://downloads.apache.org/kafka/2.8.0/kafka_2.13-2.8.0.tgz
tar -xzvf kafka_2.13-2.8.0.tgz
mv kafka_2.13-2.8.0 kafka
cd kafka
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 1 - Generate cluster id
&lt;/h3&gt;

&lt;p&gt;To get started for running Kafka without Zookeeper, a new cluster uuid needs to be generated.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./bin/kafka-storage.sh random-uuid
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2 - Format storage directories
&lt;/h3&gt;

&lt;p&gt;The next step is to format storage directories, you will need to run this command on every broker needless to say you will run this command only on one broker if you are running in single mode. This step is new if you have worked with previous version of Kafka.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./bin/kafka-storage.sh format -t &amp;lt;uuid&amp;gt; -c ./config/kraft/server.properties
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;em&gt;&lt;/em&gt; with the id generated in Step bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic test-topic1.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3 - Start Kafka Server
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./bin/kafka-server-start.sh ./config/kraft/server.properties
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There you go, if you have followed all the steps you should see Kafka running. Lets create a topic and send/receive messages to/from the topic.&lt;/p&gt;

&lt;p&gt;Create Topic,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic test-topic --partitions 1 --replication-factor 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run Kafka producer and send some messages,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic test-topic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run Kafka consumer and verify if the messages are flowing through,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test-topic --from-beginning
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There you go! If all worked well, you should see messages on the test-topic. &lt;/p&gt;

</description>
      <category>kafka</category>
      <category>zookeeper</category>
    </item>
    <item>
      <title>Make your home smart, the easy way!</title>
      <dc:creator>Aditya Kanekar</dc:creator>
      <pubDate>Tue, 06 Apr 2021 08:13:22 +0000</pubDate>
      <link>https://dev.to/adityakanekar/how-i-made-my-home-smart-19h6</link>
      <guid>https://dev.to/adityakanekar/how-i-made-my-home-smart-19h6</guid>
      <description>&lt;p&gt;For so many days I was playing with Raspberry Pi, ESP8266 and relay board to control the devices at home remotely through mobile app and digital assistants like Alexa/Google Assistant. I was able to achieve the same using Raspberry Pi and Relay control and using Alexa skill to remotely turn the devices on/off using little bit of coding in Python.&lt;/p&gt;

&lt;p&gt;However I am not a expert in electronics and I wanted something like plug and play device which can work with existing board. Now you might be thinking that I can easily do it with Raspberry Pi/ESP8266/Arduino and relay board. Yes I agree that its not that complicated, however there are some practical issues for a guy like me who has not played with electric boards and circuits.&lt;/p&gt;

&lt;h1&gt;
  
  
  Issues
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Power supply
The controller unit (Raspberry Pi/ESP8266/Arduino) will require continuous power supply to power itself. This can be resolved by designing a board with the power supply built-in which will work with direct power supply from the board or may be a mobile charger can power the board. However for me designing this circuit will be a tedious process, also packaging mobile charger inside the board is not practical.&lt;/li&gt;
&lt;li&gt;Packaging
Fitting the whole assembly Raspberry Pi/Esp8266 with Relay inside the switch board with all those floating wires connecting to the pins is messy.&lt;/li&gt;
&lt;li&gt;Additional coding
Additional coding is required for this to work with Alexa/Google Assistant. However this is trivial for me as I had done the integration with Alexa.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So then what are the options. So while watching a video on YouTube by &lt;a href="https://www.youtube.com/watch?v=1kAkF6lnjj8"&gt;TechBurner&lt;/a&gt; came across device which you can fit inside your switch board with existing manual switches. Wow, how cool is that? That's what I wanted. So then I started looking for the gadgets on Amazon and I came across two three options and based on the review I choose &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LvNQ46v2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m1nqx0f8q0n7zopi75pt.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LvNQ46v2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m1nqx0f8q0n7zopi75pt.PNG" alt="Alt Text"&gt;&lt;/a&gt; &lt;br&gt;
&lt;a href="https://tinxy.in/"&gt;Image Ref - tinxy.in&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.amazon.in/Tinxy-Channel-Smart-Switch-Compatible/dp/B07PCS8W5R/ref=sr_1_1?crid=1NT3F7N50DLJW&amp;amp;dchild=1&amp;amp;keywords=tinxy&amp;amp;qid=1617217102&amp;amp;sprefix=tinxy%2Caps%2C300&amp;amp;sr=8-1"&gt;Tinxy Smart Switch&lt;/a&gt;. It comes in various specifications I wanted to control 2 fans and 2 lights in our living room so I chose 4-Node Smart Switch. Lets look at how to connect the device in the switch board, shall we?&lt;/p&gt;

&lt;h1&gt;
  
  
  Installation Diagram
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Cik-8rUR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rxpuxly03elyme2qjh7b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Cik-8rUR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rxpuxly03elyme2qjh7b.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As shown in the diagram above, the installation is very simple. This can be done in 4 steps. But before that make sure you have spare red and black wires for doing the connection.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Remove the phase wire (Wire going to your device - fan/light etc.)  from the switch. This is usually located at the top of the switch.&lt;/li&gt;
&lt;li&gt;Attach this phase wire to the marking denoted as D1,D2,D3,D4 where D is Device 1&lt;/li&gt;
&lt;li&gt;From the other side of Tinxy board (Colored black) by using a piece of wire - preferably black to the switch in the same place which was removed in step 1&lt;/li&gt;
&lt;li&gt;Powering the device - from the wires take connection to Live and Neutral wire and connect it to the board to L - Live and N - Neutral terminal&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You will see the Smart switch will switch on green light will start blinking that means the device is not connected to WiFi. At this point you need to download Tinxy app to your mobile and follow the instructions in the app to complete registraions, set WiFi credentials in the smart switch and configure the connected devices. Try switching devices on/off. Also you will notice that if the device is manually switched off it will show in the app. The other cool thing about this Smart Switch is, it converts your normal switch to two-way switch. So the position of the switch doesn't matter. How cool is that?&lt;/p&gt;

&lt;h1&gt;
  
  
  Connecting with Alexa
&lt;/h1&gt;

&lt;p&gt;Now assuming you have completed the above steps, this step is pretty straight forward. In your Alexa app, go to Skills and search for Tinxy. Locate the Tinxy skill and proceed with the sign-in process and that's it you are good to go. You will now see all the devices which you configured in the Tinxy App, as a next step you can change the settings of the devices to rename them and add them to a group for e.g. Living room. This makes it simple for Alexa to find the right devices when you give command like 'Alexa Switch on living room light 1'.&lt;/p&gt;

&lt;h1&gt;
  
  
  Word of caution
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Before touching the board make sure you have a tester, to check the live/neutral wires&lt;/li&gt;
&lt;li&gt;Before doing the actual connections switch of the main supply&lt;/li&gt;
&lt;li&gt;Make sure you don't expose wires accidently as it might cause short circuit.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In the next article we will see how I connected my Smart AC to Alexa. Till then happy coding.&lt;/p&gt;

</description>
      <category>iot</category>
      <category>alexa</category>
      <category>aws</category>
    </item>
    <item>
      <title>Connecting to Kafka cluster using SSL with Python</title>
      <dc:creator>Aditya Kanekar</dc:creator>
      <pubDate>Tue, 19 Jan 2021 14:47:20 +0000</pubDate>
      <link>https://dev.to/adityakanekar/connecting-to-kafka-cluster-using-ssl-with-python-k2e</link>
      <guid>https://dev.to/adityakanekar/connecting-to-kafka-cluster-using-ssl-with-python-k2e</guid>
      <description>&lt;p&gt;This article specifically talks about how to write producer and consumer for Kafka cluster secured with SSL using Python. I won't be getting into how to generate client certificates in this article, that's the topic reserved for another article :). &lt;/p&gt;

&lt;h4&gt;
  
  
  Pre-Requisites
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Kafka Cluster with SSL&lt;/li&gt;
&lt;li&gt;Client certificate (KeyStore) in JKS format &lt;/li&gt;
&lt;li&gt;Linux environment with keytool and openssl installed&lt;/li&gt;
&lt;li&gt;Python 3.6&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 1 - Converting JKS to PEM file
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Why I need this step?
&lt;/h4&gt;

&lt;p&gt;Unlike Java, Python and C# uses .pem files to connect to Kafka. For this purpose we will have to convert the JKS files to PEM with the help of &lt;strong&gt;keytool&lt;/strong&gt; and &lt;strong&gt;openssl&lt;/strong&gt; commands. If you are working on Windows 10 you can refer to my article on how to run WSL on Windows &lt;a href="https://dev.to/adityakanekar/developing-for-linux-environment-in-windows-10-with-wsl-2-part-1-4422"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To make your life easy I have created a shell script to quickly convert JKS to PEM.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash
srcFolder=$1
keyStore=$1/$2
password=$3
alias=$4
outputFolder=$5

echo $keyStore
echo "Generating certificate.pem"
keytool -exportcert -alias $alias -keystore $keyStore -rfc -file $outputFolder/certificate.pem -storepass $password

echo "Generating key.pem"
keytool -v -importkeystore -srckeystore $keyStore -srcalias $alias -destkeystore $outputFolder/cert_and_key.p12 -deststoretype PKCS12 -storepass $password -srcstorepass $password
openssl pkcs12 -in $outputFolder/cert_and_key.p12 -nodes -nocerts -out $outputFolder/key.pem -passin pass:$password

echo "Generating CARoot.pem"
keytool -exportcert -alias $alias -keystore $keyStore -rfc -file $outputFolder/CARoot.pem -storepass $password
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The script generates following files from the keystore file,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;key.pem&lt;/li&gt;
&lt;li&gt;certificate.pem&lt;/li&gt;
&lt;li&gt;CARoot.pem&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  How to run this script?
&lt;/h4&gt;

&lt;p&gt;Save the script in a file e.g. jkstopem.sh and give execute permissions like below,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chmod +x jkstopem.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To generate the PEM files. Run the shell script as shown in the below example,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./jkstopem.sh &amp;lt;source_path_to_jks&amp;gt; &amp;lt;keystore_file_name&amp;gt; &amp;lt;keystore_password&amp;gt; &amp;lt;alias&amp;gt; &amp;lt;output_folder&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  How to find Alias?
&lt;/h5&gt;

&lt;p&gt;If you are not aware of what alias your certificate has. Run following command in the folder where you have the keystore file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;keytool -list -v -keystore kafka.client.keystore.jks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will be prompted to enter the password. Enter the keystore password, this will list the contents of the keystore file. You will be able to see *&lt;em&gt;Alias name&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Following is the example to run the shell script,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./jkstopem.sh ~/client-cert kafka.client.keystore.jks welcome123 client-alias ~/client-cert/pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you should be able to see following files in the output folder,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;key.pem&lt;/li&gt;
&lt;li&gt;certificate.pem&lt;/li&gt;
&lt;li&gt;CARoot.pem&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now as we have all the &lt;strong&gt;PEM&lt;/strong&gt; files, lets get cracking.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2 - Writing Kafka Producer in Python
&lt;/h3&gt;

&lt;p&gt;We will be using 'kafka-python' package to connect to Kafka. You can install it using pip,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install kafka-python
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, lets write our producer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Producer.py
from kafka import KafkaProducer

kafkaBrokers='kafka1.xyz.com:443,kafka2.xyz.com:443,kafka3.xyz.com:443'
caRootLocation='CARoot.pem'
certLocation='certificate.pem'
keyLocation='key.pem'
topic='test-topic'
password='welcome123'

producer = KafkaProducer(bootstrap_servers=kafkaBrokers,
                          security_protocol='SSL',
                          ssl_check_hostname=True,
                          ssl_cafile=caRootLocation,
                          ssl_certfile=certLocation,
                          ssl_keyfile=keyLocation,
                          ssl_password=password)

producer.send(topic, bytes('Hello Kafka!','utf-8'))

# Send to a particular partition
producer.send(topic, bytes('Hello Kafka!','utf-8'),partition=0)
producer.flush()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example we are using the pem files we generated in the last step with the password to read the pem file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kafkaBrokers='kafka1.xyz.com:443,kafka2.xyz.com:443,kafka3.xyz.com:443'
caRootLocation='CARoote.pem'
certLocation='certificate.pem'
keyLocation='key.pem'
password='welcome123'
producer = KafkaProducer(bootstrap_servers=kafkaBrokers,
                          security_protocol='SSL',
                          ssl_check_hostname=True,
                          ssl_cafile=caRootLocation,
                          ssl_certfile=certLocation,
                          ssl_keyfile=keyLocation,
                          ssl_password=password)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Sending data to random topic partition
&lt;/h4&gt;

&lt;p&gt;Below code snippet will send data to random partition decided by Kafka.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;producer.send(topic, bytes('Hello Kafka!','utf-8'))
producer.flush()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Sending data to specific topic partition
&lt;/h4&gt;

&lt;p&gt;To send data to a specific partition, you just need to specify the partition as shown in below code snippet,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;producer.send(topic, bytes('Hello Kafka - Partition 0!','utf-8'),partition=0)
producer.flush()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So we have built our Python producer for Kafka. In the next part we will write consumer to consume the message from the topic.&lt;/p&gt;

</description>
      <category>kafka</category>
      <category>shell</category>
      <category>linux</category>
      <category>python</category>
    </item>
    <item>
      <title>Creating local Redis cluster in minutes on WSL2</title>
      <dc:creator>Aditya Kanekar</dc:creator>
      <pubDate>Sun, 22 Nov 2020 12:37:00 +0000</pubDate>
      <link>https://dev.to/adityakanekar/creating-local-redis-cluster-in-minutes-on-wsl2-k63</link>
      <guid>https://dev.to/adityakanekar/creating-local-redis-cluster-in-minutes-on-wsl2-k63</guid>
      <description>&lt;p&gt;This article focuses on setting up Redis cluster quickly on local environment using WSL2 (If you have not set it up on your Windows 10 machine, you can refer my &lt;a href="https://dev.to/adityakanekar/developing-for-linux-environment-in-windows-10-with-wsl-2-part-1-4422"&gt;post&lt;/a&gt;). However this is completely optional and the same should work on other Ubuntu Distros. &lt;/p&gt;

&lt;h2&gt;
  
  
  Install Redis on Ubuntu
&lt;/h2&gt;

&lt;p&gt;To install Redis on Ubuntu we will launch Ubuntu 18.04 WSL instance on the Windows 10 machine. This step is completely optional and you can also use the same steps on any Ubuntu 18.04 instance.&lt;/p&gt;

&lt;p&gt;Before installing Redis we need to install few dependencies. Run following command in the bash to install the dependencies required for running Redis.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get update
sudo apt install make gcc libc6-dev tcl build-essential
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now lets download Redis from the official Redis channel,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ~
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Install Redis build dependencies
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd redis-stable/deps
make hiredis lua jemalloc linenoise
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will take some time, once the above step finishes run make command in the redis-stable directory as below,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ~/redis-stable
make
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make command will also take some time to complete, once its complete you can run 'make test' command to see if everything is setup properly. This is a optional step, if the make is completed successfully you can skip it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create cluster
&lt;/h2&gt;

&lt;p&gt;There are lot of articles available for setting up the cluster manually. However Redis has a utility to create a cluster quickly which will get you started in minutes. To create cluster run following command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ~/redis-stable/utils/create-cluster
./create-cluster start

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

&lt;/div&gt;



&lt;p&gt;The start command will create the cluster with port ranging from 30001 to 30006. The output should look like below,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Starting 30001
Starting 30002
Starting 30003
Starting 30004
Starting 30005
Starting 30006
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will start 6 instances of Redis, now to create a cluster run,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./create-cluster create
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will create the cluster with 3 master and 3 slaves configuration. It will also display you hash slots for all 3 masters and the slave instance mapping with master instance. Type yes in the prompt to continue.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; Performing hash slots allocation on 6 nodes...
Master[0] -&amp;gt; Slots 0 - 5460
Master[1] -&amp;gt; Slots 5461 - 10922
Master[2] -&amp;gt; Slots 10923 - 16383
Adding replica 127.0.0.1:30005 to 127.0.0.1:30001
Adding replica 127.0.0.1:30006 to 127.0.0.1:30002
Adding replica 127.0.0.1:30004 to 127.0.0.1:30003
&amp;gt;&amp;gt;&amp;gt; Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: 8106f2118a007250a1b003c01e3d84dff87e7117 127.0.0.1:30001
   slots:[0-5460] (5461 slots) master
M: 7f0c05048e8864334de8a24de1318327c11a1b8d 127.0.0.1:30002
   slots:[5461-10922] (5462 slots) master
M: f5d904e68e316d0c310cb7acb4201e5ad9539202 127.0.0.1:30003
   slots:[10923-16383] (5461 slots) master
S: e5ccc0ac06c1921f70530fa01c62ba2b6de441a3 127.0.0.1:30004
   replicates f5d904e68e316d0c310cb7acb4201e5ad9539202
S: a140fe7519762b1f2c35e06f8e5c46487bad1f6c 127.0.0.1:30005
   replicates 8106f2118a007250a1b003c01e3d84dff87e7117
S: 63d7a31d2820e346eec839470fc3ab5cafd25cc7 127.0.0.1:30006
   replicates 7f0c05048e8864334de8a24de1318327c11a1b8d
Can I set the above configuration? (type 'yes' to accept):
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create the cluster and you should be able to see output as below,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; Nodes configuration updated
&amp;gt;&amp;gt;&amp;gt; Assign a different config epoch to each node
&amp;gt;&amp;gt;&amp;gt; Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join
.
&amp;gt;&amp;gt;&amp;gt; Performing Cluster Check (using node 127.0.0.1:30001)
M: 8106f2118a007250a1b003c01e3d84dff87e7117 127.0.0.1:30001
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
M: 7f0c05048e8864334de8a24de1318327c11a1b8d 127.0.0.1:30002
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
M: f5d904e68e316d0c310cb7acb4201e5ad9539202 127.0.0.1:30003
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
S: 63d7a31d2820e346eec839470fc3ab5cafd25cc7 127.0.0.1:30006
   slots: (0 slots) slave
   replicates 7f0c05048e8864334de8a24de1318327c11a1b8d
S: e5ccc0ac06c1921f70530fa01c62ba2b6de441a3 127.0.0.1:30004
   slots: (0 slots) slave
   replicates f5d904e68e316d0c310cb7acb4201e5ad9539202
S: a140fe7519762b1f2c35e06f8e5c46487bad1f6c 127.0.0.1:30005
   slots: (0 slots) slave
   replicates 8106f2118a007250a1b003c01e3d84dff87e7117
[OK] All nodes agree about slots configuration.
&amp;gt;&amp;gt;&amp;gt; Check for open slots...
&amp;gt;&amp;gt;&amp;gt; Check slots coverage...
[OK] All 16384 slots covered.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Connecting to Redis Cluster
&lt;/h2&gt;

&lt;p&gt;To connect to Redis cluster using redis-cli, open another bash window and cd into the redis-stable directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd ~/redis-stable/src
./redis-cli -c -p 30001
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should now be connected to the Redis cluster. The output will be similar to,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;127.0.0.1:30001&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Testing the cluster
&lt;/h3&gt;

&lt;p&gt;To set key run,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set foo bar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To retrieve the value of the key run,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;get foo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The get command will show output as "bar". &lt;/p&gt;

&lt;p&gt;So your Redis cluster is now setup. If you want to stop your cluster run,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./create-cluster stop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will notice all the nodes listening from 30001-30006 have stopped.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stopping 30001
Stopping 30002
Stopping 30003
Stopping 30004
Stopping 30005
Stopping 30006
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To delete the cluster run,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./create-cluster stop
./create-cluster clean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now if you run &lt;strong&gt;ls&lt;/strong&gt; you will notice that the folder contains only two files,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;README&lt;/li&gt;
&lt;li&gt;create-cluster&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now to run a new cluster you can run the start and then create command as demonstrated earlier in this article.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>linux</category>
      <category>redis</category>
      <category>wsl</category>
    </item>
    <item>
      <title>Creating base docker image for hosting your Java 8 application</title>
      <dc:creator>Aditya Kanekar</dc:creator>
      <pubDate>Sun, 22 Nov 2020 12:25:34 +0000</pubDate>
      <link>https://dev.to/adityakanekar/creating-base-docker-image-for-hosting-your-java-8-application-45j3</link>
      <guid>https://dev.to/adityakanekar/creating-base-docker-image-for-hosting-your-java-8-application-45j3</guid>
      <description>&lt;p&gt;Creating clean image is very important from trusted sources. This article demonstrates how you can create a docker image for hosting your Java 8 application using Alpine Linux distro.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dockerfile for Java8
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM alpine

RUN apk update &amp;amp;&amp;amp; \
    apk upgrade 
RUN apk add openjdk8=8.252.09-r0

ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
EXPOSE 8080
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above Dockerfile creates image for hosting Java8 application using alpine distro. Lets go through each instruction one by one,&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FROM alpine&lt;/strong&gt; - &lt;br&gt;
FROM instruction gets the baseimage for your application which in this case is alpine. You can also specify tags if you want a specific image of alpine e.g. alpine:3.9.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RUN apk update &amp;amp;&amp;amp; apk upgrade&lt;/strong&gt;&lt;br&gt;
Runs update and upgrade instructions to update the sources and install any upgrade available.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;RUN apk add openjdk8=8.252.09-r0&lt;/strong&gt;&lt;br&gt;
Installs specific version of JDK 8 on alpine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ARG JAR_FILE=build/libs/*.jar&lt;/strong&gt;&lt;br&gt;
Argument for getting all jar files&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;COPY ${JAR_FILE} app.jar&lt;/strong&gt;&lt;br&gt;
Copy the jar file in the docker image&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EXPOSE 8080&lt;/strong&gt;&lt;br&gt;
Exposes port 8080 on the docker image, if your application should be accessible on this port. (This is only applicable if your application should be accessible on certain port e.g. REST API)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This instruction is responsible for running your application. So that's how you can create a lightweight clean image for your Java8 application. We have not touched on the safety aspect of this image, we will see how to secure this image in our next article.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>docker</category>
    </item>
    <item>
      <title>Upgrading from WSL1 to WSL2</title>
      <dc:creator>Aditya Kanekar</dc:creator>
      <pubDate>Thu, 19 Nov 2020 17:45:49 +0000</pubDate>
      <link>https://dev.to/adityakanekar/upgrading-from-wsl1-to-wsl2-1fl9</link>
      <guid>https://dev.to/adityakanekar/upgrading-from-wsl1-to-wsl2-1fl9</guid>
      <description>&lt;h1&gt;
  
  
  Background
&lt;/h1&gt;

&lt;p&gt;In my last &lt;a href="https://dev.to/adityakanekar/developing-for-linux-environment-in-windows-10-with-wsl-2-part-1-4422"&gt;post&lt;/a&gt; I talked about how to get started with developing applications on Linux on Windows 10 using WSL 2 and VS Code. Some of you might have installed the previous version of WSL1 on your Windows 10 machines. This article guides on how to upgrade from WSL to WSL2.&lt;/p&gt;

&lt;h1&gt;
  
  
  Install WSL2 Linux Kernel
&lt;/h1&gt;

&lt;p&gt;You need at least 1903 version of Windows 10. You can check the minimum requirement for upgrading from WSL1 &lt;a href="https://docs.microsoft.com/en-us/windows/wsl/install-win10#update-to-wsl-2" rel="noopener noreferrer"&gt;here&lt;/a&gt; To check windows version, click Windows + R Key and type,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

winver


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

&lt;/div&gt;

&lt;p&gt;You will be able to see the build version of your windows e.g. 1903.&lt;/p&gt;

&lt;p&gt;Download the installer for the WSL2 kernel from,&lt;br&gt;
&lt;a href="https://docs.microsoft.com/en-us/windows/wsl/wsl2-kernel" rel="noopener noreferrer"&gt;https://docs.microsoft.com/en-us/windows/wsl/wsl2-kernel&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run the installer to install WSL2 Kernel for Linux. Once the installation is successful. Open PowerShell or command prompt and run,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

wsl --list 


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

&lt;/div&gt;

&lt;p&gt;This will list all the distros and the version of WSL in the version column. The list will look somewhat similar to this,&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6dcvq9ii5jd69kguhcck.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F6dcvq9ii5jd69kguhcck.png" alt="Alt Text" width="439" height="131"&gt;&lt;/a&gt;       &lt;/p&gt;

&lt;p&gt;Since you were running WSL1 previously on your machine the distro is still using WSL1. &lt;em&gt;No magic tricks here, none of your distros will be migrated to WSL2 by default.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Upgrading from WSL1 to WSL2
&lt;/h2&gt;

&lt;p&gt;To upgrade your current distro(s) from WSL1 to WSL2. Run following command in PowerShell or command prompt,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

wsl --set-version &amp;lt;distro-name&amp;gt; 2


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

&lt;/div&gt;

&lt;p&gt;Replace the distro-name with the Name displayed in the last section. So in our case the command will look like,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

wsl --set-version Ubuntu-20.04 2


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

&lt;/div&gt;

&lt;p&gt;This will take some time to upgrade, in my experience all your data will be retained as it was previously. Once the upgrade is complete you can run the list distros command to verify whether the version was successfully upgraded.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

wsl -l -v


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

&lt;/div&gt;

&lt;p&gt;You should be able to see output similar to,&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F16gx3k3j76x3nug76fuu.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F16gx3k3j76x3nug76fuu.png" alt="Alt Text" width="642" height="131"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you can launch Ubuntu-20.04 from Start menu or from the command prompt run,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

wsl -d Ubuntu-18.04


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

&lt;/div&gt;

&lt;p&gt;This will take you to the Ubuntu-18.04 shell. The * denotes the default distribution. What does that mean? To check run following command,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

wsl


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

&lt;/div&gt;

&lt;p&gt;This will take you to Ubuntu-20.04 shell without mentioning the distro. If you want to change the default distro run,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

wsl -s Ubuntu-18.04
wsl -l -v


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

&lt;/div&gt;

&lt;p&gt;You will notice the default distribution changed to Ubuntu-18.04. &lt;/p&gt;

&lt;p&gt;NAME                   STATE           VERSION&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ubuntu-18.04           Stopped         2
Ubuntu-20.04           Stopped         2&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now if you run,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

wsl


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

&lt;/div&gt;

&lt;p&gt;Ubuntu-18.04 shell will launch. To verify if the right version is launched. Run following command,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

lsb_release -a


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

&lt;/div&gt;

&lt;p&gt;You should get output similar to,&lt;/p&gt;

&lt;p&gt;No LSB modules are available.&lt;br&gt;
Distributor ID: Ubuntu&lt;br&gt;
Description:    Ubuntu 18.04.5 LTS&lt;br&gt;
Release:        18.04&lt;br&gt;
Codename:       bionic&lt;/p&gt;

&lt;p&gt;Now open another PowerShell or command prompt window and run,&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

wsl -l -v


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

&lt;/div&gt;

&lt;p&gt;You will notice Ubuntu-18.04 is in Running state. IF you close the wsl window or run exit the state will change to Stopped.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnoflz0zko9sxfqfos9ay.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnoflz0zko9sxfqfos9ay.png" alt="Alt Text" width="663" height="127"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hopefully this will get you started on WSL2. In my next articles we will use WSL for running tools supported on Linux environment. &lt;/p&gt;

&lt;p&gt;Till then, happy coding!&lt;/p&gt;

</description>
      <category>windows</category>
      <category>wsl2</category>
      <category>linux</category>
      <category>wsl</category>
    </item>
    <item>
      <title>Developing for Linux in Windows 10 with WSL 2 - Part 2</title>
      <dc:creator>Aditya Kanekar</dc:creator>
      <pubDate>Sun, 15 Nov 2020 18:40:27 +0000</pubDate>
      <link>https://dev.to/adityakanekar/developing-for-linux-in-windows-10-part-2-1ndl</link>
      <guid>https://dev.to/adityakanekar/developing-for-linux-in-windows-10-part-2-1ndl</guid>
      <description>&lt;p&gt;In the &lt;a href="https://dev.to/adityakanekar/developing-for-linux-environment-in-windows-10-with-wsl-2-part-1-4422"&gt;Part 1&lt;/a&gt; we installed WSL 2 with Ubuntu 20.04 on our machine. To complete our development environment setup lets now install Dotnet Core on the newly installed VM. Launch Ubuntu 20.04 App from Start menu and follow along this article. We are going to install .Net Core 3.1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb

sudo apt-get update; \
  sudo apt-get install -y apt-transport-https &amp;amp;&amp;amp; \
  sudo apt-get update &amp;amp;&amp;amp; \
  sudo apt-get install -y dotnet-sdk-3.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Reference link for .Net Core installation,
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://dotnet.microsoft.com/download/dotnet-core/3.1" rel="noopener noreferrer"&gt;https://dotnet.microsoft.com/download/dotnet-core/3.1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/dotnet/core/install/linux" rel="noopener noreferrer"&gt;https://docs.microsoft.com/en-us/dotnet/core/install/linux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#2010-" rel="noopener noreferrer"&gt;https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#2010-&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Once installation is complete, run following command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet --version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should be able to see installed .Net Core version 3.1.xxx. &lt;/p&gt;

&lt;h3&gt;
  
  
  Launching VS Code from Ubuntu Shell
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir HelloWorld
cd HelloWorld

dotnet new console
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will generate project for the console application. List the file in the directory by using ls command at the shell,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should be able to see two files in the folder, &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;HelloWorld.csproj -&amp;gt; Project file for console application&lt;/li&gt;
&lt;li&gt;Program.cs&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To check if your application is running properly, run following command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will print &lt;em&gt;Hello World!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Congratulations, you have completed the first step. Now lets move to the interesting part, launching VS Code from Ubuntu app by entering following command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;code .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should be able to see that VS Code is downloading itself and in a few minutes you should see VS Code launched in Windows 10 with the project we just created. Wow that's what I called magic!&lt;/p&gt;

&lt;p&gt;If you see a prompt to install C# extensions, click Install to complete the installation. Now click Program.cs from the  Explorer menu,&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3aw03qikjeyfe3rbe6my.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3aw03qikjeyfe3rbe6my.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You might get a prompt install tools for debugging and building .Net project, click Install. Now right click the Program.cs file from Explorer menu and click &lt;em&gt;Reveal in Explorer&lt;/em&gt;. This will open your folder in Explorer. You will notice that the path is from the Ubuntu app, it will be something like,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\\wsl$\Ubuntu-20.04\home\xxxx\HelloWorld
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Running application in VS Code
&lt;/h4&gt;

&lt;p&gt;To run your application Press F5, you will see &lt;em&gt;Hello World!&lt;/em&gt; printed in the  Debug Console window. The application is running in Windows 10 but on Ubuntu.&lt;/p&gt;

&lt;h4&gt;
  
  
  Debugging application in VS Code
&lt;/h4&gt;

&lt;p&gt;To add a breakpoint, Press F9 inside the main method or alternatively you can click on the empty gutter on the left side. You should be able to see the familiar red-dot indicating the breakpoint is set. Now press F5 to launch the application, your application should pause at the breakpoint. You can press F10 to Step Over or F11 to Step Into the function.&lt;/p&gt;

&lt;p&gt;So, there you have it you have successfully built a .Net Core application running on Ubuntu without leaving Windows 10. &lt;/p&gt;

</description>
      <category>ubuntu</category>
      <category>vscode</category>
      <category>dotnet</category>
    </item>
    <item>
      <title>Developing for Linux in Windows 10 with WSL 2 - Part 1</title>
      <dc:creator>Aditya Kanekar</dc:creator>
      <pubDate>Sun, 15 Nov 2020 17:25:18 +0000</pubDate>
      <link>https://dev.to/adityakanekar/developing-for-linux-environment-in-windows-10-with-wsl-2-part-1-4422</link>
      <guid>https://dev.to/adityakanekar/developing-for-linux-environment-in-windows-10-with-wsl-2-part-1-4422</guid>
      <description>&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;Most of the open source software's are developed for Linux distros and this makes it difficult to run on Windows. Of course you can run a Ubuntu VM on Hyper-V or Virtual Box and install your development environment on the machine as you would on a regular machine.&lt;/p&gt;

&lt;p&gt;However to run the VM's on your machine your machine should have enough juice to run the VM's smoothly and its not seamless either if you want to transfer files between your Windows host and your VM. You can also setup dual boot with Windows 10 and Linux, however maintaining different operating systems on a machine is a pain.&lt;/p&gt;

&lt;p&gt;With WSL, installing Linux distros in Windows 10 is as easy as installing a app. You can share files easily between Windows and your Linux distro and you can also develop for Linux right inside Windows 10. &lt;/p&gt;

&lt;h3&gt;
  
  
  But I already have WSL1, can I upgrade?
&lt;/h3&gt;

&lt;p&gt;Sure you can upgrade from WSL1 to WSL2, you can refer my &lt;a href="https://dev.to/adityakanekar/upgrading-from-wsl1-to-wsl2-1fl9"&gt;post&lt;/a&gt; to upgrade from WSL1 to WSL2.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows Subsystem for Linux (WSL)
&lt;/h3&gt;

&lt;p&gt;Most of you might have heard of Windows Sub-system for Linux AKA WSL. What it enables you to do is install Linux distros on your Windows 10 machine like a app from Windows 10. Yes, you heard it right install distros as app. However things are not that simpler if you have Windows 10 Home Edition since WSL uses Hyper-V to run a VM behind the scenes. The other problem is Docker or MicroK8S are not supported on WSL and this was a bit of a downer. However it was a step in the right direction from Microsoft.&lt;/p&gt;

&lt;h3&gt;
  
  
  WSL 2
&lt;/h3&gt;

&lt;p&gt;Microsoft has resolved most of the issues which were bugging WSL with WSL 2. WSL 2 does uses VM behind the scenes but its managed, also it uses full Linux Kernel built by Microsoft unlike WSL. You can learn more about WSL here,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.microsoft.com/en-us/windows/wsl/compare-versions" rel="noopener noreferrer"&gt;https://docs.microsoft.com/en-us/windows/wsl/compare-versions&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-Requisites
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Installing / Upgrading WSL 2
&lt;/h3&gt;

&lt;p&gt;You can refer the instructions for installing WSL 2 on the official Microsoft site. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.microsoft.com/en-us/windows/wsl/install-win10" rel="noopener noreferrer"&gt;https://docs.microsoft.com/en-us/windows/wsl/install-win10&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  VS Code
&lt;/h3&gt;

&lt;p&gt;I will be using VS Code for this article and its my choice of IDE for development (I am obsessed with VS Code :p) &lt;/p&gt;

&lt;p&gt;&lt;a href="https://code.visualstudio.com/download" rel="noopener noreferrer"&gt;https://code.visualstudio.com/download&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install following plugins,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Remote WSL&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Windows Terminal Preview - Optional
&lt;/h3&gt;

&lt;p&gt;You can install Windows Terminal from here. This step is not necessary, however I will recommend you to try it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.microsoft.com/en-in/p/windows-terminal-preview/9n8g5rfz9xk3?rtc=1&amp;amp;activetab=pivot:overviewtab" rel="noopener noreferrer"&gt;https://www.microsoft.com/en-in/p/windows-terminal-preview/9n8g5rfz9xk3?rtc=1&amp;amp;activetab=pivot:overviewtab&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Linux Distro from Windows store
&lt;/h2&gt;

&lt;p&gt;For this article I have install Ubuntu 20.04LTS from Windows Store. Assuming you have completed above steps for installing WSL 2 on your machine. This step should be straightforward. Jut got to your Windows Store and search for Ubuntu. Install Ubuntu 20.04LTS.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fowf55rzr6051y32pu1u4.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fowf55rzr6051y32pu1u4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you install, search for Ubuntu in your Windows Search bar and click it. &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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Faci9xpm9ia1q85q1cmu1.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Faci9xpm9ia1q85q1cmu1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since the app is being launched for the first time, just follow the installation steps. After installation you will be asked to create username and password, give username and password of your choice and you are all set. &lt;/p&gt;

&lt;h3&gt;
  
  
  Launching Ubuntu
&lt;/h3&gt;

&lt;p&gt;Assuming you have completed all the steps, just search for Ubuntu or if you have installed Windows Terminal, select the shell you want to open as shown below,&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fiys9hm0v9jwfdh4r8ynp.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fiys9hm0v9jwfdh4r8ynp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Listing installed distros
&lt;/h3&gt;

&lt;p&gt;Run following command in Powershell or command prompt to display all installed distros,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wsl -l -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should be able to see similar output as shown below,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; NAME                   STATE           VERSION
* docker-desktop         Running         2
  Ubuntu-20.04           Stopped         2
  docker-desktop-data    Stopped         2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the next &lt;a href="https://dev.to/adityakanekar/developing-for-linux-in-windows-10-part-2-1ndl"&gt;part&lt;/a&gt; we will create a sample dotnet core console app and debug it in Windows 10 while developing on Ubuntu-20.04.&lt;/p&gt;

&lt;p&gt;Till then, Happy Coding !&lt;/p&gt;

</description>
      <category>ubuntu</category>
      <category>vscode</category>
      <category>dotnet</category>
      <category>wsl2</category>
    </item>
    <item>
      <title>How to pass arguments to Flink App</title>
      <dc:creator>Aditya Kanekar</dc:creator>
      <pubDate>Wed, 21 Oct 2020 17:31:41 +0000</pubDate>
      <link>https://dev.to/adityakanekar/how-to-pass-arguements-to-flink-app-2f01</link>
      <guid>https://dev.to/adityakanekar/how-to-pass-arguements-to-flink-app-2f01</guid>
      <description>&lt;p&gt;At first when I started writing Flink application I thought of it as any other Java console application and started writing the same using Spring Boot Framework. However I soon realized that running the application in Flink is a bit different than executing a Java application on say command line using&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java -jar &amp;lt;jar_path&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My application was connecting to Kafka for reading stream from the topic and performing operation on the streams. Our Kafka cluster is secured using SSL and ACL that means I need certificate to read from the topic and publish the processed output on another topic and the certificates will change per environment. In the past I had written a Java consumer app which works on the similar principle but it was a containerized app and passing parameters to Docker container is simple enough using,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-e &amp;lt;env_variable&amp;gt;=&amp;lt;value&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However this was a Flink application and things are quite different since the Flink manager has all the controls to run the application. After breaking my head for several hour(s) I figured out that its like running any other Java app. Now the beauty of Java app is you can pass the properties you are reading from application.properties from the arguments without writing a single line of code as,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java -jar &amp;lt;jar_path&amp;gt; --&amp;lt;property_name&amp;gt;=&amp;lt;value&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So I thought why not try the same thing with Flink application after all its a Java app. So I ran below command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/flink/bin/flink run app.jar --brokers=Broker1:9093 --topic=some-topic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And to my surprise this worked and I could verify that by checking the logs on the Flink dashboard. Since this option worked I thought what if I pass the property and their values in a properties file, why not give it a try by running below command,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/flink/bin/flink run app.jar -Dspring.config.name=&amp;lt;full-path&amp;gt;/application.properties
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This also worked since I had implemented the application using Spring boot, I could pass the properties file with all the required values. &lt;/p&gt;

&lt;p&gt;You can choose either of the method according to your preference and it should work seamlessly.&lt;/p&gt;

&lt;p&gt;Happy Coding :)&lt;/p&gt;

</description>
      <category>flink</category>
      <category>java</category>
      <category>springboot</category>
    </item>
  </channel>
</rss>
