/ ⚡ Intermediate
1

Overview & What's Different

⏱ 2 min ⚡ Intermediate 🔧 Prerequisite: first-application-on-Google-Kubernetes-Engine

Welcome back

In the beginner codelab, you used kubectl commands to deploy a simple hello-world app. That's a great starting point but real production apps are managed very differently.

In this codelab you'll deploy a real-world Node.js web app the way engineers actually do it: using YAML manifests, ConfigMaps & Secrets for configuration, and Helm to package and manage everything as a reusable chart.

What's new in this codelab

Beginner CodelabThis Intermediate Codelab
kubectl imperative commandsNEW Declarative YAML manifests
hello-world sample imageNEW Real Node.js web app
Config hardcoded in imageNEW ConfigMaps & Secrets
Manual kubectl applyNEW Helm chart packaging
One-off deployNEW Versioned, repeatable releases

What you'll learn

  • Write and understand real Kubernetes YAML manifests
  • Store app config in ConfigMaps and sensitive data in Secrets
  • Inject config into Pods as environment variables
  • Understand what Helm is and why teams use it
  • Create a Helm chart for your app from scratch
  • Deploy, upgrade, rollback, and uninstall with Helm

What you'll build

Production-style architecture
🌐 Internet
→
LoadBalancer Service
→
GKE Cluster · Helm Release
Pod 🟢
node-webapp
Pod 🟢
node-webapp
Pod 🟢
node-webapp
📋 ConfigMap
APP_ENV, APP_PORT
🔐 Secret
DB_PASSWORD
2

Before You Begin

⏱ 5 min

Prerequisites

  • Completed the Beginner GKE Codelab you should be comfortable with Pods, Deployments, Services
  • A Google Cloud project with billing enabled
  • Kubernetes Engine API enabled

Open Cloud Shell & create your cluster

Open Cloud Shell and create a fresh cluster:

bash
gcloud container clusters create my-app-cluster \
  --num-nodes=2 \
  --zone=us-central1-a \
  --machine-type=e2-medium

gcloud container clusters get-credentials my-app-cluster \
  --zone=us-central1-a

Install Helm

Helm is the package manager for Kubernetes. Cloud Shell doesn't have it pre-installed, so let's add it:

bash
# Download and install Helm
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

# Verify installation
helm version

You should see output like version.BuildInfo{Version:"v3.x.x"...}

✅
You're ready!

Once your cluster is RUNNING and helm version works, you're set. Let's look at the app we're deploying.

3

The App We're Building

⏱ 5 min

Meet the app: node-webapp

Instead of a one-line hello-world, we're deploying a small Node.js web server that reads its configuration from environment variables the way real 12-factor apps are built.

The app reads three values from its environment:

VariableSourceDescription
APP_ENVConfigMape.g. production or staging
APP_PORTConfigMapPort the server listens on
DB_PASSWORDSecretSensitive credential — never hardcoded

The app source code

We'll use a pre-built public image. Here's what the source looks like notice how it reads config from process.env:

server.js
// A real-world Node.js app that reads config from environment
const http = require('http');

const PORT     = process.env.APP_PORT || 8080;
const ENV      = process.env.APP_ENV  || 'development';
const DB_PASS  = process.env.DB_PASSWORD ? '***hidden***' : 'not set';

const server = http.createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'application/json' });
  res.end(JSON.stringify({
    message:  'Hello from node-webapp!',
    env:      ENV,
    port:     PORT,
    db_pass:  DB_PASS,
    hostname: require('os').hostname(),
    version:  '1.0.0'
  }, null, 2));
});

server.listen(PORT, () => {
  console.log(`Server running in ${ENV} mode on port ${PORT}`);
});
💡
Why environment variables?

The 12-factor app methodology says config that changes between environments (dev/staging/prod) should come from the environment — never hardcoded in code. Kubernetes ConfigMaps and Secrets are the standard way to inject this config into your Pods.

Project structure we'll create

node-webapp/
├── manifests/             # Raw YAML — Step 4 & 5
│   ├── configmap.yaml
│   ├── secret.yaml
│   ├── deployment.yaml
│   └── service.yaml
└── helm/                  # Helm chart — Step 8 & 9
    └── node-webapp/
        ├── Chart.yaml
        ├── values.yaml
        └── templates/
            ├── configmap.yaml
            ├── secret.yaml
            ├── deployment.yaml
            └── service.yaml
bash
# Create the folder structure
mkdir -p node-webapp/manifests
mkdir -p node-webapp/helm/node-webapp/templates
cd node-webapp
4

YAML Manifests Deep Dive

⏱ 8 min

Imperative vs Declarative

In the beginner codelab you used imperative commands like kubectl create deployment .... That's fine for learning, but professionals use declarative YAML files.

Imperative (beginner)Declarative YAML (production)
Tell Kubernetes what to doTell Kubernetes what you want
kubectl create deployment ...kubectl apply -f deployment.yaml
Hard to track changesLives in Git — full history
Can't easily recreateIdempotent run it 100 times, same result
No code review possiblePRs, reviews, approvals

Anatomy of a Deployment YAML

Every Kubernetes YAML file has 4 top-level fields. Let's write our Deployment and understand each line:

manifests/deployment.yaml
apiVersion: apps/v1          # Which Kubernetes API to use
kind: Deployment            # What kind of object this is
metadata:                     # Name and labels for this object
  name: node-webapp
  labels:
    app: node-webapp
spec:                         # The desired state you want
  replicas: 3
  selector:
    matchLabels:
      app: node-webapp   # Must match template labels below
  template:                 # Blueprint for each Pod
    metadata:
      labels:
        app: node-webapp
    spec:
      containers:
      - name: node-webapp
        image: gcr.io/google-samples/hello-app:1.0
        ports:
        - containerPort: 8080
        envFrom:             # Inject ALL keys from ConfigMap
        - configMapRef:
            name: webapp-config
        env:                 # Inject specific Secret keys
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: webapp-secret
              key: db-password
        resources:           # Always set resource limits!
          requests:
            memory: "64Mi"
            cpu: "100m"
          limits:
            memory: "128Mi"
            cpu: "200m"
💡
What is cpu: "100m"?

m stands for millicores. 1000m = 1 full CPU core. So 100m means this container requests 10% of a CPU. Always set both requests (guaranteed) and limits (maximum) without them your Pod can starve other Pods or get killed during node pressure.

The Service YAML

manifests/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: node-webapp-svc
spec:
  type: LoadBalancer
  selector:
    app: node-webapp     # Routes to Pods with this label
  ports:
  - protocol: TCP
    port: 80             # External port (what users hit)
    targetPort: 8080    # Container port (matches containerPort above)
🔑
Labels are the glue

The selector.app: node-webapp in the Service must exactly match the labels.app: node-webapp in the Deployment template. This is how Kubernetes knows which Pods belong to which Service it's just label matching.

5

ConfigMaps & Secrets

⏱ 8 min

What's the difference?

ConfigMapSecret
Use forNon-sensitive config (env name, ports, feature flags)Sensitive data (passwords, API keys, tokens)
StoragePlain text in etcdBase64-encoded in etcd (+ optional encryption)
Access controlAny Pod in namespaceRBAC-restricted, only authorized Pods
In Git?✅ Safe to commit❌ Never commit use Sealed Secrets or GCP Secret Manager

Create the ConfigMap

ConfigMaps store plain key-value pairs. Our app will read APP_ENV and APP_PORT from this:

manifests/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: webapp-config
  namespace: default
data:
  APP_ENV: "production"
  APP_PORT: "8080"
  LOG_LEVEL: "info"

Create the Secret

Secrets store sensitive values. The values must be base64-encoded. Let's encode our password first:

bash
# Encode your secret value to base64
echo -n "my-super-secret-db-password" | base64

# Output: bXktc3VwZXItc2VjcmV0LWRiLXBhc3N3b3Jk

Now paste that base64 value into your Secret YAML:

manifests/secret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: webapp-secret
  namespace: default
type: Opaque
data:
  # Value must be base64 encoded
  db-password: bXktc3VwZXItc2VjcmV0LWRiLXBhc3N3b3Jk
⚠️
Never commit secret.yaml to Git

Base64 is not encryption it's just encoding. Anyone can decode it instantly with echo "..." | base64 -d. Add secret.yaml to your .gitignore. In production, use GCP Secret Manager or Sealed Secrets.

How the Pod reads them

Look back at the Deployment YAML from Step 4. There are two ways to inject config:

Two injection patterns
# Pattern 1: envFrom inject ALL keys from a ConfigMap as env vars
envFrom:
- configMapRef:
    name: webapp-config
# Result: APP_ENV=production, APP_PORT=8080, LOG_LEVEL=info

---

# Pattern 2: env inject ONE specific key from a Secret
env:
- name: DB_PASSWORD
  valueFrom:
    secretKeyRef:
      name: webapp-secret
      key: db-password
# Result: DB_PASSWORD=my-super-secret-db-password (decoded)
✅
The Pod never sees base64

Kubernetes automatically decodes the base64 value before injecting it into the container. Your app code simply reads process.env.DB_PASSWORD and gets the plain text value.

6

Deploy with kubectl apply

⏱ 7 min

Create all the YAML files

Run these commands in Cloud Shell to create all four manifest files at once:

bash create manifests/configmap.yaml
cat > manifests/configmap.yaml << 'EOF'
apiVersion: v1
kind: ConfigMap
metadata:
  name: webapp-config
data:
  APP_ENV: "production"
  APP_PORT: "8080"
  LOG_LEVEL: "info"
EOF
bash create manifests/secret.yaml
cat > manifests/secret.yaml << 'EOF'
apiVersion: v1
kind: Secret
metadata:
  name: webapp-secret
type: Opaque
data:
  db-password: bXktc3VwZXItc2VjcmV0LWRiLXBhc3N3b3Jk
EOF
bash create manifests/deployment.yaml
cat > manifests/deployment.yaml << 'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
  name: node-webapp
  labels:
    app: node-webapp
spec:
  replicas: 3
  selector:
    matchLabels:
      app: node-webapp
  template:
    metadata:
      labels:
        app: node-webapp
    spec:
      containers:
      - name: node-webapp
        image: gcr.io/google-samples/hello-app:1.0
        ports:
        - containerPort: 8080
        envFrom:
        - configMapRef:
            name: webapp-config
        env:
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: webapp-secret
              key: db-password
        resources:
          requests:
            memory: "64Mi"
            cpu: "100m"
          limits:
            memory: "128Mi"
            cpu: "200m"
EOF
bash create manifests/service.yaml
cat > manifests/service.yaml << 'EOF'
apiVersion: v1
kind: Service
metadata:
  name: node-webapp-svc
spec:
  type: LoadBalancer
  selector:
    app: node-webapp
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080
EOF

Apply everything at once

With kubectl apply -f, you can point at an entire directory:

bash
kubectl apply -f manifests/

# Expected output:
# configmap/webapp-config created
# secret/webapp-secret created
# deployment.apps/node-webapp created
# service/node-webapp-svc created

Verify everything is running

bash
# Check all pods are Running
kubectl get pods

# Check the ConfigMap was created
kubectl get configmap webapp-config

# Check the Secret was created
kubectl get secret webapp-secret

# Watch for the external IP
kubectl get service node-webapp-svc --watch

Inspect the config inside a running Pod

Once a Pod is running, you can verify it received the config correctly:

bash
# Get the name of one pod
POD=$(kubectl get pods -l app=node-webapp -o jsonpath='{.items[0].metadata.name}')

# Print environment variables inside the pod
kubectl exec $POD -- env | grep -E "APP_ENV|APP_PORT|DB_PASSWORD"

# Expected:
# APP_ENV=production
# APP_PORT=8080
# DB_PASSWORD=my-super-secret-db-password
🎉
Your app is live with proper config management!

You've deployed a real app using declarative YAML, with config injected from a ConfigMap and a Secret. This is production-grade Kubernetes. Next let's package all of this into a Helm chart.

7

Introduction to Helm

⏱ 8 min

What is Helm?

You just wrote 4 YAML files to deploy one app. Imagine managing 10 apps, each needing their own configmap, secret, deployment, service, ingress... That's 50+ files. And what if you need to deploy the same app to dev, staging, and prod with slightly different values?

Helm is the package manager for Kubernetes. It lets you bundle all your Kubernetes manifests into a single reusable Chart, and customize them for different environments using a single values.yaml file.

