Kubernetes copy-paste snippets

Hieronder staan drie minimale voorbeelden (Deployment, Service en Ingress) die je kunt kopiëren en aanpassen.

1) Deployment (Rolling update, 1 replica)

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-world
  namespace: demo
  labels:
    app: apache
spec:
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 0
      maxSurge: 1
  selector:
    matchLabels:
      app: apache
  template:
    metadata:
      labels:
        app: apache
    spec:
      containers:
        - name: apache
          image: httpd:2.4
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 80

2) Service (ClusterIP)

---
apiVersion: v1
kind: Service
metadata:
  name: apache-service
  namespace: demo
spec:
  selector:
    app: apache
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 80

3) Ingress (basic host + path)

Vereist een Ingress Controller (bijv. NGINX Ingress). Pas de hostnaam aan.

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: apache-ingress
  namespace: demo
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
    - host: your-app.example.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: apache-service
                port:
                  number: 80

Quiz

Test je kennis over Kubernetes objecten en httpd met onderstaande korte multiple choice quiz.

Bronnen

  • Apache httpd op Docker Hub: https://hub.docker.com/_/httpd
Last change: 2025-12-05