These terraform resources define a GCP project containing a GKE cluster intended to serve as a "build cluster" for prow.k8s.io. There are also some service accounts defined for use by pods within the cluster.
Access to the k8s-infra-prow-build project hosting the cluster is granted by membership in one of two @kubernetes.io groups:
- [k8s-infra-prow-oncall@kubernetes.io][k8s-infra-prow-oncall@]: grants
roles/owneraccess - [k8s-infra-prow-viewers@kubernetes.io][k8s-infra-prow-viewers@]: grants
prow.vieweraccess
If you are not a member of either of these groups, please follow these instructions to join
# Login to set the authenticated user for gcloud
gcloud auth login
# Get kubeconfig credentials for the cluster
gcloud container clusters get-credentials \
prow-build --project=k8s-infra-prow-build --region=us-central1
# Now you can use kubectl...There was some manual work in bringing this up fully:
- expect
terraform applyto fail initially while trying to create bindings forroles/iam.workloadIdentityUser, as the identity namespace won't exist until the GKE cluster is created; re-run to succeed - edit
resources/boskos.yamlto haveboskos-metricsuse the external ip provisioned by terraform - run
ensure_e2e_projects.shto ensure e2e projects have been provisioned- edit
resources/boskos-resources.yamlto include the projects
- edit
- deploy resources to the cluster
# First get access to the cluster control plane by following the instructions
# in the section above.
# get k8s.io on here, for this example we'll assume everything's pushed to git
git clone git://github.com/kubernetes/k8s.io
# deploy the resources
cd k8s.io/infra/gcp/terraform/k8s-infra-prow-build
./deploy.sh
# create the service-account secret
gcloud iam service-accounts keys create \
--project=k8s-infra-prow-build \
--iam-account=prow-build@k8s-infra-prow-build.iam.gserviceaccount.com \
tmp.json
kubectl create secret generic -n test-pods service-account \
--from-file=service-account.json=tmp.json
rm tmp.json
# create the ssh-key-secret
# TODO: these files were manually created and the pubkey hardcoded into
# ensure_e2e_projects.sh above; consider rewriting this guide to
# describe generating the key, and then store it into cloud secrets
# to get it here
kubectl create secret generic -n test-pods ssh-key-secret \
--from-file=ssh-private=prow-build-test.ssh-key \
--from-file=ssh-public=prow-build-test.ssh-key.pub
rm prow-build-test.ssh-key*There was some manual work to hook this up to prow.k8s.io:
- generate a kubeconfig with credentials that prow.k8s.io will use to access the build cluster, and hand it off to prow.k8s.io on-call
# First get access to the cluster control plane by following the instructions
# in the section above.
# generate a kubeconfig to handoff to prow.k8s.io on-call
# the "name" is what prowjobs will specify in their cluster: field
# to target this cluster
git clone git://github.com/kubernetes/test-infra
cd test-infra/gencred && go build .
/gencred \
--context gke_k8s-infra-prow-build_us-central1_prow-build \
--name k8s-infra-prow-build \
--serviceaccount \
--output k8s-infra-prow-build.kubeconfig.yaml- ask prow.k8s.io on-call to give the build cluster's service account the following IAM privileges
# write build logs/artifacts to kubernetes-jenkins
gsutil iam ch \
serviceAccount:prow-build@k8s-infra-prow-build.iam.gserviceaccount.com:objectAdmin \
gs://kubernetes-jenkins
# stage builds for use by other jobs
gsutil iam ch \
serviceAccount:prow-build@k8s-infra-prow-build.iam.gserviceaccount.com:objectAdmin \
gs://kubernetes-release-pull- resources are deployed by post-k8sio-deploy-prow-build-resources when PRs merge
- the job runs deploy.sh to deploy resources; if necessary, users with sufficient privileges can run this script to do the same thing
- open a PR with the proposed changes
- run
tfswitchto ensure the correct version of terraform is installed - run
terraform initto ensure the correct version of modules/providers are installed - run
terraform planto verify what changes will be deployed; if there are unexpected deletions or changes, ask for help in #sig-k8s-infra - run
terraform applyto deploy the changes
- upgrades are handled automatically by GKE during a scheduled maintenance window
- this covers things like Service Accounts, GCS Buckets, APIs / Services, Google Secret Manager Secrets, etc.
- add resources to
main.tf, then follow the same steps as [Deploy cluster changes]
- jobs are not segmented into separate nodepools
- setup an autobump jump for all components installed to this build cluster
- try using local SSD for the node pools for faster IOPS