欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 新闻 > 社会 > k8s使用私有harbor镜像源

k8s使用私有harbor镜像源

2025/6/19 17:13:02 来源:https://blog.csdn.net/listhi520/article/details/148654075  浏览:    关键词:k8s使用私有harbor镜像源

前言

在node上手动执行命令可以正常从harbor拉取镜像,但是用k8s不行,使用kubectl describe pods xxx 提示未授权 unauthorized to access repository。

处理方法

  1. 创建一个secrete资源对象。以下示例中 registry-harbor 为secret资源对象的名称。除了邮箱可以随便填,其它三个需要使用实际的harbor地址和账号。
kubectl create secret docker-registry registry-harbor \--docker-server=harbor.interlweb.com \--docker-username=admin \--docker-password='Harbor12345' \--docker-email=foo@bar.com
  1. 在pod的yaml定义文件中使用 imagePullSecrets 引用secret
apiVersion: apps/v1
kind: Deployment
metadata:name: deploy-nginx
spec:replicas: 2selector:matchLabels:app: nginxenv: uattemplate:metadata:labels:app: nginxenv: uatspec:containers:- name: nginximage: harbor.interlweb.com/public/nginx:1.23.3ports:- containerPort: 80imagePullSecrets:- name: registry-harbor
  1. 创建pod测试能否正常拉取
kubectl create -f xxx.yaml

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词