1、在harbor的ui界面上注册一个账号

姓名:zihao

全名:zhuzihao

密码:Zihao@5tgb

邮箱:15613691030@163.com

2、在需要下载镜像的机器上,同样需要修改docker进程参数(跟上传镜像到私有仓库一样操作进行修改)
在node节点配置:
[root@reg harbor]# vi /etc/docker/daemon.json
{ "registry-mirrors": ["https://wb2g6zxl.mirror.aliyuncs.com"],"insecure-registries": ["192.168.43.65:5000"]} [root@reg harbor]# systemctl restart docker 3、在node节点验证登录harbor主机 [root@lab2 ~]# docker login 192.168.43.65:5000
Username (zihao): zihao
Password:
Login Succeeded
[root@lab2 ~]# docker logout
Not logged in to https://index.docker.io/v1/ 4、配置私有仓库harbor的secret 在harbor这台上先登录,输入docker login登陆成功后,会在 /root/.docker/ 目标下生成一个 config.json 文件 [root@reg harbor]# docker login 192.168.43.65:5000
Username (admin): admin
Password:
Login Succeeded
[root@reg harbor]# ls /root/.docker/
config.json
[root@reg harbor]# cat /root/.docker/config.json
{
"auths": {
"192.168.43.65:5000": {
"auth": "YWRtaW46SGFyYm9yMTIzNDU="
},
"wb2g6zxl.mirror.aliyuncs.com": {
"auth": "YWRtaW46SGFyYm9yMTIzNDU="
}
}
} 创建secret 准备: kubectl create secret docker-registry registry-secret --namespace=default \
--docker-server=192.168.43.65:5000 --docker-username=zihao \
--docker-password=Zihao@5tgb --docker-email=15613691030@163.com 创建: [root@lab2 nginx-harbor]# kubectl create secret docker-registry registry-secret --namespace=default \
> --docker-server=192.168.43.65:5000 --docker-username=zihao \
> --docker-password=Zihao@5tgb --docker-email=15613691030@163.com 查看secret [root@lab2 nginx-harbor]# kubectl get secret
NAME TYPE DATA AGE
default-token-czfbg kubernetes.io/service-account-token 3 21d
registry-secret kubernetes.io/dockerconfigjson 1 1h 删除secret [root@lab2 nginx-harbor]# kubectl delete secret registry-secret
secret "registry-secret" deleted 5、在k8s的node节点中使用yaml拉取镜像 注意: image不要写成 http:// 这样无法拉取镜像 下面两句不写也可以 imagePullSecrets:
- name: registry-secret spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: http-test-con
image: 192.168.43.65:5000/library/nginx/latest:latest
imagePullPolicy: Always
ports:
- containerPort: 80
imagePullSecrets:
- name: registry-secret 测试: [root@lab2 nginx-harbor]# vi http-test.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: http-test-dm2
spec:
replicas: 1
template:
metadata:
labels:
name: http-test-dm2
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: http-test-con
image: 192.168.43.65:5000/library/nginx/latest:latest
imagePullPolicy: Always
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: http-nginx-ser
spec:
type: NodePort
ports:
- port: 80
nodePort: 30000
targetPort: 80
selector:
name: http-test-dm2
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: grafana
spec:
rules:
- host: www.nginx2.com
http:
paths:
- path: /
backend:
serviceName: http-nginx-ser
servicePort: 80 [root@lab2 nginx-harbor]# kubectl create -f http-test.yaml
[root@lab2 nginx-harbor]# kubectl get po
NAME READY STATUS RESTARTS AGE
http-test-dm2-7f9c4fd896-jkkrx 1/1 Running 0 8m
参考地址:https://www.cnblogs.com/wayneiscoming/p/7716238.html

yaml中使用harbor的更多相关文章

  1. K8s集群中设置harbor仓库认证

    一,获取harbor的登陆用户名和密码(demo_user/demo_pwd) 二,使用kubectl命令生成secret(不同的namespace要分别生成secret,不共用) kubectl c ...

  2. 在kubernetes中搭建harbor,并利用MinIO对象存储保存镜像文件

    前言:此文档是用来在线下环境harbor利用MinIO做镜像存储的,至于那些说OSS不香吗?或者单机harbor的,不用看了.此文档对你没啥用,如果是采用单机的harbor连接集群MinIO,请看我的 ...

  3. Kubernetes集群搭建之企业级环境中基于Harbor搭建自己的私有仓库

    搭建背景 企业环境中使用Docker环境,一般出于安全考虑,业务使用的镜像一般不会从第三方公共仓库下载.那么就要引出今天的主题 企业级环境中基于Harbor搭建自己的安全认证仓库 介绍 名称:Harb ...

  4. SpringBoot整合SpringDataJPA及在页面yaml中显示

    SpringBoot整合SpringDataJPA及在页面yaml中显示 1:创建对应的数据表 2:添加依赖 3:配置数据源 1:创建对应的数据表 CREATE TABLE `user` ( `id` ...

  5. k8s中使用harbor

    参考地址:https://www.cnblogs.com/wayneiscoming/p/7716238.html .在harbor的ui界面上注册一个账号 姓名:zihao 全名:zhuzihao ...

  6. yaml中的锚点和引用

    项目引入yaml语言来写配置文件,最近发现利用其锚点&和引用*的功能,可以极大减少配置文件中的重复内容,将相同配置内容收敛到锚点处,修改时,只需要修改锚点处的内容,即可在所有引用处生效. ya ...

  7. 读取yaml中的内容

    def read_yml(path): """ 读取yml文件中的数据 :param path: 文件yaml 的路径 :return: 返回读取yaml文件内的结果 & ...

  8. YAML中重复的KEY的判断

    package com.test.util; import java.io.BufferedReader; import java.io.FileInputStream; import java.io ...

  9. YAML中使用Jinja模板以{{ foo }}开头需要整行加双引号

    YAML陷阱 YAML语法要求如果值以{{ foo }}开头的话我们需要将整行用双引号包起来.这是为了确认你不是想声明一个YAML字典.该知识点在 YAML 语法 页面有所讲述. 这样是不行的: - ...

随机推荐

  1. python - django (request 获取 访问者的 IP)

    使用 Django 获取访问者的 IP if request.META.get('HTTP_X_FORWARDED_FOR'): ip = request.META.get("HTTP_X_ ...

  2. http健康状态检查

    来自为知笔记(Wiz)

  3. Python中对列表排序实例

    Python中对列表排序实例 发布时间:2015-01-04 09:01:50 投稿:junjie 这篇文章主要介绍了Python中对列表排序实例,本文给出了9个List的排序实例,需要的朋友可以参考 ...

  4. zookeeper的补充

    七.Watcher 在ZooKeeper中,接口类Watcher用于表示一个标准的事件处理器,其定义了事件通知相关的逻辑,包含KeeperState和EventType两个枚举类,分别代表了通知状态和 ...

  5. Navicat连接mysql报错1251 -client does not support authentication protocol

    原文https://blog.csdn.net/qq_35654080/article/details/82588188 详解请参考https://blog.csdn.net/chszs/articl ...

  6. Day15:大前端

    垂直水平居中 css: display: table-cell; text-align: center; vertical-align: middle; div: display: inline-bl ...

  7. [系统]win10远程桌面其他电脑出现如下错误,由于数据加密错误,这个会话讲结束,请重新连接到远程计算机

    win10远程桌面其他电脑出现如下错误,由于数据加密错误,这个会话讲结束,请重新连接到远程计算机 这可能是由于credssp加密oracle修正的错误 HKEY_LOCAL_MACHINE\SOFTW ...

  8. Educational Codeforces Round 67 (Rated for Div. 2)

    A 考虑之前选中没有一个的,那么结果就是\(min(n-s,n-t)\) 那么能选中的第一次就是这个结果\(+1\),但需要拥有两个 \((s>t)\)考虑一开始选不中\(t\),则但选中\(t ...

  9. Linux文件与文件夹的权限问题

    0x01 修改文件可读写属性的方法 例如:把index.htm 文件修改为可写可读可执行: chmod 777 index.htm 要修改目录下所有文件属性可写可读可执行: chmod 777 *.* ...

  10. MySQL之级联删除、级联更新、级联置空

    1. 准备测试表 # 专业表major ))engine=innodb default charset=utf8; # 学生表mstudent ), major int)engine=innodb d ...