Search⌘ K
AI Features

Passing an Environment Variable to Our Container

Explore how to pass environment variables to containers in Kubernetes by defining them in deployment manifests. Understand how this simple technique allows your pods to use these variables at startup, improving configuration management and flexibility within your Kubernetes applications.

We'll cover the following...

Creating a new version

Let’s first create a Service and Deployment for the new version of our application to make sure everything is working fine:

YAML
apiVersion: v1
kind: Service
metadata:
name: hellok8s-svc
spec:
type: NodePort
selector:
app: hellok8s
ports:
- port: 4567
nodePort: 30001
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: hellok8s
spec:
replicas: 2
selector:
matchLabels:
app: hellok8s
template:
metadata:
labels:
app: hellok8s
spec:
containers:
- image: brianstorti/hellok8s:v4
name: hellok8s-container

Apply this ...