Skip to content

Move CNI template to helm#3581

Merged
zaharidichev merged 7 commits intolinkerd:masterfrom
zaharidichev:zd/move-cni-to-helm
Dec 10, 2019
Merged

Move CNI template to helm#3581
zaharidichev merged 7 commits intolinkerd:masterfrom
zaharidichev:zd/move-cni-to-helm

Conversation

@zaharidichev
Copy link
Member

@zaharidichev zaharidichev commented Oct 15, 2019

This PR moves the cni installation logic from cni-template.go to a helm template. It also simplifies some of the logic around how configuration is being supplied to the plugin.

Fixes: #2921

Signed-off-by: zaharidichev [email protected]

@zaharidichev zaharidichev changed the title WIP: Move CNI template to helm Move CNI template to helm Oct 16, 2019
@zaharidichev zaharidichev force-pushed the zd/move-cni-to-helm branch 3 times, most recently from 718d858 to 05aeeaa Compare October 16, 2019 16:18
Copy link
Member

@alpeb alpeb left a comment

Choose a reason for hiding this comment

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

Nice refactor 👍

I think we can't have cni-plugin.yaml live under charts/linkerd2/templates because it will get picked up by bin/helm-build package when building the helm release or by anyone installing with helm directly with the source (helm install charts/linikerd2). That'll create the cni resources even if not using cni.

Probably the cleanest would be to create a separate chart in charts/cni to house this guy.

@grampelberg
Copy link
Contributor

I'm a big +1 to having a separate chart. We should (as a general rule) be keeping individual charts as small as possible and introducing dependencies between them.

@zaharidichev
Copy link
Member Author

@alpeb Thanks for pointing that out, was not aware. Will split it up!

@zaharidichev
Copy link
Member Author

@alpeb Currently I am reusing the values.go for the cni template. Do we want to split that up as well and have cni_values.go with a corresponding yaml containing defaults?

@alpeb
Copy link
Member

alpeb commented Oct 18, 2019

@alpeb Currently I am reusing the values.go for the cni template. Do we want to split that up as well and have cni_values.go with a corresponding yaml containing defaults?

Yeah, I think it would make sense to have all cleanly separated 👍 People could get confused by those CNI values in the default values.yaml

@zaharidichev
Copy link
Member Author

@alpeb I split up the CNI parts further and added some tests around that. Let me know if that looks better

Copy link
Member

@alpeb alpeb left a comment

Choose a reason for hiding this comment

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

Thanks @zaharidichev !

It all looks good to me 👍 Just one minor comment below. Also, you forgot to remove /charts/linkerd2/templates/cni-plugin.yaml ;-)

I'll try running the CNI integration tests and report back.

| Parameter | Description | Default |
|--------------------------------------|-----------------------------------------------------------------------|-------------------------------|
|`Namespace` | Control plane namespace | `linkerd`|
|`ControllerNamespaceLabel` | Control plane label. Do not edit |`linkerd.io/control-plane-component`|
Copy link
Member

Choose a reason for hiding this comment

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

I believe the default here should be linkerd.io/control-plane-ns

sed -i s~__INBOUND_PORTS_TO_IGNORE__~"${INBOUND_PORTS_TO_IGNORE:=}"~g ${TMP_CONF}
sed -i s~__OUTBOUND_PORTS_TO_IGNORE__~"${OUTBOUND_PORTS_TO_IGNORE:=}"~g ${TMP_CONF}
sed -i s~__SIMULATE__~"${SIMULATE:=false}"~g ${TMP_CONF}
sed -i s~__USE_WAIT_FLAG__~"${USE_WAIT_FLAG:=false}"~g ${TMP_CONF}
Copy link
Member

Choose a reason for hiding this comment

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

Nice riddance, those were indeed not necessary, along with the env vars! 👍

@zaharidichev
Copy link
Member Author

@alpeb Thanks a lot! If I move it from a fork branch to an internal one the tests should be ran automatically, right ?

@alpeb
Copy link
Member

alpeb commented Oct 21, 2019

@alpeb Thanks a lot! If I move it from a fork branch to an internal one the tests should be ran automatically, right ?

