Skip to content

Commit c2ee2da

Browse files
authored
fix(cert): only mount ca.crt in ca secret (#6455)
1 parent d29021d commit c2ee2da

File tree

5 files changed

+39
-2
lines changed

5 files changed

+39
-2
lines changed

pkg/apiutil/core/v1alpha1/instance.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ func ClusterTLSVolume[
8989
LocalObjectReference: corev1.LocalObjectReference{
9090
Name: ca,
9191
},
92+
Items: []corev1.KeyToPath{
93+
{
94+
Key: corev1.ServiceAccountRootCAKey,
95+
Path: corev1.ServiceAccountRootCAKey,
96+
},
97+
},
9298
},
9399
},
94100
{

pkg/apiutil/core/v1alpha1/tidb.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ func TiDBMySQLTLSVolume(db *v1alpha1.TiDB) *corev1.Volume {
148148
LocalObjectReference: corev1.LocalObjectReference{
149149
Name: ca,
150150
},
151+
Items: []corev1.KeyToPath{
152+
{
153+
Key: corev1.ServiceAccountRootCAKey,
154+
Path: corev1.ServiceAccountRootCAKey,
155+
},
156+
},
151157
},
152158
},
153159
{

pkg/apiutil/core/v1alpha1/tiproxy.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ func TiProxyMySQLTLSVolume(tiproxy *v1alpha1.TiProxy) *corev1.Volume {
131131
LocalObjectReference: corev1.LocalObjectReference{
132132
Name: ca,
133133
},
134+
Items: []corev1.KeyToPath{
135+
{
136+
Key: corev1.ServiceAccountRootCAKey,
137+
Path: corev1.ServiceAccountRootCAKey,
138+
},
139+
},
134140
},
135141
},
136142
{
@@ -233,6 +239,12 @@ func TiProxyHTTPServerTLSVolume(tiproxy *v1alpha1.TiProxy) *corev1.Volume {
233239
LocalObjectReference: corev1.LocalObjectReference{
234240
Name: ca,
235241
},
242+
Items: []corev1.KeyToPath{
243+
{
244+
Key: corev1.ServiceAccountRootCAKey,
245+
Path: corev1.ServiceAccountRootCAKey,
246+
},
247+
},
236248
},
237249
},
238250
{
@@ -360,6 +372,12 @@ func TiProxyBackendTLSVolume(tiproxy *v1alpha1.TiProxy) *corev1.Volume {
360372
LocalObjectReference: corev1.LocalObjectReference{
361373
Name: ca,
362374
},
375+
Items: []corev1.KeyToPath{
376+
{
377+
Key: corev1.ServiceAccountRootCAKey,
378+
Path: corev1.ServiceAccountRootCAKey,
379+
},
380+
},
363381
},
364382
},
365383
{

tests/e2e/framework/workload/options.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ func ConfigJobWithTLS(job *batchv1.Job, o *Options) *batchv1.Job {
9999
LocalObjectReference: corev1.LocalObjectReference{
100100
Name: o.CA,
101101
},
102+
Items: []corev1.KeyToPath{
103+
{
104+
Key: corev1.ServiceAccountRootCAKey,
105+
Path: corev1.ServiceAccountRootCAKey,
106+
},
107+
},
102108
},
103109
},
104110
{

tests/e2e/suite/cluster/tls.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ var _ = ginkgo.Describe("TLS", label.Cluster, label.FeatureTLS, func() {
4040
ns := f.Namespace.Name
4141
cluster := f.Cluster.Name
4242

43-
ca := "cluster-ca"
44-
mysqlClientCA, mysqlServerCertKeyPair := "mysql-ca", "mysql-tls"
43+
// add ns prefix of ca because the bundle is a cluster scope resource
44+
ca := ns + "-cluster-ca"
45+
mysqlClientCA, mysqlServerCertKeyPair := ns+"-mysql-ca", "mysql-tls"
4546
pdg := f.MustCreatePD(ctx,
4647
data.WithMSMode(),
4748
data.WithClusterTLS[*runtime.PDGroup](ca, "pd-internal"),

0 commit comments

Comments
 (0)