-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add TLS support #23
Conversation
b47d2b4
to
f73c3ea
Compare
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 = * |
There was a problem hiding this comment.
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 *?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
controllers/mariadb_controller.go
Outdated
tlsSecretHasLabel := tlsSecret.Labels[mariaDBReconcileLabel] == instance.Name | ||
if !tlsSecretHasLabel { | ||
if tlsSecret.Labels == nil { | ||
tlsSecret.Labels = make(map[string]string) | ||
} | ||
tlsSecret.Labels[mariaDBReconcileLabel] = instance.Name |
There was a problem hiding this comment.
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
}
controllers/mariadb_controller.go
Outdated
if k8s_errors.IsConflict(err) { | ||
return ctrl.Result{Requeue: true}, err | ||
} | ||
if k8s_errors.IsNotFound(err) { | ||
return ctrl.Result{Requeue: true}, err | ||
} |
There was a problem hiding this comment.
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?
controllers/mariadb_controller.go
Outdated
if !caSecretHasLabel { | ||
if caSecret.Labels == nil { | ||
caSecret.Labels = make(map[string]string) | ||
} | ||
caSecret.Labels[mariaDBReconcileLabel] = instance.Name |
There was a problem hiding this comment.
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
[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 |
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.
e6bf838
to
2adb965
Compare
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. |
db27379
to
63c7b03
Compare
@olliewalsh: The following tests failed, say
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. |
Closing this initial POC PR. See #119 instead |
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.