Giter Club home page Giter Club logo

go-kubernetes-vscode-dev's Introduction

go-kubernetes-vscode-dev

This repo is a template to get started writing golang applications designed to run in Kubernetes. It requires access to an existing kubernetes cluster.

If you do not have access to a Kubernetes cluster than I'd recommend trying minikube (https://kubernetes.io/docs/setup/minikube/).

Dependencies

How to use

  1. Make sure that kubectl is pointed to the environment you want to debug in. Telepresence will create a deployment in the cluster you are pointed at. Be aware.
  2. Type some Go
  3. In the Terminal window run .debug/debug.sh. Your applications output will show up in this window. You only need to do this once.
  4. When you see API server listening at: [::]:2345 in the terminal window Delve is ready.
  5. Smack F5 in VSCode to connect to Delve on port 2345.
  6. After debugging you will be presented with a prompt to either start a new debug session or exit the container.

Alternatively you can run .debug/debug.sh --manual. This will start the Telepresence container and leave you at a command prompt. From here you can debug Kubernetes networking issues, manage dependencies (dep), manually trigger a debug session (.debug/runDelve.sh), etc.

Caveats

  • Telepresence mounts the actual container's file system at $TELEPRESENCE_ROOT. Note that runDelve.sh copies the service account information from this mounted filesystem into an expected spot in the telepresence container. There is probably a better solution somewhere, but this works just for simple Kubernetes development.
  • The Telepresence --docker-run parameter does not provide a way to set the service account. If you want to access the Kubernetes API you will need to setup the default service account in a way that allows you to make the queries you would like.
  • Other documented limitations here: http://www.telepresence.io/reference/limitations.html

Previous Iteration

Previously this project used a unix pipe to pass commands back and forth between two different shell scripts. It was complicated and didn't work sometimes, but it made for a nice UX when it did. This has been scrapped in favor of the above approach. If you are interested in the way things used to be done:

https://github.com/number101010/go-kubernetes-vscode-dev/tree/a296d80d84bf4ff4297b0bffe32dd1b852be7a0c

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.