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

PolicyRecommendation controller overwrites tigera-ca bundle per tenant #3191

Merged
merged 4 commits into from
Feb 24, 2024

Conversation

asincu
Copy link
Contributor

@asincu asincu commented Feb 22, 2024

Description

Tigera-ca-bundle is created by the tenant controller for a multi-tenant setup (https://github.com/tigera/operator/blob/master/pkg/controller/secrets/tenant_controller.go#L187-L212). This gets overwritten by PolicyRecommendation Controller. This causes Linseed to reject connection with Elastic.

kubectl logs -ncc-tenant-a1q3vp13 tigera-linseed-d95447fc8-8q6zc -ctigera-linseed
2024-02-22 00:38:02.708 [FATAL][1] elastic.go 59: Failed to create Elastic client error=health check timeout: Head "https://es-lss-gcpdev-01.dev.calicocloud.io:443": tls: failed to verify certificate: x509: certificate signed by unknown authority: no Elasticsearch node available

Screenshot from 2024-02-21 16-37-04

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

@asincu asincu requested a review from a team as a code owner February 22, 2024 00:37
@marvin-tigera marvin-tigera added this to the v1.34.0 milestone Feb 22, 2024
@asincu asincu changed the title PolicyRecommendation controller overwrite tigera-ca bundle per tenant PolicyRecommendation controller overwrites tigera-ca bundle per tenant Feb 22, 2024
pkg/controller/secrets/tenant_controller.go Outdated Show resolved Hide resolved
KeyPairOptions: []rcertificatemanagement.KeyPairOption{
rcertificatemanagement.NewKeyPairOption(policyRecommendationKeyPair, true, true),
},
TrustedBundle: nil,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is nil the right value here? I'm not sure what the downstream result of this value being nil would be when setting these environment variables: https://github.com/tigera/operator/blob/master/pkg/render/policyrecommendation.go#L303

I think the difference you're intending is that in multi-tenant mode we simply load the existing trusted bundle created by the tenant controller, while in single or zero-tenant mode we need to create a trusted bundle, but in both cases I think we still need to populate the TrustedBundle field no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For multi-tenant, we should leave this nil because we want to create the secrets that contain the x509 certificates, but not the actual config map tigera-ca-bundle. For zero-tenant/single-tenant we want both the secrets and the config map created, because we install in tigera-policy-recommendation namespace.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh so when those environment variables are blank it will trigger creation of the x509 certificates?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, the secrets that hold the certificates.

return reconcile.Result{}, err
}

components = append(components, component)
Copy link
Member

Choose a reason for hiding this comment

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

By adding the component after the other components, doesn't the operator try to render tls assets before the namespace exists on the first ever iteration? I think that would create an unnecessary error in the logs / tigerastatus.

Copy link
Member

@rene-dekker rene-dekker left a comment

Choose a reason for hiding this comment

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

lgtm

@rene-dekker
Copy link
Member

/merge-when-ready

@marvin-tigera
Copy link
Contributor

OK, I will merge the pull request when it's ready, leave the commits as is when I merge it, and leave the branch after I've merged it.

@marvin-tigera marvin-tigera merged commit bc08b8a into tigera:master Feb 24, 2024
5 checks passed
@asincu asincu deleted the linseed_missing_external_ca branch February 26, 2024 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants