joe-elliott / go-minikube-vscode-dev

Development environment for vscode and minikube

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-minikube-vscode-dev

This repo is a template to get started writing golang applications designed to run in Kubernetes. It requires that minikube (https://github.com/kubernetes/minikube) is already installed.

How to use

  1. Type a bunch of go code
  2. Make sure that the "Remote Minikube" launch configuration is selected in vscode
  3. Set a breakpoint or whatever
  4. F5
  5. Unfortunately debug out isn't printing into the console. You can use kubectl logs go-debug --tail=30 --follow as a substitute for now.

How it works

  • The "Remote Minikube" launch configuration has deployToMinikube setup as a prelaunch task
  • deployToMinikube runs debug.sh
  • debug.sh builds a container with debug.Dockerfile
    • .dockerignore ignores everything except the main binary
  • debug.sh uses debug.podspec.yml to install your application/service into minikube. Adjust as necessary to expose other ports. Delve uses 2345 so leave that one alone.
  • The last line of debug.sh prints out the exposed endpoints on your container. Currently launch.json is hardcoded to try to connect to the debugger at 192.168.99.100. This will need to be adjusted if the service is exposed at a different IP.

A Better Approach

See this project https://github.com/number101010/go-kubernetes-vscode-dev for a much better development experience. The only thing that this project does better is actually run your code in the cluster which gives you access to the container file system. See the caveats section in the go-kubernetes-vscode-dev readme.md for more details.

Once I fix the issue where pods fail to terminate then this project will be a much slower but more complete solution. The other project will become a much faster lightweight solution.

Issues/Improvements

  • Print application output into vscode debug console
  • Occassionally the pod/container fail to terminate. (Stopping Minikube VM is the best way I've found to fix this)
  • Windows support
  • Use kubectl port-forward to expose 2345 on localhost
  • Add example usage of ./src directory
  • Cleanup/Replace pods better

About

Development environment for vscode and minikube


Languages

Language:Shell 85.0%Language:Go 15.0%