-
Notifications
You must be signed in to change notification settings - Fork 7
Tokenize Credential Request AWS #782
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
desmax74
wants to merge
3
commits into
trustification:release/3.y.z
Choose a base branch
from
desmax74:occ
base: release/3.y.z
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
Some comments aren't visible on the classic Files Changed page.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: cco-credentialsrequest-access | ||
| rules: | ||
| - apiGroups: ["cloudcredential.openshift.io"] | ||
| resources: ["credentialsrequests"] | ||
| verbs: ["create", "delete", "get", "list", "patch", "update", "watch"] |
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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| labels: | ||
| app.kubernetes.io/name: rhtpa-operator | ||
| app.kubernetes.io/managed-by: kustomize | ||
| name: cco-credentialsrequest-rolebinding | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: cco-credentialsrequest-access | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: rhtpa-operator-controller-manager | ||
| namespace: placeholder |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| apiVersion: cloudcredential.openshift.io/v1 | ||
| kind: CredentialsRequest | ||
| metadata: | ||
| name: my-operator-credentials | ||
| namespace: openshift-cloud-credential-operator | ||
| spec: | ||
| secretRef: | ||
| name: my-cloud-creds | ||
| namespace: my-operator-namespace | ||
| providerSpec: | ||
| apiVersion: cloudcredential.openshift.io/v1 | ||
| kind: AWSProviderSpec # AWS | ||
| statementEntries: | ||
| - effect: Allow | ||
| action: | ||
| - "s3:GetObject" | ||
| - "s3:PutObject" | ||
| - "s3:DeleteObject" | ||
| - "s3:ListBucket" | ||
| - "s3:GetBucketLocation" | ||
| - "s3:ListBucketMultipartUploads" | ||
| - "s3:AbortMultipartUpload" | ||
| - "s3:ListMultipartUploadParts" | ||
| resource: "*" |
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 |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # Tokenize with Cloud Credentials Operator | ||
|
|
||
| Cloud Credentials Operator (CCO) is installed by default on OCP. | ||
| To check the CCO status | ||
|
|
||
| ```console | ||
| oc get clusteroperator cloud-credential | ||
| ``` | ||
| it shows something like | ||
|
|
||
| ```console | ||
| NAME VERSION AVAILABLE PROGRESSING DEGRADED SINCE | ||
| cloud-credential 4.x.x True False False ... | ||
| ``` | ||
| Pod status | ||
| ```console | ||
| oc get pods -n openshift-cloud-credential-operator | ||
| ``` | ||
|
|
||
| Credential requests checks | ||
| ```console | ||
| oc get credentialsrequests -n openshift-cloud-credential-operator | ||
| ``` | ||
|
|
||
| CCO details | ||
| ```console | ||
| oc describe clusteroperator cloud-credential | ||
| ``` | ||
|
|
||
| CCO Modality | ||
| ```console | ||
| oc get cloudcredential cluster -o yaml | ||
| ``` | ||
| On spec.credentialsMode will be the configured setting (Mint, | ||
| Passthrough, Manual, or empty for default). | ||
|
|
||
| ## How the Operator interacts with the CCO | ||
|
|
||
| 1. Operator declares permissions needed in a CredentialsRequest CR in the namespace openshift-cloud-credential-operator | ||
|
|
||
| ```console | ||
| apiVersion: cloudcredential.openshift.io/v1 | ||
| kind: CredentialsRequest | ||
| metadata: | ||
| name: my-operator-credentials | ||
| namespace: openshift-cloud-credential-operator | ||
| spec: | ||
| secretRef: | ||
| name: my-cloud-creds | ||
| namespace: my-operator-namespace | ||
| providerSpec: | ||
| apiVersion: cloudcredential.openshift.io/v1 | ||
| kind: AWSProviderSpec # esempio per AWS | ||
| statementEntries: | ||
|
desmax74 marked this conversation as resolved.
|
||
| - effect: Allow | ||
| action: | ||
| - "s3:GetObject" | ||
| - "s3:PutObject" | ||
| resource: "*" | ||
| ``` | ||
|
|
||
| 2. CCO processes the CR and create a Kubernetes Secret with the cloud credentails | ||
| in the namespace specified in spec.secretRef. | ||
|
|
||
| 3. Operator reads the Secret and uses the credentials to interact with the cloud API. | ||
| The Operator must tolerate the non-immediate availability of the Secret because it takes time to create. | ||
|
|
||
| ## How to integrate the CCO with the Helm Chart Operator | ||
|
|
||
| 1. Define Credential Request in the chart | ||
| 2. | ||
| 2. Configure Deployment to use the secret created by the CCO | ||
|
|
||
| 3. Handling the delay of the creation of the secret | ||
| first approach: init container | ||
| ```console | ||
| initContainers: | ||
| - name: wait-for-creds | ||
| image: registry.redhat.io/openshift4/ose-cli | ||
| command: | ||
| - /bin/bash | ||
| - -c | ||
| - | | ||
| until oc get secret {{ .Release.Name }}-cloud-creds -n {{ | ||
| .Release.Namespace }} 2>/dev/null; do | ||
| echo "Waiting for cloud credentials..." | ||
| sleep 5 | ||
| done | ||
| ``` | ||
| second approach Retry in the Operator's code, but this is available on a full Go Operator | ||
|
|
||
| 4. Support different cloud providers with values configurations | ||
|
|
||
| 5. RBAC needed to create the CredentialsRequest | ||
| 6. Support Manual Mode (STS/WIF): if the cluster uses STS mode, CCO doesn’t create the secret automatically. | ||
| In STS mode the user must : | ||
| 1. Extract CredentialsRequest from chart | ||
| 2. Use ccoctl tool to generate the credentials | ||
| 3. Create the secrets manually before installing the chart. | ||
|
|
||
30 changes: 30 additions & 0 deletions
30
helm-charts/redhat-trusted-profile-analyzer/templates/credentialrequest.yaml
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 |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| {{- if .Values.cloudProvider }} | ||
| apiVersion: cloudcredential.openshift.io/v1 | ||
| kind: CredentialsRequest | ||
| metadata: | ||
| name: {{ .Release.Name }}-cloud-creds | ||
| namespace: openshift-cloud-credential-operator | ||
| spec: | ||
| secretRef: | ||
| name: {{ .Release.Name }}-cloud-creds | ||
| namespace: {{ .Release.Namespace }} | ||
| {{- if eq (toString .Values.ccoMode) "manual" }} | ||
| cloudTokenPath: /var/run/secrets/openshift/serviceaccount/token | ||
| {{- end }} | ||
| {{- if eq .Values.cloudProvider "aws" }} | ||
| providerSpec: | ||
| apiVersion: cloudcredential.openshift.io/v1 | ||
| kind: AWSProviderSpec | ||
| statementEntries: | ||
| {{- toYaml .Values.cloudCredentials.aws.statementEntries | nindent 6 }} | ||
| {{- if eq (toString .Values.ccoMode) "manual" }} | ||
| stsIAMRoleARN: {{ .Values.cloudCredentials.aws.stsIAMRoleARN | default "" | quote }} | ||
| {{- end }} | ||
| {{- else if eq .Values.cloudProvider "gcp" }} | ||
| providerSpec: | ||
| apiVersion: cloudcredential.openshift.io/v1 | ||
| kind: GCPProviderSpec | ||
| predefinedRoles: | ||
| {{- toYaml .Values.cloudCredentials.gcp.permissions | nindent 6 }} | ||
| {{- end }} | ||
| {{- end }} |
Oops, something went wrong.
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.
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.
suggestion (typo): Rephrase this heading for clearer grammar (singular vs plural).
The phrase "Credential requests checks" is awkward. Consider "CredentialRequest checks" or "Credential request checks" for clearer, grammatically correct wording.