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

Roll pod when cert changed #5549

Merged
merged 6 commits into from
Oct 7, 2021
Merged

Conversation

sknot-rh
Copy link
Member

Type of change

  • Enhancement

Description

For now, Kafka does not support reloading the certificates dynamically. Thus, the rolling update is needed when the certificate is changed.

Fixes #5524

Checklist

  • Write tests
  • Make sure all tests pass
  • Update documentation
  • Check RBAC rights for Kubernetes / OpenShift roles
  • Try your changes from Pod inside your Kubernetes and OpenShift cluster, not just locally
  • Reference relevant issue(s) and close them after merging
  • Update CHANGELOG.md
  • Supply screenshots for visual changes, such as Grafana dashboards

@sknot-rh sknot-rh added this to the 0.26.0 milestone Sep 13, 2021
@sknot-rh sknot-rh requested a review from a team September 13, 2021 11:00
Copy link
Member

@scholzj scholzj left a comment

Choose a reason for hiding this comment

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

Few nits but LGTM otherwise.

Do we everywhere check that all the different secrets exist? If not, we might want to couple these two features together, so that we:

  • Provide nice error messages (your code currently seems to expect they exist and if the don't will probably just throw some ugly exceptions)
  • Get the secrets only once

Comment on lines 41 to 62
public Future<String> getCertificateAsync(String namespace, CertSecretSource certSecretSource) {
return this.getAsync(namespace, certSecretSource.getSecretName())
.compose(secret -> Future.succeededFuture(secret.getData().get(certSecretSource.getCertificate())));
}

public Future<CertAndKey> getCertificateAndKeyAsync(String namespace, KafkaClientAuthenticationTls auth) {
return this.getAsync(namespace, auth.getCertificateAndKey().getSecretName())
.compose(secret -> Future.succeededFuture(new CertAndKey(secret.getData().get(auth.getCertificateAndKey().getKey()).getBytes(), secret.getData().get(auth.getCertificateAndKey().getCertificate()).getBytes())));
}

public Future<String> getPasswordAsync(String namespace, KafkaClientAuthentication auth) {
if (auth instanceof KafkaClientAuthenticationPlain) {
return this.getAsync(namespace, ((KafkaClientAuthenticationPlain) auth).getPasswordSecret().getSecretName())
.compose(secret -> Future.succeededFuture(secret.getData().get(((KafkaClientAuthenticationPlain) auth).getPasswordSecret().getPassword())));
}
if (auth instanceof KafkaClientAuthenticationScramSha512) {
return this.getAsync(namespace, ((KafkaClientAuthenticationScramSha512) auth).getPasswordSecret().getSecretName())
.compose(secret -> Future.succeededFuture(secret.getData().get(((KafkaClientAuthenticationScramSha512) auth).getPasswordSecret().getPassword())));
} else {
return Future.failedFuture("Auth type " + auth.getType() + " does not have a password property");
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we really want to have these here? It introduces the api module into this quite heavily which was not the case before. They are also very specific where as the SecretOperator purpose is very generic.

Copy link
Member Author

Choose a reason for hiding this comment

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

@tombentley Do we want to pass certificate, key, and password as a String parameter?

Copy link
Member

Choose a reason for hiding this comment

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

The api is just part of it ... what is the value of having this here instead of in the Util class?

Copy link
Member

Choose a reason for hiding this comment

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

Currently we've failed to really encapsulate and abstract our certificate handling. What I mean by that is everywhere we pass around a Secret which we happen to know contains a key store (broker certificate and key), or truststore (ca certificate). But that requires that the consumer of that Secret knows what type of secret is it, and how to decode the values within it into something it can use.

I think there is value is trying to better encapsulate these concepts, so rather than passing around Secrets we pass around something higher level. For example a AdminClientSupplier might accept some Strimzi Truststore class and a Strimzi Keystore class. Providing Resource Operators for those things (Truststore and Keystore) would be a logical thing to do. This would provide a path towards being able to abstract where certain credentials are stored (e.g. option to store keys in Vault), and should make the KAO slightly simpler to understand, because there are fewer generic Secrets floating around.

At least that was my motivation for suggesting this, and I'd be interested to know whether people think that's a desirable goal or not (and if they have specific reasons to think it wouldn't work out).

@scholzj scholzj requested a review from tombentley September 13, 2021 13:33
@sknot-rh sknot-rh force-pushed the roll-pod-when-cert-changed branch from b46c409 to a842284 Compare September 14, 2021 07:08
@scholzj
Copy link
Member

scholzj commented Sep 16, 2021

/azp run regression

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tombentley
Copy link
Member

@sknot-rh I'm fine with the code, but would like to find a consensus on the abstraction idea before we decide to merge this in its current form.

Signed-off-by: Stanislav Knot <sknot@redhat.com>
Signed-off-by: Stanislav Knot <sknot@redhat.com>
Signed-off-by: Stanislav Knot <sknot@redhat.com>
Signed-off-by: Stanislav Knot <sknot@redhat.com>
Signed-off-by: Stanislav Knot <sknot@redhat.com>
Signed-off-by: Stanislav Knot <sknot@redhat.com>
@sknot-rh sknot-rh force-pushed the roll-pod-when-cert-changed branch from 2a399d7 to 48e22c1 Compare September 23, 2021 15:30
@sknot-rh
Copy link
Member Author

/azp run regression

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@scholzj
Copy link
Member

scholzj commented Oct 7, 2021

/azp run build

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

KafkaConnect and KafkaMirrorMaker2 should roll when certificates or user credentials are updated
3 participants