rancher / k3k

Kubernetes in Kubernetes
Apache License 2.0
131 stars 21 forks source link

[WIP] Adding starter code for clustersets #109

Open MbolotSuse opened 4 weeks ago

MbolotSuse commented 4 weeks ago

This PR is a POC of adding a clusterset type that allows admins to selectively limit the Resources that a given group of clusters can consume.

Overview

Using/testing

  1. Clone the branch.
  2. Build the binary make build.
  3. Build/Push the image docker build -f package/Dockerfile . -t $REPO/$IMAGE:$TAG
  4. Update values.yaml with image.repostory: $REPO/$IMAGE and tag: $TAG
  5. Generate a key using openssl: openssl genrsa -out rootCAKey.pem 4096.
  6. Generate a cert using openssl: openssl req -x509 -sha256 -nodes -key rootCAKey.pem -days 3650 -out rootCACert.pem --addext "subjectAltName=DNS:k3k-webhook.k3k-system.svc".
  7. Copy the cert: cat rootCACert.pem | base64 | tr -d '\n'
  8. Create the namespace and upload the cert as a secret kubectl create -f ns.yaml && k create secret tls webhook-secret -n k3k-system --cert=rootCACert.pem --key=rootCAKey.pem. See below for the namespace (needs helm annotations to be imported when installing the chart).
  9. Update charts/k3k/templates/webhooks.yaml with the value copied in the previous step (past in the caBundle field where "ReplaceMe" is for both the Valdating and Mutating Webhook).
  10. Deploy the chart helm install k3k ./charts/k3k -n k3k-system
apiVersion: v1
kind: Namespace
metadata:
  annotations:
    meta.helm.sh/release-name: k3k
    meta.helm.sh/release-namespace: k3k-system
  labels:
    app.kubernetes.io/managed-by: Helm
    kubernetes.io/metadata.name: k3k-system
  name: k3k-system

Note