Skip to content

Commit a712ce4

Browse files
rene-dekkerclaude
andauthored
[v1.40] Set VOLTRON_CA_SIGNER_NAME env var for certificate management (#4674)
* Set CA_SIGNER_NAME env var on Voltron when certificate management is enabled Passes the InstallationSpec CertificateManagement SignerName to the Voltron container so it can identify the correct CA issuer public key, supporting custom operator signer names (calico-private#11471). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Prefix CA_SIGNER_NAME env var with VOLTRON_ All Voltron env vars use the VOLTRON_ prefix to match envconfig processing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Use CA cert CommonName instead of SignerName for VOLTRON_CA_SIGNER_NAME Expose CACertCommonName() on the CertificateManager interface to provide the parsed CN from the CA certificate. This is the actual value Voltron needs to match against cert.Subject.CommonName in the trust bundle. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Remove redundant embedded field selector for staticcheck Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ba5e3d4 commit a712ce4

4 files changed

Lines changed: 30 additions & 0 deletions

File tree

pkg/controller/certificatemanager/certificatemanager.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ type CertificateManager interface {
119119
// SignCertificate signs a certificate using the certificate manager's private key. The function is assuming that the
120120
// public key of the requestor is already set in the certificate template.
121121
SignCertificate(certificate *x509.Certificate) ([]byte, error)
122+
// CACertCommonName returns the CommonName from the CA certificate's Subject field.
123+
CACertCommonName() string
122124
}
123125

124126
type Option func(cm *certificateManager) error
@@ -559,6 +561,14 @@ func (cm *certificateManager) GetKeyPair(cli client.Client, secretName, secretNa
559561
return keyPair, err
560562
}
561563

564+
// CACertCommonName returns the CommonName from the CA certificate's Subject field.
565+
func (cm *certificateManager) CACertCommonName() string {
566+
if cm.Certificate != nil {
567+
return cm.Subject.CommonName
568+
}
569+
return ""
570+
}
571+
562572
// CertificateManagement returns the CertificateManagement object or nil if it is not configured.
563573
func (cm *certificateManager) CertificateManagement() *operatorv1.CertificateManagement {
564574
return cm.keyPair.CertificateManagement

pkg/controller/manager/manager_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ func (r *ReconcileManager) Reconcile(ctx context.Context, request reconcile.Requ
680680
BindingNamespaces: namespaces,
681681
OSSTenantNamespaces: ossTenantNamespaces,
682682
Manager: instance,
683+
CACertCommonName: certificateManager.CACertCommonName(),
683684
}
684685

685686
// Render the desired objects from the CRD and create or update them.

pkg/render/manager.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ type ManagerConfiguration struct {
187187
ExternalElastic bool
188188

189189
Manager *operatorv1.Manager
190+
191+
// CACertCommonName is the CommonName from the CA certificate used for operator-managed certificates.
192+
// Passed to Voltron so it can identify the correct CA issuer public key.
193+
CACertCommonName string
190194
}
191195

192196
type managerComponent struct {
@@ -549,6 +553,10 @@ func (c *managerComponent) voltronContainer() corev1.Container {
549553
env = append(env, corev1.EnvVar{Name: "VOLTRON_LINSEED_SERVER_CERT", Value: linseedCertPath})
550554
}
551555

556+
if c.cfg.CACertCommonName != "" {
557+
env = append(env, corev1.EnvVar{Name: "VOLTRON_CA_SIGNER_NAME", Value: c.cfg.CACertCommonName})
558+
}
559+
552560
if c.cfg.KeyValidatorConfig != nil {
553561
env = append(env, c.cfg.KeyValidatorConfig.RequiredEnv("VOLTRON_")...)
554562
}

pkg/render/manager_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,16 @@ var _ = Describe("Tigera Secure Manager rendering tests", func() {
877877
Expect(deployment.Spec.Template.Spec.Volumes[0].Secret).To(BeNil())
878878
Expect(deployment.Spec.Template.Spec.Volumes[2].Name).To(Equal(render.ManagerInternalTLSSecretName))
879879
Expect(deployment.Spec.Template.Spec.Volumes[2].Secret).To(BeNil())
880+
881+
voltronContainer := rtest.GetContainer(deployment.Spec.Template.Spec.Containers, render.VoltronName)
882+
var caSignerName string
883+
for _, e := range voltronContainer.Env {
884+
if e.Name == "VOLTRON_CA_SIGNER_NAME" {
885+
caSignerName = e.Value
886+
break
887+
}
888+
}
889+
Expect(caSignerName).NotTo(BeEmpty(), "Expected VOLTRON_CA_SIGNER_NAME to be set")
880890
})
881891

882892
It("should not render PodAffinity when ControlPlaneReplicas is 1", func() {
@@ -1611,6 +1621,7 @@ func renderObjects(roc renderConfig) []client.Object {
16111621
Tenant: roc.tenant,
16121622
Manager: roc.manager,
16131623
ExternalElastic: roc.externalElastic,
1624+
CACertCommonName: certificateManager.CACertCommonName(),
16141625
}
16151626
component, err := render.Manager(cfg)
16161627
Expect(err).To(BeNil(), "Expected Manager to create successfully %s", err)

0 commit comments

Comments
 (0)