Learn Kubernetes - 1 Code Examples & CST Typing Practice Test
Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications across clusters of machines.
View all 1 Kubernetes code examples →
Learn KUBERNETES with Real Code Examples
Updated Nov 27, 2025
Code Sample Descriptions
Kubernetes Deployment with Service
# Namespace
apiVersion: v1
kind: Namespace
metadata:
name: my-app
labels:
name: my-app
---
# ConfigMap for application configuration
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
namespace: my-app
data:
DATABASE_HOST: "postgres-service"
DATABASE_PORT: "5432"
REDIS_HOST: "redis-service"
REDIS_PORT: "6379"
---
# Secret for sensitive data
apiVersion: v1
kind: Secret
metadata:
name: app-secrets
namespace: my-app
type: Opaque
data:
DATABASE_PASSWORD: cGFzc3dvcmQxMjM= # base64 encoded
API_KEY: YWJjZGVmZ2hpams=
---
# Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app-deployment
namespace: my-app
labels:
app: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: my-app:latest
ports:
- containerPort: 3000
env:
- name: DATABASE_HOST
valueFrom:
configMapKeyRef:
name: app-config
key: DATABASE_HOST
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: app-secrets
key: DATABASE_PASSWORD
resources:
requests:
memory: "256Mi"
cpu: "200m"
limits:
memory: "512Mi"
cpu: "500m"
livenessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 3000
initialDelaySeconds: 5
periodSeconds: 5
---
# Service
apiVersion: v1
kind: Service
metadata:
name: my-app-service
namespace: my-app
spec:
selector:
app: my-app
ports:
- protocol: TCP
port: 80
targetPort: 3000
type: LoadBalancer
---
# Horizontal Pod Autoscaler
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: my-app-hpa
namespace: my-app
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: my-app-deployment
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80
Demonstrates complete Kubernetes application deployment with configuration, secrets, services, and auto-scaling.
Frequently Asked Questions about Kubernetes
What is Kubernetes?
Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications across clusters of machines.
What are the primary use cases for Kubernetes?
Orchestrating containerized applications. Automating deployment, scaling, and rollback. Managing microservices architectures. Providing service discovery and load balancing. Running hybrid or multi-cloud workloads
What are the strengths of Kubernetes?
Highly scalable and resilient. Cloud-agnostic and portable. Strong ecosystem with tooling and extensions. Declarative and automated operations. Active community and enterprise support
What are the limitations of Kubernetes?
Steep learning curve for beginners. Operational complexity at scale. Debugging issues can be challenging. Resource-intensive compared to lightweight orchestrators. Requires good understanding of networking and storage concepts
How can I practice Kubernetes typing speed?
CodeSpeedTest offers 1+ real Kubernetes code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.