<?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: Sid</title>
    <description>The latest articles on DEV Community by Sid (@sidgod).</description>
    <link>https://dev.to/sidgod</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%2F463260%2F491422d6-5bcb-4464-b739-0d1c4c887e4e.jpeg</url>
      <title>DEV Community: Sid</title>
      <link>https://dev.to/sidgod</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sidgod"/>
    <language>en</language>
    <item>
      <title>Kubernetes - Scheduling containers</title>
      <dc:creator>Sid</dc:creator>
      <pubDate>Tue, 08 Sep 2020 10:02:35 +0000</pubDate>
      <link>https://dev.to/sidgod/kubernetes-scheduling-containers-3h91</link>
      <guid>https://dev.to/sidgod/kubernetes-scheduling-containers-3h91</guid>
      <description>&lt;h1&gt;
  
  
  One-shot containers
&lt;/h1&gt;

&lt;p&gt;There are 2 types of one-shot containers based on how they handle recovery in case of error, differentiation between these 2 approaches is from a CLI modifier called "--restart".&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Value of this modifier as "OnFailure" will ensure resource created by kubectl run will be restarted if it does not exit in a clean way (Checked using exit return code). &lt;/li&gt;
&lt;li&gt;Value of this modifier as "Never" will do nothing regardless of how resource / pod exits.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Scheduling containers
&lt;/h1&gt;

&lt;p&gt;Modifier called "--schedule" to kubectl run command will allow us to supply cron expression and will schedule pods accordingly. One-shot container modifiers can also be used along with scheduling modifiers.&lt;br&gt;
This is command for scheduling a container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Sample command&lt;/span&gt;
kubectl create cronjob &amp;lt;job-name&amp;gt; &lt;span class="nt"&gt;--schedule&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;schedule&amp;gt;"&lt;/span&gt; &lt;span class="nt"&gt;--restart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;OnFailure &lt;span class="nt"&gt;--image&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&amp;lt;image-name&amp;gt; &lt;span class="nt"&gt;--&lt;/span&gt; &amp;lt;command-to-container&amp;gt;
&lt;span class="c"&gt;# E.g. Command&lt;/span&gt;
kubectl create cronjob test-cronjob &lt;span class="nt"&gt;--schedule&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"*/3 * * * *"&lt;/span&gt; &lt;span class="nt"&gt;--restart&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;OnFailure &lt;span class="nt"&gt;--image&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;alpine &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nb"&gt;sleep &lt;/span&gt;10
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Example of container with restart on failure and schedule is a batch job that needs to work on batch of data on some frequency.&lt;/p&gt;

&lt;h1&gt;
  
  
  Command help params
&lt;/h1&gt;

&lt;p&gt;I like commands that use intuitive, multi-level switches to provide help on that topic. Thankfully kubectl does follow that practice, it'll not only auto-complete keywords, on every level you can just provide "-h" switch display help on all available CLI options, their meaning and some good examples. I love it when developers put thought to make their CLIs really good and helpful, particularly when someone like myself (with least possible main memory) is using it! ;)&lt;/p&gt;

&lt;h1&gt;
  
  
  Shortcomings of Logs
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;It seems like logs command that kubectl supports just limits no. of pods that it can pull it's data from to just 8! It does make sense since it's internally making round trips to API service and anything over 8 (Magic number ;) ) seems to be harmful that API layer that's a center-piece of whole Kubernetes architecture.&lt;/li&gt;
&lt;li&gt;As I had mentioned previously, logs command when run without a filter seems to latch onto a single pod (not even round-robin) so it feels like logs command in kubectl is good for say local development while work is in progress but not a great choice to run it in production. &lt;/li&gt;
&lt;li&gt;My application of Kubenetes is for cloud and specifically on AWS as their offering - EKS (AWS Managed Kubernetes Cluster) so seems like I'll have to find this "logging" part really well while using EKS. (I still haven't looked at EKS myself but deep down every fibre of my body is telling me that AWS would have supported option to route all logs to CloudWatch logs out of box)&lt;/li&gt;
&lt;li&gt;One option to manage logs that I learned from my Kubernetes training / course if called &lt;a href="https://github.com/wercker/stern"&gt;Stern&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Stern
&lt;/h1&gt;

&lt;p&gt;Seems like a good tool, I gave it a try, it has all options normal logs has plus some more. I would encourage everyone to try this out for local usage.&lt;/p&gt;

&lt;h1&gt;
  
  
  Deleting Stuff
&lt;/h1&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Multiple resources can be deleted together&lt;/span&gt;
kubectl delete &lt;span class="s2"&gt;"&amp;lt;resource-type&amp;gt;/&amp;lt;resource-name&amp;gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;resource-type&amp;gt;/&amp;lt;resource-name&amp;gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Delete does not mean, delete right away! It'll still follow a wait time while pods move to "Terminating" state and then finally be killed off.&lt;/p&gt;

&lt;p&gt;Phoof, this was a long post that I had anticipated ... &lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devlog</category>
    </item>
    <item>
      <title>Kubernetes - First deployment</title>
      <dc:creator>Sid</dc:creator>
      <pubDate>Tue, 08 Sep 2020 05:12:50 +0000</pubDate>
      <link>https://dev.to/sidgod/kubernetes-first-deployment-3k35</link>
      <guid>https://dev.to/sidgod/kubernetes-first-deployment-3k35</guid>
      <description>&lt;h1&gt;
  
  
  Deploying new stuff
&lt;/h1&gt;

&lt;p&gt;Start a new pod using deployments as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl run &lt;span class="s2"&gt;"&amp;lt;deployment-name&amp;gt;"&lt;/span&gt; &lt;span class="nt"&gt;--image&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;container-image&amp;gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;commands-passed-on-to-container-image&amp;gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This creates 3 resources - deployment, repliac sets and finally a pod / pods. &lt;/p&gt;

&lt;p&gt;A deployment consists of one or more replica sets, replica sets consists of pods.&lt;br&gt;
Deployment allows scaling, rolling updated and rollbacks. A replica set makes sure given number of identical pods are running, it also allows scaling.&lt;br&gt;
Since deployment "manages" it's replica sets, configuration in deployment will override changes in replica set configuration made from CLI.&lt;/p&gt;

&lt;h1&gt;
  
  
  Watching logs for a running pod
&lt;/h1&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Logs for a deployment&lt;/span&gt;
kubectl logs &lt;span class="s2"&gt;"deploy/&amp;lt;deployment-name&amp;gt;"&lt;/span&gt;

&lt;span class="c"&gt;# You can use common switches like tail and follow with this&lt;/span&gt;
kubectl logs &lt;span class="s2"&gt;"deploy/&amp;lt;deployment-name&amp;gt; --tail 1 -f"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Logs command can only pull logs from one pod, if you have multiple identical pods running, logs will stick to just one pod till that gets terminated.&lt;br&gt;
You can also pull logs for a specific pod - using get pods to get pod ID, use that ID with logs command.&lt;/p&gt;

&lt;h1&gt;
  
  
  Scaling pods
&lt;/h1&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl scale &lt;span class="s2"&gt;"deploy/&amp;lt;deployment-name&amp;gt;"&lt;/span&gt; &lt;span class="nt"&gt;--replicas&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;number&amp;gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It'll scale no. of pods to new replicas number.&lt;/p&gt;

&lt;h1&gt;
  
  
  Deleting resource
&lt;/h1&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl delete &lt;span class="s2"&gt;"&amp;lt;resource-type&amp;gt;/&amp;lt;resource-id&amp;gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Delete send SIGTERM to shut down pod gracefully, as soon as one pod is in "Terminating" state, replica set will start a new one to match total replicas configuration. Once grace period expired, Kubernetes will then kill container in "Terminating" state, this grace period is configurable to suite variety of application lifecycles.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devlog</category>
    </item>
    <item>
      <title>Kubernetes - All things kubectl</title>
      <dc:creator>Sid</dc:creator>
      <pubDate>Fri, 04 Sep 2020 09:33:36 +0000</pubDate>
      <link>https://dev.to/sidgod/kubernetes-all-things-kubectl-2o8e</link>
      <guid>https://dev.to/sidgod/kubernetes-all-things-kubectl-2o8e</guid>
      <description>&lt;p&gt;First things first - how do we pronounce "kubectl" :) Based on what I heard right now, it's now (and officially) called as "Kube Control"&lt;/p&gt;

&lt;h3&gt;
  
  
  List Nodes
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Usual Output&lt;/span&gt;
kubectl get nodes

&lt;span class="c"&gt;# Wide variant (provided more fields w.r.t. node like internal &amp;amp; external IP, OS Image, Kernel version and container runtime etc.&lt;/span&gt;
kubectl get nodes &lt;span class="nt"&gt;-o&lt;/span&gt; wide

&lt;span class="c"&gt;# Machine friendly output&lt;/span&gt;
kubectl get nodes &lt;span class="nt"&gt;-o&lt;/span&gt; yaml
kubectl get nodes &lt;span class="nt"&gt;-o&lt;/span&gt; json

&lt;span class="c"&gt;# Awesome node monitoring and all other node info, also lists all pods across all namespaces running on that node&lt;/span&gt;
kubectl describe node/&amp;lt;node-name-from-nodes-command&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;kubectl describe basically works with all resources in format as follows&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl describe &lt;span class="s2"&gt;"&amp;lt;resource-kind&amp;gt;/&amp;lt;resource-name&amp;gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Get Services
&lt;/h3&gt;

