|
| 1 | +Project Hierarchy |
| 2 | +================================================== |
| 3 | + |
| 4 | +# NAME |
| 5 | + |
| 6 | + project-hierarchy |
| 7 | + |
| 8 | +# SYNOPSIS |
| 9 | + |
| 10 | + Config Connector compatible YAML files to create |
| 11 | + a folder in an organization, and a project |
| 12 | + beneath it. |
| 13 | + |
| 14 | +# CONSUMPTION |
| 15 | + |
| 16 | + Using [kpt](https://googlecontainertools.github.io/kpt/): |
| 17 | + |
| 18 | + Run `kpt pkg get https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit.git/config-connector/solutions/projects/kpt/project-hierarchy project-hierarchy`. |
| 19 | + |
| 20 | +# REQUIREMENTS |
| 21 | + |
| 22 | + A working Config Connector cluster using a |
| 23 | + service account with the following roles in |
| 24 | + the organization: |
| 25 | + - roles/resourcemanager.folderCreator |
| 26 | + - roles/resourcemanager.projectCreator |
| 27 | + |
| 28 | +# USAGE |
| 29 | + |
| 30 | + Replace the |
| 31 | + `${BILLING_ACCOUNT_ID?}` and `${ORG_ID?}` values: |
| 32 | + |
| 33 | + From within this directory, run |
| 34 | + ``` |
| 35 | + kpt cfg set . billing-account VALUE |
| 36 | + ``` |
| 37 | + and |
| 38 | + ``` |
| 39 | + kpt cfg set . org-id VALUE |
| 40 | + ``` |
| 41 | + replacing `VALUE` with your billing account |
| 42 | + and organization ID respectively. |
| 43 | + |
| 44 | + You will also need to reset the project ID, |
| 45 | + since a project with the given ID already exists. |
| 46 | + ``` |
| 47 | + kpt cfg set . project-id VALUE |
| 48 | + ``` |
| 49 | + |
| 50 | + |
| 51 | + Currently, to create a project under a |
| 52 | + folder, you must supply a numeric folder ID, |
| 53 | + which is only available after the folder is |
| 54 | + created. An issue outlining this shortfall in |
| 55 | + Config Connector functionality is filed on the |
| 56 | + project's GitHub, |
| 57 | + https://github.com/GoogleCloudPlatform/k8s-config-connector/issues/104. |
| 58 | + |
| 59 | + |
| 60 | + To be nested beneath it, the project still needs |
| 61 | + a folder number. This can only be found after |
| 62 | + creating the folder. You can do so with |
| 63 | + ``` |
| 64 | + kubectl apply -f folder.yaml |
| 65 | + ``` |
| 66 | + |
| 67 | + Wait for GCP to generate the folder. |
| 68 | + ``` |
| 69 | + kubectl wait --for=condition=Ready -f folder.yaml |
| 70 | + ``` |
| 71 | + |
| 72 | + Now extract the folder number. |
| 73 | + ``` |
| 74 | + FOLDER_NUMBER=$(kubectl describe -f folder.yaml | grep Name:\ *folders\/ | sed "s/.*folders\///") |
| 75 | + ``` |
| 76 | + You can set the folder number using the |
| 77 | + following command: |
| 78 | + ``` |
| 79 | + kpt cfg set . folder-number $FOLDER_NUMBER --set-by "README-instructions" |
| 80 | + ``` |
| 81 | + |
| 82 | + |
| 83 | + Now you can fully apply this solution. |
| 84 | + ``` |
| 85 | + kubectl apply -f . |
| 86 | + ``` |
| 87 | + |
| 88 | +# LICENSE |
| 89 | + |
| 90 | +Apache 2.0 - See [LICENSE](/LICENSE) for more information. |
0 commit comments