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

Add support of storing the caBundle in a secret #25728

Merged
merged 1 commit into from Jun 26, 2023

Conversation

farcaller
Copy link
Contributor

@farcaller farcaller commented May 26, 2023

  • For first time contributors, read Submitting a pull request
  • All code is covered by unit and/or runtime tests where feasible.
  • All commits contain a well written commit description including a title,
    description and a Fixes: #XXX line if the commit addresses a particular
    GitHub issue.
  • If your commit description contains a Fixes: <commit-id> tag, then
    please add the commit author[s] as reviewer[s] to this issue.
  • All commits are signed off. See the section Developer’s Certificate of Origin
  • Provide a title or release-note blurb suitable for the release notes.
  • Are you a user of Cilium? Please add yourself to the Users doc
  • Thanks for contributing!

This allows to e.g. pull it from vault via external-secrets (as ES cannot write to a ConfigMap).

Allow to use a Secret for the caBundle

@farcaller farcaller requested review from a team as code owners May 26, 2023 21:38
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label May 26, 2023
@github-actions github-actions bot added the kind/community-contribution This was a contribution made by a community member. label May 26, 2023
@farcaller farcaller force-pushed the helm-ca-secret branch 3 times, most recently from 294f5d3 to c62e407 Compare June 3, 2023 10:06
@sayboras
Copy link
Member

sayboras commented Jun 5, 2023

There are a couple of CI failures, if you are taking a look at logs, there will be steps to rectify.

@sayboras
Copy link
Member

👋 friendly ping if you have a chance to perform the above. Also, would you mind to rebase with main branch for latest CI configuration.

@farcaller
Copy link
Contributor Author

@sayboras thanks for a ping! I got a bit distracted by my cilium setup breaking down in new and exciting ways but I'm back to this and I have a working solution that I just need to rewrite this nix into helm yamls: 😄

{
      patchCM = object:
        let
          volumes = object.spec.template.spec.volumes;
          projected = builtins.filter (v: builtins.hasAttr "projected" v) volumes;
          nonProjected = builtins.filter (v: builtins.hasAttr "projected" v == false) volumes;
          reprojected = builtins.map
            (p: lib.recursiveUpdate p (
              let
                caSources = builtins.filter (s: (s.configMap or { name = ""; }).name == "cilium-ca") p.projected.sources;
                nonCaSources = builtins.filter (s: (s.configMap or { name = ""; }).name != "cilium-ca") p.projected.sources;
                patchedSources = builtins.map
                  (s: {
                    secret = {
                      items = [{ key = "certificate"; path = (builtins.head s.configMap.items).path; }];
                      name = "cilium-ca";
                    };
                  })
                  caSources;
              in
              {
                projected.sources = nonCaSources ++ patchedSources;
              }
            ))
            projected;
        in
        (lib.recursiveUpdate object {
          spec.template.spec.volumes = nonProjected ++ reprojected;
        });

      patchOn = cond: object:
        if (cond object) then patchCM object
        else object;

      patchCiliumDS = patchOn (object: (object.kind == "DaemonSet" && object.metadata.name == "cilium"));
      patchApiServerDeployment = patchOn (object: (object.kind == "Deployment" && object.metadata.name == "clustermesh-apiserver"));
      patchHubbleRelayDeployment = patchOn (object: (object.kind == "Deployment" && object.metadata.name == "hubble-relay"));
      patchHubbleUIDeployment = patchOn (object: (object.kind == "Deployment" && object.metadata.name == "hubble-ui"));
}

@joamaki joamaki requested review from tommyp1ckles and removed request for joamaki June 16, 2023 13:48
@joamaki
Copy link
Contributor

joamaki commented Jun 16, 2023

Heading on vacation so unassigned myself and picked @tommyp1ckles from sig-k8s by lottery (sort -R sig-k8s | head -1).

@ti-mo ti-mo added the release-note/minor This PR changes functionality that users may find relevant to operating Cilium. label Jun 20, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jun 20, 2023
@ti-mo ti-mo added kind/enhancement This would improve or streamline existing functionality. dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. labels Jun 20, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jun 20, 2023
@joestringer
Copy link
Member

cc @cilium/sig-hubble I think some of you folks have spent more time with Cilium's secret management previously and could potentially help advise on the solution here.

@gandro
Copy link
Member

gandro commented Jun 22, 2023

Also cc @giorio94 who added the CA bundle feature in #24862

