简体   繁体   中英

Unable to access the GUI with Ingress SubPath

This issue has also been posted to the Gitlab Forum. https://forum.gitlab.com/t/unable-to-access-the-gui-with-ingress-subpath/32269 I think that it will be read by experts even on StackOverFlow, so I will post it. Please allow double posting.


I want to build GitLab CE on AWS EKS and access the GUI with the subpath set in Ingress. If host in Ingress is set to / , it can be accessed normally, but if it is other than / , for example /gitlab can not access. Nginx Ingress Controller is used.

How can I solve it?

Thank you in advance.

The following is attached as reference information.

version

  • EKS v1.14
  • Nginx-Ingress-Controller 0.26.1
  • GitLab CE latest

Nginx-Ingress-Controller Setup

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/aws/service-l4.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/aws/patch-configmap-l4.yaml

GitLab CE Deployment/Servicve/ConfigMap yaml

apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: kompose --file docker-compose.yml convert
    kompose.version: 1.17.0 (a74acad)
  creationTimestamp: null
  labels:
    io.kompose.service: gitlab
  name: gitlab
spec:
  ports:
  - name: "12080"
    port: 12080
    targetPort: 80
  selector:
    io.kompose.service: gitlab
  type: ClusterIP
status:
  loadBalancer: {}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose --file docker-compose.yml convert
    kompose.version: 1.17.0 (a74acad)
  creationTimestamp: null
  labels:
    io.kompose.service: gitlab
  name: gitlab
spec:
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: gitlab
    spec:
      containers:
      - envFrom:
        - configMapRef:
            name: gitlab-deployment-env-config
        image: gitlab/gitlab-ce:latest
        name: gitlab
        ports:
        - containerPort: 80
        volumeMounts:
        - mountPath: /etc/gitlab
          name: gitlab-vol0
        - mountPath: /var/log/gitlab
          name: gitlab-vol1
        - mountPath: /var/opt/gitlab
          name: gitlab-vol2
        imagePullPolicy: Always
      restartPolicy: Always
      volumes:
      - name: gitlab-vol0
        hostPath:
          path: /data/gitlab/vol0
          type: DirectoryOrCreate
      - name: gitlab-vol1
        hostPath:
          path: /data/gitlab/vol1
          type: DirectoryOrCreate
      - name: gitlab-vol2
        hostPath:
          path: /data/gitlab/vol2
          type: DirectoryOrCreate
status: {}
apiVersion: v1
kind: ConfigMap
metadata:
  name: gitlab-deployment-env-config
data:
  GITLAB_OMNIBUS_CONFIG: |
    gitlab_rails['initial_root_password'] = "password"
    unicorn['worker_processes'] = 3
    postgresql['shared_buffers'] = "512MB"

Ingress yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  rules:
    # host:
    - http:
        paths:
        - path: /gitlab(/|$)(.*)
          backend:
            serviceName: gitlab
            servicePort: 12080

This doesn't work, but I changed the rewrite-target setting to / and changed path to / Then you can access with GUI.

Nginx-Ingress-Controller log

210.148.59.67 - - [05/Dec/2019:00:44:31 +0000] "GET /gitlab HTTP/1.1" 302 158 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36" 515 0.037 [default-gitlab-12080] [] 10.0.32.140:80 158 0.040 302 0e252e1a2ac495d90790ec7d83546444

Behavior when accessing /gitlab subpath from browser

The URL will be redirected from /gitlab to /users/sign_in and will be 404 Not Found on the screen.

Here is the URL you are accessing.

http://{{{AWS CLB DNSName}}}/gitlab

The redirection is happening as a default behavior of the app then you got 404 as you don't have an entry for "/users/sign_in". So maybe if you add another entry for "/users/sign_in" as path, it would work

As another option to resolve that is to use / in path and use a host:

spec:
  rules:
    - host: gitlab.example.com
      http:
        paths:
        - path: /
          backend:
            serviceName: gitlab
            servicePort: 12080

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM