Kubernetes联合部署每个群集的不同图像URL

时间:2018-05-24 08:06:05

标签: kubernetes google-kubernetes-engine google-container-registry

是否知道如何定义Kubernetes联合部署以使用来自不同注册表的不同图像网址?

我有一个GKE集群的联合集群,我希望部署能够为其本地GCR提供支持。

apiVersion: extensions/v1beta1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: nginx-deployment
  annotations:
    federation.kubernetes.io/deployment-preferences: |
      {
        "rebalance": true,
        "clusters": {
          "federation-br": {
             "minReplicas": 1,
             "maxReplicas": 1,
             "weight": 1
          },
          "federation-eu": {
              "minReplicas": 3,
              "weight": 1
          },
        }
      }
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 5 # tells deployment to run 2 pods matching the template
  template: # create pods using pod definition in this template
    metadata:
      # unlike pod-nginx.yaml, the name is not included in the meta data as a unique name is
      # generated from the deployment name
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: eu.gcr.io/nginx/proj/app:master.SHAslug
        ports:
        - containerPort: 80

我想根据群集位置使用所有eu.gcr.io,us.gcr.io,asia.gcr.io。

或者我真的想要吗?

1 个答案:

答案 0 :(得分:-1)

使用联合部署的目的是为跨多个集群的部署提供一个配置文件。唯一的方法是在YAML文件中包含一个变量。但是,this does not seem like an option with YAML files。看来这不是一个选择。