在k8s上安装Harbor

先前条件

《kubernetes(k8s) 存储动态挂载》
《在k8s(kubernetes)上安装 ingress V1.1.3》
参考我之前的文档进行部署
https://www.oiox.cn/index.php/archives/32/
https://www.oiox.cn/index.php/archives/142/

我用到的批量将dockerhub导入阿里云


#!/bin/bash

for((i=0;i<n;i++)); do
echo "${i}"
done export docker_images="goharbor/harbor-db:v2.6.2 goharbor/harbor-jobservice:v2.6.2 goharbor/harbor-portal:v2.6.2 goharbor/harbor-registryctl:v2.6.2 goharbor/notary-server-photon:v2.6.2 goharbor/notary-signer-photon:v2.6.2 goharbor/redis-photon:v2.6.2 goharbor/registry-photon:v2.6.2 goharbor/trivy-adapter-photon:v2.6.2" export aliyun_image="registry.cn-hangzhou.aliyuncs.com/chenby/" for images in $docker_images;do
export end_image=`echo "$images" | awk -F "/" '{print $NF}'`
docker pull "$images"
docker tag "$images" "$aliyun_image""$end_image"
docker push "$aliyun_image""$end_image"
docker rmi "$images"
docker rmi "$aliyun_image""$end_image"
done

安装helm工具


# 安装helm工具
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh

添加Harbor 官方Helm Chart仓库


# 添加Harbor 官方Helm Chart仓库
root@cby:~# helm repo add harbor https://helm.goharbor.io
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config
"harbor" has been added to your repositories

查看源列表


# 查看源列表
root@cby:~# helm repo list
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config
NAME URL
devtron https://helm.devtron.ai
harbor https://helm.goharbor.io
root@cby:~#

列出最新版本的包


# 列出最新版本的包
root@cby:~# helm search repo harbor -l | grep harbor/harbor | head -4
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config
harbor/harbor 1.10.2 2.6.2 An open source trusted cloud native registry th...
harbor/harbor 1.10.1 2.6.1 An open source trusted cloud native registry th...
harbor/harbor 1.10.0 2.6.0 An open source trusted cloud native registry th...
harbor/harbor 1.9.4 2.5.4 An open source trusted cloud native registry th...
root@cby:~#

下载Chart包到本地


# 下载Chart包到本地
root@cby:~# helm pull harbor/harbor --version 1.10.2
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config
root@cby:~#
root@cby:~# ls harbor-1.10.2.tgz
harbor-1.10.2.tgz
root@cby:~#
root@cby:~# tar zxvf harbor-1.10.2.tgz root@cby:~# cd harbor/
root@cby:~/harbor# ll
total 276
drwxr-xr-x 5 root root 4096 Nov 22 10:35 ./
drwx------ 12 root root 4096 Nov 22 10:35 ../
drwxr-xr-x 2 root root 4096 Nov 22 10:35 cert/
-rw-r--r-- 1 root root 567 Nov 10 09:08 Chart.yaml
drwxr-xr-x 2 root root 4096 Nov 22 10:35 conf/
-rw-r--r-- 1 root root 57 Nov 10 09:08 .helmignore
-rw-r--r-- 1 root root 11357 Nov 10 09:08 LICENSE
-rw-r--r-- 1 root root 202142 Nov 10 09:08 README.md
drwxr-xr-x 16 root root 4096 Nov 22 10:35 templates/
-rw-r--r-- 1 root root 33779 Nov 10 09:08 values.yaml
root@cby:~/harbor#

修改values.yaml配置


# 修改values.yaml配置
root@cby:~/harbor# sed -i "s#harbor.domain#oiox.cn#g" values.yaml # 设置为我的阿里云仓库
root@cby:~/harbor# sed -i "s#repository: goharbor#repository: registry.cn-hangzhou.aliyuncs.com/chenby#g" values.yaml # 修改字段 externalURL
# 注意 30785 是我的ingress端口,各位的端口应该和我的不一样
root@cby:~/harbor# vim values.yaml
externalURL: https://core.oiox.cn:30785 # debug看看配置与自己的环境是否匹配,是否需要修改
root@cby:~/harbor# helm install harbor ./ --dry-run | grep oiox.cn
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config
EXT_ENDPOINT: "https://core.oiox.cn:30785"
- core.oiox.cn
host: core.oiox.cn
- notary.oiox.cn
host: notary.oiox.cn
Then you should be able to visit the Harbor portal at https://core.oiox.cn:30785
root@cby:~/harbor#

