$ mkdir credentials-request
You can authenticate the cert-manager Operator for Red Hat OpenShift on the GCP Workload Identity cluster by using the cloud credentials. You can configure the cloud credentials by using the ccoctl
binary.
Generate the cloud credentials for the cert-manager Operator for Red Hat OpenShift by using the ccoctl
binary. Then, apply them to the GCP Workload Identity cluster.
You extracted and prepared the ccoctl
binary.
You have installed version 1.11.1 or later of the cert-manager Operator for Red Hat OpenShift.
You have configured an OpenShift Container Platform cluster with GCP Workload Identity by using the Cloud Credential Operator in a manual mode.
Create a directory to store a CredentialsRequest
resource YAML file by running the following command:
$ mkdir credentials-request
In the credentials-request
directory, create a YAML file that contains the following CredentialsRequest
manifest:
apiVersion: cloudcredential.openshift.io/v1
kind: CredentialsRequest
metadata:
name: cert-manager
namespace: openshift-cloud-credential-operator
spec:
providerSpec:
apiVersion: cloudcredential.openshift.io/v1
kind: GCPProviderSpec
predefinedRoles:
- roles/dns.admin
secretRef:
name: gcp-credentials
namespace: cert-manager
serviceAccountNames:
- cert-manager
The
|
Use the ccoctl
tool to process CredentialsRequest
objects by running the following command:
$ ccoctl gcp create-service-accounts \
--name <user_defined_name> --output-dir=<path_to_output_dir> \
--credentials-requests-dir=<path_to_credrequests_dir> \
--workload-identity-pool <workload_identity_pool> \
--workload-identity-provider <workload_identity_provider> \
--project <gcp_project_id>
$ ccoctl gcp create-service-accounts \
--name abcde-20230525-4bac2781 --output-dir=/home/outputdir \
--credentials-requests-dir=/home/credentials-requests \
--workload-identity-pool abcde-20230525-4bac2781 \
--workload-identity-provider abcde-20230525-4bac2781 \
--project openshift-gcp-devel
Apply the secrets generated in the manifests directory of your cluster by running the following command:
$ ls <path_to_output_dir>/manifests/*-credentials.yaml | xargs -I{} oc apply -f {}
Update the subscription object for cert-manager Operator for Red Hat OpenShift by running the following command:
$ oc -n cert-manager-operator patch subscription openshift-cert-manager-operator --type=merge -p '{"spec":{"config":{"env":[{"name":"CLOUD_CREDENTIALS_SECRET_NAME","value":"gcp-credentials"}]}}}'
Get the name of the redeployed cert-manager controller pod by running the following command:
$ oc get pods -l app.kubernetes.io/name=cert-manager -n cert-manager
NAME READY STATUS RESTARTS AGE
cert-manager-bd7fbb9fc-wvbbt 1/1 Running 0 15m39s
Verify that the cert-manager controller pod is updated with GCP workload identity credential volumes that are mounted under the path specified in mountPath
by running the following command:
$ oc get -n cert-manager pod/<cert-manager_controller_pod_name> -o yaml
spec:
containers:
- args:
...
volumeMounts:
- mountPath: /var/run/secrets/openshift/serviceaccount
name: bound-sa-token
...
- mountPath: /.config/gcloud
name: cloud-credentials
...
volumes:
- name: bound-sa-token
projected:
...
sources:
- serviceAccountToken:
audience: openshift
...
path: token
- name: cloud-credentials
secret:
...
items:
- key: service_account.json
path: application_default_credentials.json
secretName: gcp-credentials