一、部署nginx-ingress

1、下载yaml文件

wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/baremetal/deploy.yaml

2、修改yaml文件中的镜像

grep image: deploy.yaml 
image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/registry.k8s.io/ingress-nginx/controller:v1.12.2-linuxarm64
image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/registry.k8s.io/ingress-nginx/kube-webhook-certgen:v1.5.3-linuxarm64
image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/registry.k8s.io/ingress-nginx/kube-webhook-certgen:v1.5.3-linuxarm64

3、部署并查看

kubectl apply -f deploy.yaml
kubectl get pod -n ingress-nginx -o wide
kubectl get svc -n ingress-nginx

二、创建NFS存储分配器

1、创建nfs共享目录

yum install nfs-utils rpcbind -y
mkdir -p /nfs/k8s
chmod  -R /nfs/k8s
echo "/nfs/k8s 10.211.55.0/24(rw,async,no_root_squash)" > /etc/exports
systemctl restart nfs-server
systemctl enable nfs-server

2、设置RBAC权限

[root@master storage]# cat rbac.yaml 
apiVersion: v1
kind: ServiceAccount
metadata:
  name: nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: nfs        #根据实际环境设定namespace,下面类同
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: nfs-client-provisioner-runner
rules:
  - apiGroups: [""]
    resources: ["persistentvolumes"]
    verbs: ["get", "list", "watch", "create", "delete"]
  - apiGroups: [""]
    resources: ["persistentvolumeclaims"]
    verbs: ["get", "list", "watch", "update"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["storageclasses"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["create", "update", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: run-nfs-client-provisioner
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    # replace with namespace where provisioner is deployed
    namespace: nfs
roleRef:
  kind: ClusterRole
  name: nfs-client-provisioner-runner
  apiGroup: rbac.authorization.k8s.io
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: leader-locking-nfs-client-provisioner
    # replace with namespace where provisioner is deployed
  namespace: nfs
rules:
  - apiGroups: [""]
    resources: ["endpoints"]
    verbs: ["get", "list", "watch", "create", "update", "patch"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: leader-locking-nfs-client-provisioner
  namespace: nfs
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    # replace with namespace where provisioner is deployed
    namespace: nfs
roleRef:
  kind: Role
  name: leader-locking-nfs-client-provisioner
  apiGroup: rbac.authorization.k8s.io

3、创建NFS存储分配器

[root@master storage]# cat nfs-provisioner.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nfs-client-provisioner
  labels:
    app: nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: nfs #与RBAC文件中的namespace保持一致
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nfs-client-provisioner
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: nfs-client-provisioner
  template:
    metadata:
      labels:
        app: nfs-client-provisioner
    spec:
      serviceAccountName: nfs-client-provisioner
      containers:
        - name: nfs-client-provisioner
          image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/registry.k8s.io/sig-storage/nfs-subdir-external-provisioner:v4.0.2-linuxarm64
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - name: nfs-client-root
              mountPath: /persistentvolumes
          env:
            - name: PROVISIONER_NAME
              value: nfs-storage  #provisioner名称,请确保该名称与 nfs-StorageClass.yaml文件中的provisioner名称保持一致
            - name: NFS_SERVER
              value: 10.211.55.6   #NFS Server IP地址
            - name: NFS_PATH  
              value: /nfs/k8s    #NFS挂载卷
      volumes:
        - name: nfs-client-root
          nfs:
            server: 10.211.55.6  #NFS Server IP地址
            path: /nfs/k8s     #NFS 挂载卷

4、创建StorageClass

[root@master storage]# cat nfs-StorageClass.yaml 
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: managed-nfs-storage
provisioner: nfs-storage #这里的名称要和provisioner配置文件中的环境变量PROVISIONER_NAME保持一致
parameters:
  archiveOnDelete: "false"

三、部署harbor

1、添加harbor仓库

helm repo add harbor https://helm.goharbor.io

2、下载chart

helm pull harbor/harbor

3、修改 values.yaml 配置

(1)通过http方式访问
expose:
  # Set how to expose the service. Set the type as "ingress", "clusterI
P", "nodePort" or "loadBalancer"
  # and fill the information in the corresponding section
  type: ingress
  tls:
    # Enable TLS or not.
    # Delete the "ssl-redirect" annotations in "expose.ingress.annotati
ons" when TLS is disabled and "expose.type" is "ingress"
    # Note: if the "expose.type" is "ingress" and TLS is disabled,
    # the port must be included in the command when pulling/pushing ima
ges.
    # Refer to https://github.com/goharbor/harbor/issues/5291 for detai
ls.
    enabled: false    #修改此处为false
    .
    .
    .
    .
    className: "nginx"      #此处配置ingressclassName,通过kubectl get ingressclass获取
    .
    .
    .
    .
externalURL: http://core.harbor.domain:30476     #修改此处,改https为http,并添加nginx-ingress的svc的nodePort端口
    .
    .
    .
    .
    storageClass: "managed-nfs-storage"       #修改文件中**所有**的storageClass名称


#修改文件中的镜像
[root@master harbor]# grep repository: values.yaml
    repository: ghcr.io/octohelm/harbor/nginx-photon
    repository: ghcr.io/octohelm/harbor/harbor-portal
    repository: ghcr.io/octohelm/harbor/harbor-core
    repository: ghcr.io/octohelm/harbor/harbor-jobservice
      repository: ghcr.io/octohelm/harbor/registry-photon
      repository: ghcr.io/octohelm/harbor/harbor-registryctl
    repository: ghcr.io/octohelm/harbor/trivy-adapter-photon
      repository: ghcr.io/octohelm/harbor/harbor-db
      repository: ghcr.io/octohelm/harbor/redis-photon
    repository: ghcr.io/octohelm/harbor/harbor-exporter

4、部署

helm install harbor -n harbor harbor/

5、登录访问

本地电脑配置hosts: 10.211.55.6 core.harbor.domain
http://core.harbor.domain:30476
admin/Harbor12345

6、黑屏登录harbor

cat /etc/docker/daemon.json 
{
  "insecure-registries": ["core.harbor.domain:30476"]
}
systemctl daemon-reload
systemctl restart docker
docker login -u admin -p Harbor12345 core.harbor.domain:30476
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Login Succeeded
Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