安装


# 创建命名空间
root@cby:~/harbor# kubectl create namespace harbor
namespace/harbor created
root@cby:~/harbor# # 进行安装
root@cby:~/harbor# helm install harbor . -n harbor
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config
NAME: harbor
LAST DEPLOYED: Tue Nov 22 10:56:50 2022
NAMESPACE: harbor
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Please wait for several minutes for Harbor deployment to complete.
Then you should be able to visit the Harbor portal at https://core.oiox.cn
For more details, please visit https://github.com/goharbor/harbor
root@cby:~/harbor#

编辑ingress配置


root@cby:~# kubectl edit ingress -n harbor harbor-ingress
root@cby:~# kubectl edit ingress -n harbor harbor-ingress-notary # 添加字段 ingressClassName: nginx
spec:
ingressClassName: nginx
rules:
- host: core.oiox.cn
http: # 查看
root@cby:~# kubectl get ingress -n harbor harbor-ingress -o yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
ingress.kubernetes.io/proxy-body-size: "0"
ingress.kubernetes.io/ssl-redirect: "true"
meta.helm.sh/release-name: harbor
meta.helm.sh/release-namespace: harbor
nginx.ingress.kubernetes.io/proxy-body-size: "0"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
creationTimestamp: "2022-11-22T15:21:35Z"
generation: 3
labels:
app: harbor
app.kubernetes.io/managed-by: Helm
chart: harbor
heritage: Helm
release: harbor
name: harbor-ingress
namespace: harbor
resourceVersion: "2070090"
uid: def0b549-3a00-49a4-8ece-b5ce18205427
spec:
ingressClassName: nginx
rules:
- host: core.oiox.cn
http:
paths:
- backend:
service:
name: harbor-core
port:
number: 80
path: /api/
pathType: Prefix
- backend:
service:
name: harbor-core
port:
number: 80
path: /service/
pathType: Prefix
- backend:
service:
name: harbor-core
port:
number: 80
path: /v2/
pathType: Prefix
- backend:
service:
name: harbor-core
port:
number: 80
path: /chartrepo/
pathType: Prefix
- backend:
service:
name: harbor-core
port:
number: 80
path: /c/
pathType: Prefix
- backend:
service:
name: harbor-portal
port:
number: 80
path: /
pathType: Prefix
tls:
- hosts:
- core.oiox.cn
secretName: harbor-ingress
status:
loadBalancer:
ingress:
- ip: 192.168.8.65
root@cby:~# root@cby:~# kubectl get ingress -n harbor
NAME CLASS HOSTS ADDRESS PORTS AGE
harbor-ingress nginx core.oiox.cn 192.168.8.65 80, 443 9m8s
harbor-ingress-notary nginx notary.oiox.cn 192.168.8.65 80, 443 9m8s
root@cby:~#

访问测试


# 查看管理员密码
root@cby:~# kubectl get secret -n harbor harbor-core -o jsonpath='{.data.HARBOR_ADMIN_PASSWORD}'|base64 --decode
Harbor12345 # 写入本地hosts配置
root@cby:~# echo "192.168.8.65 core.oiox.cn" >> /etc/hosts root@cby:~# sudo mkdir -p /etc/docker
root@cby:~# sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
],
"insecure-registries": [
"hb.oiox.cn",
"core.oiox.cn:30785"
],
"exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
root@cby:~# sudo systemctl daemon-reload
root@cby:~# sudo systemctl restart docker root@cby:~# docker login -uadmin -pHarbor12345 core.oiox.cn:30785
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store Login Succeeded

关于

https://www.oiox.cn/

https://www.oiox.cn/index.php/start-page.html

CSDN、GitHub、51CTO、知乎、开源中国、思否、掘金、简书、华为云、阿里云、腾讯云、哔哩哔哩、今日头条、新浪微博、个人博客

全网可搜《小陈运维》

文章主要发布于微信公众号

