此问题也已发布到Gitlab论坛。 https://forum.gitlab.com/t/unable-to-access-the-gui-with-ingress-subpath/32269 我认为即使专家在StackOverFlow上也会阅读它,因此我将其发布。 请允许重复发布。
我想在AWS EKS上构建GitLab CE,并使用Ingress中设置的子路径访问GUI。
如果将Ingress中的host
设置为/
,则可以正常访问它,但是如果它不是/
,则无法访问/gitlab
。
使用了Nginx Ingress Controller。
我该如何解决?
谢谢。
以下为参考信息。
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
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"
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
这不起作用,但是我将rewrite-target
设置更改为/
,并将path
更改为/
,然后可以使用GUI进行访问。
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
/gitlab
子路径时的行为该网址将从/gitlab
重定向到/users/sign_in
,并在屏幕上显示为404 Not Found
。
这是您正在访问的URL。
http://{{{AWS CLB DNSName}}}/gitlab
答案 0 :(得分:0)
重定向是应用程序的默认行为,然后您得到404,因为您没有“ / users / sign_in”条目。 因此,也许如果您将“ / users / sign_in”的另一个条目添加为路径,它将起作用
要解决的另一种选择是在路径中使用/并使用主机:
public void bankTest() throws Exception {
Bank bank = new Bank();
String input = "UnionBank";
InputStream stdin = System.in;
try {
System.setIn(new ByteArrayInputStream(input.getBytes()));
Scanner scanner = new Scanner(System.in);
System.out.println(scanner.nextLine());
} finally {
System.setIn(stdin);
bank.createBranches();
}
Assert.assertEquals("UnionBank", bank.branches.get(0));
}