# kubernetes-deployment > Kubernetes deployment and orchestration - Author: joseluis - Repository: joseluissaorin/clopus - Version: 20251231102703 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-06 - Source: https://github.com/joseluissaorin/clopus - Web: https://mule.run/skillshub/@@joseluissaorin/clopus~kubernetes-deployment:20251231102703 --- --- name: kubernetes-deployment description: Kubernetes deployment and orchestration version: 1.0.0 category: devops technologies: [kubernetes, helm, kubectl, kustomize] triggers: - kubernetes - k8s - container orchestration - deploy to kubernetes --- # Kubernetes Deployment Container orchestration and deployment with Kubernetes. ## Basic Deployment ```yaml # deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: 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: 8080 resources: requests: memory: "128Mi" cpu: "100m" limits: memory: "256Mi" cpu: "500m" env: - name: DATABASE_URL valueFrom: secretKeyRef: name: app-secrets key: database-url livenessProbe: httpGet: path: /health port: 8080 initialDelaySeconds: 30 periodSeconds: 10 readinessProbe: httpGet: path: /ready port: 8080 initialDelaySeconds: 5 periodSeconds: 5 ``` ## Service ```yaml # service.yaml apiVersion: v1 kind: Service metadata: name: my-app-service spec: selector: app: my-app ports: - protocol: TCP port: 80 targetPort: 8080 type: ClusterIP --- # Ingress apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: my-app-ingress annotations: kubernetes.io/ingress.class: nginx cert-manager.io/cluster-issuer: letsencrypt-prod spec: tls: - hosts: - app.example.com secretName: app-tls rules: - host: app.example.com http: paths: - path: / pathType: Prefix backend: service: name: my-app-service port: number: 80 ``` ## ConfigMap & Secrets ```yaml # configmap.yaml apiVersion: v1 kind: ConfigMap metadata: name: app-config data: LOG_LEVEL: "info" API_TIMEOUT: "30s" --- # secrets.yaml (use sealed-secrets or external-secrets in production) apiVersion: v1 kind: Secret metadata: name: app-secrets type: Opaque stringData: database-url: "postgresql://user:pass@host/db" api-key: "secret-key" ``` ## Helm Chart ```yaml # Chart.yaml apiVersion: v2 name: my-app description: My application Helm chart version: 1.0.0 appVersion: "1.0.0" # values.yaml replicaCount: 3 image: repository: my-app tag: latest pullPolicy: IfNotPresent service: type: ClusterIP port: 80 ingress: enabled: true host: app.example.com resources: requests: memory: 128Mi cpu: 100m limits: memory: 256Mi cpu: 500m ``` ## Kustomize ```yaml # kustomization.yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - deployment.yaml - service.yaml namePrefix: prod- commonLabels: environment: production images: - name: my-app newTag: v1.2.3 configMapGenerator: - name: app-config literals: - LOG_LEVEL=warn ``` ## Horizontal Pod Autoscaler ```yaml apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: my-app-hpa spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: my-app minReplicas: 2 maxReplicas: 10 metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 70 ``` ## Common Commands ```bash # Apply manifests kubectl apply -f k8s/ # Check deployment status kubectl rollout status deployment/my-app # View logs kubectl logs -f deployment/my-app # Scale deployment kubectl scale deployment/my-app --replicas=5 # Rollback kubectl rollout undo deployment/my-app # Port forward for debugging kubectl port-forward svc/my-app-service 8080:80 ``` ## Best Practices 1. Always set resource limits 2. Use liveness and readiness probes 3. Store secrets securely (sealed-secrets, vault) 4. Use namespaces for isolation 5. Implement network policies 6. Use pod disruption budgets 7. Enable RBAC 8. Use GitOps (ArgoCD, Flux)