Mic*_*ael 3 docker kubernetes minikube okteto ghcr
我希望可以征求您的建议。
\n简而言之,问题是:我的管道无法将私有镜像从 GHCR.IO 拉入 Okteto Kubernetes,但来自同一私有存储库的公共镜像可以工作。
\n我使用的是 Windows 10,使用 WSL2-Ubuntu 20.04 LTS 和 kinD 进行开发,也尝试过 minikube。
\n我在 Okteto 中收到错误,表示图像拉取为 \xe2\x80\x9cunauthorized\xe2\x80\x9d -> \xe2\x80\x9cimagePullBackOff\xe2\x80\x9d。
\n我所做的事情:浏览 Stack Overflow、RTFM、Okteto FAQ,下载 Okteto kubeconfig,费尽心思,花了比我愿意承认的更多的时间 \xe2\x80\x93 仍然没有成功。
\n无论出于何种原因,我无法创建有效的 \xe2\x80\x9ckubectl Secret\xe2\x80\x9d 。当通过 \xe2\x80\x9cdocker login --username\xe2\x80\x9d 登录到 ghcr.io 时,我可以在本地提取私有镜像。
\n无论我\xe2\x80\x99ve如何尝试,当尝试在Okteto中提取私有映像时,我仍然收到错误\xe2\x80\x9cunauthorized\xe2\x80\x9d。
\n我的设置与最新更新:
\n设置类型
\nkind create cluster --name my-name\n\nkubectl create my-namespace\n\n// create a secret to pull images from ghcr.io \nkubectl 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"\n\n// patch local service account\nkubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "my-secret"}]}'\nRun Code Online (Sandbox Code Playgroud)\nkubernetes.yaml
\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: okteto-repo\n namespace: my-namespace\nspec:\n replicas: 1\n selector:\n matchLabels:\n app: okteto-repo\n template:\n metadata:\n labels:\n app: okteto-repo\n spec:\n containers:\n - name: okteto-repo\n image: ghcr.io/user/okteto-repo:latest\n ports:\n - containerPort: 80\n imagePullSecrets:\n - name: my-secret\n---\napiVersion: v1\nkind: Service\nmetadata:\n name: okteto-repo\n annotations:\n dev.okteto.com/auto-ingress: "true"\nspec:\n type: ClusterIP\n selector:\n app: okteto-repo\n ports:\n - protocol: TCP\n port: 8080\n targetPort: 80\nRun Code Online (Sandbox Code Playgroud)\n您知道为什么它不起作用以及我能做什么吗?
\n非常感谢亲爱的朋友们,我们非常感谢您的每一次投入!
\n希望你们假期愉快。
\n干杯,\n迈克尔
\n我能够通过执行以下操作来提取私有映像:
repo。okteto build -t ghcr.io/rberrelleza/go-getting-started:0.0.1)okteto context update-kubeconfig。kubectl create secret docker-registry gh-regcred --docker-server=ghcr.io --docker-username=rberrelleza --docker-password=ghp_XXXXXXkubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "gh-regcred"}]}'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
Run Code Online (Sandbox Code Playgroud)
# 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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2790 次 |
| 最近记录: |