Example repository demonstrating the integration of k8s-bootstrap-buildkite-plugin with Buildkite Secrets.
This pipeline demonstrates:
- Securely load kubeconfig using native Buildkite Secrets
- Create scoped service accounts using k8s-bootstrap plugin
- Deploy applications using the generated scoped kubeconfig
This pipeline demonstrates the secure integration of the k8s-bootstrap plugin with Buildkite Secrets using a three-step architecture:
Step 1: Load Secrets (queue: "default"
)
- Uses native
buildkite-agent secret get
command to load kubeconfig from Buildkite Secrets - Runs on regular agents with internet access to Buildkite API
- Environment variable persists to downstream steps
Step 2: Bootstrap Service Account (queue: "kubernetes"
)
- Uses the
k8s-bootstrap
plugin with the loaded secret from Step 1 - Runs on K8s agents with direct cluster access for kubectl operations
- Creates scoped service account and uploads kubeconfig artifact
Step 3: Deploy Application (queue: "kubernetes"
)
- Downloads kubeconfig artifact from Step 2
- Runs kubectl apply commands with scoped permissions
- Runs on K8s agents for optimal deployment performance
-
Create Buildkite Secret:
- Go to your Buildkite Organization Settings → Secrets
- Create a new secret with key:
k8s_admin_kubeconfig
- Paste your cluster admin kubeconfig YAML as the value
-
Configure Agent Queues:
- Ensure you have agents in
queue=default
(regular agents with internet access) - Ensure you have agents in
queue=kubernetes
(K8s agents with cluster access)
- Ensure you have agents in
-
Plugin Integration:
# Step 1: Load secret natively command: | export KUBECONFIG_SECRET="$(buildkite-agent secret get k8s_admin_kubeconfig)" # Step 2: Use in k8s-bootstrap plugin plugins: - Mykematt/k8s-bootstrap#v1.0.0: cluster-admin-kubeconfig: "${KUBECONFIG_SECRET}"
✅ Principle of Least Privilege: Deployments use scoped service account, not cluster-admin
✅ Secret Management: Admin kubeconfig stored securely in Buildkite Secrets
✅ Temporary Credentials: Service account tokens can be rotated automatically
✅ Audit Trail: All operations logged through Buildkite pipeline
.buildkite/pipeline.yml
- Main pipeline configurationk8s/
- Kubernetes manifests for nginx deploymentconfigmap.yaml
- Configuration datadeployment.yaml
- Nginx deploymentservice.yaml
- Service to expose nginx
- Ensure you have the admin kubeconfig secret configured in Buildkite
- Run the pipeline in Buildkite
- The first step creates a scoped service account
- The second step deploys using only the scoped permissions
This demonstrates a secure, production-ready pattern for Kubernetes deployments in CI/CD pipelines.