Files
skills/public/cloud-kubernetes-deployment.html
zeekayandHanzo Dev 9e10c1c10e Each llms index points at the other two
hanzoskills.com/llms.txt now opens with the install line, the API
reference index and the company index, so an agent that lands on any
one of the three can find the rest.

robots.txt claimed 537 documents while llms.txt counts 920. The number
is gone from robots.txt; llms.txt derives it.

public/ is regenerated from scripts/site.py, which it had fallen
behind: the copy-prompt menu and agent bar were in the generator and
not in the committed pages. tests/site.mjs passes against the result.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-11 00:27:59 -07:00

623 lines
32 KiB
HTML

<!doctype html>
<html lang="en"><head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>cloud-kubernetes-deployment</title>
<meta name="color-scheme" content="dark">
<style>
/* Committed to one visual world: a dark instrument panel. No light variant —
the dot field and the hairline rules only read on black, and a naive
inversion would wash both out. Every colour is painted explicitly so the page
never borrows a host background. */
@font-face{font-family:'Zen';src:url('/fonts/Zen-Variable.woff2') format('woff2');font-weight:100 900;font-style:normal;font-display:swap}
@font-face{font-family:'Zen';src:url('/fonts/Zen-Italic-Variable.woff2') format('woff2');font-weight:100 900;font-style:italic;font-display:swap}
@font-face{font-family:'Zen Mono';src:url('/fonts/ZenMono-Variable.woff2') format('woff2');font-weight:100 900;font-style:normal;font-display:swap}
@font-face{font-family:'Zen Mono';src:url('/fonts/ZenMono-Italic-Variable.woff2') format('woff2');font-weight:100 900;font-style:italic;font-display:swap}
@font-face{font-family:'Zen Pixel Square';src:url('/fonts/ZenPixel-Square.woff2') format('woff2');font-style:normal;font-display:swap}
:root{
--ink:#f4f4f2; --soft:#9c9c98; --faint:#6a6a66; --ground:#000; --panel:#0a0a0a;
--line:#232323; --line-hi:#3a3a3a; --accent:#f4f4f2;
--font-zen-sans:'Zen',-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;
--font-zen-mono:'Zen Mono',ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
--font-zen-pixel-square:'Zen Pixel Square',monospace;
--mono:var(--font-zen-mono);
--sans:var(--font-zen-sans);
/* Controls are pills and surfaces are soft, as on hanzo.ai. */
--r:999px; --r-soft:14px;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--ground);color:var(--ink);font-family:var(--sans);
font-size:16px;line-height:1.65;-webkit-font-smoothing:antialiased}
.wrap{max-width:60rem;margin:0 auto;padding:0 1.75rem}
/* The dot field. A halftone made of one repeating radial-gradient, faded out
along the diagonal by a mask so it reads as a wave rather than wallpaper. */
/* No overflow clip here: the dot field is inset to the box already, and a clip
would cut off the copy-prompt menu. */
.hero{position:relative;border-bottom:1px solid var(--line)}
.hero::before{content:"";position:absolute;inset:0;
background-image:radial-gradient(var(--line-hi) 1px, transparent 1px);
background-size:7px 7px;
-webkit-mask-image:linear-gradient(115deg,#000 0%,rgba(0,0,0,.55) 38%,transparent 72%);
mask-image:linear-gradient(115deg,#000 0%,rgba(0,0,0,.55) 38%,transparent 72%);
pointer-events:none}
.hero .wrap{position:relative;padding-top:5.5rem;padding-bottom:4rem}
nav{border-bottom:1px solid var(--line)}
nav .in{max-width:60rem;margin:0 auto;padding:1.1rem 1.75rem;display:flex;
justify-content:space-between;align-items:center;gap:1rem}
.brand{font-family:var(--mono);font-size:.85rem;letter-spacing:.14em;
text-transform:uppercase;color:var(--ink);text-decoration:none;
display:inline-flex;align-items:center;gap:.6rem}
.brand i{font-style:normal;color:var(--faint)}
.mark{width:1.15em;height:1.15em;display:block;flex:0 0 auto}
nav a.up{font-family:var(--mono);font-size:.72rem;letter-spacing:.14em;
text-transform:uppercase;color:var(--soft);text-decoration:none}
nav a.up:hover{color:var(--ink)}
h1{font-family:var(--mono);font-size:clamp(2rem,5.4vw,3.4rem);line-height:1.12;
letter-spacing:-.02em;margin:0 0 1.1rem;font-weight:500;text-wrap:balance}
h1 em{font-style:normal;color:var(--faint)}
.lede{color:var(--soft);font-size:1.05rem;max-width:52ch;margin:0 0 2.25rem}
.btns{display:flex;flex-wrap:wrap;gap:.7rem;margin:0 0 .5rem;align-items:center}
.btn{display:inline-flex;align-items:center;gap:.5rem;font-family:var(--mono);
font-size:.72rem;letter-spacing:.14em;text-transform:uppercase;
padding:.8rem 1.4rem;border:1px solid var(--line-hi);border-radius:var(--r);
color:var(--ink);text-decoration:none;background:transparent;cursor:pointer;
line-height:1.2;font-weight:400}
.btn:hover{background:#141414;text-decoration:none;border-color:var(--soft)}
.btn.solid{background:var(--ink);color:#000;border-color:var(--ink)}
.btn.solid:hover{background:#d8d8d4}
.btn .chev{width:.7em;height:.7em;flex:0 0 auto;transition:transform .15s ease}
.btn[aria-expanded="true"] .chev{transform:rotate(180deg)}
/* Copy-prompt selector. Each row copies the prompt for its own target. */
.copy{position:relative;display:inline-flex}
.menu{position:absolute;top:calc(100% + .5rem);left:0;z-index:20;min-width:21rem;
background:var(--panel);border:1px solid var(--line-hi);border-radius:var(--r-soft);
padding:.4rem;display:flex;flex-direction:column;
box-shadow:0 12px 32px rgba(0,0,0,.75)}
.menu[hidden]{display:none}
.mi{display:flex;align-items:center;gap:.7rem;width:100%;text-align:left;
padding:.62rem .8rem;border:0;border-radius:calc(var(--r-soft) - .35rem);
background:transparent;color:var(--ink);font-family:var(--mono);font-size:.76rem;
letter-spacing:.04em;text-decoration:none;cursor:pointer;line-height:1.3;
white-space:nowrap}
.mi:hover,.mi:focus-visible{background:#181818;outline:none}
.mi .mark{width:1.05rem;height:1.05rem;color:var(--soft)}
.mi:hover .mark{color:var(--ink)}
.mi u{margin-left:auto;color:var(--faint);text-decoration:none;font-size:.68rem;
letter-spacing:.1em;text-transform:uppercase}
/* Works-with bar: one scrolling row, name and mark per agent. */
.strip{border-bottom:1px solid var(--line);background:var(--panel)}
.strip .in{max-width:60rem;margin:0 auto;padding:.9rem 1.75rem;display:flex;
align-items:center;gap:1.25rem;font-family:var(--mono);font-size:.72rem;
letter-spacing:.1em;text-transform:uppercase;color:var(--faint)}
.strip b{color:var(--soft);font-weight:400;flex:0 0 auto;
border-right:1px solid var(--line);padding-right:1.25rem;align-self:stretch;
display:flex;align-items:center}
.bar{display:flex;align-items:center;gap:.5rem;flex:1 1 auto;min-width:0;
overflow-x:auto;scrollbar-width:none;scroll-snap-type:x proximity;
-webkit-overflow-scrolling:touch;
-webkit-mask-image:linear-gradient(90deg,#000 calc(100% - 3rem),transparent);
mask-image:linear-gradient(90deg,#000 calc(100% - 3rem),transparent)}
.bar::-webkit-scrollbar{display:none}
.agent{display:inline-flex;align-items:center;gap:.45rem;flex:0 0 auto;
padding:.4rem .85rem;border:1px solid var(--line);border-radius:var(--r);
color:var(--soft);white-space:nowrap;scroll-snap-align:start;
text-decoration:none;background:var(--ground)}
.agent:hover{color:var(--ink);border-color:var(--line-hi);text-decoration:none}
.agent .mark{width:.95rem;height:.95rem}
h2{font-family:var(--mono);font-size:1.1rem;letter-spacing:-.01em;margin:2.75rem 0 .75rem;font-weight:500}
h3{font-size:1rem;margin:2rem 0 .5rem;font-weight:600}
h4,h5,h6{font-size:.94rem;margin:1.5rem 0 .5rem;font-weight:600}
p{margin:0 0 1rem;max-width:70ch}
ul,ol{margin:0 0 1rem;padding-left:1.35rem;max-width:70ch}
li{margin:.22rem 0}
a{color:var(--ink);text-decoration:underline;text-underline-offset:3px;
text-decoration-color:var(--line-hi)}
a:hover{text-decoration-color:var(--ink)}
a:focus-visible{outline:1px solid var(--ink);outline-offset:3px}
code{font-family:var(--mono);font-size:.85em;background:var(--panel);
border:1px solid var(--line);border-radius:5px;padding:.1em .36em}
pre{background:var(--panel);border:1px solid var(--line);padding:1rem 1.1rem;
border-radius:var(--r-soft);overflow-x:auto;margin:0 0 1.25rem}
pre code{background:none;border:0;padding:0;font-size:.82rem;line-height:1.7}
blockquote{margin:0 0 1rem;padding-left:1rem;border-left:1px solid var(--line-hi);color:var(--soft)}
hr{border:0;border-top:1px solid var(--line);margin:2.5rem 0}
table{border-collapse:collapse;width:100%;margin:0 0 1.25rem;font-size:.92rem;
display:block;overflow-x:auto}
th,td{border:1px solid var(--line);padding:.5rem .7rem;text-align:left}
.curl{display:block;background:var(--panel);border:1px solid var(--line);
border-radius:var(--r-soft);padding:.95rem 1.1rem;font-family:var(--mono);
font-size:.8rem;color:var(--soft);overflow-x:auto;margin:0 0 2.5rem;
white-space:pre;line-height:1.9}
.curl b{color:var(--ink);font-weight:400}
.curl i{font-style:normal;color:var(--faint)}
/* index */
#q{width:100%;padding:.85rem 1.2rem;font-family:var(--mono);font-size:.85rem;color:var(--ink);
background:var(--panel);border:1px solid var(--line);border-radius:var(--r);margin:0 0 .6rem}
#q::placeholder{color:var(--faint);text-transform:uppercase;letter-spacing:.1em;font-size:.72rem}
#q:focus{outline:none;border-color:var(--soft)}
#count{color:var(--faint);font-family:var(--mono);font-size:.72rem;letter-spacing:.1em;
text-transform:uppercase;margin:0 0 2rem}
.cat{margin:2.5rem 0 .5rem;font-family:var(--mono);font-size:.7rem;letter-spacing:.16em;
text-transform:uppercase;color:var(--faint);border-bottom:1px solid var(--line);
padding-bottom:.45rem}
.row{display:block;padding:.6rem .9rem;margin:0 -.9rem;border-bottom:1px solid var(--line);
border-radius:var(--r-soft);text-decoration:none}
.row:hover{background:#0a0a0a}
.nm{font-family:var(--mono);font-size:.84rem;color:var(--ink);display:block}
.ds{color:var(--soft);font-size:.9rem;display:block;margin-top:.12rem}
footer{margin-top:4rem;padding:2rem 0 4rem;border-top:1px solid var(--line);
color:var(--faint);font-size:.85rem}
footer a{color:var(--soft)}
.fmap{display:grid;gap:1.75rem;grid-template-columns:repeat(auto-fit,minmax(11rem,1fr));
margin:0 0 2rem;font-size:.85rem}
.fmap b{display:block;font-family:var(--mono);font-size:.68rem;letter-spacing:.16em;
text-transform:uppercase;color:var(--faint);font-weight:400;margin:0 0 .6rem;
border-bottom:1px solid var(--line);padding-bottom:.4rem}
.fmap a{display:inline-block;color:var(--ink);text-decoration:none;margin:.3rem .35rem 0 0}
.fmap a:hover{text-decoration:underline}
.fmap div{color:var(--faint);line-height:1.5}
.fend{border-top:1px solid var(--line);padding-top:1.25rem;font-size:.82rem}
@media (max-width:640px){
.hero .wrap{padding-top:3.25rem;padding-bottom:2.75rem}
.btns{gap:.5rem}
.btn{padding:.75rem 1.15rem;font-size:.68rem}
.copy,.copy .btn{width:100%;justify-content:center}
.menu{left:0;right:0;min-width:0}
.strip .in{flex-direction:column;align-items:flex-start;gap:.6rem;padding:.9rem 1.75rem}
.strip b{border-right:0;padding-right:0}
.bar{width:100%}
}
</style>
<link rel="alternate" type="text/markdown" href="/cloud-kubernetes-deployment.md">
<link rel="icon" href="/favicon.svg">
<link rel="canonical" href="https://hanzoskills.com/cloud-kubernetes-deployment">
</head>
<!-- Reading this with a machine? Every page here is also plain markdown.
This one: https://hanzoskills.com/cloud-kubernetes-deployment.md
Index: https://hanzoskills.com/llms.txt
Corpus: https://hanzoskills.com/all.md
Append .md to any path for the markdown twin. -->
<body>
<nav><div class="in">
<a class="brand" href="/"><svg class="mark" viewBox="0 0 67 67" fill="currentColor" aria-hidden="true"><path d="M22.21 67V44.6369H0V67H22.21Z"/><path d="M66.7038 22.3184H22.2534L0.0878906 44.6367H44.4634L66.7038 22.3184Z"/><path d="M22.21 0H0V22.3184H22.21V0Z"/><path d="M66.7198 0H44.5098V22.3184H66.7198V0Z"/><path d="M66.7198 67V44.6369H44.5098V67H66.7198Z"/></svg> HANZO<i>SKILLS</i></a>
<a class="up" href="/">All skills</a>
</div></nav>
<div class="wrap">
<h1>cloud-kubernetes-deployment</h1><p class="lede">Deploy and manage applications on Kubernetes with production best practices</p><h1>Kubernetes Deployment</h1>
<p>Deploy and manage containerized applications on Kubernetes with production best practices for high availability, security, and scalability.</p>
<h2>Hanzo Production Reality (read first)</h2>
<p>For Hanzo/Lux services this generic skill is background knowledge only — deployment is prescribed by HIP-0117 (one binary, three modes) and the operator. See <code>skills/hanzo-cloud-architecture/SKILL.md</code>.</p>
<ol><li><strong><code>cloud serve</code></strong> — single process, NO Kubernetes. The whole cloud</li></ol>
<p> (IAM, KMS, o11y, tasks, console, ...) in one binary with per-tenant SQLite. This is local dev and single-node/edge production.</p>
<ol><li><strong><code>cloud cluster init</code></strong> — the binary fetches k3s, bootstraps the</li></ol>
<p> cluster, installs the operator, and hands reconciliation to <code>services.hanzo.ai</code> CRs. Devs do NOT hand-write Deployments; the operator reconciles CRs. (Decided per HIP-0117; staged.)</p>
<ol><li><strong><code>helm install cloud ./helm/cloud</code></strong> — BYO Kubernetes, same image.</li></ol>
<p>Rules that override the generic advice below:</p>
<ul><li>You deploy by editing a <code>services.hanzo.ai</code> CR (or universe manifests),</li></ul>
<p> never by <code>kubectl create deployment</code>.</p>
<ul><li>CI/CD is Gitea Actions on git.hanzo.ai (GH-Actions-compatible workflows on</li></ul>
<p> our runners); GitHub is the OSS mirror. Never build images locally.</p>
<ul><li>Images: <code>ghcr.io/hanzoai/<em></code> (Hanzo) / <code>ghcr.io/luxfi/</em></code> (Lux) — never mix.</li><li>Secrets come from KMS (KMSSecret CRDs), never plain K8s Secrets in manifests.</li><li>Ingress is <code>hanzoai/ingress</code> — no nginx, no caddy.</li><li>8 Kubernetes clusters are operated; visor autoscales fleets across</li></ul>
<p> providers (BYO provider).</p>
<h2>Overview</h2>
<p>This skill covers Kubernetes deployment strategies, including:</p>
<ul><li><strong>Pod and Deployment Management</strong>: Creating and managing workloads</li><li><strong>Service Discovery</strong>: Exposing and accessing applications</li><li><strong>Rolling Updates</strong>: Zero-downtime deployments and rollbacks</li><li><strong>Resource Management</strong>: CPU, memory, and storage configuration</li><li><strong>Health Checks</strong>: Liveness, readiness, and startup probes</li><li><strong>Configuration</strong>: ConfigMaps, Secrets, and environment management</li><li><strong>Networking</strong>: Services, Ingress, and NetworkPolicies</li><li><strong>Security</strong>: RBAC, Pod Security Standards, security contexts</li><li><strong>Autoscaling</strong>: HPA, VPA, and cluster autoscaling</li><li><strong>GitOps</strong>: ArgoCD and Flux workflows</li><li><strong>Helm</strong>: Package management and templating</li></ul>
<h2>When to Use</h2>
<ul><li>Deploying containerized applications to Kubernetes</li><li>Managing application lifecycle in Kubernetes</li><li>Implementing CI/CD for Kubernetes deployments</li><li>Setting up production-ready Kubernetes workloads</li><li>Troubleshooting Kubernetes deployments</li><li>Migrating applications to Kubernetes</li></ul>
<h2>Prerequisites</h2>
<ul><li>Docker and containerization basics</li><li>YAML syntax</li><li>Basic networking concepts</li><li>Command-line proficiency</li><li>Access to a Kubernetes cluster (or local testing with kind/minikube)</li></ul>
<h2>Key Concepts</h2>
<h3>Kubernetes Resources</h3>
<p><strong>Workloads:</strong></p>
<ul><li><strong>Pod</strong>: Smallest deployable unit (one or more containers)</li><li><strong>Deployment</strong>: Manages ReplicaSets for stateless apps</li><li><strong>StatefulSet</strong>: Manages stateful workloads with stable identities</li><li><strong>DaemonSet</strong>: Runs pods on all (or selected) nodes</li><li><strong>Job/CronJob</strong>: Batch processing and scheduled tasks</li></ul>
<p><strong>Services:</strong></p>
<ul><li><strong>ClusterIP</strong>: Internal cluster communication</li><li><strong>NodePort</strong>: Expose on node IPs</li><li><strong>LoadBalancer</strong>: Cloud provider load balancer</li><li><strong>Ingress</strong>: HTTP/HTTPS routing</li></ul>
<p><strong>Configuration:</strong></p>
<ul><li><strong>ConfigMap</strong>: Non-sensitive configuration data</li><li><strong>Secret</strong>: Sensitive data (base64 encoded)</li><li><strong>PersistentVolume/PVC</strong>: Storage management</li></ul>
<p><strong>Security:</strong></p>
<ul><li><strong>ServiceAccount</strong>: Pod identity</li><li><strong>Role/ClusterRole</strong>: RBAC permissions</li><li><strong>NetworkPolicy</strong>: Pod network isolation</li><li><strong>PodSecurityPolicy/Standards</strong>: Pod security controls</li></ul>
<h3>Deployment Strategies</h3>
<p><strong>Rolling Update (Default):</strong></p>
<ul><li>Gradual replacement of old pods with new ones</li><li>Zero downtime</li><li>Configurable with maxSurge and maxUnavailable</li></ul>
<p><strong>Recreate:</strong></p>
<ul><li>Delete all old pods before creating new ones</li><li>Causes downtime</li><li>Useful when incompatible versions can&#x27;t coexist</li></ul>
<p><strong>Canary:</strong></p>
<ul><li>Deploy new version to small subset</li><li>Monitor metrics before full rollout</li><li>Manual traffic splitting</li></ul>
<p><strong>Blue-Green:</strong></p>
<ul><li>Deploy new version alongside old</li><li>Switch traffic all at once</li><li>Easy rollback</li></ul>
<h2>Basic Usage</h2>
<h3>Create Deployment</h3>
<pre><code class="lang-bash"># From command line
kubectl create deployment web --image=nginx:1.25 --replicas=3
# From YAML
kubectl apply -f deployment.yaml</code></pre>
<p><strong>deployment.yaml:</strong></p>
<pre><code class="lang-yaml">apiVersion: apps/v1
kind: Deployment
metadata:
name: web
spec:
replicas: 3
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: nginx
image: nginx:1.25
ports:
- containerPort: 80
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 200m
memory: 256Mi</code></pre>
<h3>Expose with Service</h3>
<pre><code class="lang-bash"># Create service
kubectl expose deployment web --port=80 --type=LoadBalancer
# From YAML
kubectl apply -f service.yaml</code></pre>
<p><strong>service.yaml:</strong></p>
<pre><code class="lang-yaml">apiVersion: v1
kind: Service
metadata:
name: web
spec:
selector:
app: web
ports:
- port: 80
targetPort: 80
type: LoadBalancer</code></pre>
<h3>Update Deployment</h3>
<pre><code class="lang-bash"># Update image
kubectl set image deployment/web nginx=nginx:1.26
# Edit deployment
kubectl edit deployment/web
# Apply changes from file
kubectl apply -f deployment.yaml
# Monitor rollout
kubectl rollout status deployment/web</code></pre>
<h3>Rollback Deployment</h3>
<pre><code class="lang-bash"># View history
kubectl rollout history deployment/web
# Rollback to previous version
kubectl rollout undo deployment/web
# Rollback to specific revision
kubectl rollout undo deployment/web --to-revision=2</code></pre>
<h2>Advanced Patterns</h2>
<h3>Production-Ready Deployment</h3>
<pre><code class="lang-yaml">apiVersion: apps/v1
kind: Deployment
metadata:
name: api
labels:
app: api
version: v1
spec:
replicas: 3
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
selector:
matchLabels:
app: api
template:
metadata:
labels:
app: api
version: v1
spec:
serviceAccountName: api
securityContext:
runAsNonRoot: true
runAsUser: 1000
fsGroup: 2000
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- api
topologyKey: kubernetes.io/hostname
containers:
- name: api
image: myapp/api:v1.0.0
ports:
- name: http
containerPort: 8080
env:
- name: DB_HOST
valueFrom:
configMapKeyRef:
name: api-config
key: db.host
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: api-secrets
key: db.password
resources:
requests:
cpu: 500m
memory: 512Mi
limits:
cpu: 2
memory: 2Gi
startupProbe:
httpGet:
path: /healthz/startup
port: http
periodSeconds: 10
failureThreshold: 30
livenessProbe:
httpGet:
path: /healthz/live
port: http
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /healthz/ready
port: http
periodSeconds: 5
failureThreshold: 3
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- ALL
volumeMounts:
- name: tmp
mountPath: /tmp
volumes:
- name: tmp
emptyDir: {}</code></pre>
<h3>Horizontal Pod Autoscaler</h3>
<pre><code class="lang-yaml">apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: api-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: api
minReplicas: 3
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80</code></pre>
<h3>ConfigMap and Secret</h3>
<pre><code class="lang-yaml"># ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: api-config
data:
db.host: &quot;postgres.default.svc.cluster.local&quot;
db.port: &quot;5432&quot;
app.yaml: |
server:
port: 8080
timeout: 30s
---
# Secret
# ❌ BAD: Hardcoded credentials - example only, never do this in production
# In production, use sealed-secrets, external-secrets-operator, or your cloud provider&#x27;s secret management
apiVersion: v1
kind: Secret
metadata:
name: api-secrets
type: Opaque
stringData:
db.password: &quot;changeme123&quot; # Example only - use secret management in production
api.key: &quot;secret-api-key&quot; # Example only - use secret management in production</code></pre>
<h2>Common Commands</h2>
<pre><code class="lang-bash"># Get resources
kubectl get deployments
kubectl get pods
kubectl get services
kubectl get all
# Describe resource
kubectl describe deployment web
kubectl describe pod web-abc123
# View logs
kubectl logs deployment/web
kubectl logs -f pod/web-abc123 # Follow logs
kubectl logs pod/web-abc123 --previous # Previous container
# Execute commands in pod
kubectl exec -it pod/web-abc123 -- /bin/sh
# Port forwarding
kubectl port-forward deployment/web 8080:80
# Scale deployment
kubectl scale deployment/web --replicas=5
# Delete resources
kubectl delete deployment web
kubectl delete -f deployment.yaml</code></pre>
<h2>Troubleshooting</h2>
<h3>Pod Not Starting</h3>
<pre><code class="lang-bash"># Check pod status
kubectl get pods
kubectl describe pod &lt;pod-name&gt;
# Common issues:
# - ImagePullBackOff: Check image name and registry credentials
# - CrashLoopBackOff: Check logs for application errors
# - Pending: Check resource availability and node constraints
# View events
kubectl get events --sort-by=&#x27;.lastTimestamp&#x27;
# Check logs
kubectl logs &lt;pod-name&gt;</code></pre>
<h3>Service Not Accessible</h3>
<pre><code class="lang-bash"># Check service and endpoints
kubectl get service web
kubectl get endpoints web
# Test DNS
kubectl run -it --rm debug --image=busybox --restart=Never -- nslookup web
# Test connectivity
kubectl run -it --rm debug --image=curlimages/curl --restart=Never -- curl http://web</code></pre>
<h3>Deployment Not Rolling Out</h3>
<pre><code class="lang-bash"># Check rollout status
kubectl rollout status deployment/web
# View deployment events
kubectl describe deployment web
# Check replica sets
kubectl get rs -l app=web
# Pause and resume
kubectl rollout pause deployment/web
kubectl rollout resume deployment/web</code></pre>
<h2>Best Practices</h2>
<h3>Resource Management</h3>
<ul><li>Always set resource requests and limits</li><li>Use appropriate QoS class (Guaranteed for critical workloads)</li><li>Monitor actual usage and adjust accordingly</li></ul>
<h3>Health Checks</h3>
<ul><li>Always define readiness probes</li><li>Use startup probes for slow-starting applications</li><li>Keep probe endpoints lightweight</li></ul>
<h3>Security</h3>
<ul><li>Run as non-root user</li><li>Use read-only root filesystem</li><li>Drop all capabilities unless needed</li><li>Implement NetworkPolicies</li><li>Use RBAC with least privilege</li><li>Scan images for vulnerabilities</li></ul>
<h3>High Availability</h3>
<ul><li>Run multiple replicas (minimum 3 for critical services)</li><li>Use pod anti-affinity to spread across nodes/zones</li><li>Define PodDisruptionBudgets</li><li>Use topology spread constraints</li></ul>
<h3>Configuration</h3>
<ul><li>Externalize configuration with ConfigMaps/Secrets</li><li>Use immutable ConfigMaps/Secrets in production</li><li>Never commit secrets to Git</li><li>Version configuration with application</li></ul>
<h3>Deployment</h3>
<ul><li>Use specific image tags (never :latest)</li><li>Implement gradual rollouts (canary/blue-green)</li><li>Monitor during rollout</li><li>Have rollback plan</li><li>Test in staging first</li></ul>
<h2>Related Skills</h2>
<ul><li><code>containers-docker</code>: Container fundamentals</li><li><code>cloud-aws-eks</code>: AWS Kubernetes service</li><li><code>cloud-gcp-gke</code>: Google Kubernetes Engine</li><li><code>observability-prometheus</code>: Metrics collection</li><li><code>cicd-github-actions</code>: CI/CD automation</li><li><code>infrastructure-terraform</code>: Infrastructure as Code</li></ul>
<h2>Level 3: Resources</h2>
<p>Comprehensive resources for Kubernetes deployment are available in the <code>resources/</code> directory:</p>
<h3>Reference Material</h3>
<p><strong><code>resources/REFERENCE.md</code></strong> (1,800+ lines) Complete reference covering:</p>
<ul><li>Kubernetes architecture and fundamentals</li><li>Pod lifecycle and multi-container patterns</li><li>Deployment strategies and rollout management</li><li>Service networking and discovery</li><li>Resource management and QoS</li><li>Health checks configuration</li><li>ConfigMaps and Secrets management</li><li>Persistent storage (PVs, PVCs, StorageClasses)</li><li>Networking (Services, Ingress, NetworkPolicies)</li><li>Security (RBAC, Pod Security Standards, security contexts)</li><li>Autoscaling (HPA, VPA, Cluster Autoscaler)</li><li>GitOps patterns (ArgoCD, Flux)</li><li>Helm charts and package management</li><li>Production best practices</li><li>Troubleshooting guide</li><li>Common pitfalls and anti-patterns</li></ul>
<h3>Executable Scripts</h3>
<p><strong><code>resources/scripts/validate_manifests.py</code></strong> Validate Kubernetes YAML manifests for correctness and best practices:</p>
<ul><li>YAML syntax validation</li><li>Kubernetes API schema compliance</li><li>Security best practices checks</li><li>Resource configuration validation</li><li>Common misconfiguration detection</li><li>kubectl dry-run validation</li><li>JSON and colored output options</li></ul>
<pre><code class="lang-bash"># Validate single file
./validate_manifests.py deployment.yaml
# Validate directory
./validate_manifests.py --strict manifests/
# JSON output
./validate_manifests.py --json deployment.yaml</code></pre>
<p><strong><code>resources/scripts/analyze_deployment.py</code></strong> Analyze deployments for issues and optimization opportunities:</p>
<ul><li>Configuration issue detection</li><li>Security vulnerability scanning</li><li>Resource optimization recommendations</li><li>High availability concerns</li><li>Production readiness assessment</li><li>Live cluster analysis support</li></ul>
<pre><code class="lang-bash"># Analyze file
./analyze_deployment.py deployment.yaml
# Analyze live cluster
./analyze_deployment.py --cluster --namespace production
# JSON output
./analyze_deployment.py --json --cluster</code></pre>
<p><strong><code>resources/scripts/test_deployment.sh</code></strong> Test deployments in local Kubernetes cluster:</p>
<ul><li>Creates test cluster (kind/minikube)</li><li>Deploys manifests</li><li>Validates rollout</li><li>Runs health checks</li><li>Executes smoke tests</li><li>Automatic cleanup</li></ul>
<pre><code class="lang-bash"># Test with kind
./test_deployment.sh deployment.yaml
# Test with minikube
./test_deployment.sh --provider minikube manifests/
# Keep cluster for debugging
./test_deployment.sh --no-cleanup deployment.yaml</code></pre>
<h3>Examples</h3>
<p><strong><code>resources/examples/manifests/basic-deployment/</code></strong> Simple deployment example:</p>
<ul><li>Basic Deployment with nginx</li><li>ClusterIP Service</li><li>Minimal configuration for learning</li></ul>
<p><strong><code>resources/examples/manifests/production-deployment/</code></strong> Production-ready deployment:</p>
<ul><li>Full Deployment with all best practices</li><li>LoadBalancer Service with annotations</li><li>ConfigMap and Secret management</li><li>HorizontalPodAutoscaler</li><li>PodDisruptionBudget</li><li>Security contexts and RBAC</li><li>Multi-container patterns</li><li>Health checks and lifecycle hooks</li></ul>
<p><strong><code>resources/examples/helm/sample-chart/</code></strong> Complete Helm chart structure:</p>
<ul><li>Chart.yaml with metadata and dependencies</li><li>values.yaml with sensible defaults</li><li>Templates for all resources</li><li>Helper templates (_helpers.tpl)</li><li>Configurable security and resources</li></ul>
<p><strong><code>resources/examples/kustomize/</code></strong> Kustomize overlays for environments:</p>
<ul><li><code>base/</code>: Base manifests</li><li><code>overlays/dev/</code>: Development environment customizations</li><li><code>overlays/prod/</code>: Production environment customizations</li><li>Demonstrates patching and configuration management</li></ul>
<p><strong><code>resources/examples/cicd/github-actions-deploy.yml</code></strong> Complete GitHub Actions workflow:</p>
<ul><li>Build and push Docker images</li><li>Validate manifests</li><li>Deploy to staging (on PR)</li><li>Deploy to production (on main)</li><li>Rollback on failure</li><li>Smoke tests</li></ul>
<h2>Learning Path</h2>
<ol><li><strong>Start</strong>: Basic deployment and service creation</li><li><strong>Intermediate</strong>: Add health checks, resource limits, ConfigMaps</li><li><strong>Advanced</strong>: Implement autoscaling, GitOps, production patterns</li><li><strong>Expert</strong>: Multi-cluster, service mesh, advanced networking</li></ol>
<h2>See Also</h2>
<ul><li><a href="https://kubernetes.io/docs/">Official Kubernetes Documentation</a></li><li><a href="https://k8spatterns.io/">Kubernetes Patterns</a></li><li><a href="https://kubernetes.io/docs/setup/best-practices/">Production Best Practices</a></li></ul>
<footer>
<div class="fmap">
<div><b>Build</b>
<a href="https://hanzo.app">hanzo.app</a> app builder
<a href="https://hanzo.codes">hanzo.codes</a> code with an agent
<a href="https://hanzoskills.com">hanzoskills.com</a> what an agent reads</div>
<div><b>Run</b>
<a href="https://console.hanzo.ai">console.hanzo.ai</a> cloud console
<a href="https://api.hanzo.ai">api.hanzo.ai</a> the API</div>
<div><b>Account</b>
<a href="https://hanzo.id">hanzo.id</a> sign in
<a href="https://pay.hanzo.ai">pay.hanzo.ai</a> top up
<a href="https://billing.hanzo.ai">billing.hanzo.ai</a> invoices and usage</div>
<div><b>Company</b>
<a href="https://hanzo.ai">hanzo.ai</a> canonical
<a href="https://hanzo.ventures">hanzo.ventures</a> ventures</div>
</div>
<div class="fend"><a href="/cloud-kubernetes-deployment.md">This page as plain text</a> · <a href="/llms.txt">Index for agents</a></div>
</footer>
</div></body></html>