1- # kcp
1+ # kcp
22
3- kcp folder contains isolated set of tooling to bootstrap the kube-bind to allow it to work with kcp instance.
3+ kcp folder contains isolated set of tooling to bootstrap the kube-bind to allow it to work with kcp instance.
44It is split into separate package to avoid vendoring pollution.
55
6- kcp requires initial setup to be run before it can be used.
6+ kcp requires initial setup to be run before it can be used.
77This includes setting up workspace/provider and setting up all the APIResourceSchemas and APIExports.
88
99It was its own GO module to avoid kcp dependencies in the main kube-bind module.
@@ -23,18 +23,19 @@ It will do the following:
2323
2424# How to run
2525
26- 1 . Start kcp
27- 2 . Bootstrap kcp:
26+ 1 . Start dex
27+ 2 . Start kcp
28+ 3 . Bootstrap kcp:
2829``` bash
2930cp .kcp/admin.kubeconfig .kcp/backend.kubeconfig
3031export KUBECONFIG=.kcp/backend.kubeconfig
3132./bin/kcp-init --kcp-kubeconfig $KUBECONFIG
3233```
33- 3 . Run the backend:
34+ 4 . Run the backend:
3435```
3536k ws use :root:kube-bind
3637
37- bin/backend \
38+ ./ bin/backend \
3839 --multicluster-runtime-provider kcp \
3940 --server-url=$(kubectl get apiexportendpointslice kube-bind.io -o jsonpath="{.status.endpoints[0].url}") \
4041 --oidc-issuer-client-secret=ZXhhbXBsZS1hcHAtc2VjcmV0 \
@@ -49,15 +50,15 @@ bin/backend \
4950```
5051
5152
52- 4 . Copy the kubeconfig to the provider and create provider workspace:
53+ 5 . Copy the kubeconfig to the provider and create provider workspace:
5354``` bash
5455cp .kcp/admin.kubeconfig .kcp/provider.kubeconfig
5556export KUBECONFIG=.kcp/provider.kubeconfig
5657k ws use :root
5758kubectl ws create provider --enter
5859```
5960
60- 5 . Bind the APIExport to the workspace
61+ 6 . Bind the APIExport to the provider workspace
6162``` bash
6263kubectl kcp bind apiexport root:kube-bind:kube-bind.io --accept-permission-claim clusterrolebindings.rbac.authorization.k8s.io \
6364 --accept-permission-claim clusterroles.rbac.authorization.k8s.io \
@@ -68,13 +69,14 @@ kubectl kcp bind apiexport root:kube-bind:kube-bind.io --accept-permission-claim
6869 --accept-permission-claim namespaces.core \
6970 --accept-permission-claim roles.rbac.authorization.k8s.io \
7071 --accept-permission-claim rolebindings.rbac.authorization.k8s.io \
71- --accept-permission-claim apiresourceschemas.apis.kcp.io
72+ --accept-permission-claim apiresourceschemas.apis.kcp.io
7273```
7374
74- 7 . Create CRD:
75+ 7 . Create CRD in provider :
7576``` bash
76- kubectl create -f kcp/deploy/examples/apiexport.yaml
77- kubectl create -f kcp/deploy/examples/apiresourceschema.yaml
77+ kubectl create -f kcp/deploy/examples/apiexport.yaml
78+ kubectl create -f kcp/deploy/examples/apiresourceschema-cowboys.yaml
79+ kubectl create -f kcp/deploy/examples/apiresourceschema-sheriffs.yaml
7880# recursive bind
7981kubectl kcp bind apiexport root:provider:cowboys-stable
8082```
@@ -84,7 +86,7 @@ kubectl kcp bind apiexport root:provider:cowboys-stable
8486``` bash
8587kubectl get logicalcluster
8688# NAME PHASE URL AGE
87- # cluster Ready https://192.168.2.166:6443/clusters/2xh2v3gzjhn4tmve
89+ # cluster Ready https://192.168.2.166:6443/clusters/2xh2v3gzjhn4tmve
8890```
8991
90929 . Now we gonna initiate consumer:
@@ -101,7 +103,7 @@ kubectl ws create consumer --enter
101103./bin/kubectl-bind http://127.0.0.1:8080/clusters/2vgrh380y0cq38du/exports --dry-run -o yaml > apiserviceexport.yaml
102104
103105# Extract secret for binding process. Note that secret name is not the same as output from command above. Check secret
104- # name by running `kubectl get secret -n kube-bind`
106+ # name by running `kubectl get secret -n kube-bind`
105107kubectl get secret kubeconfig-wvvsb -n kube-bind -o jsonpath=' {.data.kubeconfig}' | base64 -d > remote.kubeconfig
106108
107109./bin/kubectl-bind apiservice --remote-kubeconfig remote.kubeconfig -f apiserviceexport.yaml --skip-konnector --remote-namespace kube-bind-m5zx4
@@ -137,9 +139,9 @@ kubectl apply -f kcp/deploy/examples/cowboy.yaml
137139## Debug
138140
139141```bash
140- cp .kcp/admin.kubeconfig .kcp/debug.kubeconfig
142+ cp .kcp/admin.kubeconfig .kcp/debug.kubeconfig
141143export KUBECONFIG=.kcp/debug.kubeconfig
142144k ws use :root:kube-bind
143145
144- k -s "$(kubectl get apiexportendpointslice kube-bind.io -o jsonpath="{.status.endpoints[0].url}")/clusters/*" api-resources
145- k -s "$(kubectl get apiexportendpointslice kube-bind.io -o jsonpath="{.status.endpoints[0].url}")/clusters/*" get crd
146+ k -s "$(kubectl get apiexportendpointslice kube-bind.io -o jsonpath="{.status.endpoints[0].url}")/clusters/*" api-resources
147+ k -s "$(kubectl get apiexportendpointslice kube-bind.io -o jsonpath="{.status.endpoints[0].url}")/clusters/*" get crd
0 commit comments