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

Allow indentation for multiline strings in yaml strings of different indentation levels #451

Closed
mulhotavares opened this issue Jan 11, 2023 · 4 comments

Comments

@mulhotavares
Copy link

Is your feature request related to a problem? Please describe.
I'm trying to use a multiline string that is used on multiple places in a public helm chart.

I came across this issue which implemented the indent function, but unfortunately, indent doesn't help with the case where the same value is used on multiple places with different indentation levels in the helm chart.

Describe the solution you'd like
Ideally, the plugin should be able to identify the indentation required for that particular string and follow that automatically depending on the context. Manually specifying an indentation, in this case, is not an option because the indentation required depends on the context.

Describe alternatives you've considered
I tried playing around with different indents, but that didn't work.
Another alternative I tried was to replace the placeholders from the values files before doing helm template.
That didn't seem to work either, as argocd-vault-plugin compains with

Error: error unmarshaling JSON: while decoding JSON: Object 'Kind' is missing in

So I'm guessing it only works with actual k8s resources, not with values files.
If we could use argocd-vault-plugin with a values file, a workaround would be to use it before helm template, instead of after it.

Additional context
Basically I'm trying to install Linkerd helm chart, as documented here, but via ArgoCD.
(linkerd-control-plane).
app-version: 2.12.3
chart-version 1.9.5
chart-source

The helm install/template command requires 3 certificates to be passed:

helm install linkerd-control-plane \
  -n linkerd \
  --set-file identityTrustAnchorsPEM=ca.crt \
  --set-file identity.issuer.tls.crtPEM=issuer.crt \
  --set-file identity.issuer.tls.keyPEM=issuer.key \
  linkerd/linkerd-control-plane

So I created an Argocd application to read those values from secrets, like this:

    plugin:
      env:
      - name: HELM_VALUES
        value: |
          identityTrustAnchorsPEM: |
            <path:kv-argocd#linkerd-ca-crt>
          identity:
            issuer:
              tls:
                crtPEM: |
                  <path:kv-argocd#linkerd-issuer-crt | indent 8>
                keyPEM: |
                  <path:kv-argocd#linkerd-issuer-key | indent 8>

indent works great on the last 2 values, but not for identityTrustAnchorsPEM. The reason is that this value will be put in 2 different places:
https://github.com/linkerd/linkerd2/blob/stable-2.12.3/charts/linkerd-control-plane/templates/identity.yaml#L35
and indirectly by dumping all Values here:
https://github.com/linkerd/linkerd2/blob/stable-2.12.3/charts/linkerd-control-plane/templates/config.yaml#L38

If I apply it like that, the cert is correctly replaced on the first yaml, but the identation will be wrong on the second one:

apiVersion: v1
data:
  ca-bundle.crt: |
    -----BEGIN CERTIFICATE-----
    MIIBjjCCATSgAwIBAgIRAL6OjxDYswXXodeFAG600iEwCgYIKoZIzj0EAwIwJTEj
...

vs

apiVersion: v1
data:
...
    identityTrustAnchorsPEM: |
      -----BEGIN CERTIFICATE-----
    MIIBjjCCATSgAwIBAgIRAL6OjxDYswXXodeFAG600iEwCgYIKoZIzj0EAwIwJTEj

If I change the place holder to

          identityTrustAnchorsPEM: |
            <path:kv-argocd#linkerd-ca-crt | indent 2>

I fix the second one, but I break the first one:

apiVersion: v1
data:
  ca-bundle.crt: |
    -----BEGIN CERTIFICATE-----
      MIIBjjCCATSgAwIBAgIRAL6OjxDYswXXodeFAG600iEwCgYIKoZIzj0EAwIwJTEj
...

Although this might seem like an edge case, I think having a value being used on different places is probaly not that unlikely. Maybe a bit more unlikely to have one of this places to be an yaml as string inside another yaml...

@avdicl
Copy link

avdicl commented Mar 8, 2023

This is a frustrating issue. I recommend adding block chomping indicators to the Linkerd ConfigMap(s). You can also see this issue for context.

@werne2j
Copy link
Member

werne2j commented Mar 20, 2023

Looks like the issue is within the linkerd helm chart and a solution was provided above. Going to close this issue.

@werne2j werne2j closed this as completed Mar 20, 2023
@avdicl
Copy link

avdicl commented Mar 20, 2023

Creating additional modifiers for the argocd vault plugin could solve the issue instead of making changes in public helm charts. For my Linkerd identityTrustAnchorsPEM issue practically identical to the one here, having nindent as a modifier on my inline-path placeholder would have solved the issue.

@ppapp92
Copy link

ppapp92 commented Feb 12, 2024

Sorry to revive an old thread but I'm also facing a similar issue. Even the <path:kv-argocd#linkerd-issuer-crt | indent 8> are causing problems in the secret that gets generated.

Did you manage to solve the issue and deploy Linkerd using AVP?

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

No branches or pull requests

4 participants