Skip to content

Commit 16531c4

Browse files
committed
use the internal client CA for the new proxy
On-behalf-of: @SAP [email protected]
1 parent b80d7bb commit 16531c4

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

internal/resources/frontproxy/deployment.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,20 @@ func (r *reconciler) deploymentReconciler() reconciling.NamedDeploymentReconcile
158158
// front-proxy requestheader client cert
159159
mountSecret(r.certName(operatorv1alpha1.RequestHeaderClientCertificate), frontProxyBasepath+"/requestheader-client", true)
160160

161-
// rootshard frontproxy client ca
162-
mountSecret(resources.GetRootShardCAName(r.rootShard, operatorv1alpha1.FrontProxyClientCA), frontProxyBasepath+"/client-ca", true)
163-
164161
// kcp rootshard root ca
165162
mountSecret(resources.GetRootShardCAName(r.rootShard, operatorv1alpha1.RootCA), kcpBasepath+"/tls/ca", true)
166163

164+
// Regular front-proxies use a dedicated client CA. However the internal rootshard proxy
165+
// uses the internal client CA instead to make it easier for the kcp-operator to just use
166+
// a single certificate to access all components.
167+
if r.frontProxy != nil {
168+
// rootshard frontproxy client ca
169+
mountSecret(resources.GetRootShardCAName(r.rootShard, operatorv1alpha1.FrontProxyClientCA), frontProxyBasepath+"/client-ca", true)
170+
} else {
171+
// kcp client ca
172+
mountSecret(resources.GetRootShardCAName(r.rootShard, operatorv1alpha1.ClientCA), kcpBasepath+"/tls/client-ca", true)
173+
}
174+
167175
// front-proxy config
168176
{
169177
cmName := r.pathMappingConfigMapName()
@@ -214,16 +222,21 @@ var defaultArgs = []string{
214222
"--shards-kubeconfig=/etc/kcp-front-proxy/kubeconfig/kubeconfig",
215223
"--tls-private-key-file=/etc/kcp-front-proxy/tls/tls.key",
216224
"--tls-cert-file=/etc/kcp-front-proxy/tls/tls.crt",
217-
"--client-ca-file=/etc/kcp-front-proxy/client-ca/tls.crt",
218225
"--mapping-file=/etc/kcp-front-proxy/config/path-mapping.yaml",
219226
}
220227

221228
func (r *reconciler) getArgs() []string {
222229
args := defaultArgs
230+
231+
// rootshard proxy mode
223232
if r.frontProxy == nil {
233+
args = append(args, fmt.Sprintf("--client-ca-file=%s/tls/client-ca/tls.crt", kcpBasepath))
224234
return args
225235
}
226236

237+
// regular front-proxy
238+
args = append(args, fmt.Sprintf("--client-ca-file=%s/client-ca/tls.crt", frontProxyBasepath))
239+
227240
if auth := r.frontProxy.Spec.Auth; auth != nil {
228241
if auth.DropGroups != nil {
229242
args = append(args, fmt.Sprintf("--authentication-drop-groups=%q", strings.Join(auth.DropGroups, ",")))

internal/resources/frontproxy/deployment_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,8 @@ func TestGetArgs(t *testing.T) {
450450
"--shards-kubeconfig=/etc/kcp-front-proxy/kubeconfig/kubeconfig",
451451
"--tls-private-key-file=/etc/kcp-front-proxy/tls/tls.key",
452452
"--tls-cert-file=/etc/kcp-front-proxy/tls/tls.crt",
453-
"--client-ca-file=/etc/kcp-front-proxy/client-ca/tls.crt",
454453
"--mapping-file=/etc/kcp-front-proxy/config/path-mapping.yaml",
454+
"--client-ca-file=/etc/kcp-front-proxy/client-ca/tls.crt",
455455
},
456456
},
457457
{
@@ -467,8 +467,8 @@ func TestGetArgs(t *testing.T) {
467467
"--shards-kubeconfig=/etc/kcp-front-proxy/kubeconfig/kubeconfig",
468468
"--tls-private-key-file=/etc/kcp-front-proxy/tls/tls.key",
469469
"--tls-cert-file=/etc/kcp-front-proxy/tls/tls.crt",
470-
"--client-ca-file=/etc/kcp-front-proxy/client-ca/tls.crt",
471470
"--mapping-file=/etc/kcp-front-proxy/config/path-mapping.yaml",
471+
"--client-ca-file=/etc/kcp-front-proxy/client-ca/tls.crt",
472472
"--authentication-drop-groups=\"group1,group2\"",
473473
},
474474
},
@@ -485,8 +485,8 @@ func TestGetArgs(t *testing.T) {
485485
"--shards-kubeconfig=/etc/kcp-front-proxy/kubeconfig/kubeconfig",
486486
"--tls-private-key-file=/etc/kcp-front-proxy/tls/tls.key",
487487
"--tls-cert-file=/etc/kcp-front-proxy/tls/tls.crt",
488-
"--client-ca-file=/etc/kcp-front-proxy/client-ca/tls.crt",
489488
"--mapping-file=/etc/kcp-front-proxy/config/path-mapping.yaml",
489+
"--client-ca-file=/etc/kcp-front-proxy/client-ca/tls.crt",
490490
"--authentication-pass-on-groups=\"group3,group4\"",
491491
},
492492
},
@@ -504,8 +504,8 @@ func TestGetArgs(t *testing.T) {
504504
"--shards-kubeconfig=/etc/kcp-front-proxy/kubeconfig/kubeconfig",
505505
"--tls-private-key-file=/etc/kcp-front-proxy/tls/tls.key",
506506
"--tls-cert-file=/etc/kcp-front-proxy/tls/tls.crt",
507-
"--client-ca-file=/etc/kcp-front-proxy/client-ca/tls.crt",
508507
"--mapping-file=/etc/kcp-front-proxy/config/path-mapping.yaml",
508+
"--client-ca-file=/etc/kcp-front-proxy/client-ca/tls.crt",
509509
"--authentication-drop-groups=\"group1\"",
510510
"--authentication-pass-on-groups=\"group2\"",
511511
},

internal/resources/rootshard/certificates.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,11 @@ func OperatorClientCertificateReconciler(rootShard *operatorv1alpha1.RootShard)
261261
},
262262

263263
IssuerRef: certmanagermetav1.ObjectReference{
264-
Name: resources.GetRootShardCAName(rootShard, operatorv1alpha1.FrontProxyClientCA),
264+
// This shard is meant to be used against shards directly (cluster-local) or with
265+
// the internal root shard proxy (also cluster-local). All of these are configured
266+
// to use the regular client CA (not like "normal" front-proxies, which have their
267+
// own CA).
268+
Name: resources.GetRootShardCAName(rootShard, operatorv1alpha1.ClientCA),
265269
Kind: "Issuer",
266270
Group: "cert-manager.io",
267271
},

0 commit comments

Comments
 (0)