外部Docker注册表中的映像更新不会触发部署

问题描述 投票:1回答:1

我正在OpenShift Web客户端中导入以下模板以创建ImageStream,DeploymentConfig和Service。

ImageStream是从外部Docker注册表上可用的Docker映像创建的。

除了Docker镜像每次在外部注册表中发生更改都不会重新部署的事实之外,一切似乎都运行良好。

当外部注册表中的Docker Image更改时,Openshift和外部注册表是否有可能触发自动部署。

{
    "kind": "Template",
    "apiVersion": "v1",
    "metadata": {
        "name": "test-100"
    },
    "objects": [
        {
            "kind": "ImageStream",
            "apiVersion": "image.openshift.io/v1",
            "metadata": {
                "name": "test-100",
                "creationTimestamp": null,
                "labels": {
                    "app": "test-100"
                },
                "annotations": {
                    "openshift.io/generated-by": "OpenShiftNewApp"
                }
            },
            "spec": {
                "lookupPolicy": {
                    "local": false
                },
                "tags": [
                    {
                        "name": "latest",
                        "annotations": {
                            "openshift.io/imported-from": "artifactory.company.com/docker-dev-local/test/dev/test:latest"
                        },
                        "from": {
                            "kind": "DockerImage",
                            "name": "artifactory.company.com/docker-dev-local/test/dev/test:latest"
                        },
                        "generation": null,
                        "importPolicy": {},
                        "referencePolicy": {
                            "type": ""
                        }
                    }
                ]
            }
        },
        {
            "kind": "DeploymentConfig",
            "apiVersion": "apps.openshift.io/v1",
            "metadata": {
                "name": "test-100",
                "creationTimestamp": null,
                "labels": {
                    "app": "test-100"
                },
                "annotations": {
                    "openshift.io/generated-by": "OpenShiftNewApp"
                }
            },
            "spec": {
                "strategy": {
                    "resources": {}
                },
                "triggers": [
                    {
                        "type": "ConfigChange"
                    },
                    {
                        "type": "ImageChange",
                        "imageChangeParams": {
                            "automatic": true,
                            "containerNames": [
                                "test-100"
                            ],
                            "from": {
                                "kind": "ImageStreamTag",
                                "name": "test-100:latest"
                            }
                        }
                    }
                ],
                "replicas": 1,
                "test": false,
                "selector": {
                    "app": "test-100",
                    "deploymentconfig": "test-100"
                },
                "template": {
                    "metadata": {
                        "creationTimestamp": null,
                        "labels": {
                            "app": "test-100",
                            "deploymentconfig": "test-100"
                        },
                        "annotations": {
                            "openshift.io/generated-by": "OpenShiftNewApp"
                        }
                    },
                    "spec": {
                        "containers": [
                            {
                                "name": "test-100",
                                "image": "artifactory.company.com/docker-dev-local/test/dev/test:latest",
                                "ports": [
                                    {
                                        "containerPort": 8080,
                                        "protocol": "TCP"
                                    },
                                    {
                                        "containerPort": 8443,
                                        "protocol": "TCP"
                                    },
                                    {
                                        "containerPort": 8778,
                                        "protocol": "TCP"
                                    }
                                ],
                                "resources": {}
                            }
                        ]
                    }
                }
            }
        },
        {
            "kind": "Service",
            "apiVersion": "v1",
            "metadata": {
                "name": "test-100",
                "creationTimestamp": null,
                "labels": {
                    "app": "test-100"
                },
                "annotations": {
                    "openshift.io/generated-by": "OpenShiftNewApp"
                }
            },
            "spec": {
                "ports": [
                    {
                        "name": "8080-tcp",
                        "protocol": "TCP",
                        "port": 8080,
                        "targetPort": 8080
                    },
                    {
                        "name": "8443-tcp",
                        "protocol": "TCP",
                        "port": 8443,
                        "targetPort": 8443
                    },
                    {
                        "name": "8778-tcp",
                        "protocol": "TCP",
                        "port": 8778,
                        "targetPort": 8778
                    }
                ],
                "selector": {
                    "app": "test-100",
                    "deploymentconfig": "test-100"
                }
            }
        }
    ]
}
docker openshift artifactory openshift-enterprise
1个回答
0
投票

OpenShift无法检测到外部注册表上的映像更改。因此,您应该配置importPolicy.scheduled: true刷新图像。

例如,您可以为每个图像标签配置imagePolicy。

apiVersion: v1
kind: ImageStream
metadata:
  name: ruby
spec:
  tags:
  - from:
      kind: DockerImage
      name: openshift/ruby-20-centos7
    name: latest
    importPolicy:
      scheduled: true

默认间隔为15分钟。如果要更改该值,可以按以下方法从/etc/origin/master/master-config.yaml调整配置。

例如] ScheduledImageImportMinimumIntervalSeconds是图像流导入的间隔时间。有关其他参数的详细信息,请参考Image Policy Configuration

imagePolicyConfig:
  MaxScheduledImageImportsPerMinute: 10  
  ScheduledImageImportMinimumIntervalSeconds: 1800
  disableScheduledImport: false
  maxImagesBulkImportedPerRepository: 3

更多信息在这里:Automatically Update Red Hat Container Images on OpenShift 3.11

热门问题
推荐问题
最新问题