{"id":2948,"date":"2024-08-24T15:29:35","date_gmt":"2024-08-24T14:29:35","guid":{"rendered":"https:\/\/contentlabstudy.com\/soft\/?p=2948"},"modified":"2026-09-24T21:16:07","modified_gmt":"2026-09-24T20:16:07","slug":"kubernetes-deployment","status":"publish","type":"post","link":"https:\/\/contentlabstudy.com\/soft\/kubernetes-deployment\/","title":{"rendered":"Kubernetes Deployment"},"content":{"rendered":"<p><strong>Kubernetes<\/strong> runs containers across machines: you declare a desired state, the control plane tries to make it true. Use it when you have several services, need rolling updates and isolation, and can pay the operational tax. A single ASP.NET app on one VM does not need a cluster.<\/p>\n<h2>Objects you actually touch<\/h2>\n<ul>\n<li><strong>Deployment<\/strong> (the usual workload): replica count, image, rolling update. Other workloads: StatefulSet, DaemonSet, Job.<\/li>\n<li><strong>Pod:<\/strong> one or more containers, ephemeral. Do not treat a pod as a pet.<\/li>\n<li><strong>Service:<\/strong> stable DNS and a selector. ClusterIP default; LoadBalancer at the edge of a cloud.<\/li>\n<li><strong>Ingress \/ Gateway:<\/strong> HTTP routing and TLS. Ingress is still common; Gateway API is the successor direction.<\/li>\n<li><strong>ConfigMap \/ Secret:<\/strong> config vs sensitive config. Secrets are still base64, not magic encryption, unless you add a provider.<\/li>\n<li><strong>Probe:<\/strong> liveness vs readiness vs startup \u2014 mixing them causes kill loops.<\/li>\n<\/ul>\n<h2>A deploy<\/h2>\n<p>CI builds an image tagged with the git SHA (not only <code>latest<\/code>). The Deployment\u2019s image field changes; ReplicaSet rolls. Health checks must fail when the app cannot serve (not just when the process is up). Resource requests\/limits: without them, noisy neighbors; with cartoon limits, throttling you will blame on \u201ck8s.\u201d<\/p>\n<h2>Example<\/h2>\n<p>Liveness answers \u201cis the process up?\u201d Readiness answers \u201ccan this pod take traffic?\u201d Readiness may fail when the database is unreachable. Liveness must not.<\/p>\n<pre><code>livenessProbe:\n  httpGet:\n    path: \/healthz\n    port: 8080\nreadinessProbe:\n  httpGet:\n    path: \/ready\n    port: 8080<\/code><\/pre>\n<h2>What breaks it<\/h2>\n<p>Liveness calls <code>\/ready<\/code>, and <code>\/ready<\/code> checks the database. A database blip restarts every pod, which makes the database worse.<\/p>\n<pre><code>livenessProbe:\n  httpGet:\n    path: \/ready\n    port: 8080<\/code><\/pre>\n<h2>Pitfalls<\/h2>\n<ul>\n<li>Latest tag, no digest, no rollback.<\/li>\n<li>One giant cluster, no namespaces or NetworkPolicies, everyone is cluster-admin.<\/li>\n<li>Storing prod data only on an emptyDir.<\/li>\n<\/ul>\n<p>Laptop cluster: <a href=\"\/soft\/local-kubernetes\/\">Local Kubernetes<\/a>. Traffic from outside: <a href=\"\/soft\/local-kubernetes-with-load-balancer\/\">load balancer<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kubernetes runs containers across machines: you declare a desired state, the control plane tries to make it true. Use it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[13],"tags":[],"class_list":["post-2948","post","type-post","status-publish","format-standard","hentry","category-software-deployment"],"_links":{"self":[{"href":"https:\/\/contentlabstudy.com\/soft\/wp-json\/wp\/v2\/posts\/2948","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contentlabstudy.com\/soft\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/contentlabstudy.com\/soft\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/contentlabstudy.com\/soft\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/contentlabstudy.com\/soft\/wp-json\/wp\/v2\/comments?post=2948"}],"version-history":[{"count":4,"href":"https:\/\/contentlabstudy.com\/soft\/wp-json\/wp\/v2\/posts\/2948\/revisions"}],"predecessor-version":[{"id":3241,"href":"https:\/\/contentlabstudy.com\/soft\/wp-json\/wp\/v2\/posts\/2948\/revisions\/3241"}],"wp:attachment":[{"href":"https:\/\/contentlabstudy.com\/soft\/wp-json\/wp\/v2\/media?parent=2948"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/contentlabstudy.com\/soft\/wp-json\/wp\/v2\/categories?post=2948"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/contentlabstudy.com\/soft\/wp-json\/wp\/v2\/tags?post=2948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}