如何在k8s集群上配置Harbor?

时间:2020-02-24 08:11:50

标签: nginx kubernetes nginx-ingress minio harbor

我正在尝试使用helm(values.yaml)在k8s集群(由Rancher提供)上部署Harbor(私有Docker注册表)。 下面是我的valuse.yaml。

  1. 网络
    我在k8s入口nginx控制器上安装了nginx。
    nginx(http 301重定向到https,例如http://harbor.mydomain.com-> https://harbor.ssgadm.com) -> ingress-nginx->港口服务

  2. 使用nginx进行港口
    https://github.com/goharbor/harbor/blob/master/docs/1.10/install-config/troubleshoot-installation.md#using-nginx-or-load-balancing
    Harbor团队说,如果Harbor在Nginx代理后面运行,请删除标头“ X-Forwarded-Proto”,因此我在values.yaml中添加了入口注释。


这是我的问题。
1.成功登录docker,但未能通过以下消息推送docker映像:拒绝:请求对资源的访问被拒绝

  1. 在港口网页上看不到minio注册表终结点
    couldn't find any endpoints!

那么,您能帮我解决问题吗?

---
  harborAdminPassword: "admin"
  secretKey: "add-your-secret0"
  logLevel: "info"
  expose: 
    type: "ingress"
    ingress: 
      hosts: 
        core: "harbor.mydomain.com"
        notary: "harbor.notary.mydomain.com"
      annotations:
        ingress.kubernetes.io/proxy-body-size: "0"
        ingress.kubernetes.io/ssl-redirect: "true"
        nginx.ingress.kubernetes.io/proxy-body-size: "0"
        nginx.ingress.kubernetes.io/ssl-redirect: "true"
        nginx.org/server-snippets: |
          location / {
            proxy_hide_header 'X-Forwarded-Proto'
          }

          location /v2/ {
            proxy_hide_header 'X-Forwarded-Proto'
          }

          location /service/ {
            proxy_hide_header 'X-Forwarded-Proto'
          }
    loadBalancer: 
      IP: ""
    tls: 
      enabled: false
      secretName: ""
  externalURL: "https://harbor.mydomain.com"
  persistence: 
    imageChartStorage: 
      type: "s3"
      disableredirect: true
      azure: 
        accountname: ""
        accountkey: ""
        container: ""
      gcs: 
        bucket: ""
        encodedkey: ""
      s3: 
        bucket: "docker"
        region: "us-east-1"
        accesskey: "minio"
        secretkey: "minio"
        regionendpoint: "https://minio.mydomain.com"
      oss: 
        bucket: ""
        region: ""
        accesskeyid: ""
        accesskeysecret: ""
      swift: 
        authurl: "https://storage.myprovider.com/v3/auth"
        username: ""
        password: ""
        container: ""
    enabled: true
    persistentVolumeClaim: 
      registry: 
        storageClass: "nfs-provisioner"
        size: "1Gi"
        existingClaim: ""
      chartmuseum: 
        storageClass: "nfs-provisioner"
        size: "1Gi"
        existingClaim: ""
      jobservice: 
        storageClass: "nfs-provisioner"
        size: "1Gi"
        existingClaim: ""
      database: 
        storageClass: "nfs-provisioner"
        size: "1Gi"
        existingClaim: ""
      redis: 
        storageClass: "nfs-provisioner"
        size: "1Gi"
        existingClaim: ""
  jobservice: 
    jobLogger: "database"
  database: 
    type: "internal"
    external: 
      host: ""
      username: ""
      password: ""
      coreDatabase: "registry"
      clairDatabase: "clair"
      notaryServerDatabase: "notary_server"
      notarySignerDatabase: "notary_signer"
      sslmode: "disable"
      port: "5432"
  redis: 
    type: "internal"
    external: 
      host: ""
      port: "6379"
      password: ""
  clair: 
    enabled: true
  notary: 
    enabled: false
  chartmuseum: 
    enabled: true
  cert: 
    enabled: true

1 个答案:

答案 0 :(得分:0)

确保满足所有prerequisites

确保已向Harbor和Docker提供certificates

生成ca.crt,yourdomain.com.crt和yourdomain.com.key文件后,必须将它们提供给Harbor和Docker,然后重新配置Harbor以使用它们。最后重新启动Docker Engine。

要启用将映像推送到docker注册表,请执行以下命令:

您需要包括Docker Hub的名称空间才能将其与 您的帐户。名称空间与您的Docker Hub帐户相同 名称。您需要将图像重命名为 YOUR_DOCKERHUB_NAME / docker-whale。

在推送之前标记图像:

$ docker tag your_image YOUR_DOCKERHUB_NAME/your_image

然后您应该可以将其推入。

$ docker push YOUR_DOCKERHUB_NAME/your_image

您还已经在配置文件中复制了nginx.ingress.kubernetes.io/proxy-body-size注释。

对于NGINX,当大小为5%时,将向客户端返回413错误 请求中的请求超出了客户端请求的最大允许大小 身体。可以通过参数配置此大小 client_max_body_size。

要为所有Ingress规则全局配置此设置,可以在NGINX ConfigMap中设置proxy-body-size值。要在Ingress规则中使用自定义值,请定义以下注释:

nginx.ingress.kubernetes.io/proxy-body-size: 8m

尝试添加 0m

还进行环境完整性检查:如果没有SSL,应该失败,请在数据库中启用外部ss:

sslmode=require

如果发生更多问题,请检查已安装港口的日志:

$ kubectl logs -n harbor your-harbor-pod