Skip to content

Commit

Permalink
Add Memcached TLS stuffs
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Raisul Islam Evan <raisul@appscode.com>
  • Loading branch information
Evanraisul committed Oct 31, 2024
1 parent 3b38a01 commit 0051e70
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apis/kubedb/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ const (
MemcachedAuthVolumeName = "auth"
MemcachedAuthVolumePath = "/usr/auth"

MemcachedTLSVolumeName = "tls"
MemcachedTLSVolumePath = "/usr/certs"

MemcachedHealthKey = "kubedb_memcached_health_key"
MemcachedHealthValue = "kubedb_memcached_health_value"

Expand Down
18 changes: 18 additions & 0 deletions apis/kubedb/v1/memcached_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
kmapi "kmodules.xyz/client-go/api/v1"
"kmodules.xyz/client-go/apiextensions"
core_util "kmodules.xyz/client-go/core/v1"
meta_util "kmodules.xyz/client-go/meta"
Expand Down Expand Up @@ -291,6 +292,23 @@ func (m *Memcached) setDefaultContainerResourceLimits(podTemplate *ofstv2.PodTem
}
}

// CertificateName returns the default certificate name and/or certificate secret name for a certificate alias
func (m *Memcached) CertificateName(alias MemcachedCertificateAlias) string {
return meta_util.NameWithSuffix(m.Name, fmt.Sprintf("%s-cert", string(alias)))
}

// GetCertSecretName returns the secret name for a certificate alias if any provide,
// otherwise returns default certificate secret name for the given alias.
func (m *Memcached) GetCertSecretName(alias MemcachedCertificateAlias) string {
if m.Spec.TLS != nil {
name, ok := kmapi.GetCertificateSecretName(m.Spec.TLS.Certificates, string(alias))
if ok {
return name
}
}
return m.CertificateName(alias)
}

func (m *MemcachedSpec) GetPersistentSecrets() []string {
return nil
}
Expand Down
1 change: 1 addition & 0 deletions apis/kubedb/v1/memcached_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ type MemcachedCertificateAlias string

const (
MemcachedServerCert MemcachedCertificateAlias = "server"
MemcachedClientCert MemcachedCertificateAlias = "client"
MemcachedMetricsExporterCert MemcachedCertificateAlias = "metrics-exporter"
)

Expand Down

0 comments on commit 0051e70

Please sign in to comment.