Skip to content

Commit

Permalink
fix: serviceAccountJsonSecretKeyRef for gcedisk
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhail-klimko committed Jun 9, 2024
1 parent 656f89f commit e581e92
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 7 deletions.
6 changes: 3 additions & 3 deletions charts/cf-runtime/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
description: A Helm chart for Codefresh Runner
name: cf-runtime
version: 6.3.30
version: 6.3.31
keywords:
- codefresh
- runner
Expand All @@ -17,8 +17,8 @@ annotations:
artifacthub.io/containsSecurityUpdates: "false"
# Supported kinds: `added`, `changed`, `deprecated`, `removed`, `fixed`, `security`:
artifacthub.io/changes: |
- kind: added
description: Add pullPolicy for dind and engine
- kind: fixed
description: Fix serviceAccountJsonSecretKeyRef for gcedisk
dependencies:
- name: cf-common
repository: oci://quay.io/codefresh/charts
Expand Down
106 changes: 105 additions & 1 deletion charts/cf-runtime/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Codefresh Runner

![Version: 6.3.30](https://img.shields.io/badge/Version-6.3.30-informational?style=flat-square)
![Version: 6.3.31](https://img.shields.io/badge/Version-6.3.31-informational?style=flat-square)

Helm chart for deploying [Codefresh Runner](https://codefresh.io/docs/docs/installation/codefresh-runner/) to Kubernetes.

Expand Down Expand Up @@ -440,6 +440,110 @@ runtime:
topology.kubernetes.io/zone: northeurope-1
```
### GCE Disks backend volume configuration in GKE
`dind-volume-provisioner` should have `ComputeEngine.StorageAdmin` permissions

There are three options:

1. Run `dind-volume-provisioner` pod on the node/node-group with IAM Service Account

```yaml
storage:
# -- Set backend volume type (`local`/`ebs`/`ebs-csi`/`gcedisk`/`azuredisk`)
backend: gcedisk

gcedisk:
# -- Set GCP volume backend type (`pd-ssd`/`pd-standard`)
volumeType: "`pd-standard"
# -- Set GCP volume availability zone
availabilityZone: "us-central1-c"

volumeProvisioner:
# -- Set node selector
nodeSelector: {}
# -- Set tolerations
tolerations: []

# -- Set runtime parameters
runtime:
# -- Parameters for DinD (docker-in-docker) pod
dind:
# -- Set node selector.
nodeSelector:
topology.kubernetes.io/zone: us-central1-c
```
2. Pass static credentials in `.Values.storage.gcedisk.serviceAccountJson` (inlibe) or `.Values.storage.gcedisk.serviceAccountJsonSecretKeyRef` (from your own secret)

```yaml
storage:
# -- Set backend volume type (`local`/`ebs`/`ebs-csi`/`gcedisk`/`azuredisk`)
backend: gcedisk

gcedisk:
# -- Set GCP volume backend type (`pd-ssd`/`pd-standard`)
volumeType: "`pd-standard"
# -- Set GCP volume availability zone
availabilityZone: "us-central1-c"
# -- Set Google SA JSON key for volume-provisioner (optional)
serviceAccountJson: |
{
"type": "service_account",
"project_id": "...",
"private_key_id": "...",
"private_key": "...",
"client_email": "...",
"client_id": "...",
"auth_uri": "...",
"token_uri": "...",
"auth_provider_x509_cert_url": "...",
"client_x509_cert_url": "..."
}
# -- Existing secret containing containing Google SA JSON key for volume-provisioner (optional)
serviceAccountJsonSecretKeyRef: {}
# E.g.:
# serviceAccountJsonSecretKeyRef:
# name: gce-service-account
# key: service-account.json

# -- Set runtime parameters
runtime:
# -- Parameters for DinD (docker-in-docker) pod
dind:
# -- Set node selector.
nodeSelector:
topology.kubernetes.io/zone: us-central1-c
```
3. Assign IAM role to `dind-volume-provisioner` service account

```
storage:
# -- Set backend volume type (`local`/`ebs`/`ebs-csi`/`gcedisk`/`azuredisk`)
backend: gcedisk

gcedisk:
availabilityZone: "us-central1-c"

volumeProvisioner:
# -- Service Account parameters
serviceAccount:
# -- Create service account
create: true
# -- Additional service account annotations
annotations:
iam.gke.io/gcp-service-account: <GSA_NAME>@<PROJECT_ID>.iam.gserviceaccount.com

# -- Set runtime parameters
runtime:
# -- Parameters for DinD (docker-in-docker) pod
dind:
# -- Set node selector.
nodeSelector:
topology.kubernetes.io/zone: us-central1-c
```
### Custom global environment variables
You can add your own environment variables to the runtime environment. All pipeline steps have access to the global variables.
Expand Down
103 changes: 103 additions & 0 deletions charts/cf-runtime/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,109 @@ runtime:
topology.kubernetes.io/zone: northeurope-1
```

### GCE Disks backend volume configuration in GKE

`dind-volume-provisioner` should have `ComputeEngine.StorageAdmin` permissions

There are three options:

1. Run `dind-volume-provisioner` pod on the node/node-group with IAM Service Account

```yaml
storage:
# -- Set backend volume type (`local`/`ebs`/`ebs-csi`/`gcedisk`/`azuredisk`)
backend: gcedisk

gcedisk:
# -- Set GCP volume backend type (`pd-ssd`/`pd-standard`)
volumeType: "`pd-standard"
# -- Set GCP volume availability zone
availabilityZone: "us-central1-c"

volumeProvisioner:
# -- Set node selector
nodeSelector: {}
# -- Set tolerations
tolerations: []

# -- Set runtime parameters
runtime:
# -- Parameters for DinD (docker-in-docker) pod
dind:
# -- Set node selector.
nodeSelector:
topology.kubernetes.io/zone: us-central1-c
```

2. Pass static credentials in `.Values.storage.gcedisk.serviceAccountJson` (inlibe) or `.Values.storage.gcedisk.serviceAccountJsonSecretKeyRef` (from your own secret)

```yaml
storage:
# -- Set backend volume type (`local`/`ebs`/`ebs-csi`/`gcedisk`/`azuredisk`)
backend: gcedisk

gcedisk:
# -- Set GCP volume backend type (`pd-ssd`/`pd-standard`)
volumeType: "`pd-standard"
# -- Set GCP volume availability zone
availabilityZone: "us-central1-c"
# -- Set Google SA JSON key for volume-provisioner (optional)
serviceAccountJson: |
{
"type": "service_account",
"project_id": "...",
"private_key_id": "...",
"private_key": "...",
"client_email": "...",
"client_id": "...",
"auth_uri": "...",
"token_uri": "...",
"auth_provider_x509_cert_url": "...",
"client_x509_cert_url": "..."
}
# -- Existing secret containing containing Google SA JSON key for volume-provisioner (optional)
serviceAccountJsonSecretKeyRef: {}
# E.g.:
# serviceAccountJsonSecretKeyRef:
# name: gce-service-account
# key: service-account.json

# -- Set runtime parameters
runtime:
# -- Parameters for DinD (docker-in-docker) pod
dind:
# -- Set node selector.
nodeSelector:
topology.kubernetes.io/zone: us-central1-c
```

3. Assign IAM role to `dind-volume-provisioner` service account

```
storage:
# -- Set backend volume type (`local`/`ebs`/`ebs-csi`/`gcedisk`/`azuredisk`)
backend: gcedisk

gcedisk:
availabilityZone: "us-central1-c"

volumeProvisioner:
# -- Service Account parameters
serviceAccount:
# -- Create service account
create: true
# -- Additional service account annotations
annotations:
iam.gke.io/gcp-service-account: <GSA_NAME>@<PROJECT_ID>.iam.gserviceaccount.com

# -- Set runtime parameters
runtime:
# -- Parameters for DinD (docker-in-docker) pod
dind:
# -- Set node selector.
nodeSelector:
topology.kubernetes.io/zone: us-central1-c
```

### Custom global environment variables

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ AWS_SECRET_ACCESS_KEY:
{{- end }}

{{- if or .Values.storage.gcedisk.serviceAccountJson .Values.storage.gcedisk.serviceAccountJsonSecretKeyRef }}
GOOGLE_APPLICATION_CREDENTIALS: /etc/dind-volume-provisioner/credentials/google-service-account.json
GOOGLE_APPLICATION_CREDENTIALS: {{ printf "/etc/dind-volume-provisioner/credentials/%s" (.Values.storage.gcedisk.serviceAccountJsonSecretKeyRef.key | default "google-service-account.json") }}
{{- end }}

{{- if and .Values.storage.mountAzureJson }}
Expand Down Expand Up @@ -62,7 +62,7 @@ CLOUDCONFIG_AZURE: /etc/kubernetes/azure.json
optional: true
{{- else if .Values.storage.gcedisk.serviceAccountJsonSecretKeyRef }}
- name: credentials
secrete:
secret:
secretName: {{ .Values.storage.gcedisk.serviceAccountJsonSecretKeyRef.name }}
optional: true
{{- end }}
Expand All @@ -85,4 +85,4 @@ CLOUDCONFIG_AZURE: /etc/kubernetes/azure.json
readOnly: true
mountPath: "/etc/kubernetes/azure.json"
{{- end }}
{{- end }}
{{- end }}

0 comments on commit e581e92

Please sign in to comment.