diff --git a/docs/Home.md b/docs/Home.md index b77ed40d..141fec62 100644 --- a/docs/Home.md +++ b/docs/Home.md @@ -86,16 +86,11 @@ section. ```bash gcloud iam service-accounts create $SA ``` -1. Create custom GCP IAM Role with minimal permissions using the custom role defined within [rbac/IAMrole.yaml](rbac/IAMrole.yaml): - ```bash - gcloud iam roles create gke_deployer --project $PROJECT --file \ - rbac/IAMrole.yaml - ``` -1. Grant the IAM role to your GCP service account: +1. Grant Kubernetes Engine Cluster Viewer IAM role to your GCP service account: ```bash gcloud projects add-iam-policy-binding $PROJECT \ --member serviceAccount:$SA_EMAIL \ - --role projects/$PROJECT/roles/gke_deployer + --role roles/container.clusterViewer ``` 1. Download a JSON Service Account key for your newly created service account. Take note of where the file was created, you will upload it to Jenkins in a subsequent step: @@ -136,8 +131,7 @@ account permissions for deploying to your GKE cluster. pushd rbac/ ``` -1. The [gcp-sa-setup.tf](rbac/gcp-sa-setup.tf) Terraform plan will create a custom GCP IAM role with -restricted permissions, create a GCP service account, and grant said service account the custom role. +1. The [gcp-sa-setup.tf](rbac/gcp-sa-setup.tf) Terraform plan will create a GCP service account, and will grant said service account the minimal permissions required. (NOTE: This only needs to be done once). ```bash export TF_VAR_PROJECT=${PROJECT} diff --git a/docs/rbac/IAMrole.yaml b/docs/rbac/IAMrole.yaml deleted file mode 100644 index 66ced5e5..00000000 --- a/docs/rbac/IAMrole.yaml +++ /dev/null @@ -1,10 +0,0 @@ -title: "Jenkins GKE viewer" -description: "Minimal IAM role for the Jenkins GKE plugin." -stage: "GA" -includedPermissions: -- container.apiServices.get -- container.apiServices.list -- container.clusters.get -- container.clusters.getCredentials -- container.clusters.list -- resourcemanager.projects.get diff --git a/docs/rbac/gcp-sa-setup.tf b/docs/rbac/gcp-sa-setup.tf index 93823e12..2fd400d0 100644 --- a/docs/rbac/gcp-sa-setup.tf +++ b/docs/rbac/gcp-sa-setup.tf @@ -19,26 +19,6 @@ provider "google" { region = "${var.region}" } -# Create a custom IAM role to bind to our GCP service account - -# Declare a special IAM role -resource "google_project_iam_custom_role" "gke-deployer" { - role_id = "gke_deployer" - title = "Minimal IAM role for GKE access" - description = "Bare minimum permissions to access the kubernetes API for using the Jenkins GKE plugin." - project = "${var.project}" - - permissions = [ - "compute.zones.list", - "container.apiServices.get", - "container.apiServices.list", - "container.clusters.get", - "container.clusters.getCredentials", - "container.clusters.list", - "resourcemanager.projects.get", - ] -} - # Create our service account called jenkins-gke-deployer. # More information: https://www.terraform.io/docs/providers/google/r/google_service_account.html resource "google_service_account" "jenkins-gke-deployer" { @@ -46,9 +26,9 @@ resource "google_service_account" "jenkins-gke-deployer" { display_name = "${var.sa_name}" } -# Assign the special IAM role to the service account +# Assign Kubernetes Engine Cluster Viewer IAM role to the service account resource "google_project_iam_member" "jenkins-deployer-gke-access" { project = "${var.project}" - role = "projects/${var.project}/roles/${google_project_iam_custom_role.gke-deployer.role_id}" + role = "roles/container.clusterViewer" member = "serviceAccount:${google_service_account.jenkins-gke-deployer.email}" }