首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法将私有包/映像从GitHub容器注册表拉到

无法将私有包/映像从GitHub容器注册表拉到
EN

Stack Overflow用户
提问于 2021-12-20 20:15:04
回答 1查看 1.7K关注 0票数 3

我希望征求你的意见是可以的。

简单地说,问题是:我的管道不能将GHCR.IO中的私有图像拖到中,但是来自同一私人回购工作的公共图像。

我是在Windows 10和使用WSL2-Ubuntu20.04LTS与kinD进行开发,并尝试了微型库。

我在Okteto中看到一个错误,它说图像拉扯是“未经授权的”->“imagePullBackOff”。

我所做的事情:浏览堆栈溢出,RTFM,Okteto FAQ,下载Okteto kubeconfig,拔出我的头发,花了比我想承认的更多的时间--至今还没有成功。

无论出于什么原因,我都不能创造一个有效的“kubectl秘密”。当通过“停靠者登录--用户名”登录到ghcr.io时,我可以在本地提取私有图像。

无论我尝试了什么,当我试图在Okteto中提取一个私人图像时,我仍然会遇到“未经授权”的错误。

我的安装程序有最新更新:

  • Windows 10专业版
  • JetBrains Rider
  • WSL2 2-Ubuntu 20.04 LTS
  • ASP.NET核心MVC应用程序
  • .NET 6 SDK
  • Docker
  • kinD
  • 小库贝
  • 巧克力味
  • 自制软件

设置kinD

代码语言:javascript
复制
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

代码语言:javascript
复制
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

你知道为什么不起作用吗?我能做些什么?

非常感谢我亲爱的朋友们,每一次的投入都是非常感谢的!

希望你们假期愉快。

干杯,迈克尔

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-12-21 00:32:23

通过以下操作,我能够画出一张私人图片:

  1. 在GitHub中使用repo访问创建个人令牌。
  2. 构建图像并将其推送到GitHub的容器注册表(我使用了okteto build -t ghcr.io/rberrelleza/go-getting-started:0.0.1)
  3. 通过运行kubeconfig凭证从Okteto下载我的okteto context update-kubeconfig
  4. 用我的凭据创建一个秘密:kubectl create secret docker-registry gh-regcred --docker-server=ghcr.io --docker-username=rberrelleza --docker-password=ghp_XXXXXX
  5. 修补默认帐户以将秘密包含为图像提取秘密:kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "gh-regcred"}]}'
  6. 更新kubernetes清单中的图像名称
  7. 创建部署(kubectl apply -f k8s.yaml)

这就是我的kubernetes资源的样子,以防有帮助:

代码语言:javascript
复制
# 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
代码语言:javascript
复制
# 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
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70427486

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档