-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Handle incompatible automount token setting In service account YAML #4651
Comments
New contributor here. I'm gonna hop on this and see if I can figure it out. |
From |
Hi @han-so1omon Ideally, we should be able to add support for the You may want to check out the discussion thread on this PR - #4346 Feel free to reach out on slack if you have any questions! 😄 |
@han-so1omon Hop on the #contributors channel. We can help you out there. |
…inkerd#4651) Following linkerd#4145 the `inject` command will return an error with pods YAML that has the `automountServiceAccountToken` property set to `false`. The same validation should be applied to service accounts YAML. E.g., `linkerd inject` should return an error with the following YAML: ``` kind: ServiceAccount apiVersion: v1 metadata: name: emoji namespace: emojivoto automountServiceAccountToken: false ``` Now instead of skipping service account YAML, `inject` throws an error when `automountServiceAccountToken` is `false`. Using the YAML above: ``` $ cat cli/cmd/testdata/inject_emojivoto_serviceAccount_automountServiceAccountToken_false.input.yml Error transforming resources: failed to inject serviceaccount/emoji: automountServiceAccountToken set to "false" ``` Signed-off-by: Eric Solomon <errcsool@engineer.com>
Null automount token in service account YAML woulc cause dereference error. Use pointer to automount token instead of token itself. This allows for null parameter and prevents the need to establish a default value for automount token. ``` cat cli/cmd/testdata/inject_emojivoto_serviceAccount_automountServiceAccountToken_null.input.yml | bin/go-run cli inject - ``` Fixes linkerd#4651 Signed-off-by: Eric Solomon <errcsool@engineer.com>
`linkerd inject` would not fail correctly if automount token is set to false for a service account YAML. Create saAutomountServiceAccountToken parameter in `pkg/inject/inject.go:ResourceConfig` to capture automount token parameter in service account YAML. Reference this parameter as valid for `nil` or `true` values and invalid for `false` value. ``` cat cli/cmd/testdata/inject_emojivoto_serviceAccount_automountServiceAccountToken_null.input.yml | bin/go-run cli inject - ``` Signed-off-by: Eric Solomon <errcsool@engineer.com>
`linkerd inject` would not fail correctly if automount token is set to false for a service account YAML. Create saAutomountServiceAccountToken parameter in `pkg/inject/inject.go:ResourceConfig` to capture automount token parameter in service account YAML. Reference this parameter as valid for `nil` or `true` values and invalid for `false` value. ``` cat cli/cmd/testdata/inject_emojivoto_serviceAccount_automountServiceAccountToken_null.input.yml | bin/go-run cli inject - ``` Signed-off-by: Eric Solomon <errcsool@engineer.com>
…n: true (linkerd#4651) Signed-off-by: Eric Solomon <errcsool@engineer.com>
Null automount token in service account YAML woulc cause dereference error. Use pointer to automount token instead of token itself. This allows for null parameter and prevents the need to establish a default value for automount token. ``` cat cli/cmd/testdata/inject_emojivoto_serviceAccount_automountServiceAccountToken_null.input.yml | bin/go-run cli inject - ``` Fixes linkerd#4651 Signed-off-by: Eric Solomon <errcsool@engineer.com>
I don't think that this is the right solution to this problem. As @han-so1omon correctly pointed out, ServiceAccounts are not injectable. What we really care about is that if a ServiceAccount with Unfortunately, just failing if a ServiceAccount with Ultimately, trying to catch this at the inject stage seems difficult. Would it be easier to catch this as a validating admission webhook? |
I think I agree with @adleong . Among other things, a failure for serviceaccount yaml If I am understanding your suggestion correctly @adleong , all serviceaccount yaml will pass, and the failure will be delegated to validating admission webhooks. Since I am a new contributor and am not entirely familiar with the architecture, could you explain how this is different from the current behavior? Is validating admission webhooks during runtime, pre-runtime but post-inject, or something else? I believe the idea here is to invalidate incorrect serviceaccount configurations prior to |
Take a look at https://github.com/linkerd/linkerd2/blob/main/controller/proxy-injector/webhook.go The proxy injector is a webhook that sees every pod as they are created and adds the proxy sidecar when appropriate. I think it could also validate that the pod's service account has the correct setting for |
@adleong Thanks. I'll do some digging and write back here. |
Agreed that the injector webhook is an excellent place to validate this. In the One caveat is that |
I'm adding a k8s Does anyone have an idea why this would happen? So far I have added service account support to
Edit: showing
In |
I ran into this today. The automountServiceAccountToken was set to false in the deployment. But I think there is an operational issue. There did not seem to be any evidence of what was happening. No events on the deployment. Proxy injector logs at the default level had no logs. Changing to debug level was still the same behaviour. We are using stable-2.8.1 at the moment. |
Hi @alpeb! |
Sounds to me the latter should do. Looks like we already have a check in place, but do nothing if the mount is not there: Lines 535 to 541 in b5dddf5
|
Signed-off-by: Jimil Desai <jimildesai42@gmail.com>
Signed-off-by: Jimil Desai <jimildesai42@gmail.com>
Signed-off-by: Jimil Desai <jimildesai42@gmail.com>
Signed-off-by: Jimil Desai <jimildesai42@gmail.com>
Signed-off-by: Jimil Desai <jimildesai42@gmail.com>
…inkerd#5549) Fixes linkerd#4651 This PR adds a check in the proxy injector webhook. This checks if the concerned container has serviceaccount volume mounted. In case, the volume is not mounted, which essentially means that automountServiceAccountToken field in the service account used by the injected workload is set to false, we don't inject the sidecar proxy. Signed-off-by: Jimil Desai <jimildesai42@gmail.com> Signed-off-by: Jijeesh <jijeesh.ka@gmail.com>
…inkerd#5549) Fixes linkerd#4651 This PR adds a check in the proxy injector webhook. This checks if the concerned container has serviceaccount volume mounted. In case, the volume is not mounted, which essentially means that automountServiceAccountToken field in the service account used by the injected workload is set to false, we don't inject the sidecar proxy. Signed-off-by: Jimil Desai <jimildesai42@gmail.com> Signed-off-by: Jijeesh <jijeesh.ka@gmail.com>
Following #4145, the
inject
command will return an error with pods YAML that has theautomountServiceAccountToken
property set tofalse
. The same validation should be applied to service accounts YAML. E.g.,linkerd inject
should return an error with the following YAML:The text was updated successfully, but these errors were encountered: