我使用 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).
不过,从另一个角度你可以考虑:
1。 init contianers直接在集群上构建镜像
2。 kaniko with 构建上下文的外部位置(gcs bucket git 存储库)
3。 helm 预安装 Hook 以便使用上述解决方案
4。最后其他解决方案,如 cloud build或 cloud build locally
另请参阅“Switching from CircleCI to Google Cloud Build”。 如上文所述,您可以使用 keel当 docker 存储库中的图像更新时自动更新您的部署。
如果有帮助,请告诉我。
关于docker - 在 helm 安装之前将 go 二进制文件移动到 pod 中的惯用方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57489083/