<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Kubernetes on Alperen Doc</title><link>https://blog.ulutasalperen.com/docs/kubernetes/</link><description>Recent content in Kubernetes on Alperen Doc</description><generator>Hugo</generator><language>en</language><atom:link href="https://blog.ulutasalperen.com/docs/kubernetes/index.xml" rel="self" type="application/rss+xml"/><item><title>kubernetes-minikube</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-minikube/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-minikube/</guid><description>&lt;h1 id="minikube"&gt;Minikube&lt;a class="anchor" href="#minikube"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;During this blog, we&amp;rsquo;ll be using &lt;a href="https://minikube.sigs.k8s.io/docs/"&gt;Minikube&lt;/a&gt; to practice with Kubernetes. In production, you probably wouldn&amp;rsquo;t use Minikube, you would use a cluster of servers, probably in the cloud. That&amp;rsquo;s expensive! Minikube is a fantastic tool that allows you to run a single-node Kubernetes cluster on your local machine.&lt;/p&gt;&#10;&lt;h2 id="kubectl"&gt;Kubectl&lt;a class="anchor" href="#kubectl"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;The Kubernetes command-line tool, &lt;code&gt;kubectl&lt;/code&gt;, allows you to run commands against Kubernetes clusters. It&amp;rsquo;s a client that communicates with a Kubernetes API server.&lt;/p&gt;</description></item><item><title>kubernetes-pods-minikube</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-pods-minikube/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-pods-minikube/</guid><description>&lt;h1 id="pods"&gt;Pods&lt;a class="anchor" href="#pods"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;blockquote class='book-hint '&gt;&#10;&lt;p&gt;&amp;ldquo;Pods are the smallest deployable units of computing that you can create and manage in Kubernetes.&amp;rdquo;&lt;/p&gt;&#10;&lt;p&gt;&amp;ndash; The &lt;a href="https://kubernetes.io/docs/concepts/workloads/pods/"&gt;Kubernetes team&lt;/a&gt;&lt;/p&gt;&#10;&lt;/blockquote&gt;&lt;p&gt;A Pod is the smallest and simplest unit in the Kubernetes object model that you create or deploy. It represents one (or sometimes more) running container(s) in a cluster. In a simple web application, you might have one single pod: the web server. As traffic grows, you might deploy that same code to multiple pods to handle the increased load. Several pods, one codebase. In a more complex backend system, you might have several pods for the web server and several pods that handle video processing. Multiple pods, multiple codebases.&lt;/p&gt;</description></item><item><title>kubernetes-deployments-minikube</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-deployments-minikube/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-deployments-minikube/</guid><description>&lt;h1 id="deployments"&gt;Deployments&lt;a class="anchor" href="#deployments"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;A &lt;em&gt;&lt;a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/"&gt;Deployment&lt;/a&gt;&lt;/em&gt; provides declarative updates for Pods and ReplicaSets.&lt;/p&gt;&#10;&lt;p&gt;You describe your &lt;em&gt;desired state&lt;/em&gt; in a Deployment, and the Deployment Controller&amp;rsquo;s job is to make the &lt;em&gt;current state&lt;/em&gt; match the &lt;em&gt;desired state&lt;/em&gt;. You declare your hopes and dreams, and it&amp;rsquo;s Kubernetes&amp;rsquo; job to make them come true.&lt;/p&gt;&#10;&lt;h2 id="why-deleting-a-pod-doesnt-feel-like-a-deletion"&gt;Why Deleting a Pod Doesn&amp;rsquo;t Feel Like a Deletion&lt;a class="anchor" href="#why-deleting-a-pod-doesnt-feel-like-a-deletion"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Remember when we had you delete a pod, only to see that a new pod was created in its place? It&amp;rsquo;s kinda like chopping heads off of a hydra.&lt;/p&gt;</description></item><item><title>kubernetes-probes</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-probes/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-probes/</guid><description>&lt;h1 id="probes"&gt;Probes&lt;a class="anchor" href="#probes"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;We&amp;rsquo;ve created pods, watched them get replaced when we deleted them, and even debugged a &lt;code&gt;CrashLoopBackOff&lt;/code&gt; or two. But here&amp;rsquo;s the uncomfortable truth: &lt;strong&gt;&lt;code&gt;Running&lt;/code&gt; does not mean &lt;code&gt;healthy&lt;/code&gt;&lt;/strong&gt;. A pod can be &amp;ldquo;Running&amp;rdquo; while the app inside is completely broken - a web server listening on the wrong port, an API that hangs on every request, or a process that deadlocked mid-chat.&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/"&gt;Probes&lt;/a&gt; are Kubernetes&amp;rsquo; way of asking your application: &amp;ldquo;are you &lt;em&gt;actually&lt;/em&gt; okay?&amp;rdquo; They come in three flavors:&lt;/p&gt;</description></item><item><title>kubernetes-deployment-rollouts</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-deployment-rollouts/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-deployment-rollouts/</guid><description>&lt;h1 id="rolling-updates"&gt;Rolling Updates&lt;a class="anchor" href="#rolling-updates"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;In the &lt;a href="../kubernetes-deployments-minikube/"&gt;deployments&lt;/a&gt; chapter we saw that a Deployment keeps the right number of pods alive no matter what. And in &lt;a href="../kubernetes-probes/"&gt;probes&lt;/a&gt; we made those pods &lt;em&gt;smart&lt;/em&gt; enough to fail health checks before they take traffic. Now the obvious question: what happens when we want to change the app itself - a new image, a new env var, a bug fix?&lt;/p&gt;&#10;&lt;p&gt;Remember the hydra? A &lt;a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy"&gt;rolling update&lt;/a&gt; is the same trick applied to software versions: we grow new heads &lt;em&gt;while&lt;/em&gt; chopping off the old ones. Users see one consistent service the whole time, and if the new heads turn out to be poisonous, we grow the old ones back.&lt;/p&gt;</description></item><item><title>kubernetes-yaml-configurations</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-yaml-configurations/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-yaml-configurations/</guid><description>&lt;h1 id="yaml-config"&gt;YAML Config&lt;a class="anchor" href="#yaml-config"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;Kubernetes resources are primarily configured using YAML files. We&amp;rsquo;ve used the &lt;code&gt;kubectl edit&lt;/code&gt; command to edit resources in the cluster on-demand, but let&amp;rsquo;s inspect our deployment&amp;rsquo;s YAML file a bit more closely.&lt;/p&gt;&#10;&lt;h2 id="assignment"&gt;Assignment&lt;a class="anchor" href="#assignment"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;First, download a copy of your deployment&amp;rsquo;s YAML file and save it in your current directory:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;kubectl get deployment synergychat-web -o yaml &amp;gt; web-deployment.yaml&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then open it in your text editor. There are 5 top-level fields in the file:&lt;/p&gt;</description></item><item><title>kubernetes-secrets</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-secrets/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-secrets/</guid><description>&lt;h1 id="secrets"&gt;Secrets&lt;a class="anchor" href="#secrets"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;In the &lt;a href="../kubernetes-yaml-configurations/"&gt;YAML config&lt;/a&gt; chapter we saw that ConfigMaps are a great way to manage &lt;em&gt;innocent&lt;/em&gt; environment variables - ports, URLs, feature flags. But we also learned that ConfigMaps are &lt;strong&gt;not&lt;/strong&gt; encrypted, and anyone with access to the cluster can read them.&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://kubernetes.io/docs/concepts/configuration/secret/"&gt;Secrets&lt;/a&gt; are the Kubernetes object designed for sensitive data: passwords, tokens, and keys. Functionally, they look a &lt;em&gt;lot&lt;/em&gt; like ConfigMaps. The differences are:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Values are stored base64-encoded in the object&lt;/li&gt;&#10;&lt;li&gt;Access can be restricted with &lt;a href="../kubernetes-rbac/"&gt;RBAC&lt;/a&gt; (who can read which secrets)&lt;/li&gt;&#10;&lt;li&gt;etcd can be configured to encrypt secret data at rest&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="creating-a-secret"&gt;Creating a Secret&lt;a class="anchor" href="#creating-a-secret"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;The imperative way:&lt;/p&gt;</description></item><item><title>kubernetes-rbac</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-rbac/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-rbac/</guid><description>&lt;h1 id="rbac"&gt;RBAC&lt;a class="anchor" href="#rbac"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;In the &lt;a href="../kubernetes-secrets/"&gt;secrets&lt;/a&gt; chapter we said that secret data &amp;ldquo;can be restricted with RBAC&amp;rdquo;. That was a promise we haven&amp;rsquo;t paid off yet. Let&amp;rsquo;s pay it off.&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/"&gt;RBAC&lt;/a&gt; - Role Based Access Control - answers one question: &lt;em&gt;who&lt;/em&gt; is allowed to do &lt;em&gt;what&lt;/em&gt; to &lt;em&gt;which&lt;/em&gt; objects. It&amp;rsquo;s the bouncer at the club door. Everyone with a &lt;code&gt;kubeconfig&lt;/code&gt; on your laptop is a cluster-admin, which is why it never came up until now. But the moment you hand a namespace to a team, or give an app a token, the bouncer starts working.&lt;/p&gt;</description></item><item><title>kubernetes-jobs-cronjobs</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-jobs-cronjobs/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-jobs-cronjobs/</guid><description>&lt;h1 id="jobs"&gt;Jobs&lt;a class="anchor" href="#jobs"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;Everything we&amp;rsquo;ve deployed so far has been a long-running service. A &lt;a href="../kubernetes-deployments-minikube/"&gt;deployment&lt;/a&gt; promises &amp;ldquo;keep N replicas running at all times&amp;rdquo;. But a lot of real work is the opposite: run once, finish, exit. Think database backups, schema migrations, or batch processing.&lt;/p&gt;&#10;&lt;p&gt;A &lt;a href="https://kubernetes.io/docs/concepts/workloads/controllers/job/"&gt;Job&lt;/a&gt; creates one or more pods and keeps retrying them until the specified number of pods &lt;em&gt;successfully terminate&lt;/em&gt;.&lt;/p&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Deployment&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;Job&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Amaç&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Servis sürekli çalışsın&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;İş tamamlanana kadar çalışsın&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Pod durumu&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;Running&lt;/code&gt; (olması beklenen)&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;code&gt;Completed&lt;/code&gt; (başarı sinyali)&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Çalışma biçimi&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Sonsuz döngü&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Bitince exit code ile biter&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Örnek&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;web, api, crawler&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;migration, backup, batch&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;A minimal job looks like this:&lt;/p&gt;</description></item><item><title>kubernetes-services</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-services/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-services/</guid><description>&lt;h1 id="services"&gt;Services&lt;a class="anchor" href="#services"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;We&amp;rsquo;ve spun up pods and connected to them individually, but that&amp;rsquo;s frankly not super useful if we want to distribute real traffic across those pods. That&amp;rsquo;s where services come in.&lt;/p&gt;&#10;&lt;p&gt;&lt;a href="https://kubernetes.io/docs/concepts/services-networking/service/"&gt;Services&lt;/a&gt; provide a stable endpoint for pods. They are an abstraction used to provide a stable endpoint and load balance traffic across a group of Pods. By &amp;ldquo;stable endpoint&amp;rdquo;, I just mean that the service will always be available at a given URL, even if the pod is destroyed and recreated.&lt;/p&gt;</description></item><item><title>kubernetes-ingress</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-ingress/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-ingress/</guid><description>&lt;h1 id="ingress"&gt;Ingress&lt;a class="anchor" href="#ingress"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;In the &lt;a href="../kubernetes-services/"&gt;services&lt;/a&gt; chapter we promised to talk more about exposing things to the outside world. Time to pay that off too.&lt;/p&gt;&#10;&lt;p&gt;A &lt;code&gt;LoadBalancer&lt;/code&gt; service gives every app its own cloud load balancer and its own public IP. That&amp;rsquo;s fine when you have one app. With three apps, three IPs, three DNS records, three TLS certificates, three bills. What we actually want is one entry point that routes &lt;code&gt;chat.example.com&lt;/code&gt; to the web app and &lt;code&gt;api.example.com&lt;/code&gt; to the API - and gives us HTTPS while it&amp;rsquo;s at it.&lt;/p&gt;</description></item><item><title>kubernetes-gateway-minikube</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-gateway-minikube/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-gateway-minikube/</guid><description>&lt;h1 id="gateway"&gt;Gateway&lt;a class="anchor" href="#gateway"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;A &lt;a href="https://kubernetes.io/docs/concepts/services-networking/gateway/"&gt;Gateway&lt;/a&gt; resource exposes services to the outside world and is used often in production environments. From the docs:&lt;/p&gt;&#10;&lt;blockquote class='book-hint '&gt;&#10;&lt;p&gt;A Gateway describes an instance of traffic handling infrastructure. It defines a network endpoint that can be used for processing traffic, i.e. filtering, balancing, splitting, etc. for backends such as a Service. For example, a Gateway may represent a cloud load balancer or an in-cluster proxy server that is configured to accept HTTP traffic.&lt;/p&gt;&#10;&lt;/blockquote&gt;</description></item><item><title>kubernetes-namespaces</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-namespaces/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-namespaces/</guid><description>&lt;h1 id="namespaces"&gt;Namespaces&lt;a class="anchor" href="#namespaces"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;To quote the &lt;a href="https://www.python.org/dev/peps/pep-0020/"&gt;Zen of Python&lt;/a&gt;:&lt;/p&gt;&#10;&lt;blockquote class='book-hint '&gt;&#10;&lt;p&gt;Namespaces are one honking great idea &amp;ndash; let&amp;rsquo;s do more of those!&lt;/p&gt;&#10;&lt;/blockquote&gt;&lt;p&gt;&lt;a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/"&gt;Namespaces&lt;/a&gt; are a way to isolate cluster resources into groups. They&amp;rsquo;re a bit like directories on your computer, but instead of containing files, they contain Kubernetes objects. As you&amp;rsquo;ve already learned, every resource in Kubernetes has a name. Some of our names include:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;synergychat-api-configmap&lt;/li&gt;&#10;&lt;li&gt;api-service&lt;/li&gt;&#10;&lt;li&gt;api-deployment&lt;/li&gt;&#10;&lt;li&gt;web-deployment&lt;/li&gt;&#10;&lt;li&gt;&amp;hellip;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;You can only use a name once. It is a unique identifier. That&amp;rsquo;s how &lt;code&gt;kubectl apply&lt;/code&gt; knows when it should create a new resource and when it should update an existing one. Namespaces allow us to use the same name for different resources, as long as they&amp;rsquo;re in different namespaces.&lt;/p&gt;</description></item><item><title>kubernetes-dns-coredns</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-dns-coredns/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-dns-coredns/</guid><description>&lt;h1 id="cluster-dns"&gt;Cluster DNS&lt;a class="anchor" href="#cluster-dns"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;In the &lt;a href="../kubernetes-namespaces/"&gt;namespaces&lt;/a&gt; chapter we casually dropped the magic formula &lt;code&gt;&amp;lt;service&amp;gt;.&amp;lt;namespace&amp;gt;.svc.cluster.local&lt;/code&gt; and told you to wire &lt;code&gt;CRAWLER_BASE_URL&lt;/code&gt; with it. It worked, which means &lt;em&gt;something&lt;/em&gt; in the cluster is doing name resolution for us. What is it?&lt;/p&gt;&#10;&lt;p&gt;Kubernetes runs a DNS server inside the cluster and automatically creates a record for every Service. That&amp;rsquo;s why pods can find each other by name instead of by IP - and why pod IPs (which are ephemeral and worthless to hardcode) don&amp;rsquo;t scare anyone.&lt;/p&gt;</description></item><item><title>kubernetes-scaling-vertical</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-scaling-vertical/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-scaling-vertical/</guid><description>&lt;h1 id="top"&gt;Top&lt;a class="anchor" href="#top"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;We&amp;rsquo;ve already learned how to look at logs for k8s pods, but sometimes that&amp;rsquo;s not enough when it comes to debugging. Sometimes we want to know about the &lt;em&gt;resources&lt;/em&gt; that a pod is using.&lt;/p&gt;&#10;&lt;p&gt;To get metrics working, we need to enable the &lt;code&gt;metrics-server&lt;/code&gt; addon. Run:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;minikube addons enable metrics-server&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Take a look inside the &lt;code&gt;kube-system&lt;/code&gt; namespace:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;kubectl -n kube-system get pod&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You should see a new &amp;ldquo;metrics-server&amp;rdquo; pod. &lt;em&gt;It might take a couple of minutes to get started&lt;/em&gt;, but once that pod is ready, you should be able to run:&lt;/p&gt;</description></item><item><title>kubernetes-scaling-horizontal</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-scaling-horizontal/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-scaling-horizontal/</guid><description>&lt;h1 id="horizontal-pod-autoscaling-hpa"&gt;Horizontal Pod Autoscaling (HPA)&lt;a class="anchor" href="#horizontal-pod-autoscaling-hpa"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;A &lt;a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/"&gt;Horizontal Pod Autoscaler&lt;/a&gt; can automatically scale the number of Pods in a Deployment based on observed CPU utilization or other custom metrics. It&amp;rsquo;s very common in a Kubernetes environment to have a low number of pods in a deployment, and then scale up the number of pods automatically as CPU usage increases.&lt;/p&gt;&#10;&lt;h2 id="assignment"&gt;Assignment&lt;a class="anchor" href="#assignment"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;First, delete the &lt;code&gt;replicas: 1&lt;/code&gt; line from the &lt;code&gt;synergychat-testcpu&lt;/code&gt; deployment. This will allow our new autoscaler to have full control over the number of pods.&lt;/p&gt;</description></item><item><title>kubernetes-storage</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-storage/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-storage/</guid><description>&lt;h1 id="storage-in-kubernetes"&gt;Storage in Kubernetes&lt;a class="anchor" href="#storage-in-kubernetes"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;By default, containers running in pods on Kubernetes have access to the filesystem, but as we&amp;rsquo;re about to find out, there are some big limitations to this.&lt;/p&gt;&#10;&lt;h2 id="example"&gt;example&lt;a class="anchor" href="#example"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;The &lt;code&gt;api&lt;/code&gt; application in SynergyChat can be configured to save its data (the messages) to a file on the filesystem. That way, even if the program is restarted, the messages will still be there.&lt;/p&gt;&#10;&lt;p&gt;Update the &lt;code&gt;api&lt;/code&gt; service&amp;rsquo;s ConfigMap to include a new environment variable:&lt;/p&gt;</description></item><item><title>kubernetes-persistent-volumes</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-persistent-volumes/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-persistent-volumes/</guid><description>&lt;h2 id="persistent-volumes-pv"&gt;Persistent Volumes (PV)&lt;a class="anchor" href="#persistent-volumes-pv"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Instead of simply adding a volume to a deployment, a persistent volume is a cluster-level resource that is created separately from the pod and then attached to the pod. It&amp;rsquo;s similar to a ConfigMap in that way.&lt;/p&gt;&#10;&lt;p&gt;PVs can be created statically or dynamically.&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Static PVs are created manually by a cluster admin&lt;/li&gt;&#10;&lt;li&gt;Dynamic PVs are created automatically when a pod requests a volume that doesn&amp;rsquo;t exist yet&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;Generally speaking, and especially in the cloud-native world, we want to use dynamic PVs. It&amp;rsquo;s less work and more flexible.&lt;/p&gt;</description></item><item><title>kubernetes-storage-classes</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-storage-classes/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-storage-classes/</guid><description>&lt;h1 id="storageclasses"&gt;StorageClasses&lt;a class="anchor" href="#storageclasses"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;In the &lt;a href="../kubernetes-persistent-volumes/"&gt;persistent volumes&lt;/a&gt; chapter we created a PVC and a PV just&amp;hellip; appeared. Nobody wrote a &lt;code&gt;PersistentVolume&lt;/code&gt; object. So who decided its size, its disk type, and what happens when we delete it?&lt;/p&gt;&#10;&lt;p&gt;That somebody is a &lt;a href="https://kubernetes.io/docs/concepts/storage/storage-classes/"&gt;StorageClass&lt;/a&gt;. Think of it as a &lt;em&gt;template&lt;/em&gt; for dynamically provisioned volumes: a name a PVC can ask for, plus the recipe the cluster uses to go create a real disk.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;kubectl get storageclass&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Minikube has one called &lt;code&gt;standard&lt;/code&gt; (usually marked &lt;code&gt;default&lt;/code&gt;). Longhorn, if you installed the &lt;a href="../../kubernetes_v2/longhorn/"&gt;longhorn&lt;/a&gt; chapter, adds another. The &lt;code&gt;(default)&lt;/code&gt; annotation is what makes &lt;code&gt;storageClassName&lt;/code&gt; optional in a PVC - leave it out and you get that one.&lt;/p&gt;</description></item><item><title>kubernetes-statefulsets</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-statefulsets/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-statefulsets/</guid><description>&lt;h1 id="statefulsets"&gt;StatefulSets&lt;a class="anchor" href="#statefulsets"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;In &lt;a href="../kubernetes-storage/"&gt;storage&lt;/a&gt; we learned that the filesystem inside a pod is ephemeral, and in &lt;a href="../kubernetes-persistent-volumes/"&gt;persistent volumes&lt;/a&gt; we attached a PVC to keep data alive across pod restarts. But there&amp;rsquo;s one piece of the puzzle missing.&lt;/p&gt;&#10;&lt;p&gt;Deployments treat all their pods as &lt;strong&gt;identical, interchangeable clones&lt;/strong&gt;. &lt;code&gt;synergychat-web-679cbcc6cd-cq6vx&lt;/code&gt; could die at any moment and a fresh &lt;code&gt;synergychat-web-679cbcc6cd-x9k2f&lt;/code&gt; takes its place - nobody cares which is which. That&amp;rsquo;s perfect for web servers and APIs.&lt;/p&gt;&#10;&lt;p&gt;Databases are different. Each instance needs:&lt;/p&gt;</description></item><item><title>kubernetes-nodes-basic</title><link>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-nodes-basic/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://blog.ulutasalperen.com/docs/kubernetes/kubernetes-nodes-basic/</guid><description>&lt;h1 id="nodes"&gt;Nodes&lt;a class="anchor" href="#nodes"&gt;#&lt;/a&gt;&lt;/h1&gt;&#10;&lt;p&gt;We&amp;rsquo;ve talked about how in a production environment, you&amp;rsquo;ll have multiple nodes in your cluster. For this course, we&amp;rsquo;ve been using a single node cluster with &lt;code&gt;minikube&lt;/code&gt;. The nice thing about Kubernetes is that almost everything you do with it is abstracted away from the underlying infrastructure with the &lt;code&gt;kubectl&lt;/code&gt; CLI.&lt;/p&gt;&#10;&lt;p&gt;All the commands we&amp;rsquo;ve been using locally will work the same way on a production cluster.&lt;/p&gt;&#10;&lt;h2 id="ways-to-deploy-to-production"&gt;Ways to Deploy to Production&lt;a class="anchor" href="#ways-to-deploy-to-production"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;There are several popular ways to deploy a Kubernetes cluster to production:&lt;/p&gt;</description></item></channel></rss>