本文由簡體中文內容自動轉碼而成。阿里雲不保證此自動轉碼的準確性、完整性及時效性。本文内容請以簡體中文版本為準。

自訂設定ECI Pod的hosts

更新時間:2024-07-05 23:25

某些情境下,您可能需要自訂設定ECI Pod的hosts,例如拉取自建鏡像倉庫的鏡像時,需要通過hosts明確鏡像倉庫的實際IP地址。本文介紹如何自訂設定ECI Pod層級的hosts(即/etc/hosts)。

配置說明

您可以通過k8s.aliyun.com/eci-custom-hosts的Annotation自訂設定ECI Pod的hosts,支援傳入多組IP和網域名稱的映射關係,單組格式為{\"host\":\"example.com\",\"ip\":\"100.100.XX.XX\"}

重要
  • Annotation請添加在Pod的metadata下,例如:建立Deployment時,Annotation需添加在spec>template>metadata下。

  • 僅支援在建立ECI Pod時添加ECI相關Annotation來生效ECI功能,更新ECI Pod時添加或者修改ECI相關Annotation均不會生效。

配置樣本

例如拉取自建鏡像倉庫的鏡像時,需要通過hosts明確鏡像倉庫的實際IP地址時,可參考以下YAML樣本。

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
  labels:
    app: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      name: test
      labels:
        app: test
        alibabacloud.com/eci: "true" 
      annotations:
        k8s.aliyun.com/eci-custom-hosts: "[{\"host\":\"example.com\",\"ip\":\"100.100.XX.XX\"},{\"host\":\"aliyundoc.com\",\"ip\":\"100.100.XX.XX\"}]"
    spec:
      containers:
      - name: nginx
        image: example.com/test/nginx:latest
        ports:
        - containerPort: 80
      - name: busybox
        image: aliyundoc.com/test/busybox:1.30
        command: ["sleep"]
        args: ["999999"]

  • 本頁導讀 (1, M)
  • 配置說明
  • 配置樣本
文檔反饋