2017-08-05 82 views
0

我试图用一个图像开始一个cronjob Openshift已经从我的构建配置构建。如何避免在cronjob中对图像url进行硬编码?

以下yaml的作品,但它不是便携式。我不想指定整个网址。

# crontest.yaml 
apiVersion: batch/v2alpha1 
kind: CronJob 
metadata: 
    name: test-job 
spec: 
    schedule: "* * * * *" 
    jobTemplate: 
     spec: 
      template: 
       metadata: 
        labels: 
         parent: "cronjobtest" 
       spec: 
        containers: 
        - name: myimage 
         image: 172.30.1.1:5000/test/myimage # This is not portable 
        restartPolicy: Never 

我想以类似于我能够指定dockerhub图像的方式访问我的图像。 例如

# Example from https://docs.openshift.com/container-platform/3.5/dev_guide/cron_jobs.html 
spec: 
    containers: 
    - name: pi 
    image: perl 

我期望能够通过改变spec.containers.image值要做到这一点,但至今尚未能找到一种有效的方式。看起来这只适用于我迄今发现的例子中的Dockerhub镜像。

我试图测试/ MYIMAGE但导致部署失败与以下几点:

Failed to pull image "myimage": Error response from daemon: {"message":"repository myimage not found: does not exist or no pull access"} 
Error syncing pod, skipping: failed to "StartContainer" for "myimage" with ErrImagePull: "Error response from daemon: {\"message\":\"repository myimage not found: does not exist or no pull access\"}" 

有没有引用我的形象,我缺少的一种方式?

回答

0

会使用域名为你工作吗?那么你不需要硬编码地址。

相关问题