Skip to content

Commit

Permalink
Use env to load the TLS certificate
Browse files Browse the repository at this point in the history
Signed-off-by: muicoder <[email protected]>
  • Loading branch information
muicoder committed Jul 5, 2023
1 parent 200196e commit 6162230
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
5 changes: 3 additions & 2 deletions k8sutils/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ func getRedisTLSArgs(tlsConfig *redisv1beta1.TLSConfig, clientHost string) []str
cmd := []string{}
if tlsConfig != nil {
cmd = append(cmd, "--tls")
cmd = append(cmd, "--cacert")
cmd = append(cmd, "/tls/ca.crt")
cmd = append(cmd, "--cacert", "$(REDIS_TLS_CA_KEY)")
cmd = append(cmd, "--cert", "$(REDIS_TLS_CERT)")
cmd = append(cmd, "--key", "$(REDIS_TLS_CERT_KEY)")
cmd = append(cmd, "-h")
cmd = append(cmd, clientHost)
}
Expand Down
23 changes: 3 additions & 20 deletions k8sutils/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,29 +574,12 @@ func getProbeInfo(params containerParameters, probeType string) *corev1.Probe {
}

if params.TLSConfig != nil {
root := "/tls/"

// get and set Defaults
caCert := "ca.crt"
tlsCert := "tls.crt"
tlsCertKey := "tls.key"

if params.TLSConfig.CaKeyFile != "" {
caCert = params.TLSConfig.CaKeyFile
}
if params.TLSConfig.CertKeyFile != "" {
tlsCert = params.TLSConfig.CertKeyFile
}
if params.TLSConfig.KeyFile != "" {
tlsCertKey = params.TLSConfig.KeyFile
}

probeCommand = []string{
"redis-cli", "-p", strconv.Itoa(probePort),
"--tls",
"--cacert", path.Join(root, caCert),
"--cert", path.Join(root, tlsCert),
"--key", path.Join(root, tlsCertKey),
"--cacert", "$(REDIS_TLS_CA_KEY)",
"--cert", "$(REDIS_TLS_CERT)",
"--key", "$(REDIS_TLS_CERT_KEY)",
"ping",
}
}
Expand Down

0 comments on commit 6162230

Please sign in to comment.