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 CA bundle injector #274

Merged
merged 3 commits into from
Aug 15, 2019

Conversation

JacobTanenbaum
Copy link
Contributor

This adds the ability to inject a combined CA bundle into configmaps that are setup to want them

JIRA SDN-496

PTAL @danehans

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 6, 2019
@JacobTanenbaum JacobTanenbaum changed the title WIP Add CA bundle injector [WIP] Add CA bundle injector Aug 6, 2019
func (r *ReconcileConfigMapInjector) Reconcile(request reconcile.Request) (reconcile.Result, error) {
log.Printf("Reconciling update for ca-certs from %s/%s\n", request.Name, request.Namespace)

combinedCAbundleConfigMap := &corev1.ConfigMap{}
Copy link
Contributor

@danehans danehans Aug 7, 2019

Choose a reason for hiding this comment

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

I would like to refrain from referencing the trusted ca bundle by different names such as combined, merged, etc. to avoid confusion. I would like to standardize with trustedCABundle + whatever representing the trusted ca bundle (i.e. combined user/system bundle) and additionalTrustBundle + whatever representing the user-provided bundle. trustBundle can be used to represent a generic trust bundle, not additionalTrustBundle or trustedCABundle specific. I'll make sure my PR's follow the same naming convention.

const TRUST_BUNDLE_CONFIGMAP_ANNOTATION = "config.openshift.io/inject-trusted-cabundle"

// Proxy returns the namespaced name of the proxy
// object named "cluster" in namespace "openshift-config-managed".
Copy link
Contributor

Choose a reason for hiding this comment

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

proxy "cluster' resided in the default ns, not the "openshift-config-managed" ns. cc @squeed

Copy link

Choose a reason for hiding this comment

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

it doesn't reside in any namespace, it's a cluster scoped resource.

Copy link
Contributor

@danehans danehans Aug 8, 2019

Choose a reason for hiding this comment

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

@JacobTanenbaum this is a doc bug that was fixed in https://github.com/openshift/cluster-network-operator/pull/245/files#diff-dc24d687a587f957b553ce29a8dfaff8R40-R46. Rebase your PR from latest master since PR has merged to fix this bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

@bparees what is the difference? I thought default, cluster-scoped and non-namespaced are the same.

Copy link

Choose a reason for hiding this comment

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

default is an actual namespace you can go look at on a cluster

 oc get sa -n default
NAME       SECRETS   AGE
builder    2         124m
default    2         130m
deployer   2         124m

Copy link
Contributor

Choose a reason for hiding this comment

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

@bparees thanks for the clarification.


// TrustBundleConfigMap returns the namespaced name of the ConfigMap
// containing the merged user/system trust bundle.
func TrustBundleConfigMap() types.NamespacedName {
Copy link
Contributor

Choose a reason for hiding this comment

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

s/TrustBundleConfigMap/TrustedCABundleConfigMap/


// TRUST_BUNDLE_CONFIGMAP is the name of the ConfigMap
// containing the combined user/system trust bundle.
const TRUST_BUNDLE_CONFIGMAP = "trusted-ca-bundle"
Copy link
Contributor

Choose a reason for hiding this comment

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

s/TRUST_BUNDLE_CONFIGMAP/TRUSTED_CA_BUNDLE_CONFIGMAP/

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we're likely to have multiple different trust bundles. Let's add proxy to this name so that we can distinguish. We can always provide combinations at some point, but we cannot resplit.

Copy link

Choose a reason for hiding this comment

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

We ended up on this name because the thinking (as driven by @smarterclayton) was that ultimately we would want this to be the mechanism for providing the canonical "CAs to trust" to things on the cluster that wanted to be told what to trust. e.g. if an admin wanted to entirely replace the system trust bundle, this would eventually be that admin-provided bundle. (today it aggregates in system, but at some point we might make it optional to not do that).

So given that target use, i'm reluctant to put proxy back in the name of this thing. But i'm not sure how to reconcile that w/ your goal of "there might be many CA bundles".

I suppose if we ever reach the world I described above, we could introduce "trusted-ca-bundle" as a thing at that point in time, so I guess i'm ok w/ the proposed rename.

tldr: we started out including proxy in the name, i'm ok going back to it I guess.

But this probably also means you're not going to like the label name that we've socialized for people to put on their configmaps (that gets the CAs injected into the CM). So we better settle on that asap as we're causing downstream teams churn every time we change direction on it (we already moved them from annotations to labels).

Copy link

Choose a reason for hiding this comment

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

@smarterclayton is going to weigh in on this, please don't rename anything yet.

// TRUST_BUNDLE_CONFIGMAP_NS is the namespace that hosts the
// ADDL_TRUST_BUNDLE_CONFIGMAP and TRUST_BUNDLE_CONFIGMAP
// ConfigMaps.
const TRUST_BUNDLE_CONFIGMAP_NS = "openshift-config-managed"
Copy link
Contributor

Choose a reason for hiding this comment

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

s/TRUST_BUNDLE_CONFIGMAP_NS/TRUSTED_CA_BUNDLE_CONFIGMAP_NS/


// TRUST_BUNDLE_CONFIGMAP_ANNOTATION is the name of the annotation that
// determines whether or not to inject the combined ca certificate
const TRUST_BUNDLE_CONFIGMAP_ANNOTATION = "config.openshift.io/inject-trusted-cabundle"
Copy link
Contributor

Choose a reason for hiding this comment

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

s/TRUST_BUNDLE_CONFIGMAP_ANNOTATION/TRUSTED_CA_BUNDLE_CONFIGMAP_ANNOTATION/

Copy link

Choose a reason for hiding this comment

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

I think @deads2k is going to suggest this name include proxy for the same reasons he mentioned in another PR (that we might have other bundles to inject in the future). but i'll let him comment.

Copy link

Choose a reason for hiding this comment

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

and @smarterclayton since we went down this path somewhat at your behest, if you do not think we should be anticipating multiple bundles, would also like to hear from you.

Copy link

Choose a reason for hiding this comment

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

@smarterclayton is going to weigh in on this, please don't rename anything yet.


func newReconciler(mgr manager.Manager, status *statusmanager.StatusManager) reconcile.Reconciler {
if err := configv1.Install(mgr.GetScheme()); err != nil {
return &ReconcileConfigMapInjector{}

Choose a reason for hiding this comment

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

Shouldn't this be return nil ?

Choose a reason for hiding this comment

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

Maybe even "bubble-up" the error returned by Install()

@squeed
Copy link
Contributor

squeed commented Aug 8, 2019

So, a question - by making this reliant on an annotation, it means that we always need to watch all configmaps forever. This could easily result in scaling issues, since our client will have every configmap in cache. Can we make this a label?

While the operator-framework doesn't currently support label-selected watches, the underlying client machinery certainly does. That will help us down-the-line.

@enj as the maintainer of the service-ca-controller (which does a similar thing), what do you think?

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 8, 2019
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 8, 2019
@JacobTanenbaum JacobTanenbaum changed the title [WIP] Add CA bundle injector Add CA bundle injector Aug 8, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 8, 2019
@squeed
Copy link
Contributor

squeed commented Aug 13, 2019

I think this is ready to merge - with one question: is the validation cherry-picked from #271 still correct?

@squeed
Copy link
Contributor

squeed commented Aug 13, 2019

I'll approve this - @danehans, can you give it the final lgtm?
/approve

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 13, 2019
This adds the ability to inject a combined CA bundle into configmaps that are setup to want them
@danehans
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 14, 2019
@danehans
Copy link
Contributor

@JacobTanenbaum this PR makes an api call to get the trust bundle configmap for every configmap injection request. See if you can improve in a future PR by adding []byte to ReconcileConfigMapInjector, storing the trust bundle configmap data in the slice, updating the []byte whenever a change to the trust bundle configmap is observed and the configmap data and local []byte differ, using the []byte for injection requests when it's not empty or getting the trust bundle data and populating the []byte when it's empty. Thoughts @squeed?

@bparees
Copy link

bparees commented Aug 14, 2019

/lgtm

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bparees, danehans, JacobTanenbaum, squeed

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@bparees
Copy link

bparees commented Aug 14, 2019

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 14, 2019
@bparees
Copy link

bparees commented Aug 14, 2019

holding in case squashing is in order or other housekeeping.

@squeed
Copy link
Contributor

squeed commented Aug 15, 2019

this PR makes an api call to get the trust bundle configmap for every configmap injection request.

That should be cached, so I'm not so concerned about that.

@squeed
Copy link
Contributor

squeed commented Aug 15, 2019

Looks fine to me, commit-wise
/hold cancel
woo

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 15, 2019
@squeed
Copy link
Contributor

squeed commented Aug 15, 2019

/woof

@openshift-ci-robot
Copy link
Contributor

@squeed: dog image

In response to this:

/woof

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@akostadinov
Copy link

Is there any documentation about how this should be used from user point of view?

wking added a commit to wking/cluster-network-operator that referenced this pull request Oct 30, 2019
…e} log inversion

Typo from e4e10d7 (Adds a CA bundle injector, 2019-08-06, openshift#274).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants