-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for GCP fleet workload identity in KES (#1501)
This allows KES to use the workload identity to communicate with GCP secret store instead of managing and rotating the GCP service account. This PR provides the support by mounting the default app credentials to the KES pods via k8s secret. For more details, please refer https://cloud.google.com/anthos/fleet-management/docs/use-workload-identity.
- Loading branch information
1 parent
511cfc6
commit c8df636
Showing
16 changed files
with
322 additions
and
8 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
examples/kustomization/tenant-kes-encryption-gcp/gcp-default-creds-secret.yaml
This file contains 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: gcp-default-creds | ||
namespace: tenant-kms-encrypted | ||
type: Opaque | ||
stringData: | ||
# NOTE: refer https://cloud.google.com/anthos/fleet-management/docs/use-workload-identity#impersonate_a_service_account for the process to extract application default credentials | ||
# Please replace <WORKLOAD_IDENTITY_POOL>,<IDENTITY_PROVIDER>,<GSA_NAME> and <GSA_PROJECT_ID> with the respective values from application default credentials. | ||
config: | | ||
{ | ||
"type": "external_account", | ||
"audience": "identitynamespace:<WORKLOAD_IDENTITY_POOL>:<IDENTITY_PROVIDER>", | ||
"service_account_impersonation_url": "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/<GSA_NAME>@<GSA_PROJECT_ID>.iam.gserviceaccount.com:generateAccessToken", | ||
"subject_token_type": "urn:ietf:params:oauth:token-type:jwt", | ||
"token_url": "https://sts.googleapis.com/v1/token", | ||
"credential_source": { | ||
"file": "/var/run/secrets/tokens/gcp-ksa/token" | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
examples/kustomization/tenant-kes-encryption-gcp/kes-configuration-secret.yaml
This file contains 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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: kes-configuration | ||
namespace: tenant-kms-encrypted | ||
type: Opaque | ||
stringData: | ||
server-config.yaml: |- | ||
version: v1 | ||
address: :7373 | ||
admin: | ||
identity: _ # Effectively disabled since no root identity necessary. | ||
tls: | ||
key: /tmp/kes/server.key # Path to the TLS private key | ||
cert: /tmp/kes/server.crt # Path to the TLS certificate | ||
proxy: | ||
identities: [] | ||
header: | ||
cert: X-Tls-Client-Cert | ||
policy: | ||
my-policy: | ||
allow: | ||
- /v1/api | ||
- /v1/key/create/* | ||
- /v1/key/import/* | ||
- /v1/key/delete/* | ||
- /v1/key/list/* | ||
- /v1/key/generate/* | ||
- /v1/key/decrypt/* | ||
- /v1/key/encrypt/* | ||
- /v1/key/bulk/decrypt/* | ||
- /v1/status | ||
- /v1/api | ||
- /v1/metrics | ||
- /v1/log/audit | ||
- /v1/log/error | ||
identities: | ||
- ${MINIO_KES_IDENTITY} | ||
cache: | ||
expiry: | ||
any: 5m0s | ||
unused: 20s | ||
log: | ||
error: on | ||
audit: on | ||
keystore: | ||
gcp: | ||
secretmanager: | ||
# The project ID is a unique, user-assigned ID that can be used by Google APIs. | ||
# The project ID must be a unique string of 6 to 30 lowercase letters, digits, or hyphens. | ||
# It must start with a letter, and cannot have a trailing hyphen. | ||
# See: https://cloud.google.com/resource-manager/docs/creating-managing-projects#before_you_begin | ||
project_id: <PROJECT_ID>" | ||
# An optional GCP SecretManager endpoint. If not set, defaults to: secretmanager.googleapis.com:443 | ||
endpoint: "" | ||
# An optional list of GCP OAuth2 scopes. For a list of GCP scopes refer to: https://developers.google.com/identity/protocols/oauth2/scopes | ||
# If not set, the GCP default scopes are used. | ||
scopes: | ||
- "https://www.googleapis.com/auth/cloud-platform" | ||
# The credentials for your GCP service account. If running inside GCP (app engine) the credentials | ||
# can be empty and will be fetched from the app engine environment automatically. | ||
credentials: | ||
client_email: "" # The service account email - e.g. <account>@<project-ID>.iam.gserviceaccount.com | ||
client_id: "" # The service account client ID - e.g. 113491952745362495489" | ||
private_key_id: "" # The service account private key - e.g. 381514ebd3cf45a64ca8adc561f0ce28fca5ec06 | ||
private_key: "" | ||
## KES configured with fs (File System mode) doesnt work in Kubernetes environments and it's not recommended |
9 changes: 9 additions & 0 deletions
9
examples/kustomization/tenant-kes-encryption-gcp/kes-service-account.yaml
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
kind: ServiceAccount | ||
apiVersion: v1 | ||
metadata: | ||
namespace: tenant-kms-encrypted | ||
# This should be the service account which was created in `kes-service-account.yaml` | ||
# Please refer https://cloud.google.com/anthos/fleet-management/docs/use-workload-identity#impersonate_a_service_account to know how | ||
# this service account is authorized to use GCP workload identity | ||
name: <SERVICE_ACCOUNT> | ||
automountServiceAccountToken: false |
13 changes: 13 additions & 0 deletions
13
examples/kustomization/tenant-kes-encryption-gcp/kustomization.yaml
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
namespace: tenant-kms-encrypted | ||
|
||
resources: | ||
- ../base | ||
- kes-configuration-secret.yaml | ||
- gcp-default-creds-secret.yaml | ||
- kes-service-account.yaml | ||
|
||
patchesStrategicMerge: | ||
- tenant.yaml |
64 changes: 64 additions & 0 deletions
64
examples/kustomization/tenant-kes-encryption-gcp/tenant.yaml
This file contains 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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
apiVersion: minio.min.io/v2 | ||
kind: Tenant | ||
metadata: | ||
name: myminio | ||
namespace: minio-tenant | ||
spec: | ||
## Define configuration for KES (stateless and distributed key-management system) | ||
## Refer https://github.com/minio/kes | ||
kes: | ||
image: "" # minio/kes:v0.22.3 | ||
env: [ ] | ||
replicas: 2 | ||
kesSecret: | ||
name: kes-configuration | ||
imagePullPolicy: "IfNotPresent" | ||
gcpCredentialSecretName: gcp-default-creds | ||
gcpWorkloadIdentityPool: <WORKLOAD_IDENTITY_POOL> | ||
## Use this field to provide external certificates for the KES server. TLS for KES pods will be configured | ||
## by mounting a Kubernetes secret under /tmp/kes folder, supported types: | ||
## Opaque | kubernetes.io/tls | cert-manager.io/v1alpha2 | cert-manager.io/v1 | ||
## | ||
## ie: | ||
## | ||
## externalCertSecret: | ||
## name: tls-certificates-for-kes | ||
## type: kubernetes.io/tls | ||
## | ||
## Create secrets as explained here: | ||
## https://github.com/minio/minio/tree/master/docs/tls/kubernetes#2-create-kubernetes-secret | ||
externalCertSecret: null | ||
## Use this field to provide client certificates for KES. This can be used to configure | ||
## mTLS for KES and your KMS. Files will be mounted under /tmp/kes folder, supported types: | ||
## Opaque | kubernetes.io/tls | cert-manager.io/v1alpha2 | cert-manager.io/v1 | ||
## | ||
## ie: | ||
## | ||
## clientCertSecret: | ||
## name: mtls-certificates-for-kms | ||
## type: Opaque | ||
## | ||
## Create secrets as explained here: | ||
## https://github.com/minio/minio/tree/master/docs/tls/kubernetes#2-create-kubernetes-secret | ||
clientCertSecret: null | ||
## Key name to be created on the KMS, default is "my-minio-key" | ||
keyName: "" | ||
|
||
resources: { } | ||
nodeSelector: { } | ||
affinity: | ||
nodeAffinity: { } | ||
podAffinity: { } | ||
podAntiAffinity: { } | ||
tolerations: [ ] | ||
annotations: { } | ||
labels: { } | ||
# This should be the service account which was created in `kes-service-account.yaml` | ||
# Please refer https://cloud.google.com/anthos/fleet-management/docs/use-workload-identity#impersonate_a_service_account to know how | ||
# this service account is authorized to use GCP workload identity | ||
serviceAccountName: "<SERVICE_ACCOUNT>" | ||
securityContext: | ||
runAsUser: 1000 | ||
runAsGroup: 1000 | ||
runAsNonRoot: true | ||
fsGroup: 1000 |
This file contains 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 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 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 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 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 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 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 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.