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

Linkerd chart anti-patterns around namespace #6463

Closed
darkn3rd opened this issue Jul 11, 2021 · 5 comments
Closed

Linkerd chart anti-patterns around namespace #6463

darkn3rd opened this issue Jul 11, 2021 · 5 comments
Labels
priority/P1 Planned for Release
Milestone

Comments

@darkn3rd
Copy link

If the namespace linkerd already exists, the chart fails. Thus the helm chart is not idempotent, which makes it difficult to manage changes on an existing infrastructure. It is true that this can be overridden (e.g. installNamespace: false), but the helm chart by default is not idempotent.

Embedded namespaces in a helm chart is an anti-pattern as it removes the ability to manage the kubernetes cluster away from the Kubernetes operator, and makes the chart not idempotent.

Further, explicit definition of namespace: linkerd is also an anti-pattern, as this value is set during deployment with .Release.Namespace. Templates can use .Release.Namespace to set values like linkerd.io/control-plane-ns for example.

Steps to Reproduce

LINKERD_EXP=$(date -v+8760H +"%Y-%m-%dT%H:%M:%SZ" 2> /dev/null) || \
 LINKERD_EXP=$(date -d '+8760 hour' +"%Y-%m-%dT%H:%M:%SZ")
export LINKERD_EXP
step certificate create root.linkerd.cluster.local ca.crt ca.key
step certificate create identity.linkerd.cluster.local issuer.crt issuer.key

helm install linkerd \
  --create-namespace --namespace linkerd \
  --set-file identityTrustAnchorsPEM=certs/ca.crt \
  --set-file identity.issuer.tls.crtPEM=certs/issuer.crt \
  --set-file identity.issuer.tls.keyPEM=certs/issuer.key \
  --set identity.issuer.crtExpiry=$LINKERD_EXP \
  linkerd/linkerd2

Additionally, when using downstream tools helmfile, this also reproduces:

## helmfile.yaml - helmfile  apply
repositories:
  - name: linkerd
    url: https://helm.linkerd.io/stable

releases:
  - name: linkerd
    namespace: linkerd
    chart: linkerd/linkerd2
    version: 2.10.2
    values:
      - identityTrustAnchorsPEM: |
{{ readFile "certs/ca.crt" | indent 10 }}
        identity:
          issuer:
            crtExpiry: {{ requiredEnv "LINKERD_EXP" }}
            tls:
              crtPEM: |
{{ readFile "certs/issuer.crt" | indent 16 }}
              keyPEM: |
{{ readFile "certs/issuer.key" | indent 16 }}

Actual Results

The deployment will fail with the following error.

Error: namespaces "linkerd" already exists

Expected Results

I expected this chart to be idempotent. If the namespace linkerd already exists, the chart should not error out. Forcing namespace is an anti-pattern, this should be under the control of the operator.

@alpeb
Copy link
Member

alpeb commented Jul 12, 2021

That's a great point. The reason we set the namespace by default is because it requires metadata that Helm has no way of declaring. We could have gone the other way, and not provide the namespace by default and give instructions about adding that metadata. But that's an additional step that would make things a little bit more complicated for users. Instead, we opted for making things simpler and working out of the box without extra config, while leaving the door open to operators adopting a more "correct" Helm pattern via those params you pointed out.

Also, all this was designed under Helm v2's paradigm (see #3211), so it might be time to take another look and better align with v3's way of doing things. For starters, we should think about ways of no longer depending on that metadata.

There's a section in our Helm docs about Customizing the Namespace. One first thing we could do is better explain how that is a preferred approach, in order to better integrate with other Helm tools.

@adleong adleong added this to the stable-2.11.0 milestone Jul 13, 2021
@adleong adleong added the priority/P1 Planned for Release label Jul 13, 2021
@stale
Copy link

stale bot commented Oct 11, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 11, 2021
@adleong adleong removed the wontfix label Oct 12, 2021
@adleong adleong modified the milestones: stable-2.11.0, stable-2.12.0 Oct 12, 2021
@adleong
Copy link
Member

adleong commented Oct 12, 2021

I believe this is in progress at #6635

@adleong
Copy link
Member

adleong commented Dec 16, 2021

@alpeb this is done, right?

@alpeb
Copy link
Member

alpeb commented Dec 16, 2021

Yep, addressed in #6635

@alpeb alpeb closed this as completed Dec 16, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority/P1 Planned for Release
Projects
None yet
Development

No branches or pull requests

3 participants