I'm afraid not. The CNI integration tests only run when merging to master, or when tagging master.

@alpeb
Copy link
Member

alpeb commented Oct 21, 2019

It took me a while to run the integration tests because I had a misconfigured docker install 😬

They are throwing some errors, could you please address those? It's actually not a big deal to run those tests after all, and they don't even require a cluster.
First do bin/docker-build-cni-plugin and then go test -v github.com/linkerd/linkerd2/cni-plugin/test -integration-tests.
That'll likely complain that the docker image is missing, I think because they're designed to run in master. To run from the branch, just tag the gcr.io/linkerd-io/cni-plugin image with the tag in the error message. After addressing that you'll see the real errors.

Feel free to ping me if you need any assistance.

Copy link
Member

@alpeb alpeb left a comment

Choose a reason for hiding this comment

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

It all looks good to me 👍
Also tested fine in cluster.

@alpeb
Copy link
Member

alpeb commented Oct 22, 2019

@zaharidichev this tested well using the CLI, but in order to do it through Helm, a new value in linkerd's values.yaml file, something like ProxyInit.Enabled will need to be added for the main chart to skip the init containers. I think that can be tackled in a separate PR.

@zaharidichev
Copy link
Member Author

@alpeb there is already Values.NoInitContainer, which is not included in the values.yaml file but it defaults to false. Why is there te need for ProxyInit.Enabled in that case?

@alpeb
Copy link
Member

alpeb commented Oct 23, 2019

You're right, I was thrown off by the absence of NoInitContainer in values.yaml.
After creating some docs explaining how to go about with Helm and CNI, we can add it there, pointing to the docs.

This tested fine in Minikube using the following commands:

(Minikube requires UseWaitFlag=true)
helm install -f ~/k8s/helm/linkerd-overrides.yaml --set UseWaitFlag=true charts/linkerd2-cni
helm install -f ~/k8s/helm/linkerd-overrides.yaml --set NoInitContainer=true --set InstallNamespace=false charts/linkerd

@grampelberg
Copy link
Contributor

Aw man, I hate having PRs fall through the cracks. This looks good to me, @adleong or @ihcsim mind taking a look so we can get two 👍 ?

@zaharidichev
Copy link
Member Author

@grampelberg yes its been a while :) the refactor I did here will align nicely with some other work I am doing atm so that's where my desire to get it merged comes from

Copy link
Contributor

@ihcsim ihcsim left a comment

Choose a reason for hiding this comment

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

@zaharidichev Thanks for cleaning this up 👍!

This branch works with the following commands on my GKE cluster:

# nodes should run Ubuntu, as COS uses read-only root filesystem
$ linkerd install-cni --dest-cni-bin-dir=/home/kubernetes/bin|k apply -f -
$ linkerd install --linkerd-cni-enabled|k apply -f -

$ helm install --name=linkerd2-cni --set DestCNIBinDir=/home/kubernetes/bin charts/linkerd2-cni
$ helm install --name=linkerd2 --set Identity.Issuer.CrtExpiry="Dec 9 16:10:37 2019" --set-file Identity.TrustAnchorsPEM=ca.crt --set-file Identity.Issuer.TLS.CrtPEM=issuer.crt --set-file Identity.Issuer.TLS.KeyPEM=issuer.key --set LinkerdVersion=git-57e39022 --set Proxy.Image.Version=git-57e39022 --set NoInitContainer=true --set InstallNamespace=false charts/linkerd2

See some comments on the README and variable names (in light of the Go convention) below.

Copy link
Contributor

@ihcsim ihcsim left a comment

Choose a reason for hiding this comment

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

LGTM 👍! See a comment below regarding the extra println().

@ihcsim
Copy link
Contributor

ihcsim commented Dec 9, 2019

I just noticed the unresolved conflicts and fork. Please run the integration test on this fork, once the conflicts are resolved, before merging into master. Thanks.

@zaharidichev zaharidichev merged commit 0313f10 into linkerd:master Dec 10, 2019
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.

Convert go-style CNI template to Helm template

4 participants