capi-runtime-extensions

module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2024 License: Apache-2.0

README

CAPI Runtime Extensions

For user docs, please see [https://d2iq-labs.github.io/capi-runtime-extensions/].

See upstream documentation.

Development

Install tools

To deploy a local build, either initial install to update an existing deployment, run:

make dev.run-on-kind
eval $(make kind.kubeconfig)

Pro-tip: to redeploy without rebuilding the binaries, images, etc (useful if you have only changed the Helm chart for example), run:

make SKIP_BUILD=true dev.run-on-kind

You can just update the image in the webhook Deployment on an existing KIND cluster:

make KIND_CLUSTER_NAME=<> dev.update-webhook-image-on-kind

If creating an AWS cluster using the example files, you will also need to create a secret with your AWS credentials:

kubectl apply --server-side -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
  name: "aws-quick-start-creds"
  namespace: capa-system
stringData:
  AccessKeyID: ${AWS_ACCESS_KEY_ID}
  SecretAccessKey: ${AWS_SECRET_ACCESS_KEY}
  SessionToken: ${AWS_SESSION_TOKEN}
EOF

If you are using an AWS_PROFILE to log in use the following:

kubectl apply --server-side -f - <<EOF
apiVersion: v1
kind: Secret
metadata:
  name: "aws-quick-start-creds"
  namespace: capa-system
stringData:
  AccessKeyID: $(aws configure get aws_access_key_id)
  SecretAccessKey: $(aws configure get aws_secret_access_key)
  SessionToken: $(aws configure get aws_session_token)
EOF

To create an example cluster:

clusterctl generate cluster docker-quick-start-helm-addon-cilium \
  --from examples/capi-quick-start/docker-cluster-cilium-helm-addon.yaml \
  --kubernetes-version v1.29.1 \
  --worker-machine-count 1 | \
  kubectl apply --server-side -f -

Wait until control plane is ready:

kubectl wait clusters/docker-quick-start-helm-addon-cilium --for=condition=ControlPlaneInitialized --timeout=5m

To get the kubeconfig for the new cluster, run:

clusterctl get kubeconfig docker-quick-start-helm-addon-cilium > docker-kubeconfig

If you are not on Linux, you will also need to fix the generated kubeconfig's server, run:

kubectl config set-cluster docker-quick-start-helm-addon-cilium \
  --kubeconfig docker-kubeconfig \
  --server=https://$(docker container port docker-quick-start-helm-addon-cilium-lb 6443/tcp)

Wait until all nodes are ready (this indicates that CNI has been deployed successfully):

kubectl --kubeconfig docker-kubeconfig wait nodes --all --for=condition=Ready --timeout=5m

Show that Cilium is running successfully on the workload cluster:

kubectl --kubeconfig docker-kubeconfig get daemonsets -n kube-system cilium

Deploy kube-vip to provide service load-balancer:

helm repo add --force-update kube-vip https://kube-vip.github.io/helm-charts
helm repo update
kind_subnet_prefix="$(docker network inspect kind -f '{{ (index .IPAM.Config 0).Subnet }}' | \
                      grep -o '^[[:digit:]]\+\.[[:digit:]]\+\.')"
kubectl create configmap \
  --namespace kube-system kubevip \
  --from-literal "range-global=${kind_subnet_prefix}100.0-${kind_subnet_prefix}100.20" \
  --dry-run=client -oyaml |
  kubectl --kubeconfig docker-kubeconfig apply --server-side -n kube-system -f -

helm upgrade kube-vip-cloud-provider kube-vip/kube-vip-cloud-provider --version 0.2.2 \
  --install \
  --wait --wait-for-jobs \
  --namespace kube-system \
  --kubeconfig docker-kubeconfig \
  --set-string=image.tag=v0.0.6

helm upgrade kube-vip kube-vip/kube-vip --version 0.4.2 \
  --install \
  --wait --wait-for-jobs \
  --namespace kube-system \
  --kubeconfig docker-kubeconfig \
  --set-string=image.tag=v0.6.0

Deploy traefik as a LB service:

helm --kubeconfig docker-kubeconfig repo add traefik https://helm.traefik.io/traefik
helm repo update &>/dev/null
helm --kubeconfig docker-kubeconfig upgrade --install traefik traefik/traefik \
  --version v10.9.1 \
  --wait --wait-for-jobs \
  --set ports.web.hostPort=80 \
  --set ports.websecure.hostPort=443 \
  --set service.type=LoadBalancer

Watch for traefik LB service to get an external address:

watch -n 0.5 kubectl --kubeconfig docker-kubeconfig get service/traefik

To delete the workload cluster, run:

kubectl delete cluster docker-quick-start-helm-addon-cilium

Notice that the traefik service is deleted before the cluster is actually finally deleted.

Check the pod logs:

kubectl logs deployment/capi-runtime-extensions -f

To delete the dev KinD cluster, run:

make kind.delete

Directories

Path Synopsis
api module
common module
pkg
handlers/generic/lifecycle/cni/calico
Package calico provides a handler for managing Calico deployments on clusters, configurable via variables on the Cluster resource.
Package calico provides a handler for managing Calico deployments on clusters, configurable via variables on the Cluster resource.
handlers/generic/lifecycle/cni/cilium
Package cilium provides a handler for managing Cilium deployments on clusters, configurable via variables on the Cluster resource.
Package cilium provides a handler for managing Cilium deployments on clusters, configurable via variables on the Cluster resource.
handlers/generic/lifecycle/cpi
Package calico provides a handler for managing Calico deployments on clusters, configurable via labels and annotations.
Package calico provides a handler for managing Calico deployments on clusters, configurable via labels and annotations.
handlers/generic/lifecycle/csi
Package calico provides a handler for managing Calico deployments on clusters, configurable via labels and annotations.
Package calico provides a handler for managing Calico deployments on clusters, configurable via labels and annotations.
handlers/generic/lifecycle/nfd
Package calico provides a handler for managing Calico deployments on clusters, configurable via labels and annotations.
Package calico provides a handler for managing Calico deployments on clusters, configurable via labels and annotations.
handlers/generic/lifecycle/servicelbgc
+kubebuilder:rbac:groups="",resources=secrets,verbs=watch;list;get
+kubebuilder:rbac:groups="",resources=secrets,verbs=watch;list;get
handlers/generic/mutation/httpproxy
+kubebuilder:rbac:groups=cluster.x-k8s.io,resources=clusters,verbs=watch;list;get
+kubebuilder:rbac:groups=cluster.x-k8s.io,resources=clusters,verbs=watch;list;get
handlers/generic/mutation/imageregistries/credentials
+kubebuilder:rbac:groups="",resources=secrets,verbs=watch;list;get;patch;create;update
+kubebuilder:rbac:groups="",resources=secrets,verbs=watch;list;get;patch;create;update
handlers/generic/mutation/imageregistries/credentials/credentialprovider
Package credentialprovider includes Functions copied from https://github.com/kubernetes/kubernetes/blob/v1.26.1/pkg/credentialprovider/keyring.go#L160-L233.
Package credentialprovider includes Functions copied from https://github.com/kubernetes/kubernetes/blob/v1.26.1/pkg/credentialprovider/keyring.go#L160-L233.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL