This guide provides instructions for building, running, and debugging the agent-sandbox controller.
Before you begin, ensure you have the following tools installed:
- Go
- Docker
- Docker buildx plugin On Debian-based systems,
apt install docker-buildx-plugin
- Docker buildx plugin On Debian-based systems,
- kind (optional, a convenient tool for running local Kubernetes clusters using Docker container)
- kubectl
To build the controller binary, run the following command:
make buildThis will compile the controller and create a binary at bin/manager.
For working with a remote cluster you can build and push the image to a container registry.
./dev/tools/push-images --image-prefix=<registry-url-with-trailing-slash>Whenever any changes are made to the api/ folder or the controllers/ folder (kubebuilder tags), you may have to regenerate the CRDs and the RBAC manifests.
make all
# which runs dev/tools/fix-go-generateWhenever any changes are made to the api/ folder or the extensions/, you may need to regenerate API documentation to keep it up-to-date. You will probably need to rebase your branch.
make generate-api-docsTo run the controller on a local kind cluster, use the following command:
make deploy-kindThis command will:
- Create a
kindcluster namedagent-sandboxif it doesn't already exist. - Build the controller's container image.
- Push the image to the
kindcluster. - Deploy the controller to the
kindcluster.
You can verify that the controller is running by checking the pods in the agent-sandbox-system namespace:
kubectl get pods -n agent-sandbox-systemMake sure your kubectl context is set to the cluster you want to deploy to.
./dev/tools/deploy-to-kube --image-prefix=<registry-url-with-trailing-slash>There are several ways to debug the controller while it's running in the cluster.
To view the controller's logs, use the kubectl logs command. First, find the name of the controller's pod:
kubectl get pods -n agent-sandbox-systemThen, view the logs for that pod:
kubectl logs -n agent-sandbox-system <pod-name>You can get a shell into the controller's pod to inspect its filesystem and environment:
kubectl exec -it -n agent-sandbox-system <pod-name> -- /bin/bashFor a faster feedback loop, you can run the controller directly on your host machine and have it connect to the kind cluster.
-
Get the
kubeconfigfor thekindcluster:kind get kubeconfig --name agent-sandbox > /tmp/kubeconfig -
Set the
KUBECONFIGenvironment variable:export KUBECONFIG=/tmp/kubeconfig -
Apply the CRD:
kubectl apply -f ./k8s/crds/
-
Run the controller:
go run ./cmd/agent-sandbox-controller/main.go
The controller will now be running on your host machine and will be connected to the kind cluster. You can now use a debugger like Delve to debug the controller.
To improve productivity and maintain consistency, this project supports the use of AI coding assistants. We provide a set of instructions and guidelines for AI agents in the .agents/skills/ directory located at the repository root.
These skills cover:
- Kubernetes API Conventions: Guidelines for creating and modifying CRDs.
- Development Rules: Project-specific rules like Go style and CLA considerations.
If you are using an AI assistant to contribute, please reference these skills to ensure your contributions align with project standards.
The project uses Prow for CI/CD.
The configuration for these jobs is managed in the kubernetes/test-infra repository, see config/jobs/kubernetes-sigs/agent-sandbox.
The CI scripts are located in the dev/ci/ directory.
Note that presubmits are triggered on every push to the main branch, and postsubmits are triggered on every merge to the main branch.
@k8s-ci-robot will automatically merge PRs that have both lgtm and approve labels, and have passed all the Prow presubmits, see the code review process.
You can add commands in PRs/issues to trigger certain actions, see Prow command help for more information.
This repo uses squash merge by default. If you need to retain separate commits in a PR when it merges, use the /label tide/merge-method-rebase command to change the merge method.
@k8s-ci-robot doesn't handle GitHub Actions in presubmits, so GitHub Workflows should contain only non-presubmit jobs.
For information about image registries, image promotion, and the automated release workflow, see the Release Guide.