美文网首页
linux harbor搭建

linux harbor搭建

作者: 小小的小帅 | 来源:发表于2022-04-20 16:12 被阅读0次

    参考1:https://blog.csdn.net/weixin_45308292/article/details/107248788
    参考2:https://www.cnblogs.com/linanjie/p/13912017.html
    参考3:https://www.cnblogs.com/fuyuteng/p/15242621.html

    1. 下载:https://github.com/goharbor/harbor/releases
      或者网盘:
      image.png
    tar -zxvf  harbor-offline-installer-v2.5.0.tgz
    
    1. 修改配置
    • harbor.yml:
    hostname: 192.168.16.144
    
    # http related config
    http:
      # port for http, default is 80. If https enabled, this port will redirect to https port
      port: 7129
    
    # https related config
    #https:
      # https port for harbor, default is 443
    #  port: 443
    
    
    • 修改数据存储地方:


      image.png
    1. 启动Harbor
      修改完配置文件后,在的当前目录执行./install.sh,Harbor服务就会根据当期目录下的docker-compose.yml开始下载依赖的镜像,检测并按照顺序依次启动各个服务
    #修改配置后要执行,不然不生效
    ./prepare
    #启动
    sudo ./install.sh
    
    • 若提示docker版本问题
     wget "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -O /usr/local/bin/docker-compose
     chmod +x /usr/local/bin/docker-compose
    
    1. 输入账户密码进入 默认账号/密码:admin/Harbor12345
      http://192.168.16.144:7129/
    1. 修改daemon配置(k8s每个节点都需执行):
    vi /etc/docker/daemon.json
    
    • 配置:
    {
      "registry-mirrors": ["https://dockerhub.azk8s.cn","https://quay.azk8s.cn"],
      "insecure-registries": ["10.244.0.0/18","10.244.64.0/18","192.168.0.0/18","192.168.16.144:7129"],
      "max-concurrent-downloads": 10,
      "log-driver": "json-file",
      "log-level": "warn",
      "log-opts": {
        "max-size": "10m",
        "max-file": "3"
        },
      "data-root": "/var/lib/docker",
      "exec-opts": ["native.cgroupdriver=systemd"],
      "storage-driver": "overlay2",
      "storage-opts": [
        "overlay2.override_kernel_check=true"
      ]
    }
    
    {
      "insecure-registries": ["192.168.16.144:7129"]
    }
    
    • 重启docker:
    systemctl daemon-reload
    systemctl restart docker
    
    1. 登录k8s每个节点都需执行
    docker login -u admin -p Harbor12345 192.168.16.144:7129
    #可查看
    cat ~/.docker/config.json
    
    1. harbor停掉、启动
    #查看harbor
    docker-compose ps
    #停掉harbor
    docker-compose down -v
    #启动qharbor
    docker-compose up -d
    
    1. 基于现有Docker凭据创建secret 注意命名空间
    kubectl create secret generic harborsecret \
        --from-file=.dockerconfigjson=/root/.docker/config.json \
        --type=kubernetes.io/dockerconfigjson
    

    注意:主要修改红色部分。
    harborsecret 表示key名
    /root/.docker/config.json 表示docker认证文件,注意要写绝对路径。

    • 查看内容 注意命名空间
    kubectl get secrets -n hips-dev harborsecret -n hips-dev --output="jsonpath={.data.\.dockerconfigjson}" | base64 -d
    
    • 应用pod yaml配置文件添加:添加在containers:下,每个pod都需添加
          dnsPolicy: ClusterFirst
    #添加内容 start
          imagePullSecrets:
          - name: harborsecret
    #添加内容 end
          restartPolicy: Always
    
    image.png

    相关文章

      网友评论

          本文标题:linux harbor搭建

          本文链接:https://www.haomeiwen.com/subject/dimsertx.html