<?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: Athavan Kanapuli</title>
    <description>The latest articles on DEV Community by Athavan Kanapuli (@kanapuli).</description>
    <link>https://dev.to/kanapuli</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%2F238348%2F35580bb1-ee60-4675-9eda-05389b85f178.jpeg</url>
      <title>DEV Community: Athavan Kanapuli</title>
      <link>https://dev.to/kanapuli</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kanapuli"/>
    <language>en</language>
    <item>
      <title>kube(cuttle)</title>
      <dc:creator>Athavan Kanapuli</dc:creator>
      <pubDate>Mon, 03 Feb 2020 02:32:01 +0000</pubDate>
      <link>https://dev.to/kanapuli/kube-cuttle-49cl</link>
      <guid>https://dev.to/kanapuli/kube-cuttle-49cl</guid>
      <description>&lt;h2&gt;
  
  
  Kubectl
&lt;/h2&gt;

&lt;p&gt;Kubernetes is actually a one big API server and kubectl is the command-line client tool to manage Kubernetes clusters. Kubectl is also the new SSH for Kubernetes. Kubectl reads the cluster context from the config file present inside $HOME/kube directory. &lt;/p&gt;

&lt;p&gt;Here is Hightower's word on kubectl,&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Syntax structure
&lt;/h2&gt;

&lt;p&gt;Kubectl has the following syntax,&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Kubectl [operation] [resource] [name] [options]&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;em&gt;operations&lt;/em&gt; are the tasks that you want to perform such as &lt;em&gt;create, get, describe, delete, apply -f, exec -it&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;a href="https://book-v1.book.kubebuilder.io/basics/what_is_a_resource.html"&gt;resource&lt;/a&gt;&lt;/em&gt; is the Kubernetes resource kinds like &lt;em&gt;deployment, pods, connfigmap, daemonset etc.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;name&lt;/em&gt; specifies the name of the resource such as POD name, deployment name etc.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;options&lt;/em&gt; are the various choices available for the operations and the resources. Some of the common options are &lt;br&gt;
         * &lt;strong&gt;-o yaml&lt;/strong&gt; - outputs in yaml format &lt;br&gt;
         * &lt;strong&gt;-o json&lt;/strong&gt; - outputs in json format &lt;br&gt;
         * &lt;strong&gt;--watch&lt;/strong&gt;&lt;br&gt;
         * &lt;strong&gt;--show-labels&lt;/strong&gt;&lt;br&gt;
         * &lt;strong&gt;--namespace&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Kubectl works?
&lt;/h2&gt;

&lt;p&gt;kubectl works on REST apis. Whenever a command is entered using kubectl, it's translated into a REST API call and hits the Kubernetes API server. Now based on the kubectl command, the API server either refers kubelet or the etcd database to retrieve or modify the data.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Get documentation using Kubectl
&lt;/h2&gt;

&lt;p&gt;Kubernetes has a lot of resources and custom resource definitions. Kubectl has a wonderful feature to read all the documentation about these resources from the command line. It's pretty useful while writing the Kubernetes manifest yamls. For example, to view the options of the &lt;em&gt;Pod&lt;/em&gt; resource, just run &lt;code&gt;kubectl explain pod&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;The &lt;strong&gt;explain&lt;/strong&gt; command also works to explain any inner field of a resource. For example, to know about the &lt;strong&gt;spec&lt;/strong&gt; of a POD resource, just call the explain API with dot notation like &lt;code&gt;kubectl explain pod.spec&lt;/code&gt;&lt;/p&gt;

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

&lt;h2&gt;
  
  
  kubectl - an alternative to SSH for containers
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;kubectl exec&lt;/code&gt; is a valuable command for those who are working with the pods. It helps to get into the containers and allows us to execute commands.&lt;/p&gt;

&lt;p&gt;Say, for example when we run the &lt;code&gt;exec&lt;/code&gt; command to a running nginx POD, the following happens, &lt;/p&gt;

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

&lt;p&gt;From the above image, the following can be noted,&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A GET request is called to fetch the POD nginx&lt;/li&gt;
&lt;li&gt;A POST request to the &lt;code&gt;exec&lt;/code&gt; subresource of the POD&lt;/li&gt;
&lt;li&gt;Finally, the server responds with the Response status 101 and switches to &lt;a href="https://en.wikipedia.org/wiki/SPDY"&gt;SPDY&lt;/a&gt; protocol to serve the content.
Now technically we've logged-in to a pod and can run any commands.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  kubectl - For Local debugging of the remote services
&lt;/h2&gt;

&lt;p&gt;One of the top features of kubectl is the &lt;code&gt;port-forward&lt;/code&gt; command. This allows forwarding one or more local ports to the remote service/pod running in the cluster and allows debugging of a remote service locally.&lt;/p&gt;

&lt;p&gt;The following is an example where we port forward the local 8080 port to the remote 80 port of an nginx POD and we can access the remote nginx server using localhost:8080 for the terminal.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Common Useful kubectl commands
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;apply&lt;/strong&gt; - &lt;code&gt;kubectl apply -f FILENAME.yaml&lt;/code&gt; will create/apply all configurations specified in the file. &lt;code&gt;apply&lt;/code&gt; also takes input from STDIN&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;annotate&lt;/strong&gt; - &lt;code&gt;kubectl annotate (-f FILENAME.yaml | RESOURCE NAME) KEY1=VAL1 KEY2=VAL2&lt;/code&gt;. This adds or updates annotations on one or more resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;delete&lt;/strong&gt; - &lt;code&gt;kubectl delete (-f FILENAME | RESOURCE NAME)&lt;/code&gt; . This deletes the specified resources from the cluster&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;describe&lt;/strong&gt; - &lt;code&gt;kubectl describe RESOURCE NAME&lt;/code&gt; displays all the detailed state of the specified resource.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;diff&lt;/strong&gt; - &lt;code&gt;kubectl diff FILENAME [flags]&lt;/code&gt; shows the diff between resources specified in the file against the live server configurations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;edit&lt;/strong&gt; - &lt;code&gt;kubectl edit ( FILENAME | RESOURCE NAME)&lt;/code&gt; edits or updates the resources specified. This helps to dynamically change the server resources. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;get&lt;/strong&gt; - &lt;code&gt;kubectl get RESOURCE NAME&lt;/code&gt; retrieves the specified resource information from the server. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;logs&lt;/strong&gt; - &lt;code&gt;kubectl logs -f RESOURCE NAME&lt;/code&gt;. This is an equivalent of &lt;code&gt;tail -f&lt;/code&gt;. This tails the logs of a resource directly from your terminal&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The complete reference of kubectl commands with examples can be found in the &lt;a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands"&gt;kubectl reference&lt;/a&gt; document.&lt;/p&gt;

&lt;p&gt;Thanks for Reading ! See you soon again with another post :)&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What are Kubernetes Pods Anyway?</title>
      <dc:creator>Athavan Kanapuli</dc:creator>
      <pubDate>Thu, 23 Jan 2020 01:27:18 +0000</pubDate>
      <link>https://dev.to/kanapuli/what-are-kubernetes-pods-anyway-1app</link>
      <guid>https://dev.to/kanapuli/what-are-kubernetes-pods-anyway-1app</guid>
      <description>&lt;h2&gt;
  
  
  What is a Pod?
&lt;/h2&gt;

&lt;p&gt;A Pod is a colocated group of containers and represents the very basic unit in Kubernetes. By this, we are not implying that a pod always contains more than a container. It's usual for pods to have a single &lt;a href="https://jvns.ca/blog/2016/10/10/what-even-is-a-container/"&gt;container&lt;/a&gt; most of the time. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why do we need a Pod?
&lt;/h2&gt;

&lt;p&gt;Why would we run multiple containers together? Why can't we run a single container that does all our jobs? Let's try to answer these.&lt;/p&gt;

&lt;p&gt;Generally, containers are designed to run a single process. It doesn't have an init system which manages all processes. So if we run multiple processes inside a container, it is our responsibility to keep all those processes running, manage their logs, handle all &lt;a href="https://en.wikipedia.org/wiki/Signal_(IPC)"&gt;SIGNALS&lt;/a&gt; and so on. Truth be told, this is a pain. So it is always recommended to run a single process inside a container. Now it's obvious that we need some higher-level construct which helps to bind containers together and manage them as a single unit.&lt;/p&gt;

&lt;p&gt;A Pod of containers allows multiple processes to be tied together and provide them with the same environment as if they were all running in the same container. &lt;/p&gt;

&lt;h2&gt;
  
  
  What's shared inside a Pod?
&lt;/h2&gt;

&lt;p&gt;All containers in a pod share the same &lt;a href="https://en.wikipedia.org/wiki/Linux_namespaces"&gt;Linux namespaces&lt;/a&gt;. They are in the same Network and UTS namespaces. Because of this, containers within a pod shares the same IP address and hostname. Similarly, all containers run under the same IPC namespace and can communicate themselves through IPC.&lt;br&gt;
  &lt;a href="https://postimg.cc/dkMRTXwM"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--q8m33pOj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/MTH9g2LG/containers.jpg" alt="containers.jpg"&gt;&lt;/a&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  What's different inside a Pod?
&lt;/h2&gt;

&lt;p&gt;Each container in a pod has it's own PID namespace. So when you run &lt;code&gt;ps aux&lt;/code&gt; inside a container, you see only the container's own processes.&lt;br&gt;
   When we speak about the filesystem, they mostly come from the container image. Hence the file system of each container inside the Pod is fully isolated. Here is a note, you can still have a shared volume for all containers in a pod using &lt;a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-volume-storage/"&gt;&lt;strong&gt;Kubernetes Volumes&lt;/strong&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Pod's Network
&lt;/h2&gt;

&lt;p&gt;Containers inside the pod share the same IP and port space. They all are in the same loopback interface and a container can talk to another container in a pod using localhost. Since the port space is shared, processes running in two containers cannot bind to the same port inside a Pod. Containers of different pods can never run into such port conflicts.&lt;br&gt;
   All pods in a Kubernetes cluster stay in a single flat, network space. Hence any pod can communicate with any other pod with the pod IP. There are no NAT gateways required for Pod-to-Pod communication.&lt;br&gt;
&lt;a href="https://postimg.cc/Q99Xv4TM"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LLlX8mM9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/sXKvQbf5/Flat-network.jpg" alt="Flat-network.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://kubernetes.io/docs/concepts/workloads/pods/pod/"&gt;Kubernetes documentation on Pods&lt;/a&gt; provides the most complete explanation of pods and I would recommend to read it as it's a better and more correct explanation than I could write.&lt;/p&gt;

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