-
Notifications
You must be signed in to change notification settings - Fork 4.5k
helm chart: add Kubernetes Auth options #12314
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
Conversation
Hi @ufou, thank you for opening this PR. I'm going to review it soon, I also asked for @davinchia's eye 👀 😄 |
@@ -22,6 +22,9 @@ spec: | |||
{{- end }} | |||
spec: | |||
serviceAccountName: {{ include "airbyte.serviceAccountName" . }} | |||
{{- if and .Values.serviceAccount.create .Values.kubernetesAuth.tryServiceAccount }} | |||
automountServiceAccountToken: true |
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.
isn't this set to true by default?
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.
I was trying to keep it consistent with the other pod that needs service account token access to k8s https://github.com/airbytehq/airbyte/blob/master/charts/airbyte/templates/worker/deployment.yaml#L22
## @param kubernetesAuth.tryServiceAccount if true, will try to use serviceAccount credentials from serviceAccount.name (default: false) | ||
## | ||
kubernetesAuth: | ||
tryKubeConfig: true |
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.
what does tryKubeConfig
do?
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.
it tells you in the param section a couple of lines up:
## @param kubernetesAuth.tryKubeConfig if true, will try to use kube config mounted inside the pod (default: true)
I defaulted this to true
as this is what seemed to be the way airbyte wanted to auth against k8s, given the errors in the logs
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.
Thanks for the fabric link. I understand this now. What do you think about removing the try kube config option and switching on the service account? I don't think a user would want to want both to be set to true/false so this seems like a clearer configuration option to me. We can have this tryServiceAccount variable be the switch. What do you think?
Can we rename tryServiceAccount
to useServiceAccount
? That seems clearer to me.
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.
Thanks for the fabric link. I understand this now. What do you think about removing the try kube config option and switching on the service account? I don't think a user would want to want both to be set to true/false so this seems like a clearer configuration option to me. We can have this tryServiceAccount variable be the switch. What do you think?
Yeah, sounds good - I'll make the changes - I could not think of a use-case for having kube config mounted inside a k8s pod - but did not want to deviate too much, but I agree - it doesn't make sense - I also think that useServiceAccount
should default to true as, again, I can't see many scenarios where this is not the desired behaviour?
Can we rename
tryServiceAccount
touseServiceAccount
? That seems clearer to me.
Yep, will do
@@ -239,6 +239,16 @@ spec: | |||
configMapKeyRef: | |||
name: {{ include "common.names.fullname" . }}-env | |||
key: INTERNAL_API_HOST | |||
- name: KUBERNETES_AUTH_TRYSERVICEACCOUNT |
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.
what is using these env vars?
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.
I think you are most likely using a k8s client lib to interact with k8s, eg: https://github.com/fabric8io/kubernetes-client/blob/master/README.md#configuring-the-client
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.
Got it. Thanks for the link.
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.
same comment here on adding the link to make it clear what is consuming this
@ufou I took a quick look. I don't understand how this fixes the stated issue. Can you explain more? Have you tested this on the infrastructure you want to support? |
Yeah, we've been running it like this for ~1 month - by default I think the client lib airbyte uses to interact with k8s, expects kube config to be available inside the pod, but for k8s on bare metal (and maybe cloud providers too?) this is not desirable, so instead the option to use service account token is available, the syntax I've used matches that of this client lib, which may or may not be the one airbyte uses: https://github.com/fabric8io/kubernetes-client/blob/master/README.md#configuring-the-client |
@@ -40,6 +43,16 @@ spec: | |||
valueFrom: | |||
fieldRef: | |||
fieldPath: metadata.namespace | |||
- name: KUBERNETES_AUTH_TRYSERVICEACCOUNT |
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.
can we add the link to the fabric client documentation here to make it clear for users what is consuming these?
@ufou thanks for the explanation! I didn't realise you were running this on bare metal Kubernetes. I left some comments around simplifying the configuration. Lmk if this makes sense. |
After merging upstream into my branch and testing again - these changes no longer seem to be required - I'm not sure if the underlying k8s auth mechanism has been updated or not but I no longer need to explicitly declare to use the service account token - and since the service account token is mounted by default this whole PR is moot - maybe the only thing of contention is whether the |
@ufou you are good! I'm not sure what changes would have solved this. Cannot think of any off the top of my head. Thank you for the contribution and sorry it took me a while to get back to you. Feel free to reopen if it's still causing you grief. |
What
Helm chart deployed pod-sweeper and worker pods both require k8s authentication to query the local cluster - this more often requires service account + tokens rather than mounting the kube config fixes #11323
How
this PR offers the helm chart user flexibility to use either kube config or more probably service account + token
Add 2 new ENV vars:
If either is set to
true
then the pod will try to use the authentication method against kubernetes, afaik this is onlyworker
andpod_sweeper
🚨 User Impact 🚨
Should be no breaking changes as the current behaviour is left as default
Pre-merge Checklist
Expand the relevant checklist and delete the others.
New Connector
Community member or Airbyter
airbyte_secret
./gradlew :airbyte-integrations:connectors:<name>:integrationTest
.README.md
bootstrap.md
. See description and examplesdocs/SUMMARY.md
docs/integrations/<source or destination>/<name>.md
including changelog. See changelog exampledocs/integrations/README.md
airbyte-integrations/builds.md
Airbyter
If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.
/test connector=connectors/<name>
command is passing/publish
command described hereUpdating a connector
Community member or Airbyter
airbyte_secret
./gradlew :airbyte-integrations:connectors:<name>:integrationTest
.README.md
bootstrap.md
. See description and examplesdocs/integrations/<source or destination>/<name>.md
including changelog. See changelog exampleAirbyter
If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.
/test connector=connectors/<name>
command is passing/publish
command described hereConnector Generator
-scaffold
in their name) have been updated with the latest scaffold by running./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates
then checking in your changesTests
Unit
Put your unit tests output here.
Integration
Put your integration tests output here.
Acceptance
Put your acceptance tests output here.