0

我只是将 nexus 存储库部署到 kubernetes 集群。这个关系有 3 个 docker 存储库。一个 docker hub 的代理,一个是私有的,一个是之前的。

我使用 haproxy 作为入口控制器。是否可以部署与此处描述的配置匹配的入口?Nexus3:推送到 Docker 组回购

我的目标是只有一个 url 可以推送和拉取到 docker 存储库。

4

1 回答 1

0

我在这里发布我的解决方案。我使用自定义注释来实现生根以根据请求的 url 更正端点。

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nexus-ingress-docker
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.org/client-max-body-size: "1G"
    nginx.org/proxy-buffering: "off"
    nginx.org/server-snippets: |
      location ~ ^/(v1|v2)/[^/]+/?[^/]+/blobs/ {
        if ($request_method ~* (POST|PUT|DELETE|PATCH|HEAD) ) {
            rewrite ^/(.*)$ /repository/docker-private/$1 last;
        }
        rewrite ^/(.*)$ /repository/docker-public/$1 last;
      }

      location ~ ^/(v1|v2)/ {
        if ($request_method ~* (POST|PUT|DELETE|PATCH) ) {
            rewrite ^/(.*)$ /repository/docker-private/$1 last;
        }
        rewrite ^/(.*)$ /repository/docker-public/$1 last;
      }
    nginx.org/location-snippets: |
      proxy_set_header X-Forwarded-Proto https;


spec:
  ingressClassName: nginx
  rules:
    - host: my-host
      http:
        paths:
          - backend:
              service:
                name: nexus
                port:
                  name: nexus
            path: /
            pathType: Prefix

和服务:

apiVersion: v1
kind: Service
metadata:
  name: nexus
  labels:
    app: nexus
spec:
  type: ClusterIP
  ports:
    - port: 8081
      name: nexus
    - port: 8082
      name: docker-private
    - port: 8083
      name: docker-public
  selector:
    app: nexus
于 2020-12-03T08:59:04.500 回答