TExcelTAD
Home › Kubernetes Packaging: Helm & Kustomize › The Running Example: linkly

The Running Example: linkly

Packaging is easier to learn on a real application than on nginx placeholders, so most lessons package the same app: linkly, the link shortener that the planned DevOps Capstone builds and runs end to end. You don't need its source code here, only what it expects from Kubernetes.

What linkly needs

linkly is a single Go binary in a distroless image (ghcr.io/acme/linkly), listening on port 8080.

Endpoint Purpose Used by
POST /links store a short code in PostgreSQL clients
GET /{code} redirect, with Redis as a read-through cache browsers
GET /healthz "the process is alive" liveness probe
GET /readyz "the database and cache are reachable" readiness probe
GET /metrics Prometheus metrics the monitoring stack

It is configured only through environment variables (twelve-factor style):

Variable Example Secret?
LISTEN_ADDR :8080 no
BASE_URL https://lnk.example.com no
LOG_LEVEL info no
REDIS_ADDR linkly-redis:6379 no
DATABASE_URL postgres://linkly:…@db:5432/linkly yes

The plain manifests

Before any packaging tool, here is linkly as hand-written YAML: a ConfigMap for the settings, a Deployment that reads it (and the database URL from a Secret created out of band), a Service, a Gateway API HTTPRoute that attaches the Service to a shared Gateway, and a HorizontalPodAutoscaler. The session writes the files and validates them with kubeconform in -strict mode, which also rejects unknown fields.

bash · try it yourself
mkdir -p linkly && cd linkly
cat > config.yaml <<'EOF'
apiVersion: v1
kind: ConfigMap
metadata:
  name: linkly-config
data:
  LISTEN_ADDR: ":8080"
  BASE_URL: https://lnk.example.com
  LOG_LEVEL: info
  REDIS_ADDR: linkly-redis:6379
EOF
cat > deployment.yaml <<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
  name: linkly
  labels: {app.kubernetes.io/name: linkly}
spec:
  replicas: 2
  selector:
    matchLabels: {app.kubernetes.io/name: linkly}
  template:
    metadata:
      labels: {app.kubernetes.io/name: linkly}
    spec:
      securityContext: {runAsNonRoot: true}
      containers:
        - name: linkly
          image: ghcr.io/acme/linkly:1.4.0
          ports: [{name: http, containerPort: 8080}]
          envFrom: [{configMapRef: {name: linkly-config}}]
          env:
            - name: DATABASE_URL
              valueFrom: {secretKeyRef: {name: linkly-db, key: url}}
          readinessProbe: {httpGet: {path: /readyz, port: http}}
          livenessProbe: {httpGet: {path: /healthz, port: http}}
          resources:
            requests: {cpu: 100m, memory: 64Mi}
            limits: {memory: 128Mi}
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            capabilities: {drop: [ALL]}
EOF
cat > service.yaml <<'EOF'
apiVersion: v1
kind: Service
metadata:
  name: linkly
spec:
  selector: {app.kubernetes.io/name: linkly}
  ports: [{name: http, port: 80, targetPort: http}]
EOF
cat > httproute.yaml <<'EOF'
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: linkly
spec:
  parentRefs:
    - {name: public, namespace: gateway-system}
  hostnames: [lnk.example.com]
  rules:
    - backendRefs: [{name: linkly, port: 80}]
EOF
cat > hpa.yaml <<'EOF'
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: linkly
spec:
  scaleTargetRef: {apiVersion: apps/v1, kind: Deployment, name: linkly}
  minReplicas: 2
  maxReplicas: 10
  metrics:
    - type: Resource
      resource: {name: cpu, target: {type: Utilization, averageUtilization: 70}}
EOF
kubeconform -strict -summary *.yaml
Summary: 5 resources found in 5 files - Valid: 5, Invalid: 0, Errors: 0, Skipped: 0

The HTTPRoute is a custom resource, not part of core Kubernetes, yet it validated: the image's kubeconform has the Gateway API schemas next to the Kubernetes 1.34 ones. Routing goes through Gateway API rather than an Ingress in this course because the community ingress-nginx controller was retired in March 2026; the Kubernetes Gateway API lesson explains Gateways and routes. Where a chart offers an Ingress as well, it targets a maintained controller.

What changes between environments

Now list everything that differs between staging and production. This table is the real requirement that packaging has to meet:

Setting staging production
namespace linkly-staging linkly-prod
image tag latest build, e.g. 1.5.0-rc.2 a released version, e.g. 1.4.0
replicas / HPA 1, no HPA HPA 3 to 20
LOG_LEVEL debug info
hostname lnk.staging.example.com lnk.example.com
resources small larger requests and limits
database Secret staging DB production DB, managed elsewhere

Two ways to meet it:

  • Helm: turn each varying field into a template expression (replicas: {{ .Values.replicaCount }}), give defaults in values.yaml, and keep one small values file per environment.
  • Kustomize: keep the YAML above exactly as it is, as a base, and write one overlay per environment that patches the fields in the table.

You will do both. The Helm section builds the linkly chart piece by piece, the Kustomize section builds the overlays, and the Mini Project puts the finished chart and its overlays together.

A quick check with yq

The manifests are data, so you can query them before packaging anything. yq (covered in the planned DevOps Scripting course) reads several documents at once; here it lists each object and the field production will need to change:

bash · try it yourself
cat > deployment.yaml <<'EOF'
apiVersion: apps/v1
kind: Deployment
metadata: {name: linkly}
spec:
  replicas: 2
  template:
    spec:
      containers:
        - name: linkly
          image: ghcr.io/acme/linkly:1.4.0
EOF
yq '.kind + "/" + .metadata.name' deployment.yaml
yq '.spec.template.spec.containers[0].image' deployment.yaml
yq '.spec.replicas = 5 | .spec.replicas' deployment.yaml
Deployment/linkly
ghcr.io/acme/linkly:1.4.0
5

yq edits like the last line are how many teams start ("just sed the replica count in CI"). It works until the edits multiply; the rest of the course replaces them with something reviewable.

Test yourself

Why does linkly have two separate probe endpoints?

  1. Kubernetes requires two ports
  2. /healthz answers 'alive?' for the liveness probe, /readyz answers 'can serve traffic?' for the readiness probe
  3. One is for HTTP and one for HTTPS
  4. They are aliases

How did kubeconform validate the HTTPRoute, a custom resource?

  1. It skipped it
  2. It asked the cluster
  3. The image ships the Gateway API CRD schemas alongside the Kubernetes ones
  4. HTTPRoute is a core Kubernetes kind

Which approach keeps the base manifests as valid, unmodified YAML?

  1. Helm
  2. Kustomize
  3. Both
  4. Neither