欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

containerd中如何配置鏡像倉庫

本篇文章為大家展示了containerd中如何配置鏡像倉庫,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。

成都創(chuàng)新互聯(lián)主營甘泉網(wǎng)站建設的網(wǎng)絡公司,主營網(wǎng)站建設方案,成都app開發(fā),甘泉h5微信小程序開發(fā)搭建,甘泉網(wǎng)站營銷推廣歡迎甘泉等地區(qū)企業(yè)咨詢

關于 K3s 和 containerd

K3s 是一個輕量級 Kubernetes 發(fā)行版,二進制大小小于100MB,所需內存不到Kubernetes的一半。K3s 為了降低資源消耗,將默認的 runtime 修改為 containerd,同時也內置了 Kubernetes CLI 工具 crictl和ctr。

K3s 默認的 containerd 配置文件目錄為/var/lib/rancher/k3s/agent/etc/containerd/config.toml,但直接操作 containerd 的配置文件去設置鏡像倉庫或加速器相比于操作 docker 要復雜許多。K3s 為了簡化配置 containerd 鏡像倉庫的復雜度,K3s 會在啟動時檢查/etc/rancher/k3s/中是否存在 registries.yaml 文件,如果存在該文件,就會根據(jù) registries.yaml 的內容轉換為 containerd 的配置并存儲到/var/lib/rancher/k3s/agent/etc/containerd/config.toml,從而降低了配置 containerd 鏡像倉庫的復雜度。

使用 K3s 配置私有鏡像倉庫

K3s 鏡像倉庫配置文件由兩大部分組成:mirrorsconfigs:

  • Mirrors 是一個用于定義專用鏡像倉庫的名稱和 endpoint 的指令

  • Configs 部分定義了每個 mirror 的 TLS 和證書配置。對于每個 mirror,你可以定義auth和/或tls

containerd 使用了類似 K8S 中 svc 與 endpoint 的概念,svc 可以理解為訪問名稱,這個名稱會解析到對應的 endpoint 上。也可以理解 mirror 配置就是一個反向代理,它把客戶端的請求代理到 endpoint 配置的后端鏡像倉庫。mirror 名稱可以隨意填寫,但是必須符合IP或域名的定義規(guī)則。并且可以配置多個 endpoint,默認解析到第一個 endpoint,如果第一個 endpoint 沒有返回數(shù)據(jù),則自動切換到第二個 endpoint,以此類推。

比如以下配置示例:

mirrors:
  "172.31.6.200:5000":
    endpoint:
      - "http://172.31.6.200:5000"
  "rancher.ksd.top:5000":
    endpoint:
      - "http://172.31.6.200:5000"
  "docker.io":
    endpoint:
      - "https://fogjl973.mirror.aliyuncs.com"
      - "https://registry-1.docker.io"

可以通過 crictl pull 172.31.6.200:5000/library/alpinecrictl pull rancher.ksd.top:5000/library/alpine獲取到鏡像,但鏡像都是從同一個倉庫獲取到的。

root@rancher-server:/etc/rancher/k3s# systemctl restart k3s.service
root@rancher-server:/etc/rancher/k3s# crictl pull 172.31.6.200:5000/library/alpine
Image is up to date for sha256:a24bb4013296f61e89ba57005a7b3e52274d8edd3ae2077d04395f806b63d83e
root@rancher-server:/etc/rancher/k3s# crictl pull rancher.ksd.top:5000/library/alpine
Image is up to date for sha256:a24bb4013296f61e89ba57005a7b3e52274d8edd3ae2077d04395f806b63d83e
root@rancher-server:/etc/rancher/k3s#

非安全(http)私有倉庫配置

配置非安全(http)私有倉庫,只需要在 endpoint 中指定 http 協(xié)議頭的地址即可。

在沒有 TLS 通信的情況下,需要為 endpoints 指定http:// ,否則將默認為 https。

無認證

如果你使用的是非安全(http)私有倉庫,那么可以通過下面的參數(shù)來配置 K3s 連接私有倉庫:

root@ip-172-31-13-117:~# cat >> /etc/rancher/k3s/registries.yaml <<EOF
mirrors:
  "172.31.6.200:5000":
    endpoint:
      - "http://172.31.6.200:5000"
EOF
systemctl restart k3s

然后可以通過 crictl 去 pull 鏡像:

root@ip-172-31-13-117:~# crictl pull 172.31.6.200:5000/my-ubuntu
Image is up to date for sha256:9499db7817713c4d10240ca9f5386b605ecff7975179f5a46e7ffd59fff462ee

接下來,在看一下 containerd 的配置,可以看到文件末尾追加了如下配置:

root@ip-172-31-13-117:~# cat /var/lib/rancher/k3s/agent/etc/containerd/config.toml
[plugins.cri.registry.mirrors]

[plugins.cri.registry.mirrors."172.31.6.200:5000"]
  endpoint = ["http://172.31.6.200:5000"]

[plugins.cri.registry.mirrors."rancher.ksd.top:5000"]
  endpoint = ["http://172.31.6.200:5000"]

有認證

如果你的非安全(http)私有倉庫帶有認證,那么可以通過下面的參數(shù)來配置 k3s 連接私有倉庫:

mirrors:
  "35.182.134.80":
    endpoint:
      - "http://35.182.134.80"
configs:
  "35.182.134.80":
    auth:
      username: admin # this is the registry username
      password: Harbor12345 # this is the registry password
EOF
systemctl restart k3s

通過 crictl 去 pull 鏡像:

root@ip-172-31-13-117:~# crictl pull 35.182.134.80/ksd/ubuntu:16.04
Image is up to date for sha256:9499db7817713c4d10240ca9f5386b605ecff7975179f5a46e7ffd59fff462ee

Containerd 配置文件末尾追加了如下配置:

[plugins.cri.registry.mirrors]

[plugins.cri.registry.mirrors."35.182.134.80"]
  endpoint = ["http://35.182.134.80"]

[plugins.cri.registry.configs."35.182.134.80".auth]
  username = "admin"
  password = "Harbor12345"

安全(https)私有倉庫配置

以下示例均啟用了認證,所以每個示例都配置了configs.auth,如果實際環(huán)境未配置認證,刪除configs.auth配置即可。

使用授信 ssl 證書

與非安全(http)私有倉庫配置類似,只需要配置 endpoint 對應的倉庫地址為 https 即可。

root@ip-172-31-13-117:~# cat >> /etc/rancher/k3s/registries.yaml <<EOF
mirrors:
  "harbor.kingsd.top":
    endpoint:
      - "https://harbor.kingsd.top"
configs:
  "harbor.kingsd.top":
    auth:
      username: admin # this is the registry username
      password: Harbor12345 # this is the registry password
EOF
systemctl restart k3s

通過 crictl 去 pull 鏡像:

root@ip-172-31-13-117:~# crictl pull harbor.kingsd.top/ksd/ubuntu:16.04
Image is up to date for sha256:9499db7817713c4d10240ca9f5386b605ecff7975179f5a46e7ffd59fff462ee

Containerd 配置文件末尾追加了如下配置:

root@ip-172-31-13-117:~# cat /var/lib/rancher/k3s/agent/etc/containerd/config.toml
[plugins.cri.registry.mirrors]

[plugins.cri.registry.mirrors."harbor.kingsd.top"]
  endpoint = ["https://harbor.kingsd.top"]

[plugins.cri.registry.configs."harbor.kingsd.top".auth]
  username = "admin"
  password = "Harbor12345"

使用自簽 ssl 證書

如果后端倉庫使用的是自簽名的 ssl 證書,那么需要配置 CA 證書 用于 ssl 證書的校驗。

mirrors:
  "harbor-ksd.kingsd.top":
    endpoint:
      - "https://harbor-ksd.kingsd.top"
configs:
  "harbor-ksd.kingsd.top":
    auth:
      username: admin # this is the registry username
      password: Harbor12345 # this is the registry password
    tls:
      ca_file: /opt/certs/ca.crt
EOF
systemctl restart k3s

通過 crictl 去 pull 鏡像:

root@ip-172-31-13-117:~# crictl pull harbor-ksd.kingsd.top/ksd/ubuntu:16.04
Image is up to date for sha256:9499db7817713c4d10240ca9f5386b605ecff7975179f5a46e7ffd59fff462ee

Containerd 配置文件末尾追加了如下配置:

root@ip-172-31-13-117:~# cat /var/lib/rancher/k3s/agent/etc/containerd/config.toml
[plugins.cri.registry.mirrors]

[plugins.cri.registry.mirrors."harbor-ksd.kingsd.top"]
  endpoint = ["https://harbor-ksd.kingsd.top"]

[plugins.cri.registry.configs."harbor-ksd.kingsd.top".auth]
  username = "admin"
  password = "Harbor12345"

[plugins.cri.registry.configs."harbor-ksd.kingsd.top".tls]
  ca_file = "/opt/certs/ca.crt"

ssl 雙向認證

如果鏡像倉庫配置了雙向認證,那么需要為 containerd 配置 ssl 證書用于 鏡像倉庫對 containerd 做認證。

root@ip-172-31-13-117:~# cat >> /etc/rancher/k3s/registries.yaml <<EOF
mirrors:
  "harbor-ksd.kingsd.top":
    endpoint:
      - "https://harbor-ksd.kingsd.top"
configs:
  "harbor-ksd.kingsd.top":
    auth:
      username: admin # this is the registry username
      password: Harbor12345 # this is the registry password
    tls:
      ca_file: /opt/certs/ca.crt # path to the ca file used in the registry
      cert_file: /opt/certs/harbor-ksd.kingsd.top.cert # path to the cert file used in the registry
      key_file: /opt/certs/harbor-ksd.kingsd.top.key # path to the key file used in the registry
EOF
systemctl restart k3s

通過 crictl 去 pull 鏡像:

root@ip-172-31-13-117:~# crictl pull harbor-ksd.kingsd.top/ksd/ubuntu:16.04
Image is up to date for sha256:9499db7817713c4d10240ca9f5386b605ecff7975179f5a46e7ffd59fff462ee

Containerd 配置文件末尾追加了如下配置:

[plugins.cri.registry.mirrors]

[plugins.cri.registry.mirrors."harbor-ksd.kingsd.top"]
  endpoint = ["https://harbor-ksd.kingsd.top"]

[plugins.cri.registry.configs."harbor-ksd.kingsd.top".auth]
  username = "admin"
  password = "Harbor12345"

[plugins.cri.registry.configs."harbor-ksd.kingsd.top".tls]
  ca_file = "/opt/certs/ca.crt"
  cert_file = "/opt/certs/harbor-ksd.kingsd.top.cert"
  key_file = "/opt/certs/harbor-ksd.kingsd.top.key"

加速器配置

Containerd 與 docker 都有默認倉庫,均為 docker.io 。如果配置中未指定 mirror 為 docker.io,containerd 后會自動加載 docker.io 配置。與 docker 不同的是,containerd 可以修改 docker.io 對應的 endpoint(默認為 https://registry-1.docker.io ) ,而 docker 無法修改。

Docker 中可以通過 registry-mirrors 設置鏡像加速地址。如果 pull 的鏡像不帶倉庫地址(項目名+鏡像名:tag),則會從默認鏡像倉庫去拉取鏡像。如果配置了鏡像加速地址,會先訪問鏡像加速倉庫,如果沒有返回數(shù)據(jù),再訪問默認的鏡像倉庫。

Containerd 目前沒有直接配置鏡像加速的功能,但 containerd 中可以修改 docker.io 對應的 endpoint,所以可以通過修改 endpoint 來實現(xiàn)鏡像加速下載。因為 endpoint 是輪詢訪問,所以可以給 docker.io 配置多個倉庫地址來實現(xiàn) 加速地址+默認倉庫地址。如下配置示例:

mirrors:
  "docker.io":
    endpoint:
      - "https://fogjl973.mirror.aliyuncs.com"
      - "https://registry-1.docker.io"
EOF

systemctl restart k3s

Containerd 配置文件末尾追加了如下配置:

root@ip-172-31-13-117:~# cat /var/lib/rancher/k3s/agent/etc/containerd/config.toml
[plugins.cri.registry.mirrors]

[plugins.cri.registry.mirrors."docker.io"]
  endpoint = ["https://fogjl973.mirror.aliyuncs.com", "https://registry-1.docker.io"]

完整配置示例

  "192.168.50.119":
    endpoint:
      - "http://192.168.50.119"
  "docker.io":
    endpoint:
      - "https://fogjl973.mirror.aliyuncs.com"
      - "https://registry-1.docker.io"
configs:
  "192.168.50.119":
    auth:
      username: '' # this is the registry username
      password: '' # this is the registry password
    tls:
      cert_file: '' # path to the cert file used in the registry
      key_file: '' # path to the key file used in the registry
      ca_file: '' # path to the ca file used in the registry
  "docker.io":
    auth:
      username: '' # this is the registry username
      password: '' # this is the registry password
    tls:
      cert_file: '' # path to the cert file used in the registry
      key_file: '' # path to the key file used in the registry
      ca_file: '' # path to the ca file used in the registry

上述內容就是containerd中如何配置鏡像倉庫,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

網(wǎng)站標題:containerd中如何配置鏡像倉庫
網(wǎng)站路徑:http://chinadenli.net/article40/ppseeo.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、App設計、云服務器外貿建站、企業(yè)網(wǎng)站制作App開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設
日本办公室三级在线观看| 最好看的人妻中文字幕| 欧美精品在线播放一区二区| 欧美日韩高清不卡在线播放| 日本在线不卡高清欧美| 国产偷拍盗摄一区二区| 国产盗摄精品一区二区视频| 精品视频一区二区不卡| 国产亚洲成av人在线观看| 亚洲黄色在线观看免费高清| 亚洲中文字幕在线观看黑人| 亚洲视频一区二区久久久| 麻豆在线观看一区二区| 婷婷色香五月综合激激情| 国产欧美性成人精品午夜| 大香蕉大香蕉手机在线视频| 中文字幕91在线观看| 亚洲中文在线中文字幕91| 激情爱爱一区二区三区| 国产欧美一区二区色综合| 亚洲专区中文字幕在线| 亚洲天堂男人在线观看| 精品国产一区二区欧美| 亚洲欧美日韩熟女第一页| 色小姐干香蕉在线综合网| 亚洲精品中文字幕在线视频| 久久老熟女一区二区三区福利| 女人精品内射国产99| 成人精品日韩专区在线观看| 国产在线日韩精品欧美| 国产一区在线免费国产一区| 日本深夜福利在线播放| 午夜成年人黄片免费观看| 精品少妇人妻一区二区三区| 精品熟女少妇av免费久久野外| 日本不卡在线视频中文国产 | 精品熟女少妇一区二区三区| 欧美日韩国产福利在线观看| 欧美日韩亚洲巨色人妻| 久久一区内射污污内射亚洲| 熟女体下毛荫荫黑森林自拍|