&lt;p&gt;Get's all deployed services that someone can "talk" to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get svc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Namespaces
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Get all namespaces&lt;/span&gt;
kubectl get ns
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Most commands can take -n  or -A (for all namespaces) as a modifier to run command on&lt;/p&gt;

&lt;h3&gt;
  
  
  Get Pods
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Gets all pods across all namespaces&lt;/span&gt;
kubectl get pods &lt;span class="nt"&gt;-A&lt;/span&gt;

&lt;span class="c"&gt;# Gets all pods in a specific namespace&lt;/span&gt;
kubectl get pods &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;namespace-name&amp;gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>kubernete</category>
      <category>devlog</category>
    </item>
    <item>
      <title>Kubernetes - Initiate Level 1</title>
      <dc:creator>Sid</dc:creator>
      <pubDate>Fri, 04 Sep 2020 08:13:21 +0000</pubDate>
      <link>https://dev.to/sidgod/kubernetes-initiate-level-1-3k8g</link>
      <guid>https://dev.to/sidgod/kubernetes-initiate-level-1-3k8g</guid>
      <description>&lt;p&gt;As one of the first things that I wanted to learn, I picked up Kubernetes. I have started taking a lesson in learning Kubernetes on Udemy Course and I'll use this space to document my learning as I progress through course:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There seem to be waaay too many Kubernetes Certified Distributions&lt;/li&gt;
&lt;li&gt;Kubernetes is a container management system&lt;/li&gt;
&lt;li&gt;What can Kubernetes do out of box:

&lt;ul&gt;
&lt;li&gt;Spawn multiple container of an image&lt;/li&gt;
&lt;li&gt;Put internal / External ALB in front of these multiple containers&lt;/li&gt;
&lt;li&gt;Grow / shrink cluster&lt;/li&gt;
&lt;li&gt;Replace image with latest with rolling update&lt;/li&gt;
&lt;li&gt;Auto scaling - nodes and appliacations&lt;/li&gt;
&lt;li&gt;Scheduled / cron containers&lt;/li&gt;
&lt;li&gt;Batch mode&lt;/li&gt;
&lt;li&gt;Integrate third party services (service catalog)&lt;/li&gt;
&lt;li&gt;RBAC&lt;/li&gt;
&lt;li&gt;Automate complex tasks (operators)&lt;/li&gt;
&lt;/ul&gt;


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

&lt;h1&gt;
  
  
  Kubernetes Basic Architecture
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;Kubernetes master&lt;/em&gt; - also called by Control Plane. Includes API Server, Scheduler, etcd and Controller Manager. One of more master nodes can exist.&lt;/p&gt;

&lt;p&gt;Kubelet - runs on Host Machines, controls local docker&lt;/p&gt;

&lt;p&gt;Kube-proxy - Controls network, works with kubelet&lt;/p&gt;

&lt;p&gt;CoreDNS - Naming service on master&lt;/p&gt;

&lt;p&gt;Cloud Kubernes providers usually hide control plane and run it externally, all we get in return is API endpoint.&lt;/p&gt;

&lt;h1&gt;
  
  
  Interacting with Kubenetes
&lt;/h1&gt;

&lt;p&gt;Only interact through API that supports CRUD operations.&lt;/p&gt;

&lt;p&gt;Pods - Abstract around one or more containers. Lowest deployable unit in Kubernetes. Pods get IP address, not individual containers in a pod. Containers in a pod share localhost and can share volumes. Containers in pod are deployed together.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devlog</category>
    </item>
    <item>
      <title>Not 100 days of code</title>
      <dc:creator>Sid</dc:creator>
      <pubDate>Fri, 04 Sep 2020 04:58:36 +0000</pubDate>
      <link>https://dev.to/sidgod/not-100-days-of-code-3km1</link>
      <guid>https://dev.to/sidgod/not-100-days-of-code-3km1</guid>
      <description>&lt;p&gt;If you're reading this, only god knows how did you land on my blog here but this is supposed to be my dev log of sort. Before you say anything, ... nope I'm not in "100 days of code" thing, I'm quite burned out already in just 15 years into IT and software engineering so I just don't have enough energy right now to code outside of my work for 100 days.&lt;/p&gt;

&lt;p&gt;This weblog is just attempt to document what I'm learning as I progress through some of the new courses that I'm taking on Udemy to learn new stuff.&lt;/p&gt;

&lt;p&gt;This way I would be able to just come back to this and find out important stuff like hacks / commands (if at all) that I can continue to use while I work in future!&lt;/p&gt;

&lt;p&gt;Thanks for stopping by and off you go to reading something actually meaningful ...&lt;/p&gt;

</description>
      <category>devlog</category>
      <category>log</category>
    </item>
  </channel>
</rss>