📦 The apt/npm Analogy

Helm is to Kubernetes what apt is to Ubuntu or npm is to Node.js. Instead of manually downloading and configuring software, you run helm install my-app ./my-chart and everything is set up correctly. You can also install community charts: helm install nginx ingress-nginx/ingress-nginx.

Core Helm concepts

TermWhat it is
ChartA package of Kubernetes YAML templates + a values.yaml
values.yamlDefault configuration values for the chart
ReleaseA deployed instance of a chart. You can deploy the same chart multiple times with different names.
TemplateA YAML file with {{ .Values.something }} placeholders that get filled in at deploy time
RepositoryA collection of published charts (like npmjs.com but for Helm)

The Helm workflow

values.yaml
your config
+
templates/
your YAML templates
→
helm install
→
Kubernetes
rendered manifests applied

Essential Helm commands

helm
# Install a chart (create a new release)
helm install <release-name> <chart-path>

# Install with custom values
helm install <release-name> <chart-path> --set key=value

# Upgrade an existing release (rolls out changes)
helm upgrade <release-name> <chart-path>

# Roll back to a previous version
helm rollback <release-name> <revision>

# List all releases in the cluster
helm list

# See the history of a release
helm history <release-name>

# Remove a release (deletes all its Kubernetes objects)
helm uninstall <release-name>
💡
Helm vs kubectl apply

Both apply Kubernetes manifests, but Helm additionally tracks release history, supports one-command rollback, and lets you parameterize everything via values.yaml. Teams use Helm for anything they'll deploy more than once.

8

Package App as a Helm Chart

⏱ 10 min

Scaffold the chart structure

bash
# Create the chart skeleton
helm create helm/node-webapp

