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 TLS support #23

Closed
wants to merge 2 commits into from
Closed

Conversation

olliewalsh
Copy link
Contributor

Add a TLS property to the CR to specify the the cert and CA secrets.
TLS/secretName and TLS/caSecretName seems to be the convention in other
operators.

Add secrets to rbac and fix missing patch support for pods. Fix Pod
CreateOrUpdate logic.

Trigger reconcile using a label watch as we do not own the TLS secrets.

Add volume mounts for the TLS secrets and kolla config.
Fix mariadb conf ownership, it was being silently ignored.

@olliewalsh olliewalsh requested review from dprince, abays and stuggi July 1, 2022 11:57
@olliewalsh olliewalsh force-pushed the tls branch 2 times, most recently from b47d2b4 to f73c3ea Compare July 1, 2022 20:45
Comment on lines +25 to +28
ssl-cert = /etc/pki/tls/certs/mariadb.crt
ssl-cipher = !SSLv2:kEECDH:kRSA:kEDH:kPSK:+3DES:!aNULL:!eNULL:!MD5:!EXP:!RC4:!SEED:!IDEA:!DES:!SSLv3:!TLSv1
ssl-key = /etc/pki/tls/private/mariadb.key
ssl-ca = /etc/pki/tls/certs/mariadbca.crt
Copy link
Contributor

Choose a reason for hiding this comment

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

does it still start without TLS? because we do not force TLS if I read the above correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. The client decides to initiate the SSL handshake. If the SSL files
exist on the server then it will work. There is a conf option to force ssl
by default but it does not exist in this version of mariadb
https://mariadb.com/kb/en/server-system-variables/#require_secure_transport.

I believe we can require SSL for specific accounts though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was when using centos8/train images. If the target is centos9/wallaby then we should have require_secure_transport as it's mariadb 10.5.16.

@@ -7,7 +7,7 @@ key_buffer_size = 16M

[mysqld]
basedir = /usr
bind-address = 127.0.0.1
bind-address = *
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to listen on *?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, loopback would only be accessible within the pod. It's the default that we have been using all along since mysql user could not read this file.

Copy link
Contributor

Choose a reason for hiding this comment

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

we could set the actual ip via an init container to the status.PodIP, but not sure if that is better than * as we only have a single pod interface.

Copy link
Contributor Author

@olliewalsh olliewalsh Aug 19, 2022

Choose a reason for hiding this comment

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

keystone-operator apache uses Listen 0.0.0.0:5000, which is basically the same but IPv4 only. In fact we should change keystone to Listen 5000.

Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -20,6 +20,15 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)


// TLSSpec defines the TLS options
type TLSSpec struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure how static this is. is this a generic type we want to add to lib-common as its used by all operators?

Comment on lines 176 to 181
tlsSecretHasLabel := tlsSecret.Labels[mariaDBReconcileLabel] == instance.Name
if !tlsSecretHasLabel {
if tlsSecret.Labels == nil {
tlsSecret.Labels = make(map[string]string)
}
tlsSecret.Labels[mariaDBReconcileLabel] = instance.Name
Copy link
Contributor

Choose a reason for hiding this comment

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

could also use labels.Merge

if value, ok := tlsSecret.Labels[mariaDBReconcileLabel]; !ok || value != instance.Name {
    tlsSecret.GetObjectMeta().SetLabels(labels.Merge(tlsSecret.GetObjectMeta().GetLabels(), tlsSecret.Labels[mariaDBReconcileLabel] = instance.Name)
    ... update secret
}

Comment on lines 184 to 289
if k8s_errors.IsConflict(err) {
return ctrl.Result{Requeue: true}, err
}
if k8s_errors.IsNotFound(err) {
return ctrl.Result{Requeue: true}, err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

could do this in one if as the return ctrl is the same?

Comment on lines 207 to 211
if !caSecretHasLabel {
if caSecret.Labels == nil {
caSecret.Labels = make(map[string]string)
}
caSecret.Labels[mariaDBReconcileLabel] = instance.Name
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above, could use labels.Merge

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Apr 24, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: olliewalsh

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

Add a TLS property to the CR to specify the the cert and CA secrets.
TLS/secretName and TLS/caSecretName seems to be the convention in other
operators.

Add secrets to rbac and fix missing patch support for pods. Fix Pod
CreateOrUpdate logic.

Trigger reconcile using a label watch as we do not own the TLS secrets.

Add volume mounts for the TLS secrets and kolla config.
Fix mariadb conf ownership, it was being silently ignored.
@openshift-merge-robot
Copy link
Collaborator

PR needs rebase.

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.

@olliewalsh olliewalsh force-pushed the tls branch 2 times, most recently from db27379 to 63c7b03 Compare May 11, 2023 15:05
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 8, 2023

@olliewalsh: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/images a1c76ba link true /test images
ci/prow/unit a1c76ba link true /test unit
ci/prow/precommit-check a1c76ba link true /test precommit-check
ci/prow/mariadb-operator-build-deploy-kuttl a1c76ba link true /test mariadb-operator-build-deploy-kuttl

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@olliewalsh
Copy link
Contributor Author

Closing this initial POC PR. See #119 instead

@olliewalsh olliewalsh closed this Jan 12, 2024
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