Skip to content

Commit f69716c

Browse files
committed
kcp certs examples ci fix
kcp certs examples ci fix
1 parent 15d121d commit f69716c

File tree

2 files changed

+28
-97
lines changed

2 files changed

+28
-97
lines changed

examples/kcp-certs/README.md

Lines changed: 27 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -315,66 +315,14 @@ The resource-broker will see the Certificate in the virtual workspace of the API
315315
> The original consumer-side name `cert-from-consumer` becomes `{hash}-cert-from-consumer` in
316316
> the provider's virtual workspace.
317317
318-
In the provider's virtual workspace the Certificate looks like this.
318+
Wait for the certificate to appear on the internalca provider cluster:
319319

320-
Grab the hash-prefixed name from the VW:
321-
322-
<!--
323-
Wait for the certificate to appear in the provider's virtual workspace:
324-
```bash ci
325-
kubectl::wait::list \
326-
kubeconfigs/workspaces/internalca.vw.kubeconfig \
327-
certificates.example.platform-mesh.io \
328-
--all-namespaces
329-
```
330-
-->
331-
332-
```bash ci
333-
provider_cert="$(kubectl --kubeconfig kubeconfigs/workspaces/internalca.vw.kubeconfig get certificates.example.platform-mesh.io -A -o jsonpath="{.items[0].metadata.name}")"
334-
```
335-
336-
```bash ci
337-
kubectl --kubeconfig kubeconfigs/workspaces/internalca.vw.kubeconfig get certificates.example.platform-mesh.io "$provider_cert" -o yaml
338-
```
339-
340-
```yaml
341-
apiVersion: v1
342-
items:
343-
- apiVersion: example.platform-mesh.io/v1alpha1
344-
kind: Certificate
345-
metadata:
346-
# ...
347-
name: {hash}-cert-from-consumer
348-
namespace: default
349-
# ...
350-
spec:
351-
fqdn: app.internal.corp
352-
status:
353-
# ...
354-
relatedResources:
355-
secret:
356-
gvk:
357-
group: core
358-
kind: Secret
359-
version: v1
360-
name: {hash}-cert-from-consumer
361-
namespace: default
362-
# ...
363-
kind: List
364-
metadata:
365-
resourceVersion: ""
366-
```
367-
368-
On the compute cluster, api-syncagent further transforms the name using its own cluster IDs and hashes:
369-
370-
<!--
371320
```bash ci
372321
kubectl::wait::list \
373322
kubeconfigs/internalca.kubeconfig \
374323
certificates.example.platform-mesh.io \
375-
--all-namespaces -l kro.run/owned=true
324+
--all-namespaces
376325
```
377-
-->
378326

379327
```bash ci
380328
kubectl --kubeconfig kubeconfigs/internalca.kubeconfig get certificates.example.platform-mesh.io --all-namespaces
@@ -420,21 +368,24 @@ metadata:
420368
Grab the name and namespace from the compute cluster:
421369
422370
```bash ci
423-
secret_name="$(kubectl --kubeconfig kubeconfigs/internalca.kubeconfig get certificates.example.platform-mesh.io --all-namespaces -o jsonpath="{.items[0].metadata.name}")"
424-
secret_namespace="$(kubectl --kubeconfig kubeconfigs/internalca.kubeconfig get certificates.example.platform-mesh.io --all-namespaces -o jsonpath="{.items[0].metadata.namespace}")"
371+
cert_name="$(kubectl --kubeconfig kubeconfigs/internalca.kubeconfig get certificates.example.platform-mesh.io --all-namespaces -o jsonpath="{.items[0].metadata.name}")"
372+
cert_namespace="$(kubectl --kubeconfig kubeconfigs/internalca.kubeconfig get certificates.example.platform-mesh.io --all-namespaces -o jsonpath="{.items[0].metadata.namespace}")"
373+
kubectl --kubeconfig kubeconfigs/internalca.kubeconfig wait \
374+
"certificates.example.platform-mesh.io/$cert_name" \
375+
--namespace="$cert_namespace" \
376+
--for=jsonpath="{.status.relatedResources.secret.name}" \
377+
--timeout=5m
378+
secret_name="$(kubectl --kubeconfig kubeconfigs/internalca.kubeconfig get "certificates.example.platform-mesh.io/$cert_name" --namespace="$cert_namespace" -o jsonpath="{.status.relatedResources.secret.name}")"
379+
secret_namespace="$(kubectl --kubeconfig kubeconfigs/internalca.kubeconfig get "certificates.example.platform-mesh.io/$cert_name" --namespace="$cert_namespace" -o jsonpath="{.status.relatedResources.secret.namespace}")"
425380
```
426381

427-
<!--
428-
Wait for the certificate to be issued.
429382
```bash ci
430383
kubectl::wait::cert::subject \
431384
kubeconfigs/internalca.kubeconfig \
432-
"$provider_cert" \
385+
"$secret_name" \
433386
"$secret_namespace" \
434387
"app.internal.corp"
435388
```
436-
-->
437-
438389

439390
The provider has created a cert-manager Certificate, which in turn
440391
generated a Secret with the issued certificate:
@@ -446,24 +397,21 @@ kubectl --kubeconfig kubeconfigs/internalca.kubeconfig get secrets --namespace "
446397
Decoding the `tls.crt` field shows the certificate was correctly issued for `app.internal.corp`:
447398

448399
```bash ci
449-
kubectl --kubeconfig kubeconfigs/internalca.kubeconfig get secrets --namespace "$secret_namespace" "$provider_cert" -o jsonpath="{.data.tls\.crt}" \
400+
kubectl --kubeconfig kubeconfigs/internalca.kubeconfig get secrets --namespace "$secret_namespace" "$secret_name" -o jsonpath="{.data.tls\.crt}" \
450401
| base64 --decode \
451402
| openssl x509 -noout -subject
452403
# subject=CN=app.internal.corp
453404
```
454405

455-
The same secret is now also available in the consumer cluster:
406+
Wait for the certificate secret to be synced to the consumer workspace:
456407

457-
<!--
458-
Wait for the certificate secret to be synced:
459408
```bash ci
460409
kubectl::wait::cert::subject \
461410
kubeconfigs/workspaces/consumer.kubeconfig \
462411
"cert-from-consumer" \
463412
"default" \
464413
"app.internal.corp"
465414
```
466-
-->
467415

468416
```bash ci
469417
kubectl --kubeconfig kubeconfigs/workspaces/consumer.kubeconfig get secrets "cert-from-consumer"
@@ -473,7 +421,7 @@ And comparing the serial number shows it's the same certificate:
473421

