-
Notifications
You must be signed in to change notification settings - Fork 236
Group replication SSL #115
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: "mysql.oracle.com/v1" | ||
kind: MySQLCluster | ||
metadata: | ||
name: mysql | ||
spec: | ||
replicas: 3 | ||
sslSecretRef: | ||
name: mysql-ssl-secret |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: mysql-ssl-secret | ||
type: Opaque | ||
data: | ||
ca.crt: <base64'd Root CA certificate> | ||
tls.crt: <base64'd server certificate> | ||
tls.key: <base64'd server private key> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ const ( | |
|
||
mySQLBackupVolumeName = "mysqlbackupvolume" | ||
mySQLVolumeName = "mysqlvolume" | ||
mySQLSSLVolumeName = "mysqlsslvolume" | ||
|
||
replicationGroupPort = 13306 | ||
) | ||
|
@@ -82,6 +83,13 @@ func volumeMounts(cluster *api.MySQLCluster) []v1.VolumeMount { | |
}) | ||
} | ||
|
||
if cluster.RequiresCustomSSLSetup() { | ||
mounts = append(mounts, v1.VolumeMount{ | ||
Name: mySQLSSLVolumeName, | ||
MountPath: "/etc/ssl/mysql", | ||
}) | ||
} | ||
|
||
return mounts | ||
} | ||
|
||
|
@@ -211,6 +219,13 @@ func mysqlServerContainer(cluster *api.MySQLCluster, mysqlServerImage string, ro | |
"--log-error-verbosity=3", | ||
} | ||
|
||
if cluster.RequiresCustomSSLSetup() { | ||
args = append(args, | ||
"--ssl-ca=/etc/ssl/mysql/ca.crt", | ||
"--ssl-cert=/etc/ssl/mysql/tls.crt", | ||
"--ssl-key=/etc/ssl/mysql/tls.key") | ||
} | ||
|
||
entryPointArgs := strings.Join(args, " ") | ||
|
||
cmd := fmt.Sprintf(` | ||
|
@@ -331,6 +346,39 @@ func NewForCluster(cluster *api.MySQLCluster, images operatoropts.Images, servic | |
}) | ||
} | ||
|
||
if cluster.RequiresCustomSSLSetup() { | ||
podVolumes = append(podVolumes, v1.Volume{ | ||
Name: mySQLSSLVolumeName, | ||
VolumeSource: v1.VolumeSource{ | ||
Projected: &v1.ProjectedVolumeSource{ | ||
Sources: []v1.VolumeProjection{ | ||
v1.VolumeProjection{ | ||
Secret: &v1.SecretProjection{ | ||
LocalObjectReference: v1.LocalObjectReference{ | ||
Name: cluster.Spec.SSLSecretRef.Name, | ||
}, | ||
Items: []v1.KeyToPath{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use a TLS secret? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we can use it i'd like to - unfortunately we have to provide the CA cert file too for MySQL to be happy - tls secrets only have the server cert and key pair. Also it isn't tls, it's ssl still. So we could 1) add a ca.crt field to the tls secret. 2) have the ca.crt in a different secret or 3) leave it how it is. Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, shame. I’d follow the naming scheme from the TLS secret and add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
v1.KeyToPath{ | ||
Key: "ca.crt", | ||
Path: "ca.crt", | ||
}, | ||
v1.KeyToPath{ | ||
Key: "tls.crt", | ||
Path: "tls.crt", | ||
}, | ||
v1.KeyToPath{ | ||
Key: "tls.key", | ||
Path: "tls.key", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
containers := []v1.Container{ | ||
mysqlServerContainer(cluster, images.MySQLServerImage, rootPassword, serviceName, replicas, baseServerID), | ||
mysqlAgentContainer(cluster, images.MySQLAgentImage, rootPassword, serviceName, replicas)} | ||
|
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 relevant to this PR but I'd be in favour of abstracting this given how often it comes up in the codebase and how easy it would be to make a mistake by not setting defaults.
cluster := NewMySQLCluster() | NewMySQLClusterWithDefaults()