-
Notifications
You must be signed in to change notification settings - Fork 15
add support for authentication without GCP Service Account #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nazarewk
wants to merge
3
commits into
pfnet-research:main
Choose a base branch
from
nazarewk:feat/serviceaccount-less
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,10 @@ Note: GKE or Anthos natively support injecting workload identity for pods. This | |
| # The value must be one of 'gcloud'(default) or 'direct'. | ||
| # Refer to the next section for 'direct' injection mode | ||
| cloud.google.com/injection-mode: "gcloud" | ||
|
|
||
| # optional: Defaults to value inside `service-account-email` | ||
| # | ||
| cloud.google.com/project: "12345" | ||
| ``` | ||
|
|
||
| 4. All new pods launched using the Kubernetes `ServiceAccount` will be mutated so that they can impersonate the GCP service account. Below is an example pod spec with the environment variables and volume fields mutated by the webhook. | ||
|
|
@@ -62,13 +66,13 @@ Note: GKE or Anthos natively support injecting workload identity for pods. This | |
| metadata: | ||
| name: app-x-pod | ||
| namespace: service-a | ||
| annotations: | ||
| # optional: A comma-separated list of initContainers and container names | ||
| # to skip adding volumeMounts and environment variables | ||
| cloud.google.com/skip-containers: "init-first,sidecar" | ||
| # optional: Defaults to 86400, or value specified in ServiceAccount | ||
| # annotation as shown in previous step, for expirationSeconds if not set | ||
| cloud.google.com/token-expiration: "86400" | ||
| annotations: | ||
| # optional: A comma-separated list of initContainers and container names | ||
| # to skip adding volumeMounts and environment variables | ||
| cloud.google.com/skip-containers: "init-first,sidecar" | ||
| # optional: Defaults to 86400, or value specified in ServiceAccount | ||
| # annotation as shown in previous step, for expirationSeconds if not set | ||
| cloud.google.com/token-expiration: "86400" | ||
| spec: | ||
| serviceAccountName: app-x | ||
| initContainers: | ||
|
|
@@ -167,27 +171,27 @@ To use direct injection mode: | |
| metadata: | ||
| name: app-x-pod | ||
| namespace: service-a | ||
| annotations: | ||
| # optional: A comma-separated list of initContainers and container names | ||
| # to skip adding volumeMounts and environment variables | ||
| cloud.google.com/skip-containers: "init-first,sidecar" | ||
| # | ||
| # The Generated External Credentials Json is added as an annotation, and mounted into the container filesystem via the DownwardAPI Volume | ||
| # | ||
| cloud.google.com/external-credentials-json: |- | ||
| { | ||
| "type": "external_account", | ||
| "audience": "//iam.googleapis.com/projects/123456789/locations/global/workloadIdentityPools/on-prem-kubernetes/providers/this-cluster", | ||
| "subject_token_type": "urn:ietf:params:oauth:token-type:jwt", | ||
| "token_url": "https://sts.googleapis.com/v1/token", | ||
| "service_account_impersonation_url": "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/[email protected]:generateAccessToken", | ||
| "credential_source": { | ||
| "file": "/var/run/secrets/sts.googleapis.com/serviceaccount/token", | ||
| "format": { | ||
| "type": "text" | ||
| annotations: | ||
| # optional: A comma-separated list of initContainers and container names | ||
| # to skip adding volumeMounts and environment variables | ||
| cloud.google.com/skip-containers: "init-first,sidecar" | ||
| # | ||
| # The Generated External Credentials Json is added as an annotation, and mounted into the container filesystem via the DownwardAPI Volume | ||
| # | ||
| cloud.google.com/external-credentials-json: |- | ||
| { | ||
| "type": "external_account", | ||
| "audience": "//iam.googleapis.com/projects/123456789/locations/global/workloadIdentityPools/on-prem-kubernetes/providers/this-cluster", | ||
| "subject_token_type": "urn:ietf:params:oauth:token-type:jwt", | ||
| "token_url": "https://sts.googleapis.com/v1/token", | ||
| "service_account_impersonation_url": "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/[email protected]:generateAccessToken", | ||
| "credential_source": { | ||
| "file": "/var/run/secrets/sts.googleapis.com/serviceaccount/token", | ||
| "format": { | ||
| "type": "text" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| spec: | ||
| serviceAccountName: app-x | ||
| initContainers: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not obvious whether this needs to be the project ID or the project Number.
If it's normally parsed out of the SA then it seems it should be the Project ID, but the example here has a number?!
Unless "SA" means Kubernetes SA, and the project number is parsed out of workload identity provider annotation?
Either way, it would be clearer if the annotation name was explicit (e.g.
projectIDorprojectNumber)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure whether it matters. I'm not working with GCP for a while already so I can't test, but I remember most of the tools calling the field
projectand accepting both numerical IDs and project names.