我希望可以征求你的意見。
簡而言之,問題是:我的管道無法將私有鏡像從 GHCR.IO 拉入 Okteto Kubernetes,但來自同一個私有倉庫的公共鏡像可以作業。
我在 Windows 10 上使用 WSL2-Ubuntu 20.04 LTS 和 kinD 進行開發,也嘗試過 minikube。
我在 Okteto 中收到一個錯誤,提示影像拉取“未經授權”->“imagePullBackOff”。
我所做的事情:瀏覽 Stack Overflow、RTFM、Okteto 常見問題解答、下載 Okteto kubeconfig、拉我的頭發并花費了比我想承認的更多的時間 - 仍然沒有成功。
無論出于何種原因,我都無法創建有效的“kubectl 秘密”。當通過“docker login --username”登錄到 ghcr.io 時,我可以在本地拉取私有鏡像。
無論我嘗試過什么,在嘗試在 Okteto 中提取私有映像時,仍然會出現“未經授權”錯誤。
我的設定與最新更新:
- 視窗 10 專業版
- JetBrains Rider IDE
- WSL2-Ubuntu 20.04 LTS
- ASP.NET Core MVC 應用程式
- .NET 6 SDK
- 碼頭工人
- 種類
- 迷你酷
- 巧克力味
- 家釀
設定種類
kind create cluster --name my-name
kubectl create my-namespace
// create a secret to pull images from ghcr.io
kubectl create secret docker-registry my-secret -n my-namespace --docker-username="my-username" --docker-password="my-password" --docker-email="my-email" --docker-server="https://ghcr.io"
// patch local service account
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "my-secret"}]}'
kubernetes.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: okteto-repo
namespace: my-namespace
spec:
replicas: 1
selector:
matchLabels:
app: okteto-repo
template:
metadata:
labels:
app: okteto-repo
spec:
containers:
- name: okteto-repo
image: ghcr.io/user/okteto-repo:latest
ports:
- containerPort: 80
imagePullSecrets:
- name: my-secret
---
apiVersion: v1
kind: Service
metadata:
name: okteto-repo
annotations:
dev.okteto.com/auto-ingress: "true"
spec:
type: ClusterIP
selector:
app: okteto-repo
ports:
- protocol: TCP
port: 8080
targetPort: 80
你知道為什么它不起作用以及我能做什么嗎?
非常感謝親愛的朋友們,非常感謝每一個輸入!
希望你們有一個愉快的假期。
干杯,邁克爾
uj5u.com熱心網友回復:
我能夠通過執行以下操作來提取私有影像:
- 在 GitHub 中創建一個具有
repo訪問權限的個人令牌。 - 構建鏡像并將其推送到 GitHub 的容器注冊表(我使用過
okteto build -t ghcr.io/rberrelleza/go-getting-started:0.0.1) - 通過運行從 Okteto Cloud下載我的kubeconfig 憑據
okteto context update-kubeconfig。 - 使用我的憑據創建一個秘密:
kubectl create secret docker-registry gh-regcred --docker-server=ghcr.io --docker-username=rberrelleza --docker-password=ghp_XXXXXX - 修補了默認帳戶以將秘密包含在影像拉取秘密中:
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "gh-regcred"}]}' - 更新了 kubernetes manifest 中的鏡像名稱
- 創建部署 (
kubectl apply -f k8s.yaml)
這些是我的 kubernetes 資源的樣子,以防萬一:
# k8s.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
spec:
replicas: 1
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- image: ghcr.io/rberrelleza/go-getting-started:0.0.1
name: hello-world
---
apiVersion: v1
kind: Service
metadata:
name: hello-world
annotations:
dev.okteto.com/auto-ingress: "true"
spec:
type: ClusterIP
ports:
- name: "hello-world"
port: 8080
selector:
app: hello-world
# default SA
apiVersion: v1
imagePullSecrets:
- name: gh-regcred
- name: okteto-regcred
kind: ServiceAccount
metadata:
creationTimestamp: "2021-05-21T22:26:38Z"
name: default
namespace: rberrelleza
resourceVersion: "405042662"
uid: 2b6a6eef-2ce7-40d3-841a-c0a5497279f7
secrets:
- name: default-token-7tm42
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/390055.html
標籤:码头工人 Kubernetes 迷你酷 生长激素受体 奥克特托
上一篇:使用pymongo啟動ReplicaSet節點的問題
下一篇:如何根據模板型別名檢查執行操作?
