helm kubernetes部署
更新時(shí)間:2026-05-04 16:19:36
Harbor簡(jiǎn)介
Harbor是部署一個(gè)開(kāi)源的企(′?`)業(yè)級容器注冊中心,用于存儲和分發(fā)D(′▽?zhuān)?)ocker鏡像,部署它提供了一個(gè)簡(jiǎn)單易用的部署Web界面,方便用戶(hù)管理和操作容器鏡像,部署Kubernetes(簡(jiǎn)稱(chēng)K8s)是部署一(╯°□°)╯︵ ┻━┻個(gè)開(kāi)源的容器編排系??統,可以自動(dòng)化地部署、部署擴展和管理容器化應用程序,部署Helm是部署Kubernetes的一個(gè)包管理工具,ヽ(′ー`)ノ可以幫助用戶(hù)更方便地安裝和管理K??ubernetes應用,部署本文將介紹如何在Kubernetes Helm中安裝和使用Harbor。部署
安裝Harbor
1、部署準備環(huán)境
在安裝Harbor之前,部署需要確保已經(jīng)安裝了Kubernetes集群和Helm,部署還需要配置好kubectl命令行工具,部署以便與Kubernetes集群進(jìn)行交互。??部署??
2、下載Harbor安裝包
從Ha(/ω\)rbor的GitHub倉庫ヾ(^-^)ノ下載最新版本??的Harbor安裝包:https://github.co(′_`)m/gヾ(′▽?zhuān)??oharbor/harbor/releases
3、解壓安裝包
將ヽ(′?`)ノ下載的安裝包解壓到一個(gè)目錄中,/opt/ha(′?`*)rbor
tar -zxvf harbor-offline-installer-vx.y.z.tgz -C /opt/harbor4、修改配??置文件
進(jìn)入解壓后的目錄,編輯harbor.yml文件,設置相關(guān)參數,主要需要修改以下幾個(gè)參數:
hostname:設置Harbor的域??名或IP地址;
http:設置??Harbor的HTTP端口;
https:設置Harbor的HTTPS端口;
d(′?ω?`)ata_volume:設置Harbor的數據持久化存儲路徑;
expose:設(′?`)置Harbor的訪(fǎng)問(wèn)端口。
hostname: your_domain_or_iphttp: port: 80https: port: 443expose:?? 80 443(′▽?zhuān)?)datˉ\_(ツ)_/ˉa_volum??e: /path/to/your/data_volume5、安裝Harbor
運行以下(xia)命令開(kāi)始安裝Harbor:
./install.sh --with-notary --with-trivy --with-clair --with-regulatory --with-( ?ヮ?)selfsigned-certs --with-persistence=redis --with-mqtt=disabled='disabled' --with-sy??slo??g --with-insecure-registry=true --with-pachd=false --with-graphql=false --with-replication=none --with-backup=none --with-storagedriver=nullstore --with-dbauth=true --wi(′-ι_-`)th-ldapauth=true --with-tokenauth=true --with-cosiauth=fal┐(′?`)┌se --with??-jwtauth=false --with-redisauth=false --with-mysqlauth=false --with-postgresauth=false --with-sqlaauth=false --with-approleauth=false --wi??th-keycloakauth=false --with-kubernetesauth=true --with-traefik=false --with??-nodeport=true --with-cleanup=false --with-allowadmin="true" --set="global.registry='your_registry_host'" | sudo tee /etc/yum.repos.d/harbor.repo && sudo yum install -y harbor && sudo sys(????)temctl enable and start harbor?? && sudo sy(??-)?stemctl status harbor && sudo docker run -d -p 80:80 -p 443:443 --name harbor regist??ry:2 || true && sudo docker login your_registry_ho??st && sudo docker pul(╯°□°)╯l your_regis(°□°)try_host/library/harbor &&( ?▽?) sudo docker tag your_registry_hos??t/library??/harbor your_domain_or_ip/harbor && sudo docker push your_domain_or_ip/harbor && sudo docker ps | grep harbor || true && sudo docker logs harbor || true&quo??t;
根據提示完成輸入即可,安裝完成后,可以(yi)通過(guò)瀏覽器(′?_?`)訪(fǎng)問(wèn)http://your_domain_or_ip進(jìn)入Harbor的管理(′?_?`)界面。
在Kubernetes中部署Harbor
1、創(chuàng )建命名空間
在Kub??ernetes中,所有的資源都需要在一個(gè)命名空間中,可以使用以下命令創(chuàng )建一個(gè)名為harbor的命名空間:
kubectl?? create namespace harbor
創(chuàng )建一個(gè)名為harbor-deployment.yaml的文件,內容如下:
apiVersion: apps/v1kind: Deploymentmetadata: name: harborspec: re??plicas: 1 se(′▽?zhuān)?lector: matchLabels: app: harbor template: metadata: labels: app: harbor spe(′;ω;`)c: containers: name: harbor image: harbor:latest ports: containerPort:( ?ヮ?) 8080 env??From: configMapRef: name: harbor-conf(′?_?`)igmapapiVersion: v1kind: ServiceAccountmetadata: name: harbor-serviceaccountnamespace: harborapiVersion: rbac.authorization.k8s.io/v1beta1kind: ClusterRoleBindingmetadata: name: harbor-adminuserrolebindingsubject??s: []roleR(╯°□°)╯︵ ┻━┻ef: kind: ClusterRole name: cluster-adminapiVersion: rbac.authorization.k8s.io/v1bet??a1kind: RoleBindingmetadata: name: harbor-adminuserroleb(′?_?`)inding202201191726??5??5969(?⊿?)3900023679696569759397596759675967596759??675967596759675967596759(′?`)67596759675967596ヽ(′▽?zhuān)?ノ7596759675967596759675967(′?`)596759675967596759675967596759675967596759675967596759675967596759675967596759ヽ(′▽?zhuān)?ノ67596759675967596759675967596759(?⊿?)675967596759675967596759(???)6759675967596759675967596759675967593823(′?_?`)423423423(╯°□°)╯︵ ┻━┻42342342342342342342342342342342342342342342342342342342342342342342342??3423423423423423423423423423423423423423423(╬ ò﹏ó)4234234234234234234234234234234234234234234234234234 == harbor@harbor && serviceaccount:default: + envValue + = true && seヽ(′ー`)ノrviceaccount_name != harbor &(′?_?`)& serviceaccount_uid?? != harbor && path != /* &&(′?_?`)amp; path != */ + user && path != /* + group &??& path != */ + privileged?? + * =&g??t; *,subjects: [{ kind: ServiceAccountKind, name: "harbor", namespace: "harbor"}],ru??les=[{ api(′▽?zhuān)?)Groups: [&q??uot;&quo(???)t;], resources: ["events"], verbs: ["create&ヽ(′▽?zhuān)?ノquot;]},{ apiGroups: ["&??quot;], resources: ["nodes"], verbs: ["crea( ???)te&qu???ot;]},{ apiGroups: [""], resources: ["pods"], verbs: ["getヽ(′ー`)ノ", "watch", "list", "update", "patc??h", "delete&q??uot;], verbsIgnoreUnknownParams: true},{ apiGroups??: ["extensions"], resources: ["replicasets"], verbs: ["get", "list&??quot;, "watch"??;, "create", "update", "patch", "delete"], verbsIgnoreUnkn??ownPa(O_O)rams: true},{ apiGroups: [""], resources: ["serviceaccounts"], verb???s: [&quo??t;get", "list", "watch", "create", "update", &q(′ω`*)uot;patch", "??;delete"], verbsIgnore( ???)UnknownParams: true},{ apiGroups: [&qu?ot;&q??uot;], resources: + env( ?° ?? ?°)Value + , verbs: + envValue + ={ read=true},verbsIgnoreUnknownParams: true}],kinds=[ClusterRole(′?_?`)],metadata: { },scope":"Namespaced") > harbor-adminuserrolebinding.yaml && kubectl apply -f harbor-??adminuser 
