This project demonstrates a Kubernetes controller written in Go that manages custom resources (Foo
resources) and their associated Deployments in a Kubernetes cluster.
The controller watches for changes to Foo
resources and ensures that corresponding Deployment
objects are created, updated, or deleted based on the spec.replicas
field of the Foo
resource.
- Automatically creates or updates a
Deployment
when aFoo
resource is added or updated. - Deletes the associated
Deployment
when aFoo
resource is deleted. - Uses Kubernetes client-go library for interacting with Kubernetes APIs.
- Utilizes dynamic client and informers for handling custom resources.
- Kubernetes cluster (local or remote).
kubectl
configured to communicate with your cluster.- Go programming language (if building or modifying the controller).
- Docker (if containerizing the controller).
-
Clone the repository:
git clone git@github.com:Rahul1804/sample-controller.git cd sample-controller
-
Create the CRD
kubectl apply -f foo-crd.yaml
-
Run the program
go run main.go --kubeconfig=/Users/rmishra/.kube/config
-
Create a foo resource to see the magic
kubectl apply -f foo.yaml