Skip to content

Conversation

@andrewstucki
Copy link
Contributor

This implements external secret-configurable fields any place where cluster sources may be specified. Under cluster source, the affected fields:

Deprecated:

Kafka:

  • clusterSource.staticConfiguration.kafka.tls.caCertSecretKeyRef
  • clusterSource.staticConfiguration.kafka.tls.certSecretRef
  • clusterSource.staticConfiguration.kafka.tls.keySecretRef
  • clusterSource.staticConfiguration.kafka.sasl.passwordSecretRef
  • clusterSource.staticConfiguration.kafka.sasl.oauth.tokenSecretRef
  • clusterSource.staticConfiguration.kafka.sasl.gssapi.passwordSecretRef
  • clusterSource.staticConfiguration.kafka.sasl.awsMskIam.secretKeySecretRef
  • clusterSource.staticConfiguration.kafka.sasl.awsMskIam.sessionTokenSecretRef

Admin:

  • clusterSource.staticConfiguration.admin.tls.caCertSecretKeyRef
  • clusterSource.staticConfiguration.admin.tls.certSecretRef
  • clusterSource.staticConfiguration.admin.tls.keySecretRef
  • clusterSource.staticConfiguration.admin.sasl.passwordSecretRef
  • clusterSource.staticConfiguration.admin.sasl.token

SchemaRegistry:

  • clusterSource.staticConfiguration.schemaRegistry.tls.caCertSecretKeyRef
  • clusterSource.staticConfiguration.schemaRegistry.tls.certSecretRef
  • clusterSource.staticConfiguration.schemaRegistry.tls.keySecretRef
  • clusterSource.staticConfiguration.schemaRegistry.sasl.passwordSecretRef
  • clusterSource.staticConfiguration.schemaRegistry.sasl.token

Added:

For all of the above a corresponding ValueSource field with the following structure was added:

  • inline (string pointer)
  • configMapKeyRef (corev1.ConfigMapKeySelector pointer)
  • secretKeyRef (corev1.SecretKeySelector pointer)
  • externalSecretRef (ExternalSecretKeySelector pointer -- this struct just has a name reference for now)

The general naming convetion is just drop the SecretRef suffix from the above deprecated fields with the exception of token which was renamed authToken. Thus the following fields were added:

Kafka:

  • clusterSource.staticConfiguration.kafka.tls.caCert
  • clusterSource.staticConfiguration.kafka.tls.cert
  • clusterSource.staticConfiguration.kafka.tls.key
  • clusterSource.staticConfiguration.kafka.sasl.password
  • clusterSource.staticConfiguration.kafka.sasl.oauth.token
  • clusterSource.staticConfiguration.kafka.sasl.gssapi.password
  • clusterSource.staticConfiguration.kafka.sasl.awsMskIam.secretKey
  • clusterSource.staticConfiguration.kafka.sasl.awsMskIam.sessionToken

Admin:

  • clusterSource.staticConfiguration.admin.tls.caCert
  • clusterSource.staticConfiguration.admin.tls.cert
  • clusterSource.staticConfiguration.admin.tls.key
  • clusterSource.staticConfiguration.admin.sasl.password
  • clusterSource.staticConfiguration.admin.sasl.authToken

SchemaRegistry:

  • clusterSource.staticConfiguration.schemaRegistry.tls.caCert
  • clusterSource.staticConfiguration.schemaRegistry.tls.cert
  • clusterSource.staticConfiguration.schemaRegistry.tls.key
  • clusterSource.staticConfiguration.schemaRegistry.sasl.password
  • clusterSource.staticConfiguration.schemaRegistry.sasl.authToken

For all of the above fields, we handle them by prioritizing the old, deprecated fields if specified, but if they are not, the new fields are used.

@andrewstucki
Copy link
Contributor Author

Note that we currently have no acceptance tests that validate the work here. I can add one maybe after this general shape lands using something like localstack, but don't want to complicate an already extremely large diff.

@andrewstucki andrewstucki changed the title Implement cluster source fields with external secrets @andrewstucki Implement cluster source fields with external secrets Nov 11, 2025
Copy link
Contributor

@RafalKorepta RafalKorepta left a comment

Choose a reason for hiding this comment

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

LGTM

Brokers: []string{"kafka:9092"},
SASL: &ir.KafkaSASL{
Username: "user",
Password: &ir.ValueSource{},
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 this change is wrong as the test case is named nil values handling. Could you change this to Password: nil?

Comment on lines +194 to +195
// Should the value be contained in a k8s secret rather than configmap, we can refer
// to it here.
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: For consistency the documentation should be exactly the same as for ConfigMapKeyRef or it the comment should clearly state please see ConfigMapKeyRef.

if source := o.GetClusterSource(); source != nil {
if spec := source.GetKafkaAPISpec(); spec != nil {
return spec
return redpandav1alpha2.ConvertKafkaAPISpecToIR(obj.GetNamespace(), spec)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return redpandav1alpha2.ConvertKafkaAPISpecToIR(obj.GetNamespace(), spec)
return redpandav1alpha2.ConvertKafkaAPISpecToIR(o.GetNamespace(), spec)

I think it better match after type check. Never the less it would be good to be consistent with using obj.GetNamespace() or o.GetNamespace().

if source := o.GetRemoteClusterSource(); source != nil {
if spec := source.GetKafkaAPISpec(); spec != nil {
return spec
return redpandav1alpha2.ConvertKafkaAPISpecToIR(obj.GetNamespace(), spec)
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

return nil, err
}
return commonTLS.Config(ctx, k8sClient)
return commonTLS.Config(ctx, k8sClient, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Code comment could help future me why we don't need external secret expander.

return nil, err
}
return commonTLS.Load(ctx, k8sClient)
return commonTLS.Load(ctx, k8sClient, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

Code comment could help future me why we don't need external secret expander.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, I'm not entirely sure where we want to comment that, but the main thing is that the commonTLS stuff here is synthetically constructed via looking at the v1 cluster, it doesn't actually come from a StaticConfiguration, so there's literally no way for it to be an external secret. It's always going to be a SecretKeyRef if commonTLS exists at all based on the returns of this function:

func getCommonTLS(certs *apiCertificates) (*ir.CommonTLS, error) {

@andrewstucki
Copy link
Contributor Author

@RafalKorepta I'll circle back on some of the NIT comments after this lands just so we can unblock some folks.

@andrewstucki andrewstucki enabled auto-merge (squash) November 12, 2025 18:02
@andrewstucki andrewstucki merged commit 103d5f6 into main Nov 12, 2025
10 checks passed
@andrewstucki andrewstucki deleted the as/cluster-source-external-secrets branch November 12, 2025 18:44
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

Successfully merging this pull request may close these issues.

3 participants