474422
```bash ci
475423
kubectl --kubeconfig kubeconfigs/internalca.kubeconfig \
476-
get secrets --namespace "$secret_namespace" "$provider_cert" \
424+
get secrets --namespace "$secret_namespace" "$secret_name" \
477425
-o jsonpath="{.data.tls\.crt}" \
478426
| base64 --decode \
479427
| openssl x509 -noout -serial
@@ -508,68 +456,51 @@ The internalca and externalca providers have the same setup, with KRO
508456
relaying the Certificate example resource to a cert-manager Certificate
509457
and back, so the secret name and namespace can be grabbed the same way:
510458

511-
<!--
512459
```bash ci
513460
kubectl::wait::list \
514461
kubeconfigs/externalca.kubeconfig \
515462
certificates.example.platform-mesh.io \
516-
--all-namespaces -l kro.run/owned=true
517-
```
518-
-->
519-
520-
Grab the hash-prefixed name from the externalca VW:
521-
522-
<!--
523-
Wait for the certificate to appear in the externalca provider's virtual workspace:
524-
```bash ci
525-
kubectl::wait::list \
526-
kubeconfigs/workspaces/externalca.vw.kubeconfig \
527-
certificates.example.platform-mesh.io \
528463
--all-namespaces
529464
```
530-
-->
531-
532-
```bash ci
533-
provider_cert="$(kubectl --kubeconfig kubeconfigs/workspaces/externalca.vw.kubeconfig get certificates.example.platform-mesh.io -A -o jsonpath="{.items[0].metadata.name}")"
534-
```
535465

536466
```bash ci
537-
secret_name="$(kubectl --kubeconfig kubeconfigs/externalca.kubeconfig get certificates.example.platform-mesh.io --all-namespaces -o jsonpath="{.items[0].metadata.name}")"
538-
secret_namespace="$(kubectl --kubeconfig kubeconfigs/externalca.kubeconfig get certificates.example.platform-mesh.io --all-namespaces -o jsonpath="{.items[0].metadata.namespace}")"
467+
cert_name="$(kubectl --kubeconfig kubeconfigs/externalca.kubeconfig get certificates.example.platform-mesh.io --all-namespaces -o jsonpath="{.items[0].metadata.name}")"
468+
cert_namespace="$(kubectl --kubeconfig kubeconfigs/externalca.kubeconfig get certificates.example.platform-mesh.io --all-namespaces -o jsonpath="{.items[0].metadata.namespace}")"
469+
kubectl --kubeconfig kubeconfigs/externalca.kubeconfig wait \
470+
"certificates.example.platform-mesh.io/$cert_name" \
471+
--namespace="$cert_namespace" \
472+
--for=jsonpath="{.status.relatedResources.secret.name}" \
473+
--timeout=5m
474+
secret_name="$(kubectl --kubeconfig kubeconfigs/externalca.kubeconfig get "certificates.example.platform-mesh.io/$cert_name" --namespace="$cert_namespace" -o jsonpath="{.status.relatedResources.secret.name}")"
475+
secret_namespace="$(kubectl --kubeconfig kubeconfigs/externalca.kubeconfig get "certificates.example.platform-mesh.io/$cert_name" --namespace="$cert_namespace" -o jsonpath="{.status.relatedResources.secret.namespace}")"
539476
```
540477

541-
<!--
542-
Wait for the certificate to be issued.
543478
```bash ci
544479
kubectl::wait::cert::subject \
545480
kubeconfigs/externalca.kubeconfig \
546-
"$provider_cert" \
481+
"$secret_name" \
547482
"$secret_namespace" \
548483
"app.corp.com"
549484
```
550-
-->
551485

552486
And decoding the `tls.crt` field shows the certificate was correctly issued for `app.corp.com`:
553487

554488
```bash ci
555489
kubectl --kubeconfig kubeconfigs/externalca.kubeconfig \
556-
get secrets --namespace "$secret_namespace" "$provider_cert" \
490+
get secrets --namespace "$secret_namespace" "$secret_name" \
557491
-o jsonpath="{.data.tls\.crt}" \
558492
| base64 --decode \
559493
| openssl x509 -noout -subject
560494
# subject=CN=app.corp.com
561495
```
562496

563-
<!--
564-
Wait for the certificate secret to be synced:
565497
```bash ci
566498
kubectl::wait::cert::subject \
567499
kubeconfigs/workspaces/consumer.kubeconfig \
568500
"cert-from-consumer" \
569501
"default" \
570502
"app.corp.com"
571503
```
572-
-->
573504

574505
And the secret in the consumer workspace has been updated accordingly:
575506

@@ -586,7 +517,7 @@ And again comparing the serial numbers, now with the certificate in the external
586517

587518
```bash ci
588519
kubectl --kubeconfig kubeconfigs/externalca.kubeconfig \
589-
get secrets --namespace "$secret_namespace" "$provider_cert" \
520+
get secrets --namespace "$secret_namespace" "$secret_name" \
590521
-o jsonpath="{.data.tls\.crt}" \
591522
| base64 --decode \
592523
| openssl x509 -noout -serial

examples/kcp-certs/run.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ _provider_setup_new() {
170170

171171
# Grab the VW endpoint URL for later use
172172
local cluster_id="$(_cluster_id "$ws_kubeconfig" apiexportendpointslices/certificates)"
173-
local endpoint_url="https://127.0.0.1:8443/services/apiexport/$cluster_id/certificates"
173+
local endpoint_url="https://127.0.0.1:8443/services/apiexport/$cluster_id/certificates/clusters/$cluster_id"
174174

175175
# Create a service account for the broker to use; this should get proper
176176
# RBAC in a prod setup

0 commit comments

Comments
 (0)