To me, the overall motivation "this allows to e.g. pull it from vault via external-secrets (as ES cannot write to a ConfigMap)." sounds very reasonable. Since we have not shipped the CA bundle feature in a release yet, I'd even say let's always make it a secret if that makes the CA bundle easier to manage (and I'm not a big fan of having a resource either be a configmap or a secret based on a Helm value).

It was also the case that before we added the CA bundle, the CA was already part of a secret, so that should also not be a problem. But I think it would be interesting to know from @giorio94 if there is a particular reason why the CA bundle is a ConfigMap, or if the intent just was that "it's a public key, so it doesn't need to be a secret".

I'm marking this as a release blocker for now, since I think this is something that we can quite easily resolve now, where it will become harder to resolve once we ship the CA bundle feature in a stable release.

@gandro gandro added the release-blocker/1.14 This issue will prevent the release of the next version of Cilium. label Jun 22, 2023
@giorio94
Copy link
Member

It was also the case that before we added the CA bundle, the CA was already part of a secret, so that should also not be a problem. But I think it would be interesting to know from @giorio94 if there is a particular reason why the CA bundle is a ConfigMap, or if the intent just was that "it's a public key, so it doesn't need to be a secret".

No specific reason beside the fact that it is not a "secret" value as you mentioned, and to mimic the kubernetes behavior (specifically the kube-root-ca.crt ConfigMap, indeed also the default name was picket to look like that). But I don't personally have any objection to making that a secret if it simplifies the CABundle management process.

Copy link
Member

@gandro gandro left a comment

Choose a reason for hiding this comment

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

Please run make -C install/kubernetes, it generates the install/kubernetes/cilium/README.md which needs to be updated if you add or change Helm values.

@gandro
Copy link
Member

gandro commented Jun 22, 2023

Thanks @giorio94 for the quick response!

I did a quick look at trust-manager, and it seems to only support ConfigMaps unfortunately https://cert-manager.io/docs/projects/trust-manager/api-reference/#bundlespectarget

So maybe we do need to use flag that switches between ConfigMap and Secrets 😞

In that case I'll remove the release-blocker label again, since the change with useSecret can be done in a backwards compatible manner and I think this PR still needs a bit of iteration.

@gandro gandro removed the release-blocker/1.14 This issue will prevent the release of the next version of Cilium. label Jun 22, 2023
@giorio94
Copy link
Member

I did a quick look at trust-manager, and it seems to only support ConfigMaps unfortunately https://cert-manager.io/docs/projects/trust-manager/api-reference/#bundlespectarget

Oh right, I actually forgot to double-check it. Thanks!

@gandro gandro requested review from sayboras and removed request for sayboras June 22, 2023 09:13
@farcaller farcaller requested a review from gandro June 22, 2023 16:47
@sayboras
Copy link
Member

/test

Copy link
Member

@sayboras sayboras left a comment

Choose a reason for hiding this comment

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

The changes lgtm ✅

Copy link
Member

@kaworu kaworu left a comment

Choose a reason for hiding this comment

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

Thanks for the patch @farcaller!

Couple of cosmetic comments, but other than that LGTM.

install/kubernetes/cilium/values.yaml.tmpl Outdated Show resolved Hide resolved
Copy link
Member

@kaworu kaworu left a comment

Choose a reason for hiding this comment

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

Please squash all the PR's commits into one on the way!

@farcaller farcaller force-pushed the helm-ca-secret branch 2 times, most recently from 202f059 to b49610e Compare June 23, 2023 08:53
@farcaller farcaller requested a review from kaworu June 23, 2023 08:58
@ti-mo
Copy link
Contributor

ti-mo commented Jun 23, 2023

One more: https://github.com/cilium/cilium/actions/runs/5354804806/jobs/9712313069?pr=25728

-     - Use a Secret instead of a ConfigMap
+     - Use a Secret instead of a ConfigMap.

@farcaller
Copy link
Contributor Author

One more

Done (thought that one was supposed to be re-generated from make -C install/kubernetes)

This allows to e.g. pull it from vault via external-secrets

Signed-off-by: Vladimir Pouzanov <farcaller@gmail.com>
@gandro
Copy link
Member

gandro commented Jun 26, 2023

/test

@gandro gandro removed the request for review from tommyp1ckles June 26, 2023 09:45
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jun 26, 2023
@michi-covalent michi-covalent requested review from a team and learnitall and removed request for a team June 26, 2023 15:51
Copy link
Member

@qmonnet qmonnet left a comment

Choose a reason for hiding this comment

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

“docs” change looks good. Thanks!

@maintainer-s-little-helper maintainer-s-little-helper bot removed the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jun 26, 2023
@michi-covalent michi-covalent merged commit 049e77a into cilium:main Jun 26, 2023
65 checks passed
@farcaller farcaller deleted the helm-ca-secret branch June 26, 2023 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/community-contribution This was a contribution made by a community member. kind/enhancement This would improve or streamline existing functionality. release-note/minor This PR changes functionality that users may find relevant to operating Cilium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet