iT邦幫忙

2025 iThome 鐵人賽

DAY 21
0
Cloud Native

我在 CKS 考完只拿 47% 後痛定思痛決定好好準備內容系列 第 21

[Day21] 5-3. Secure your supply chain (permitted registries, sign and validate artifacts, etc.)

  • 分享至 

  • xImage
  •  

今天主要是討論 image 的安全性,這麼部分稍微與前面 [Day5] 有所重複,主要是介紹當使用 image 時該注意的事項,之前有介紹過的 checksum 以及 Cosign 今天就不再重複提了。

  1. 將 image 設定為 private
    Production 的 image 強烈建議儲存於 private 中

image 的名稱可以是 {Registry}/{User/Account}/{Image/Repository},不過在 aws 中的ECR會是 {Account_id}.dkr.ecr.{region}.amazonaws.com/{namespace}/{repo_name},命名主要會根據 image 儲存位置而有所不同。

以 aws 為例除了命名外還可以設定該 image 的 tag 是否可以重複(Mutable),這邊會建議如果是 production 環境會需要開啟該功能,以版號去控制各個版本,不要每個都是 latest。

  1. docker login
    一般而言當我們登入時可以透過以下指令登入
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin {Account_id}.dkr.ecr.{Region}.amazonaws.com

但是也可以透過將登入資訊存於 secrets 中,當抓取 image 時自動登入
(1) 建立 Secrets

# 建立 secrets
  kubectl create secret docker-registry regcred --docker-username=user
--docker-password=password --docker-email=email [--docker-server=string]
[--from-file=[key=]source] [--dry-run=server|client|none] [options]

參考資料
https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/


上一篇
[Day20] 5-2. Understand your supply chain (e.g. SBOM, CI/CD, artifact repositories)
系列文
我在 CKS 考完只拿 47% 後痛定思痛決定好好準備內容21
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言