An example of a custom Kubernetes controller that with HTTP router endpoint /health
, by default GET
method supports. But the HTTP method could be changed via Custom Resource Definition to enable/disable other HTTP method on endpoint /health
.
Ensure you got Go 1.11 installed with go mod
support.
brew install go
export GO111MODULE=on
go mod vendor
Docker is required. You may download and install the installation package, or install it via Homebrew Cask.
brew cask install docker
kubernetes is required. You may setup a K8s cluster by docker-for-desktop or minikube
kubectl is required. You could install kubectl, or install it via Homebrew.
brew install kubernetes-cli
Helm is required. You may download and install the binary releases, or install it via Homebrew.
brew install kubernetes-helm
Tiller is required. You can install it via command.
kubectl -n kube-system create sa tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account tiller
Draft is required. You may download and install the binary releases, or install it via Homebrew.
brew tap azure/draft && brew install draft
- Set up draft (after Development environment are prepared)
draft init
- To deploy the application to a Kubernetes dev sandbox, accessible using draft connect over a secured tunnel
draft up
- Show information
helm list
kubectl get all
- Apply CRD deployment
kubectl apply -f patch/deploy.yaml
- Test default CRD behavior (GET enabled; PUT disabled)
curl -XGET -i 'localhost:8888/health'
curl -XPUT -i 'localhost:8888/health'
- Enable PUT method
kubectl replace -f patch/put-on.yaml
- Test CRD behavior (GET and enabled)
curl -XGET -i 'localhost:8888/health'
curl -XPUT -i 'localhost:8888/health'
- Disable PUT method
kubectl replace -f patch/put-off.yaml
- Test CRD behavior (GET enabled; PUT disabled)
curl -XGET -i 'localhost:8888/health'
curl -XPUT -i 'localhost:8888/health'
- You could try other HTTP method on/off behavior with
patch/xxx-on.yaml
orpatch/xxx-off.yaml
draft delete