Rebuild and Rerun Go application in Minikube

11/28/2017

I'm building a micro service in Golang which is going to live in a Kubernetes cluster. I'm developing it and using Minikube to run a copy of the cluster locally.

The problem I ran into is that if I run my application inside of the container using go run main.go, I need to kill the pod for it to detect changes and update what is running.

I tried using a watcher for the binary so that the binary is updated on every save and a binary is running inside the pod, but even after compiling the new version, minikube is running the old one.

Any suggestion? Here is my deployment file for running the MS locally:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    name: pokedex
  name: pokedex
spec:
  template:
    metadata:
      labels:
        name: pokedex
    spec:
      volumes:
        - name: source
          hostPath:
            path: *folder where source resides*
      containers:
        - name: pokedex
          image: golang:1.8.5-jessie
          workingDir: *folder where source resides*
          command: ["./pokedex"] # Here I tried both the binary and go run main.go
          ports:
            - containerPort: 8080
              name: go-server
              protocol: TCP
          volumeMounts:
            - name: source
              mountPath: /source
          env:
          - name: GOPATH
            value: /source
-- Pietro Bongiovanni
go
kubernetes
minikube

0 Answers