JKube 不创建 imagePullSecret

Posted

技术标签:

【中文标题】JKube 不创建 imagePullSecret【英文标题】:JKube doesn't create imagePullSecret 【发布时间】:2021-11-18 19:04:51 【问题描述】:

我尝试使用 JKube maven 插件。我有一个私有 docker 存储库,我在 pom.xml 中指定了它,如下所示:

<plugin>
        <groupId>org.eclipse.jkube</groupId>
        <artifactId>kubernetes-maven-plugin</artifactId>
        <version>$jkube.version</version>
        <configuration>
          <registry>zamek.xxx:nnnn</registry>
          <images>
            <image>
              <name>helloworld-java:$project.version</name>
              <alias>hello-world</alias>
              <build>
                <from>openjdk:latest</from>
                <cmd>java -jar maven/$project.artifactId-$project.version.jar</cmd>
              </build>
              <run>
                <wait>
                  <log>Hello World!</log>
                </wait>
              </run>
            </image>
          </images>
          <resources>
            <secrets>
              <secret>
                <dockerServerId>zamek.xxx:nnnn</dockerServerId>
                <name>hello-world-secret</name>
              </secret>
            </secrets>
          </resources>
        </configuration>
      </plugin>
    </plugins>
  </build>

它创建了 hello-world-secrets 并且很好地包含了所有内容。但是插件不会在生成的 helloworld-deployment.yml 中创建 imagePullSecret。然后我尝试在我的 src/main/jkube 目录中创建一个名为 deployment.yaml 的模板:

---
spec:
  imagePullSecrets:
    -name: hello-world-secret

但插件没有生成包含 imagePullSecret 的部署。如何指定我的私有 Docker 注册表?

谢谢, 扎梅克

【问题讨论】:

【参考方案1】:

这是我的错误,因为我的模板错误。 这是正确的 deployment.yaml:

---
spec:
  template:
    spec:
      imagePullSecrets:
        - name: hello-world-secret

【讨论】:

以上是关于JKube 不创建 imagePullSecret的主要内容,如果未能解决你的问题,请参考以下文章

k8s中imagePullSecrets

k8s的imagePullSecrets如何生成及使用

k8s的imagePullSecrets如何生成及使用

Harbor认证:K8S无法正常拉取harbor镜像

k8s-私有云镜像库使用

Kubernetes笔记