Skip to content

fix: dont-query-secrets #82

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

Merged
merged 1 commit into from
Apr 24, 2024
Merged

fix: dont-query-secrets #82

merged 1 commit into from
Apr 24, 2024

Conversation

JasonPowr
Copy link
Contributor

Changes the script to, use the bearer token of the service account used to run the SBJ pod.

CC: @tommyd450 @osmman @lance @Gregory-Pereira

Copy link
Member

@lance lance left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@Gregory-Pereira
Copy link
Contributor

Gregory-Pereira commented Apr 22, 2024

IF you want to go this strategy of mounting the token to the pod via the SA, you need to add it to the SA spec as a secret, in the operator code, there is an example of this here in the k8s docs.

I say if though because im not sure how you are going to mount this easily. As portrayed in the main state of the code, the secret is made from a generateName and thus produces something like the following:

oc get secret -n openshift-user-workload-monitoring | grep  prometheus-user-workload-token | head -n 1 | awk '{print $1}'
prometheus-user-workload-token-cw7jl

This is why I make consecutive calls to it rather than mounting it. Also this token is created by the system so not sure you can mount it in a consistent way in yaml without having to get this identifier. I suppose you might be able to do something from the static sa name ...:
oc get sa prometheus-user-workload -n openshift-user-workload-monitoring

@JasonPowr
Copy link
Contributor Author

@Gregory-Pereira I don't believe we need to mount the bearer-token as a secret for the SA, we don't need to use the token outside of this pod, all communication is done inside the pod. So it can just be passed to the function using it.

https://www.ibm.com/docs/en/cloud-private/3.2.x?topic=kubectl-using-service-account-tokens-connect-api-server#pod

@osmman WDYT?

@osmman
Copy link

osmman commented Apr 23, 2024

@Gregory-Pereira I don't believe we need to mount the bearer-token as a secret for the SA, we don't need to use the token outside of this pod, all communication is done inside the pod. So it can just be passed to the function using it.

https://www.ibm.com/docs/en/cloud-private/3.2.x?topic=kubectl-using-service-account-tokens-connect-api-server#pod

@osmman WDYT?

you are correct. The service accounts token is automatically mounted to pod by serviceaccount admission controller and I expect that it is same token which is used by python kubernetes client used in SBJ.

Copy link
Contributor

@Gregory-Pereira Gregory-Pereira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah all this checks out. Sorry for my misunderstandings, after meeting with Jason to understand the changes and re-review ing this gets my conceptual approval. I have not tested it but If you can vouch that it works as intended, I am happy with the direction of the pr.
/lgtm

@JasonPowr
Copy link
Contributor Author

/retest

@JasonPowr JasonPowr merged commit ee37f19 into main Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants