Kubernetes as the Primary Deployment Platform: a Practitioner's Workflow

Kubernetes has evolved from a necessity to a preferred deployment platform, offering scalability, consistency.

JR

3 minute read

Kubernetes has evolved from a necessity to a preferred deployment platform, offering scalability, consistency, and ecosystem maturity that simplify modern application hosting.

Why This Matters in Production

Once a complex necessity, Kubernetes now provides a unified interface for deploying and managing applications at scale. For platform engineers, it reduces context switching between environments, enforces standardized operations, and integrates with modern tooling like GitOps and CI/CD pipelines. The shift from “necessary evil” to “preferred platform” reflects maturity in both the ecosystem and operational practices.

Actionable Workflow for K8s-First Deployments

  1. Cluster Setup & Lifecycle Management

    • Use lightweight distributions like K3s or MicroK8s for non-production environments.
    • Automate cluster provisioning with Terraform or Ansible (e.g., terraform apply for AWS EC2 clusters).
    • Enforce RBAC and network policies from day one (e.g., kubectl apply -f rbac.yaml).
  2. GitOps Pipeline

    • Adopt ArgoCD or Flux for declarative sync between Git repositories and cluster state.
    • Store Helm charts in version-controlled repositories (e.g., helm repo add stakater https://helm.stakater.com).
    • Use GitHub Actions or GitLab CI to automate image builds and Helm chart updates:
      jobs:  
        build:  
          runs-on: ubuntu-latest  
          steps:  
            - name: Build and push Docker image  
              run: |  
                docker build -t myapp:$TAG .  
                docker push myapp:$TAG  
      
  3. Storage Strategy

    • For homelabs, use external storage solutions like TrueNAS with CSI drivers (e.g., tns-csi for TrueNAS).
    • In production, prefer cloud-native storage classes (e.g., AWS EBS, GCP Persistent Disk) with replication.
    • Avoid in-cluster storage solutions unless redundancy is strictly required.
  4. Monitoring & Maintenance

    • Deploy Prometheus/Grafana for metrics and alerting.
    • Use OpenPolicyAgent (OPA) for policy enforcement (e.g., blocking privileged containers).
    • Regularly rotate certificates and audit IAM roles.

Policy Example: Security Updates via Helm Hooks

# helm-hook.yaml  
hooks:  
  pre-upgrade:  
    - cmd:  
        - sh  
        - -c  
        - |  
            echo "Checking for security updates..."  
            helm dependency update  
            echo "Updating images..."  
            sed -i 's|image: .*/.*|image: myapp:$(date +%Y%m%d)|' values.yaml  

Tooling Recommendations

  • Cluster Management: K3s (lightweight), OpenShift (enterprise), kops (AWS-specific).
  • GitOps: ArgoCD (declarative sync), Flux (Git-centric).
  • Storage: Longhorn (stateful workloads), Rook (ceph-based), CSI drivers for external storage.
  • CI/CD: GitHub Actions (native integration), Tekton (K8s-native pipelines).

Tradeoffs & Caveats

  • Storage Complexity: Solutions like Longhorn add operational overhead. For homelabs, external storage (e.g., TrueNAS) simplifies management but introduces a SPOF.
  • GitOps Latency: ArgoCD sync intervals can delay deployments; adjust syncWindow for critical workloads.
  • Ephemeral Environments: Tools like K3d or Kind are great for testing but lack parity with production clusters.

Troubleshooting Common Failures

  • StorageClass Misconfigurations:
    kubectl get storageclass  # Verify default class  
    kubectl describe pvc <name>  # Check provisioning errors  
    
  • NetworkPolicy Issues:
    kubectl get networkpolicies  # Review rules  
    kubectl describe pod <name>  # Check pod IP and policy matches  
    
  • ArgoCD Sync Errors:
    argo cd sync <app-name>  # Manually sync  
    argo cd get events <app-name>  # Debug sync failures  
    

Conclusion

Kubernetes’ strengths—portability, declarative management, and ecosystem tooling—make it a pragmatic choice for modern deployments. While storage and complexity remain challenges, structured workflows and pragmatic tooling mitigate risks. The homelab-to-production pipeline benefits from consistency, but always align with team expertise and operational capacity.

Source thread: Haven’t used anything but K8s for deployment for years now? Just me?

comments powered by Disqus