docker - 在 helm 安装之前将 go 二进制文件移动到 pod 中的惯用方法是什么?

标签 docker go kubernetes kubernetes-helm circleci

我使用 CircleCI 构建一个 go 二进制文件,我想在 Helm charts 安装的 pod 中运行它。我想将二进制文件从 CircleCI 移动到远程集群,以便在 pod 启动时可用。我知道使用 ConfigMap 或 Secrets 等卷是可能的,但我不确定执行此操作的最佳方法是什么。

我曾经让它与私有(private) docker 注册表和用于注册表凭据的 kubernetes Secrets 一起使用,但我不喜欢这个选项。我不想在每次二进制更改时都构建和推送新的 docker 镜像。

version: 2.1
jobs:
  build_and_deploy:
    docker:
      - image: circleci/golang:1.12.7
    steps:
      - checkout
      - run: go get -v -t -d ./...
      - run: go build cmd/main.go
      - run: ...
      - run: helm install

workflows:
  version: 2
  build:
    jobs:
      - build_and_deploy:

每次作业运行时,预期结果应该是集群上可用的新二进制文件。

最佳答案

根据最佳实践 - 二进制文件应在构建镜像执行期间应用 - 正如上面的社区和 best developer practices 所提到的:

Don’t create images from running containers – In other terms, don’t use “docker commit” to create an image. This method to create an image is not reproducible and should be completely avoided. Always use a Dockerfile or any other S2I (source-to-image) approach that is totally reproducible, and you can track changes to the Dockerfile if you store it in a source control repository (git).

不过,从另一个角度你可以考虑:

1init contianers直接在集群上构建镜像

2kaniko with 构建上下文的外部位置(gcs bucket git 存储库)

3。 helm 预安装 Hook 以便使用上述解决方案

4。最后其他解决方案,如 cloud buildcloud build locally

另请参阅“Switching from CircleCI to Google Cloud Build”。 如上文所述,您可以使用 keel当 docker 存储库中的图像更新时自动更新您的部署。

如果有帮助,请告诉我。

关于docker - 在 helm 安装之前将 go 二进制文件移动到 pod 中的惯用方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57489083/

相关文章:

python - 如何 git 安装而不是 pip 安装?

json - 是否可以重写未知 json 结构中的字符串?

ssl - Kubernetes: Nginx Ingress注解----> nginx.ingress.kubernetes.io/secure-backends

kubernetes - 无法为volumeMount准备子路径

smtp - Gmail:530 5.5.1 需要身份验证。了解更多信息

Kubernetes 为同一个 Deployment 报告不同的 apiVersion

php - 在Docker容器中安装Composer

docker-compose healthcheck 和 dependent_on service_healthy 非常慢

docker - 超出高磁盘水位线 [90%] [...] 分片将被重新定位到远离此节点的位置

go - 在 golang 中 slice unicode/ascii 字符串?