Start right away with a development environment for kubebuilder using Visual Studio Code Remote - Containers.
We assume you have a running docker daemon and a working connection to a kubernetes cluster.
- configure vscode in order to be able to use Visual Studio Code Remote - Containers
- configure connection to your k8s cluster: copy your kubernetes config file to the
.devcontainer
directory. e.g.cp ~/.kube/config .devcontainer
- use this repo as remote container: Press F1 and select the Remote-Containers: Open Folder in Container... command.
After vscode is has been setup ( can last a few minutes for the first time) check whether all tools are present:
# k8s cluster
kubectl cluster-info
# golang
go version
# docker
docker info
# kubebuilder
kubebuilder version
# kustomize
kustomize version
create a project guestbook
( see kubebuilder-book for details)
go mod init guestbook
kubebuilder init
kubebuilder create api --group webapp --version v1 --kind Guestbook
make install
standard with make make run
or press F5 for debugging with vscode
kubectl apply -f config/samples/
make docker-build IMG=guestbook-controller:latest
You can skip this step when using local cluster. If you have push access rights to the registry:
make docker-push IMG=<registry>/guestbook-controller:latest
Here an example for using docker hub (docker.io
):
docker login
docker tag guestbook-controller:latest <dockerhub-username>/guestbook-controller:latest
make docker-push IMG=<dockerhub-username>/guestbook-controller:latest
make deploy IMG=<dockerhub-username>/guestbook-controller:latest