# Remove the default boilerplate templates
rm -rf helm/node-webapp/templates/*
rm helm/node-webapp/templates/.gitkeep 2>/dev/null; true

# List what was created
ls helm/node-webapp/

Chart.yaml chart metadata

helm/node-webapp/Chart.yaml
cat > helm/node-webapp/Chart.yaml << 'EOF'
apiVersion: v2
name: node-webapp
description: A real-world Node.js web app deployed on GKE
type: application
version: 0.1.0        # Chart version
appVersion: "1.0.0"   # Your app version
EOF

values.yaml all configurable defaults

This is the heart of Helm. Everything that might change between environments goes here:

helm/node-webapp/values.yaml
cat > helm/node-webapp/values.yaml << 'EOF'
# Deployment settings
replicaCount: 3

image:
  repository: gcr.io/google-samples/hello-app
  tag: "1.0"

# App configuration (goes into ConfigMap)
config:
  appEnv: "production"
  appPort: "8080"
  logLevel: "info"

# Sensitive values (goes into Secret)
secret:
  dbPassword: "bXktc3VwZXItc2VjcmV0LWRiLXBhc3N3b3Jk"

# Service settings
service:
  type: LoadBalancer
  port: 80
  targetPort: 8080

# Resource limits
resources:
  requests:
    memory: "64Mi"
    cpu: "100m"
  limits:
    memory: "128Mi"
    cpu: "200m"
EOF

Templates YAML with placeholders

Now convert your static manifests into templates using {{ .Values.xxx }} syntax:

helm/node-webapp/templates/configmap.yaml
cat > helm/node-webapp/templates/configmap.yaml << 'EOF'
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-config
data:
  APP_ENV:   {{ .Values.config.appEnv | quote }}
  APP_PORT:  {{ .Values.config.appPort | quote }}
  LOG_LEVEL: {{ .Values.config.logLevel | quote }}
EOF
helm/node-webapp/templates/secret.yaml
cat > helm/node-webapp/templates/secret.yaml << 'EOF'
apiVersion: v1
kind: Secret
metadata:
  name: {{ .Release.Name }}-secret
type: Opaque
data:
  db-password: {{ .Values.secret.dbPassword }}
EOF
helm/node-webapp/templates/deployment.yaml
cat > helm/node-webapp/templates/deployment.yaml << 'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Release.Name }}
  labels:
    app: {{ .Release.Name }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ .Release.Name }}
  template:
    metadata:
      labels:
        app: {{ .Release.Name }}
    spec:
      containers:
      - name: node-webapp
        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
        ports:
        - containerPort: {{ .Values.service.targetPort }}
        envFrom:
        - configMapRef:
            name: {{ .Release.Name }}-config
        env:
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: {{ .Release.Name }}-secret
              key: db-password
        resources:
          {{- toYaml .Values.resources | nindent 10 }}
EOF
helm/node-webapp/templates/service.yaml
cat > helm/node-webapp/templates/service.yaml << 'EOF'
apiVersion: v1
kind: Service
metadata:
  name: {{ .Release.Name }}-svc
spec:
  type: {{ .Values.service.type }}
  selector:
    app: {{ .Release.Name }}
  ports:
  - port: {{ .Values.service.port }}
    targetPort: {{ .Values.service.targetPort }}
EOF

Preview the rendered output

Before deploying, use helm template to see exactly what YAML Helm will generate:

helm
helm template my-webapp helm/node-webapp

You'll see all 4 fully-rendered YAML files printed to the terminal with all {{ }} placeholders replaced by your values.

💡
{{ .Release.Name }} is special

This is replaced by whatever name you give the release at install time. So if you run helm install prod-webapp ..., all your resources get prefixed with prod-webapp-. This lets you deploy the same chart multiple times (staging, prod) without name collisions.

9

Deploy & Manage with Helm

⏱ 7 min

First delete the kubectl-deployed resources

We'll re-deploy the same app using Helm instead:

bash
kubectl delete -f manifests/

Install with Helm

helm
helm install my-webapp helm/node-webapp

# Expected output:
# NAME: my-webapp
# LAST DEPLOYED: ...
# NAMESPACE: default
# STATUS: deployed
# REVISION: 1
bash
# Verify all resources were created
kubectl get pods,svc,configmap,secret

# List Helm releases
helm list

Upgrade change replicas & image version

Bump to 5 replicas and update the image tag — no YAML editing needed:

helm
helm upgrade my-webapp helm/node-webapp \
  --set replicaCount=5 \
  --set image.tag=2.0

# Watch pods rolling out
kubectl get pods --watch

View release history

helm
helm history my-webapp

# REVISION  STATUS      DESCRIPTION
# 1         superseded  Install complete
# 2         deployed    Upgrade complete

Rollback to revision 1

Something went wrong with version 2.0? Roll back instantly:

helm
helm rollback my-webapp 1

# Kubernetes rolls Pods back to image:1.0 with 3 replicas
kubectl get pods --watch

Clean up

helm
# Uninstall the release (removes ALL Kubernetes objects it created)
helm uninstall my-webapp

# Delete the cluster
gcloud container clusters delete my-app-cluster \
  --zone=us-central1-a
🎉
You're thinking like a production engineer!

You just deployed, upgraded, rolled back, and uninstalled a real app using Helm with proper config management via ConfigMaps and Secrets. This is how apps are managed in real GKE environments.

✓

Congratulations!

🏆

Intermediate GKE Complete!

You've graduated from hello-world commands to production-grade Kubernetes engineering.

What you accomplished

  • Wrote real declarative YAML manifests for Deployment and Service
  • Created a ConfigMap to inject non-sensitive app configuration
  • Created a Secret to inject sensitive credentials securely
  • Deployed a full app with kubectl apply -f
  • Built a complete Helm chart with parameterized templates
  • Deployed, upgraded, rolled back, and uninstalled using Helm

Your GKE progression

LevelSkillsStatus
Beginner kubectl commands, Pods, Deployments, Services, scaling ✅ Done
Intermediate YAML manifests, ConfigMaps, Secrets, Helm charts ✅ Done
Advanced Ingress, HPA, Workload Identity, GitOps, Cloud Build CI/CD ⏭ Up next

What to learn next

TopicWhy it mattersWhere to learn
Horizontal Pod AutoscalerScale Pods automatically based on CPU/memorykubernetes.io
GKE Ingress / Gateway APIRoute traffic by domain, path, and TLSGKE Docs
Workload IdentityLet Pods access GCP services without service account keysGKE Docs
Cloud Build CI/CDAuto-deploy on every Git pushCloud Build Docs
Sealed SecretsSafely store encrypted Secrets in GitGitHub