/example

simple golang / kubernetes / skaffold / ko example

Primary LanguageGoApache License 2.0Apache-2.0

Example Golang Kubernetes Devthingy

Prerequisites:

Development environment

Kubernetes cluster

I've included kind configuration for initializing a minimalistic Kubernetes cluster which forwards host port 80 (http) and 443 (https) to the kubernetes cluster.

$ kind create cluster --config hacking/kind.yaml
Creating cluster "kind" ...
 ✓ Ensuring node image (kindest/node:v1.21.1) 🖼
 ✓ Preparing nodes 📦  
 ✓ Writing configuration 📜 
 ✓ Starting control-plane 🕹️ 
 ✓ Installing CNI 🔌 
 ✓ Installing StorageClass 💾 
Set kubectl context to "kind-kind"
You can now use your cluster with:

kubectl cluster-info --context kind-kind

Thanks for using kind! 😊

Running example application

This example project utilizes skaffold, ko and kustomize to build and deploy the example application.

$ skaffold dev
$ curl -k https://example.127.0.0.1.nip.io

If you change the source code while skaffold is running, it will rebuild and redeploy the application for you.

Debugging the application

I've included example vscode debugging support, allowing you to step through the execution of a process running as a Pod in a remote Kubernetes cluster.

$ skaffold debug

You should now be able to set a breakpoint in the handler defined in pkg/service/service.go using VSCode. After setting up the breakpoint you can use the Skaffold Debug profile included in the repository. Hot reloading won't work in skaffold debug mode.