Skip to content
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

Make Kuma's init container first by default #3121

Closed
johnharris85 opened this issue Nov 10, 2021 · 18 comments
Closed

Make Kuma's init container first by default #3121

johnharris85 opened this issue Nov 10, 2021 · 18 comments
Assignees
Labels
area/k8s area/kuma-dp good first issue Good for newcomers kind/improvement Improvement on an existing feature triage/accepted The issue was reviewed and is complete enough to start working on it

Comments

@johnharris85
Copy link
Contributor

Summary

Currently we append the Kuma init container to an existing list of init containers:

pod.Spec.InitContainers = append(pod.Spec.InitContainers, ic)
We should insert ourselves first by default to ensure that nothing 'slips through' before we can redirect traffic.

Worth calling out that if anything starts after our init but before kuma-dp it's going to have no network access (unless the ports are explicitly ignored - traffic.kuma.io/exclude-outbound-ports)

Happy to make this change once we decide on the details above ^^.

@johnharris85
Copy link
Contributor Author

Was thinking some more about this. We don't specify a reinvocationpolicy (https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#reinvocation-policy) and the default is never, so even if we put something first, another admission controller could absolutely re-order that without us knowing. If we were to set reinvocation to ifneeded then we would need additional logic to determine if we were already injected to be idempotent, I still don't think we're guaranteed to see the final state though unless we also implemented a validating hook to 'ensure' we were first. This probably needs a little more thought / consensus on how we want to move foward.

@lahabana lahabana added area/k8s area/kuma-dp kind/improvement Improvement on an existing feature triage/pending This issue will be looked at on the next triage meeting labels Nov 22, 2021
@github-actions
Copy link
Contributor

This issue was inactive for 30 days it will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant please comment on it promptly or attend the next triage meeting.

@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Dec 30, 2021
@lahabana lahabana added triage/accepted The issue was reviewed and is complete enough to start working on it and removed triage/pending This issue will be looked at on the next triage meeting triage/stale Inactive for some time. It will be triaged again labels Jan 31, 2022
@lahabana
Copy link
Contributor

Triage: Yes it makes sense

@lahabana lahabana added the good first issue Good for newcomers label Jan 31, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2022

This issue was inactive for 30 days it will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant please comment on it promptly or attend the next triage meeting.

@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Mar 4, 2022
@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label May 23, 2022
@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Jun 23, 2022
@github-actions
Copy link
Contributor

This issue was inactive for 30 days it will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant please comment on it promptly or attend the next triage meeting.

@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Jun 27, 2022
@lahabana lahabana added triage/pending This issue will be looked at on the next triage meeting and removed triage/accepted The issue was reviewed and is complete enough to start working on it labels Jul 15, 2022
@jakubdyszkiewicz
Copy link
Contributor

Triage: let's introduce config in Kuma CP to indicate if we want to inject by default first or last. Then, let's add an annotation to override this behavior.

@jakubdyszkiewicz jakubdyszkiewicz added triage/accepted The issue was reviewed and is complete enough to start working on it and removed triage/pending This issue will be looked at on the next triage meeting labels Jul 25, 2022
@slonka
Copy link
Contributor

slonka commented Sep 13, 2022

This issue is needed to be able to implement this: #2483 - any updates on development here?

@michaelgoodrx
Copy link

Hi, I got pointed to this issue from https://kuma-mesh.slack.com/archives/C013ALVE1GU/p1663005053300479.

We have init containers that need the internet to run. Specifically, they need the internet in order to decrypt secrets and generate a config file. So we actually need the kuma init container to go last, because as soon as it runs, there is no internet access until the sidecar starts.

It sounds like there are use cases where the init container should run first and use cases where the container should run last. It probably doesn't make sense to run it "in the middle".

Also, I noticed the thing about the admission controller too, and I have been a little nervous that one day the order of init containers would change and our apps would no longer start. So would definitely be in favor of setting up reinvocation to make sure it is in the "correct" order. RE #3121 (comment)

@lahabana
Copy link
Contributor

lahabana commented Sep 15, 2022

I was just thinking this could be configurable through container-patches.

Something like:

apiVersion: kuma.io/v1alpha1
kind: ContainerPatch
metadata:
  name: container-patch-1
  namespace: kuma-system
spec:
   initOrder: first|last|<a specific integer>

or after/before container name

@github-actions github-actions bot added the triage/stale Inactive for some time. It will be triaged again label Dec 15, 2022
@github-actions
Copy link
Contributor

This issue was inactive for 90 days. It will be reviewed in the next triage meeting and might be closed.
If you think this issue is still relevant, please comment on it or attend the next triage meeting.

@lahabana lahabana removed the triage/stale Inactive for some time. It will be triaged again label Dec 16, 2022
@lahabana
Copy link
Contributor

This was done by #5436

@michaelgoodrx
Copy link

@lahabana it looks to me like #5436 only changed the order of the sidecar, not the init container.

@curtiscook
Copy link
Contributor

curtiscook commented Feb 18, 2023

@lahabana it looks to me like #5436 only changed the order of the sidecar, not the init container.

IIRC the initcontainer goes first anyway. #5436 only changed the order, but we need to wait for the sidecar to be ready before the application start. I don't think you need #5857 to get the desired behavior

#5498 will implement the wait functionality with a timeout (once it's complete)

@michaelgoodrx
Copy link

IIRC the initcontainer goes first anyway

In the version we are on, it runs last, which is important to us because we have other init containers that need internet access so they have to run before it.

But in my comment, I was pointing out that it looks like you closed this ticket, for changing the init container order, when you actually changed the sidecar order.

@curtiscook
Copy link
Contributor

IIRC the initcontainer goes first anyway

In the version we are on, it runs last, which is important to us because we have other init containers that need internet access so they have to run before it.

But in my comment, I was pointing out that it looks like you closed this ticket, for changing the init container order, when you actually changed the sidecar order.

I didn't close the issue :) but I think there's confusion over this issue. The problem I've been working on addressing is that a container doesn't have DNS access after Init, before sidecar ready. Possible that my issue is separate from this one and we misattributed, but I think my understanding was that this issue was the kuma equivalent of istio/istio#11130

That being said it looks like zekth change to run kuma init as the first init container has been merged so it seems moot?

@michaelgoodrx
Copy link

Sorry, I meant "you" as in Kong, I was assuming you worked for them.

Can you link me to the change that affects the init container? If that was merged then I need to open a ticket, because that breaks the mesh for us.

@curtiscook
Copy link
Contributor

Sorry, I meant "you" as in Kong, I was assuming you worked for them.

Can you link me to the change that affects the init container? If that was merged then I need to open a ticket, because that breaks the mesh for us.

Ah, no I'm a community edition user with a problem that I want to fix :)

This should be the initcontainer pr
#5857

@michaelgoodrx
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/k8s area/kuma-dp good first issue Good for newcomers kind/improvement Improvement on an existing feature triage/accepted The issue was reviewed and is complete enough to start working on it
Projects
None yet
Development

No branches or pull requests

6 participants