Skip to content

Latest commit

 

History

History
118 lines (88 loc) · 3.35 KB

developer-getting-started.md

File metadata and controls

118 lines (88 loc) · 3.35 KB

Developer Getting Started

Setting Up a Local Development Environment

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.

Running the controller external to the cluster

To test and run the project with your local changes, follow these steps to set up a development environment:

  1. Install Dependencies: Ensure you have the necessary dependencies installed, including:

    • Go (version specified in go.mod).
    • kubectl for interacting with Kubernetes clusters.
    • A local Kubernetes cluster such as kind.
  2. 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
  3. Install the Custom Resource Definitions (CRDs): Apply the latest CRDs to your cluster:

    make manifests
    kubectl apply -k ./config/crd
  4. 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.

Running the controller inside a KinD cluster with ko

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.

  1. 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
  1. 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 -

Dev Environment Hello World

  1. Create a NoOp ResourceGraph using the ResourceGraphDefinition.

    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 CRD NoOp.

    kubectl get ResourceGraphDefinition noop
    kubectl get crds | grep noops
  2. 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