简体   繁体   English

Skaffold 图像标记的环境变量

[英]Environment variable for Skaffold image tagging

I'm just starting using Skaffold for Kubernetes development and I'm not able to tag the docker images created as I intended with environment variables as shown我刚刚开始使用 Skaffold 进行 Kubernetes 开发,但我无法使用环境变量标记按我的意图创建的 docker 映像,如图所示

tagPolicy:
    envTemplate:
      template: '{{.SERVER_DEV_IMAGE_TAG}}'
    # dateTime:
    #   format: "2006-01-02_15-04-05.999_MST"
    #   timezone: "Local"

using dateTime works as expected but I'm not sure I'm setting correctly the environment variable I mean to use..使用 dateTime 按预期工作,但我不确定我是否正确设置了我要使用的环境变量..

I added export SERVER_DEV_IMAGE_TAG=dev to zshrc via vim ~/.zshrc or code ~/.zshrc but still but image has the :latest tag..tried SERVER_DEV_IMAGE_TAG="dev" but didn't make a difference..我通过vim ~/.zshrc .zshrc 或code ~/.zshrc .zshrc 将export SERVER_DEV_IMAGE_TAG=dev添加到 zshrc 但仍然但图像具有:latest标签..尝试过SERVER_DEV_IMAGE_TAG="dev"但没有任何区别..

what am I doing wrong?我究竟做错了什么? Many thanks Cheers非常感谢干杯

Maybe you need double-quotes around the template?也许您需要在模板周围加上双引号? Like喜欢

template: "{{.SERVER_DEV_IMAGE_TAG}}"

I say this because single quotes ' do not expand the variable defined in your environment and will translate to a literal SERVER_DEV_IMAGE_NAME .我这样说是因为单引号'不会扩展您环境中定义的变量,而是会转换为文字SERVER_DEV_IMAGE_NAME If put inside double quotes " , this will be exanded and interpreted as $SERVER_DEV_IMAGE_TAG .如果放在双引号内" ,这将被扩展并解释为$SERVER_DEV_IMAGE_TAG

Otherwise, there is no reason for this to not work.否则,没有理由不工作。 As per the docs here .根据此处的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM