@@ -79,17 +79,17 @@ func startFrontProxy(
79
79
Path : "/services/" ,
80
80
// TODO: support multiple virtual workspace backend servers
81
81
Backend : fmt .Sprintf ("https://localhost:%s" , vwPort ),
82
- BackendServerCA : filepath .Join (workDirPath , ".kcp/ serving-ca.crt" ),
83
- ProxyClientCert : filepath .Join (workDirPath , ".kcp-front-proxy/ requestheader.crt" ),
84
- ProxyClientKey : filepath .Join (workDirPath , ".kcp-front-proxy/ requestheader.key" ),
82
+ BackendServerCA : filepath .Join (workDirPath , ".kcp" , " serving-ca.crt" ),
83
+ ProxyClientCert : filepath .Join (workDirPath , ".kcp-front-proxy" , " requestheader.crt" ),
84
+ ProxyClientKey : filepath .Join (workDirPath , ".kcp-front-proxy" , " requestheader.key" ),
85
85
},
86
86
{
87
87
Path : "/clusters/" ,
88
88
// TODO: support multiple shard backend servers
89
89
Backend : "https://localhost:6444" ,
90
- BackendServerCA : filepath .Join (workDirPath , ".kcp/ serving-ca.crt" ),
91
- ProxyClientCert : filepath .Join (workDirPath , ".kcp-front-proxy/ requestheader.crt" ),
92
- ProxyClientKey : filepath .Join (workDirPath , ".kcp-front-proxy/ requestheader.key" ),
90
+ BackendServerCA : filepath .Join (workDirPath , ".kcp" , " serving-ca.crt" ),
91
+ ProxyClientCert : filepath .Join (workDirPath , ".kcp-front-proxy" , " requestheader.crt" ),
92
+ ProxyClientKey : filepath .Join (workDirPath , ".kcp-front-proxy" , " requestheader.key" ),
93
93
},
94
94
}
95
95
@@ -98,13 +98,13 @@ func startFrontProxy(
98
98
return fmt .Errorf ("error marshaling mappings yaml: %w" , err )
99
99
}
100
100
101
- if err := os .WriteFile (filepath .Join (workDirPath , ".kcp-front-proxy/ mapping.yaml" ), mappingsYAML , 0644 ); err != nil {
101
+ if err := os .WriteFile (filepath .Join (workDirPath , ".kcp-front-proxy" , " mapping.yaml" ), mappingsYAML , 0644 ); err != nil {
102
102
return fmt .Errorf ("failed to create front-proxy mapping.yaml: %w" , err )
103
103
}
104
104
105
105
// write root shard kubeconfig
106
106
configLoader := clientcmd .NewNonInteractiveDeferredLoadingClientConfig (
107
- & clientcmd.ClientConfigLoadingRules {ExplicitPath : filepath .Join (workDirPath , ".kcp-0/ admin.kubeconfig" )},
107
+ & clientcmd.ClientConfigLoadingRules {ExplicitPath : filepath .Join (workDirPath , ".kcp-0" , " admin.kubeconfig" )},
108
108
& clientcmd.ConfigOverrides {CurrentContext : "shard-base" },
109
109
)
110
110
raw , err := configLoader .RawConfig ()
@@ -115,31 +115,31 @@ func startFrontProxy(
115
115
if err := clientcmdapi .MinifyConfig (& raw ); err != nil {
116
116
return err
117
117
}
118
- if err := clientcmd .WriteToFile (raw , filepath .Join (workDirPath , ".kcp/ root.kubeconfig" )); err != nil {
118
+ if err := clientcmd .WriteToFile (raw , filepath .Join (workDirPath , ".kcp" , " root.kubeconfig" )); err != nil {
119
119
return err
120
120
}
121
121
122
122
// create serving cert
123
- hostnames := sets .New [ string ] ("localhost" , hostIP )
123
+ hostnames := sets .New ("localhost" , hostIP )
124
124
logger .Info ("creating kcp-front-proxy serving cert with hostnames" , "hostnames" , hostnames )
125
125
cert , err := servingCA .MakeServerCert (hostnames , 365 )
126
126
if err != nil {
127
127
return fmt .Errorf ("failed to create server cert: %w" , err )
128
128
}
129
- if err := cert .WriteCertConfigFile (filepath .Join (workDirPath , ".kcp-front-proxy/ apiserver.crt" ), filepath .Join (workDirPath , ".kcp-front-proxy/ apiserver.key" )); err != nil {
129
+ if err := cert .WriteCertConfigFile (filepath .Join (workDirPath , ".kcp-front-proxy" , " apiserver.crt" ), filepath .Join (workDirPath , ".kcp-front-proxy" , " apiserver.key" )); err != nil {
130
130
return fmt .Errorf ("failed to write server cert: %w" , err )
131
131
}
132
132
133
133
// run front-proxy command
134
134
commandLine := append (kcptestingserver .Command ("kcp-front-proxy" , "front-proxy" ),
135
135
"--bind-address=" + hostIP ,
136
- fmt .Sprintf ("--mapping-file=%s" , filepath .Join (workDirPath , ".kcp-front-proxy/ mapping.yaml" )),
136
+ fmt .Sprintf ("--mapping-file=%s" , filepath .Join (workDirPath , ".kcp-front-proxy" , " mapping.yaml" )),
137
137
fmt .Sprintf ("--root-directory=%s" , filepath .Join (workDirPath , ".kcp-front-proxy" )),
138
- fmt .Sprintf ("--root-kubeconfig=%s" , filepath .Join (workDirPath , ".kcp/ root.kubeconfig" )),
139
- fmt .Sprintf ("--shards-kubeconfig=%s" , filepath .Join (workDirPath , ".kcp-front-proxy/ shards.kubeconfig" )),
140
- fmt .Sprintf ("--client-ca-file=%s" , filepath .Join (workDirPath , ".kcp/ client-ca.crt" )),
141
- fmt .Sprintf ("--tls-cert-file=%s" , filepath .Join (workDirPath , ".kcp-front-proxy/ apiserver.crt" )),
142
- fmt .Sprintf ("--tls-private-key-file=%s" , filepath .Join (workDirPath , ".kcp-front-proxy/ apiserver.key" )),
138
+ fmt .Sprintf ("--root-kubeconfig=%s" , filepath .Join (workDirPath , ".kcp" , " root.kubeconfig" )),
139
+ fmt .Sprintf ("--shards-kubeconfig=%s" , filepath .Join (workDirPath , ".kcp-front-proxy" , " shards.kubeconfig" )),
140
+ fmt .Sprintf ("--client-ca-file=%s" , filepath .Join (workDirPath , ".kcp" , " client-ca.crt" )),
141
+ fmt .Sprintf ("--tls-cert-file=%s" , filepath .Join (workDirPath , ".kcp-front-proxy" , " apiserver.crt" )),
142
+ fmt .Sprintf ("--tls-private-key-file=%s" , filepath .Join (workDirPath , ".kcp-front-proxy" , " apiserver.key" )),
143
143
"--secure-port=6443" ,
144
144
"--v=4" ,
145
145
)
@@ -148,7 +148,7 @@ func startFrontProxy(
148
148
149
149
cmd := exec .CommandContext (ctx , commandLine [0 ], commandLine [1 :]... ) //nolint:gosec
150
150
151
- logFilePath := filepath .Join (workDirPath , ".kcp-front-proxy/ proxy.log" )
151
+ logFilePath := filepath .Join (workDirPath , ".kcp-front-proxy" , " proxy.log" )
152
152
if logDirPath != "" {
153
153
logFilePath = filepath .Join (logDirPath , "kcp-front-proxy.log" )
154
154
}
@@ -204,7 +204,7 @@ func startFrontProxy(
204
204
}
205
205
206
206
// intentionally load again every iteration because it can change
207
- configLoader := clientcmd .NewNonInteractiveDeferredLoadingClientConfig (& clientcmd.ClientConfigLoadingRules {ExplicitPath : filepath .Join (workDirPath , ".kcp/ admin.kubeconfig" )},
207
+ configLoader := clientcmd .NewNonInteractiveDeferredLoadingClientConfig (& clientcmd.ClientConfigLoadingRules {ExplicitPath : filepath .Join (workDirPath , ".kcp" , " admin.kubeconfig" )},
208
208
& clientcmd.ConfigOverrides {CurrentContext : "base" },
209
209
)
210
210
config , err := configLoader .ClientConfig ()
@@ -249,7 +249,7 @@ func scrapeMetrics(ctx context.Context, cfg *rest.Config, workDir string) error
249
249
if ! set || promUrl == "" {
250
250
return nil
251
251
}
252
- return kcptestingserver .ScrapeMetrics (ctx , cfg , promUrl , workDir , "kcp-front-proxy" , filepath .Join (workDir , ".kcp-front-proxy/ apiserver.crt" ), map [string ]string {
252
+ return kcptestingserver .ScrapeMetrics (ctx , cfg , promUrl , workDir , "kcp-front-proxy" , filepath .Join (workDir , ".kcp-front-proxy" , " apiserver.crt" ), map [string ]string {
253
253
"server" : "kcp-front-proxy" ,
254
254
})
255
255
}
@@ -260,18 +260,18 @@ func writeAdminKubeConfig(hostIP string, workDirPath string) error {
260
260
var kubeConfig clientcmdapi.Config
261
261
kubeConfig .AuthInfos = map [string ]* clientcmdapi.AuthInfo {
262
262
"kcp-admin" : {
263
- ClientKey : filepath .Join (workDirPath , ".kcp/ kcp-admin.key" ),
264
- ClientCertificate : filepath .Join (workDirPath , ".kcp/ kcp-admin.crt" ),
263
+ ClientKey : filepath .Join (workDirPath , ".kcp" , " kcp-admin.key" ),
264
+ ClientCertificate : filepath .Join (workDirPath , ".kcp" , " kcp-admin.crt" ),
265
265
},
266
266
}
267
267
kubeConfig .Clusters = map [string ]* clientcmdapi.Cluster {
268
268
"root" : {
269
269
Server : baseHost + "/clusters/root" ,
270
- CertificateAuthority : filepath .Join (workDirPath , ".kcp/ serving-ca.crt" ),
270
+ CertificateAuthority : filepath .Join (workDirPath , ".kcp" , " serving-ca.crt" ),
271
271
},
272
272
"base" : {
273
273
Server : baseHost ,
274
- CertificateAuthority : filepath .Join (workDirPath , ".kcp/ serving-ca.crt" ),
274
+ CertificateAuthority : filepath .Join (workDirPath , ".kcp" , " serving-ca.crt" ),
275
275
},
276
276
}
277
277
kubeConfig .Contexts = map [string ]* clientcmdapi.Context {
@@ -284,20 +284,20 @@ func writeAdminKubeConfig(hostIP string, workDirPath string) error {
284
284
return err
285
285
}
286
286
287
- return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp/ admin.kubeconfig" ))
287
+ return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp" , " admin.kubeconfig" ))
288
288
}
289
289
290
290
func writeShardKubeConfig (workDirPath string ) error {
291
291
var kubeConfig clientcmdapi.Config
292
292
kubeConfig .AuthInfos = map [string ]* clientcmdapi.AuthInfo {
293
293
"shard-admin" : {
294
- ClientKey : filepath .Join (workDirPath , ".kcp-front-proxy/ shard-admin.key" ),
295
- ClientCertificate : filepath .Join (workDirPath , ".kcp-front-proxy/ shard-admin.crt" ),
294
+ ClientKey : filepath .Join (workDirPath , ".kcp-front-proxy" , " shard-admin.key" ),
295
+ ClientCertificate : filepath .Join (workDirPath , ".kcp-front-proxy" , " shard-admin.crt" ),
296
296
},
297
297
}
298
298
kubeConfig .Clusters = map [string ]* clientcmdapi.Cluster {
299
299
"base" : {
300
- CertificateAuthority : filepath .Join (workDirPath , ".kcp/ serving-ca.crt" ),
300
+ CertificateAuthority : filepath .Join (workDirPath , ".kcp" , " serving-ca.crt" ),
301
301
},
302
302
}
303
303
kubeConfig .Contexts = map [string ]* clientcmdapi.Context {
@@ -309,7 +309,7 @@ func writeShardKubeConfig(workDirPath string) error {
309
309
return err
310
310
}
311
311
312
- return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp-front-proxy/ shards.kubeconfig" ))
312
+ return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp-front-proxy" , " shards.kubeconfig" ))
313
313
}
314
314
315
315
func writeLogicalClusterAdminKubeConfig (hostIP , workDirPath string ) error {
@@ -321,14 +321,14 @@ func writeLogicalClusterAdminKubeConfig(hostIP, workDirPath string) error {
321
321
var kubeConfig clientcmdapi.Config
322
322
kubeConfig .AuthInfos = map [string ]* clientcmdapi.AuthInfo {
323
323
"logical-cluster-admin" : {
324
- ClientKey : filepath .Join (workDirPath , ".kcp/ logical-cluster-admin.key" ),
325
- ClientCertificate : filepath .Join (workDirPath , ".kcp/ logical-cluster-admin.crt" ),
324
+ ClientKey : filepath .Join (workDirPath , ".kcp" , " logical-cluster-admin.key" ),
325
+ ClientCertificate : filepath .Join (workDirPath , ".kcp" , " logical-cluster-admin.crt" ),
326
326
},
327
327
}
328
328
kubeConfig .Clusters = map [string ]* clientcmdapi.Cluster {
329
329
"base" : {
330
330
Server : baseHost ,
331
- CertificateAuthority : filepath .Join (workDirPath , ".kcp/ serving-ca.crt" ),
331
+ CertificateAuthority : filepath .Join (workDirPath , ".kcp" , " serving-ca.crt" ),
332
332
},
333
333
}
334
334
kubeConfig .Contexts = map [string ]* clientcmdapi.Context {
@@ -340,7 +340,7 @@ func writeLogicalClusterAdminKubeConfig(hostIP, workDirPath string) error {
340
340
return err
341
341
}
342
342
343
- return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp/ logical-cluster-admin.kubeconfig" ))
343
+ return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp" , " logical-cluster-admin.kubeconfig" ))
344
344
}
345
345
346
346
func writeExternalLogicalClusterAdminKubeConfig (hostIP , workDirPath string ) error {
@@ -350,14 +350,14 @@ func writeExternalLogicalClusterAdminKubeConfig(hostIP, workDirPath string) erro
350
350
var kubeConfig clientcmdapi.Config
351
351
kubeConfig .AuthInfos = map [string ]* clientcmdapi.AuthInfo {
352
352
"external-logical-cluster-admin" : {
353
- ClientKey : filepath .Join (workDirPath , ".kcp/ external-logical-cluster-admin.key" ),
354
- ClientCertificate : filepath .Join (workDirPath , ".kcp/ external-logical-cluster-admin.crt" ),
353
+ ClientKey : filepath .Join (workDirPath , ".kcp" , " external-logical-cluster-admin.key" ),
354
+ ClientCertificate : filepath .Join (workDirPath , ".kcp" , " external-logical-cluster-admin.crt" ),
355
355
},
356
356
}
357
357
kubeConfig .Clusters = map [string ]* clientcmdapi.Cluster {
358
358
"base" : {
359
359
Server : baseHost ,
360
- CertificateAuthority : filepath .Join (workDirPath , ".kcp/ serving-ca.crt" ),
360
+ CertificateAuthority : filepath .Join (workDirPath , ".kcp" , " serving-ca.crt" ),
361
361
},
362
362
}
363
363
kubeConfig .Contexts = map [string ]* clientcmdapi.Context {
@@ -369,5 +369,5 @@ func writeExternalLogicalClusterAdminKubeConfig(hostIP, workDirPath string) erro
369
369
return err
370
370
}
371
371
372
- return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp/ external-logical-cluster-admin.kubeconfig" ))
372
+ return clientcmd .WriteToFile (kubeConfig , filepath .Join (workDirPath , ".kcp" , " external-logical-cluster-admin.kubeconfig" ))
373
373
}
0 commit comments