ds78662302 2017-11-28 13:10
浏览 63

在Minikube中重建并重新运行Go应用程序

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
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line