在k8s上安装Harbor的更多相关文章

  1. 在k8s上安装Jenkins及常见问题

    持续集成和部署是DevOps的重要组成部分,Jenkins是一款非常流行的持续集成和部署工具,最近试验了一下Jenkins,发现它是我一段时间以来用过的工具中最复杂的.一个可能的原因是它需要与各种其它 ...

  2. k8s上安装elasticsearch集群

    官方文档地址:https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-quickstart.html yaml文件地址:https://dow ...

  3. k8s上安装安装 Ingress Controller &卸载

    在 master 节点上执行 nginx-ingress.yaml文件内容 # 如果打算用于生产环境,请参考 https://github.com/nginxinc/kubernetes-ingres ...

  4. kubernetes(k8s) helm安装kafka、zookeeper

    通过helm在k8s上部署kafka.zookeeper 通过helm方法安装 k8s上安装kafka,可以使用helm,将kafka作为一个应用安装.当然这首先要你的k8s支持使用helm安装.he ...

  5. kubernetes上安装MongoDB-3.6.5集群副本集方式

    一.安装部署: 想直接一步创建集群的小伙伴直接按以下步骤安装(再往后是记录自己出过的错): 1.生成docker镜像: docker build -t 144.202.127.156/library/ ...

  6. kubernetes实战(十):k8s使用Helm安装harbor

    1.基本概念 对于复杂的应用中间件,需要设置镜像运行的需求.环境变量,并且需要定制存储.网络等设置,最后设计和编写Deployment.Configmap.Service及Ingress等相关yaml ...

  7. .NET遇上Docker - Harbor的安装与基本使用

    Harbor是一个开源企业级Docker注册中心,可以用于搭建私有的Docker Image仓库.可以实现权限控制等. 安装Harbor 首先,需要安装Docker和Docker Compose,参考 ...

  8. 在 Ubuntu 上安装 K8S教程

    在 Ubuntu 上安装 K8S教程 1,更新系统源 如果系统本身自带得镜像地址,服务器在国外,下载速度会很慢,可以打开 /etc/apt/sources.lis 替换为国内得镜像源. apt upg ...

  9. Istio(二):在Kubernetes(k8s)集群上安装部署istio1.14

    目录 一.模块概览 二.系统环境 三.安装istio 3.1 使用 Istioctl 安装 3.2 使用 Istio Operator 安装 3.3 生产部署情况如何? 3.4 平台安装指南 四.Ge ...

  10. 超详细实操教程!在现有K8S集群上安装JenkinsX,极速提升CI/CD体验!

    在2018年年初,Jenkins X首次发布,它由Apache Groovy语言的创建者Jame Strachan创建.Jenkins X 是一个高度集成化的 CI/CD 平台,基于 Jenkins ...

随机推荐

  1. 一招彻底解决——双系统下windows时间错误显示

    双系统下windows与ubuntu系统时间不同步 我的笔电是windows系统,工作需要安装了ubuntu,于是成为双系统,于是从18年我就遇到了装了ubuntu系统之后windows时间显示错误的 ...

  2. <c:forEach>循环获取下一次循环数据

    <c:forEach>循环获取下一次循环数据 实现案例类似于多级导航栏下拉.双循环便利ul.li,利用外层循环的index获取数据.动态id设置. varLista[vs.index][l ...

  3. DataRow[]数组转换为DataTable

    DataRow[] drData=DataTable.Select("....."); DataTable dtNew=drData.CopyToDataTable(); 注:Da ...

  4. java 操作 zookeeper

    pom.xml<dependency> <groupId>com.101tec</groupId> <artifactId>zkclient</a ...

  5. Web _Servlet(url-pattern)的配置与优先级

    url-pattern的配置方式有三种: 1.完全路径匹配:以  '/'  开始 例: /ServletDemo1  , /aaa/ServletDemo2 , /aa/bb/ServletDemo3 ...

  6. FCC 高级算法题 对称差分

    Symmetric Difference 创建一个函数,接受两个或多个数组,返回所给数组的 对等差分(symmetric difference) (△ or ⊕)数组. 给出两个集合 (如集合 A = ...

  7. python中将各种类型表达式中的 \ 符号,都看作转义符

    python中将各种类型表达式中的 \ 符号,都看作转义符,如 \n 代表换行  \t  代表空tab,还发现 \a 相当于什么都不是,改行末尾的 \ 的意思是该行还没写完,接着下边一行的内容. 转义 ...

  8. Error java 错误 不支持发行版本5 ( 完美解决版)

    问题 在Intellij idea中新建了一个Maven项目,运行时报错如下:Error : java 不支持发行版本5 解决方案 1. 原因 是因为ideal中默认配置中有几个地方的jdk版本与实际 ...

  9. C#获取本地所有打印机名称

    引用:using System.Drawing.Printing; 实现代码: List<string> PrintS = new List<string>(); foreac ...

  10. 代码片断:GDI绘制带一定角度的椭圆

    //先将DXF文件中的Ellipse 解析到elpList 中 foreach (Ellipse ellipse in elpList) { //定义一个矩形 RectangleF rect = ne ...