By following the steps for externally running a controller or
running the controller inside a KinD
cluster, you can set up
a local environment to test your contributions before submitting a pull request.
To test and run the project with your local changes, follow these steps to set up a development environment:
-
Install Dependencies: Ensure you have the necessary dependencies installed, including:
-
Create a Local Kubernetes Cluster: If you don't already have a cluster, create one with your preferred tool. For example, with
kind
:kind create cluster
-
Install the Custom Resource Definitions (CRDs): Apply the latest CRDs to your cluster:
make manifests kubectl apply -k ./config/crd
-
Run the kro Controller Locally: Execute the controller with your changes:
go run ./cmd/controller --log-level 2
This will connect to the default Kubernetes context in your local kubeconfig (
~/.kube/config
). Ensure the context is pointing to your local cluster.
A helper Makefile target is used to (re)create a kind cluster, install the CRDs, build the container image and helm install the controller manifests in the kind cluster.
Note: This target re-creates the kind cluster from scratch and should be used as a starting point or when you want to start over fresh.
KIND_CLUSTER_NAME=kro make deploy-kind
For iterating on an existing cluster, follow the instructions below.
- Prepare the cluster
export KIND_CLUSTER_NAME=my-other-cluster
# Create a kind cluster if needed
kind create cluster
## Create the kro-system namespace
kubectl create namespace kro-system || true
- Build and install KRO components
## install the KRO CRDs
make install
# render the helm chart and apply using ko
export KO_DOCKER_REPO=kind.local
helm template kro ./helm \
--namespace kro-system \
--set image.pullPolicy=Never \
--set image.ko=true | ko apply -f -
-
Create a
NoOp
ResourceGraph using theResourceGraphDefinition
.kubectl apply -f - <<EOF apiVersion: kro.run/v1alpha1 kind: ResourceGraphDefinition metadata: name: noop spec: schema: apiVersion: v1alpha1 kind: NoOp spec: {} status: {} resources: [] EOF
Inspect that the
ResourceGraphDefinition
was created, and also the newly created CRDNoOp
.kubectl get ResourceGraphDefinition noop kubectl get crds | grep noops
-
Create an instance of the new
NoOp
kind.kubectl apply -f - <<EOF apiVersion: kro.run/v1alpha1 kind: NoOp metadata: name: demo EOF
And inspect the new instance,
kubectl get noops -oyaml