Kubectl gives you direct power—apply deployments, scale services, delete resources. GitHub Actions trigger these commands through CI/CD. Skilled teams wire kubectl commands into automated stages for rapid delivery. But every automation step should have clear, enforced boundaries.
CI/CD controls start with authentication. Use short-lived Kubernetes credentials created by a secure provider. Avoid storing long-term kubeconfig files in GitHub repository secrets. Rotate tokens through automation to block stale access. Enable Role-Based Access Control (RBAC) so each CI/CD workflow only performs the exact actions it must.
Restrict kubectl in pipelines. Place commands behind approved scripts that validate input before touching the cluster. Audit workflows for direct kubectl calls. Pipeline jobs should run in isolated environments with network policies that block unnecessary destinations.