Skip to content

Commit

Permalink
Merge pull request #117 from cnvergence/update-helm-guide
Browse files Browse the repository at this point in the history
update helm readme.md docs
  • Loading branch information
kcp-ci-bot authored Jan 9, 2025
2 parents bc5babb + 1c8b0d0 commit 19bcb84
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ progress and are not ready for production use.

## Pre-requisites

- Cert-manager installed and running
- [cert-manager](https://cert-manager.io/docs/installation) installed and running
- Ingress installed (e.g. nginx-ingress or OpenShift router)

## Usage
Expand Down Expand Up @@ -50,6 +50,10 @@ kcpFrontProxy:
enabled: true
```
Export the externalHostname variable, that will be used later to interact with kcp setup:
export KCP_EXTERNAL_HOSTNAME=kcp.dev.local
Note that by default all certificates are signed by the Helm chart's own PKI and so will not be
trusted by browsers. You can however change the `kcp-front-proxy`'s certificate to be issued
by, for example, Let's Encrypt. For this you have to enable the creation of the Let's Encrypt
Expand Down Expand Up @@ -133,16 +137,15 @@ First we get the CA cert for the front proxy, saving it to a file `ca.crt`

Now we create a new kubeconfig which references the `ca.crt`

kubectl --kubeconfig=admin.kubeconfig config set-cluster base --server https://<externalHostname>:443 --certificate-authority=ca.crt
kubectl --kubeconfig=admin.kubeconfig config set-cluster root --server https://<externalHostname>:443/clusters/root --certificate-authority=ca.crt
kubectl --kubeconfig=admin.kubeconfig config set-cluster base --server https://$KCP_EXTERNAL_HOSTNAME:443 --certificate-authority=ca.crt
kubectl --kubeconfig=admin.kubeconfig config set-cluster root --server https://$KCP_EXTERNAL_HOSTNAME:443/clusters/root --certificate-authority=ca.crt

### Create client-cert credentials

Now we must add credentials to the kubeconfig, so requests to the front-proxy may be authenticated.

One way to do this is to create a client certificate with a cert-manager `Certificate`:

$ cat admin-client-cert.yaml
cat <<EOF | kubectl apply -f -
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
Expand All @@ -160,24 +163,23 @@ One way to do this is to create a client certificate with a cert-manager `Certif
- system:kcp:admin
usages:
- client auth

$ kubectl apply -f admin-client-cert.yaml
EOF

This will result in a `cluster-admin-client-cert` secret which we can again save to local files:

$ kubectl get secret cluster-admin-client-cert -o=jsonpath='{.data.tls\.crt}' | base64 -d > client.crt
$ kubectl get secret cluster-admin-client-cert -o=jsonpath='{.data.tls\.key}' | base64 -d > client.key
$ chmod 600 client.crt client.key
kubectl get secret cluster-admin-client-cert -o=jsonpath='{.data.tls\.crt}' | base64 -d > client.crt
kubectl get secret cluster-admin-client-cert -o=jsonpath='{.data.tls\.key}' | base64 -d > client.key
chmod 600 client.crt client.key

We can now add these credentials to the `admin.kubeconfig` and access kcp:

$ kubectl --kubeconfig=admin.kubeconfig config set-credentials kcp-admin --client-certificate=client.crt --client-key=client.key
$ kubectl --kubeconfig=admin.kubeconfig config set-context base --cluster=base --user=kcp-admin
$ kubectl --kubeconfig=admin.kubeconfig config set-context root --cluster=root --user=kcp-admin
$ kubectl --kubeconfig=admin.kubeconfig config use-context root
$ kubectl --kubeconfig=admin.kubeconfig workspace
$ export KUBECONFIG=$PWD/admin.kubeconfig
$ kubectl workspace
kubectl --kubeconfig=admin.kubeconfig config set-credentials kcp-admin --client-certificate=client.crt --client-key=client.key
kubectl --kubeconfig=admin.kubeconfig config set-context base --cluster=base --user=kcp-admin
kubectl --kubeconfig=admin.kubeconfig config set-context root --cluster=root --user=kcp-admin
kubectl --kubeconfig=admin.kubeconfig config use-context root
kubectl --kubeconfig=admin.kubeconfig workspace
export KUBECONFIG=$PWD/admin.kubeconfig
kubectl workspace
Current workspace is "1gnrr0twy6c3o".

## Install to kind cluster (for development)
Expand Down

0 comments on commit 19bcb84

Please sign in to comment.