<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ali Kahoot on Medium]]></title>
        <description><![CDATA[Stories by Ali Kahoot on Medium]]></description>
        <link>https://medium.com/@kahootali?source=rss-7cbc6f8d3b08------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4r6iNU9diAd3bsNGQl-mfQ.jpeg</url>
            <title>Stories by Ali Kahoot on Medium</title>
            <link>https://medium.com/@kahootali?source=rss-7cbc6f8d3b08------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 05:16:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kahootali/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Getting Started with AWS EKS using Terraform]]></title>
            <link>https://medium.com/stakater/getting-started-with-aws-eks-using-terraform-7487ffeac48f?source=rss-7cbc6f8d3b08------2</link>
            <guid isPermaLink="false">https://medium.com/p/7487ffeac48f</guid>
            <category><![CDATA[ek]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[Ali Kahoot]]></dc:creator>
            <pubDate>Tue, 03 Mar 2020 07:30:21 GMT</pubDate>
            <atom:updated>2020-03-03T10:36:54.091Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*EW-5IJ3TJX1q8GnRNI_P-Q.jpeg" /></figure><p>Kubernetes (K8s) is an open-source container orchestration system for automating deployment, scaling, and management of containerized applications. Following is the architecture of a Kubernetes cluster</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*BbrbBu7KiY09r9RiptRRhg.png" /><figcaption>Source: <a href="https://www.guru99.com/kubernetes-tutorial.html">https://www.guru99.com/kubernetes-tutorial.html</a></figcaption></figure><p>There are different ways to provision a Kubernetes cluster</p><ul><li><a href="https://kubernetes.io/docs/setup/learning-environment/minikube/">Minikube</a>: Easily create a local, single-node Kubernetes cluster for<br>development and testing</li><li><a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/">kubeadm</a>: Bootstrap a Kubernetes cluster conforming to best practices. Can be installed on various types of platforms and can easily integrate<br>with provisioning systems such as Terraform or Ansible</li><li><a href="https://kubernetes.io/docs/setup/production-environment/tools/kops/">Kops</a>: Create, destroy, upgrade and maintain production-grade, highly<br>available Kubernetes clusters from the command line on AWS only</li><li>Hosted/Managed Solutions: Almost all clouds provide managed Kubernetes services like Azure offers AKS, IBM cloud offers IKS, Google offers GKE and AWS offers EKS.</li></ul><p>In Managed Kubernetes, you don’t have to manage the master node components of K8s, rather the cloud manages that, and you just provision the worker nodes and the cloud will handle the uptime and related features. You just start deploying your workloads on the cluster.</p><p>In this post, I will be discussing how to provision an AWS EKS cluster using Terraform. Terraform is a tool to manage your infrastructure as code so rather than provisioning an EKS cluster and related things manually, you can use terraform to provision them for you.</p><p>You can install terraform by following this <a href="https://learn.hashicorp.com/terraform/getting-started/install.html">link</a>. And you can verify it by running</p><pre>$ terraform<br>Usage: terraform [--version] [--help] &lt;command&gt; [args]</pre><pre>The available commands for execution are listed below.<br>The most common, useful commands are shown first, followed by<br>less common or more advanced commands. If you&#39;re just getting<br>started with Terraform, stick with the common commands. For the<br>other commands, please read the help and docs before usage.</pre><pre>Common commands:<br>    apply              Builds or changes infrastructure<br>    console            Interactive console for Terraform interpolations<br># ...</pre><p>And confirm the version by running</p><pre>terraform version</pre><h3><strong>Assumptions</strong></h3><ul><li>You’ve created a Virtual Private Cloud (VPC) and subnets where you intend to put the EKS resources. The VPC satisfies <a href="https://docs.aws.amazon.com/eks/latest/userguide/network_reqs.html">EKS requirements</a>.</li><li>You have aws configured locally i.e. your ACCESS_KEY and SECRET_ACCESS_KEY is set and you have a user that has <a href="https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/iam-permissions.md">these permissions</a></li><li>If manage_aws_auth = true, it&#39;s required that both <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl">kubectl</a> (&gt;=1.10) and <a href="https://github.com/kubernetes-sigs/aws-iam-authenticator#4-set-up-kubectl-to-use-authentication-tokens-provided-by-aws-iam-authenticator-for-kubernetes">aws-iam-authenticator</a> are installed and on your shell&#39;s PATH.</li></ul><h3><strong>Steps</strong></h3><ol><li>Get the VPC and subnet ids and the region in which you want to create an EKS cluster.</li></ol><p>2. Create a file <strong>main.tf </strong>in which we will define the cluster manifest and for simplicity, instead of using variables, we will be using <strong>locals </strong>and defining customizable variables there.</p><p>Create a locals section in the file and copy following manifest in it and replace the variables with your values</p><pre>locals{<br>    vpc_id = &quot;vpc-1234ab&quot;<br>    region = eu-west-1<br>    cluster_name = &quot;dev-eks-cluster&quot;<br>    subnets = [&quot;subnet-1234&quot;, &quot;subnet-1235&quot;, &quot;subnet-1236&quot;]<br>    cluster_enabled_log_types = [&quot;api&quot;, &quot;audit&quot;, &quot;authenticator&quot;, &quot;controllerManager&quot;, &quot;scheduler&quot;]<br>    asg_desired_capacity = 1<br>    asg_max_size = 3<br>    asg_min_size = 1<br>    instance_type = &quot;m4.large&quot;<br>    spot_price = &quot;0.20&quot;<br>}</pre><p>These are the customizable variables that will be used in the terraform module. The variables are self explanatory like VPC id and subnet ids where your EKS cluster will be running. The variable <strong>cluster_enabled_log_types </strong>is the list of the desired control plane logs to enable. These logs will be available in Cloudwatch -&gt; LogGroups. The other variables are regarding the Autoscaling Group Instance counts.</p><p>We also focus on cost reduction so we are using Spot Instances rather than dedicated instances. So you can set the <strong>spot_price </strong>that you want to bid for the instances. Spot instances are almost 80–90% cheaper than normal dedicated instances. For details about Spot Instances vs Dedicated Instances see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-purchasing-options.html">AWS Instance Purchasing Options</a></p><p>Add a <strong>provider aws</strong> and <strong>terraform</strong> section to specify region and version.</p><pre>provider &quot;aws&quot; {<br>  region  = local.region<br>}<br>terraform {<br>  required_version = &quot;&gt;= 0.12.7&quot;<br>}</pre><p>And now setup the EKS module to be used</p><pre>module &quot;eks-cluster&quot; {<br>  source       = &quot;terraform-aws-modules/eks/aws&quot;<br>  version = &quot;v7.0.1&quot;<br>  cluster_name = local.cluster_name<br>  subnets = local.subnets<br>  vpc_id  = local.vpc_id</pre><pre>  worker_groups = [<br>    {<br>      spot_price = locals.spot_price<br>      asg_desired_capacity = locals.asg_desired_capacity<br>      asg_max_size = locals.asg_max_size<br>      asg_min_size = locals.asg_min_size<br>      instance_type = locals.instance_type<br>      name = &quot;worker-group&quot;<br>      additional_userdata = &quot;Worker group configurations&quot;<br>      tags = [{<br>          key                 = &quot;worker-group-tag&quot;<br>          value               = &quot;worker-group-1&quot;<br>          propagate_at_launch = true<br>      }]<br>    }<br>  ]</pre><pre>  map_users = [<br>      {<br>        userarn = &quot;arn:aws:iam::AWS_ACCOUNT:user/AWS_USERNAME&quot;<br>        username = &quot;AWS_USERNAME&quot;<br>        groups = [&quot;system:masters&quot;]<br>      },<br>    ]<br>  cluster_enabled_log_types = local.cluster_enabled_log_types<br>  tags = {<br>    environment = &quot;dev-env&quot;<br>  }<br>}</pre><p>Your final file should have all of the above manifests and should look like</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/72ae510239d1954f3e1ac49fd71a6d52/href">https://medium.com/media/72ae510239d1954f3e1ac49fd71a6d52/href</a></iframe><p>3. Replace the above placeholders with your values. You can set the worker nodes autoscaling group desired, minimum and maximum capacity and the spot price for the nodes in the <strong>worker_groups</strong> section</p><p>In the <strong>map_users</strong> section, you can add any other AWS user that you want to have access to the cluster that you created.</p><p>These are the simplest variables that you can set to create your cluster, for other variables and their details, see <a href="https://github.com/terraform-aws-modules/terraform-aws-eks#inputs">Terraform-AWS-EKS-Inputs</a></p><p>4. After this run</p><pre>terraform init<br>terraform apply</pre><p>This will show the resources that the terraform module will create and will ask you to confirm them, type <strong>yes </strong>so terraform will start creating. <br>It takes sometime to create the cluster almost 10 minutes, and after that if everything goes smooth hopefully, terraform will show</p><pre>Apply complete! Resources: N added, 0 changed, 0 destroyed.</pre><p>It will also add the <strong>kubeconfig</strong> of your cluster in the folder directory. And a configmap, which will contain the user that you had given permission while creating the cluster. That user/users and the user that created the cluster can access the cluster using the kubeconfig.</p><p>5. Run the following commands to verify your access to the cluster</p><pre>kubectl get nodes --kubeconfig kubeconfig_dev-eks-cluster<br>kubectl get pods --all-namespaces --kubeconfig kubeconfig_dev-eks-cluster</pre><p>And your EKS cluster is ready, you can start deploying your workloads and take use of managed Kubernetes from AWS.</p><h4>Cleanup</h4><p>Now to destroy the workloads, run</p><pre>terraform destroy</pre><p>And it will show resources that will be deleted, acknowledge it by entering yes and the resources will be deleted.</p><h4><strong>Cost</strong></h4><p>Cost of Running an EKS cluster is $0.10 per hour, so for a month(almost 744 hours) it becomes almost 75$ per month per EKS cluster(the master instance that AWS manages for you) in AWS. Other than this, the cost for worker nodes is dependent on number &amp; type of EC2 instances that you create and their cost is the same as you create a normal EC2 instance.</p><p>We deployed <a href="https://github.com/stakater/stakaterplatform">StakaterPlatform</a>(A consolidated solution that helps the community to adopt Security, Monitoring, Logging, Tracing, Alerting and CI/CD processes for their workloads) and <a href="https://stakater.com/">Stakater</a>’s production grade applications which needs almost 8 VCPUs &amp; 32 GB of RAM(2 * t2.xlarge spot instances) and it cost us around <strong>5-6$ per day</strong> which is quite reasonable keeping in view that the master is managed by AWS and they will guarantee the uptime of master components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*Eb2RuyjrL1wsw1gbPHxS5A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7487ffeac48f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stakater/getting-started-with-aws-eks-using-terraform-7487ffeac48f">Getting Started with AWS EKS using Terraform</a> was originally published in <a href="https://medium.com/stakater">Stakater</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[K8s: Deployments vs StatefulSets vs DaemonSets]]></title>
            <link>https://medium.com/stakater/k8s-deployments-vs-statefulsets-vs-daemonsets-60582f0c62d4?source=rss-7cbc6f8d3b08------2</link>
            <guid isPermaLink="false">https://medium.com/p/60582f0c62d4</guid>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[statefulsets]]></category>
            <category><![CDATA[pods]]></category>
            <dc:creator><![CDATA[Ali Kahoot]]></dc:creator>
            <pubDate>Thu, 18 Apr 2019 11:29:33 GMT</pubDate>
            <atom:updated>2021-06-09T09:56:42.821Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*dSL05n34oOKHwFMJJHETRw.jpeg" /><figcaption>Containers Ship Source: <a href="https://pixabay.com/photos/container-ship-container-ship-537724/">https://pixabay.com/photos/container-ship-container-ship-537724/</a></figcaption></figure><p>I have explained this blog in detail with live example on <a href="https://www.youtube.com/watch?v=7Tnm9hRyoYU">Data on Kubernetes Community Meetup 49 Deployments vs StatefulSets vs Daemonsets</a>.</p><p>Kubernetes (K8s) is an open-source container orchestration system for automating deployment, scaling, and management of containerized applications.</p><p>Kubernetes provides a basic resource called Pod. A pod is the smallest deployable unit in Kubernetes which is actually a wrapper around containers. A pod can have one or more containers and you can pass different configuration to the container(s) using the pod’s configuration e.g. passing environment variables, mounting volumes, having health checks, etc. For more details about pods, check <a href="https://kubernetes.io/docs/concepts/workloads/pods/pod/">Pod</a>.</p><p>In this post, I will be discussing three different ways to deploy your application(pods) on Kubernetes using different Kubernetes resources. Below are 3 different resources that Kubernetes provides for deploying pods.</p><ol><li>Deployments</li><li>StatefulSets</li><li>DaemonSets</li></ol><p>There is one other type ReplicationController but Kubernetes now favors Deployments as Deployments configure ReplicaSets to support replication.</p><p>For detailed differences between the 3 resources, I will be deploying a <a href="https://github.com/kahootali/counter-app">sample counter app</a>, which logs and increments the count from a counter file like 1,2,3,…. I am using the counter file from a Persistent Volume to detail the differences between the Deployments, StatefulSets and DaemonSets. The manifests files to deploy the following resources can be found in the <a href="https://github.com/kahootali/counter-app/tree/master/kubernetes">counter app</a>.</p><h3>Deployments</h3><p>Deployment is the easiest and most used resource for deploying your application. It is a Kubernetes controller that matches the current state of your cluster to the desired state mentioned in the Deployment manifest. e.g. If you create a deployment with 1 replica, it will check that the desired state of ReplicaSet is 1 and current state is 0, so it will create a ReplicaSet, which will further create the pod. If you create a deployment with name <strong>counter</strong>, it will create a ReplicaSet with name <strong>counter-&lt;replica-set-id&gt;</strong>, which will further create a Pod with name <strong>counter-&lt;replica-set-&gt;-&lt;pod-id&gt;.</strong></p><p>Deployments are usually used for stateless applications. However, you can save the state of deployment by attaching a Persistent Volume to it and make it stateful, but all the pods of a deployment will be sharing the same Volume and data across all of them will be same.</p><p>For deploying the <a href="https://github.com/kahootali/counter-app">sample counter app</a> using a deployment, we will be using the following manifest, you can deploy it by copying the below manifest and saving it in a file e.g. deployment.yaml, and then applying by</p><p>kubectl apply -f deployment.yaml</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/670900cf1a442b2a10b3255fb9644153/href">https://medium.com/media/670900cf1a442b2a10b3255fb9644153/href</a></iframe><p>If you deploy the above deployment, and see the logs of the pod, you will be able to see the log in order like 1,2,3,…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cv6hmDbeWQKZzSEEnL37hg.png" /><figcaption>The logs from the 1st pod, Note the name of pod, counter-c9d778cf7-jd9bw,<strong> counter</strong> — deployment name, <strong>c9d778cf7</strong> — ReplicaSet id, <strong>jd9b2</strong> — Pod id</figcaption></figure><figure><img alt="Persistence in Deployments" src="https://cdn-images-1.medium.com/max/1024/1*0WtBPfINnpP6b4Q_cnog0A.png" /></figure><p>Now if you scale the deployment to 2 by running</p><pre>kubectl scale deployment counter --replicas=2</pre><p>you can see a new pod created, if you check the logs of the new pod, its logs will not start from 1 rather it will start from the last number of the 1st pod.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RLUVkPAliz_rAAU70R504g.png" /><figcaption>The logs from the 2nd pod, Note the name of pod, <strong>counter-c9d778cf7-jd9bw. </strong>Deployment and replicaset id are same only pod id is different than previous pod.</figcaption></figure><p>If you see the logs, they are starting from 73, meaning that the previous pod had written till 72 in the file and they both are sharing the same file and volume and data is shared across all pods of a Deployment. Also if you check the Persistent Volume Claims(PVCs), only one PVC will be created that both the pods will be sharing so it can cause Data Inconsistency.</p><figure><img alt="Persistence for replicas in Deployments" src="https://cdn-images-1.medium.com/max/1024/1*m1BoqSmhxGeGHmeexJ_mZA.png" /><figcaption>Persistence for Deployments sharing single Volume can cause Data Inconsistency</figcaption></figure><p>Deployments, as discussed, creates a ReplicaSet which then creates a Pod so whenever you update the deployment using RollingUpdate(default) strategy, a new ReplicaSet is created and the Deployment moves the Pods from the old ReplicaSet to the new one at a controlled rate. Rolling Update means that the previous ReplicaSet doesn’t scale to 0 unless the new ReplicaSet is up &amp; running ensuring 100% uptime. If an error occurs while updating, the new ReplicaSet will never be in <strong>Ready</strong> state, so old ReplicaSet will not terminate again ensuring 100% uptime in case of a failed update. In Deployments, you can also manually roll back to a previous ReplicaSet, if needed in case if your new feature is not working as expected.</p><h3>StatefulSets</h3><p>StatefulSet(stable-GA in k8s v1.9) is a Kubernetes resource used to manage stateful applications. It manages the deployment and scaling of a set of Pods, and provides guarantee about the ordering and uniqueness of these Pods.</p><p>StatefulSet is also a Controller but unlike Deployments, it doesn’t create ReplicaSet rather itself creates the Pod with a unique naming convention. e.g. If you create a StatefulSet with name <strong>counter, </strong>it will create a pod with name <strong>counter-0, </strong>and for multiple replicas of a statefulset, their names will increment like <strong>counter-0</strong>, <strong>counter-1</strong>, <strong>counter-2, etc</strong></p><p>Every replica of a stateful set will have its own state, and each of the pods will be creating its own PVC(Persistent Volume Claim). So a statefulset with 3 replicas will create 3 pods, each having its own Volume, so total 3 PVCs.</p><p>For deploying the <a href="https://github.com/kahootali/counter-app">sample counter app</a> using a statefulset, we will be using the following manifest. you can deploy it by copying the below manifest and saving it in a file e.g. statefulset.yaml, and then applying by</p><p>kubectl apply -f statefulset.yaml</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f888c9481ae228c5040157faf09955be/href">https://medium.com/media/f888c9481ae228c5040157faf09955be/href</a></iframe><p>If you deploy the above statefulset, and see the logs of the pod, you will be able to see the log in order like 1,2,3,…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yQtGqDw54yitDPgT7-O7qQ.png" /><figcaption>The logs from the 1st pod. Note the name of the pod is <strong>counter-0</strong></figcaption></figure><p>Here, you can see the logs start from 1. Now if we scale up the statefulset to 3 replicas by run</p><pre>kubectl scale statefulsets counter --replicas=3</pre><p>it will first create a new pod <strong>counter-1, </strong>and once that pod is ready, then another pod <strong>counter-2. </strong>The new pods will have their own Volume and if you check the logs, the count will again start from 1 for the new pods, unlike in Deployments as we saw earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nM-hkzuUqrh4ulBcJmCFyA.png" /><figcaption>The logs from 2nd pod. Note the name is <strong>counter-1.</strong></figcaption></figure><p>Here, the logs are again starting from 1, as this pod has its own Volume, so it doesn’t read the file of 1st pod. And if we see the Persistent Volume Claims,their will be 3 claims created as we had scaled the replicas to 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*307Wn2ioKOYwA3guEvZycw.png" /><figcaption>PVC</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t0TyiZMRyJCPOGg2XphzwA.png" /><figcaption>Persistence for StatefulSets each having its own Volume</figcaption></figure><p>StatefulSets don’t create ReplicaSet or anything of that sort, so you cant rollback a StatefulSet to a previous version. You can only delete or scale up/down the Statefulset. If you update a StatefulSet, it also performs RollingUpdate i.e. one replica pod will go down and the updated pod will come up, then the next replica pod will go down in same manner e.g. If I change the image of the above StatefulSet, the <strong>counter-2 </strong>will terminate and once it terminates completely, then <strong>counter-2</strong> will be recreated and <strong>counter-1</strong> will be terminated at the same time, similarly for next replica i.e. counter-0. If an error occurs while updating, so only <strong>counter-2</strong> will be down, counter-1 &amp; counter-0 will still be up, running on previous stable version. Unlike Deployments, you cannot roll back to any previous version of a StatefulSet.</p><p>StatefulSets are useful in case of Databases especially when we need Highly Available Databases in production as we create a cluster of Database replicas with one being the primary replica and others being the secondary replicas. The primary will be responsible for read/write operations and secondary for read only operations and they will be syncing data with the primary one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0b7yevdOXKmluG-ElZ2H6Q.png" /><figcaption>Using StatefulSets to provision Postgres as Highly Available Database</figcaption></figure><p>If the primary goes down, any of the secondary replica will become primary and the StatefulSet controller will create a new replica in account of the one that went down, which will now become a secondary replica.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dh5O8yRAbdXHjmVnu9IfzA.png" /><figcaption>In case if postgres-0 went down, now postgres-1 became the primary replica</figcaption></figure><h3>DaemonSet</h3><p>A DaemonSet is a controller that ensures that the pod runs on all the nodes of the cluster. If a node is added/removed from a cluster, DaemonSet automatically adds/deletes the pod.</p><p>Some typical use cases of a DaemonSet is to run cluster level applications like:</p><ul><li><strong>Monitoring Exporters</strong>: You would want to monitor all the nodes of your cluster so you will need to run a monitor on all the nodes of the cluster like NodeExporter.</li><li><strong>Logs Collection Daemon:</strong> You would want to export logs from all nodes so you would need a DaemonSet of log collector like Fluentd to export logs from all your nodes.</li></ul><p>However, Daemonset automatically doesn’t run on nodes which have a taint e.g. Master. You will have to specify the tolerations for it on the pod.</p><p>Taints are a way of telling the nodes to repel the pods i.e. no pods will be schedule on this node unless the pod tolerates the node with the same toleration. The master node is already tainted by:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b113486ca4b409d5fb269f46f207f6e3/href">https://medium.com/media/b113486ca4b409d5fb269f46f207f6e3/href</a></iframe><p>Which means it will repel all pods that do not tolerate this taint, so for daemonset to run on all nodes, you would have to add following tolerations on DaemonSet</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9dd0c3294a1333718cea8180c701ffeb/href">https://medium.com/media/9dd0c3294a1333718cea8180c701ffeb/href</a></iframe><p>which means that it should tolerate all nodes.</p><p>For deploying the <a href="https://github.com/kahootali/counter-app">sample counter app</a> using a daemonset, we will be using the following manifest. you can deploy it by copying the below manifest and saving it in a file e.g. daemonset.yaml, and then applying by</p><p>kubectl apply -f daemonset.yaml</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62feaeedc58e798c5624da26b3b7aa8c/href">https://medium.com/media/62feaeedc58e798c5624da26b3b7aa8c/href</a></iframe><p>When you deploy the daemonset, it will create pods equal to the number of nodes. In terms of behavior, it will behave the same as Deployments i.e. all pods will share the same Persistent Volume.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-4H5HgNp5hOIwasX5-nYWg.png" /><figcaption>Logs of a pod of DaemonSet</figcaption></figure><p>These are the logs of a pod of DaemonSet, you can see the logs are not in order, meaning that all pods are sharing the same Volume. Also only one PVC will be created that all pods will be sharing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xrAwDE0tFymV62BiAwDyGw.png" /><figcaption>Similar to ReplicaSet, but DaemonSets run one replica per node in the cluster</figcaption></figure><p>If you update a DaemonSet, it also performs RollingUpdate i.e. one pod will go down and the updated pod will come up, then the next replica pod will go down in same manner e.g. If I change the image of the above DaemonSet, one pod will go down, and when it comes back up with the updated image, only then the next pod will terminate and so on. If an error occurs while updating, so only one pod will be down, all other pods will still be up, running on previous stable version. Unlike Deployments, you cannot roll back your DaemonSet to a previous version.</p><p>That’s all, these are the main resources to deploy your applications (containers) on Kubernetes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60582f0c62d4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stakater/k8s-deployments-vs-statefulsets-vs-daemonsets-60582f0c62d4">K8s: Deployments vs StatefulSets vs DaemonSets</a> was originally published in <a href="https://medium.com/stakater">Stakater</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>