Expose Jenkins on Kubernetes behind nginx ingress

216 Views Asked by At

Jenkins is deployed on aws eks using this helm chart. Also, used below values.yaml to customize Jenkins deployment based on our needs.

controller:
  jenkinsUrlProtocol: https
  jenkinsUrl: https://jenkins.mydomain.com
  ingress:
    enabled: true
    apiVersion: networking.k8s.io/v1
    ingressClassName: jenkins-nginx --> ingressClass 
    hostName: jenkins.mydomain.com

After deploying this, its created below ingress object:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: jenkins
  namespace: jenkins
spec:
  ingressClassName: jenkins-nginx
  rules:
  - host: jenkins.mydomain.com
    http:
      paths:
      - backend:
          service:
            name: jenkins
            port:
              number: 8080
        pathType: ImplementationSpecific

Apart from this, there is ingress-nginx controller is running behind aws nlb with aws-load-balancer-backend-protocol: http (in other words, tls termination in aws nlb load balancer). If we open the ingress-nginx configuration, we can easily notice, it uses below config to handle (http/https) request.

  http-snippet: |
    server {
      listen 2443;
      return 308 https://$host$request_uri;
    }

Problem statement:

While accessing Jenkins UI using (https://jenkins.mydomain.com), first login page is opening smoothly. But clicking submit button after filling the username/password, it redirects to Jenkins url following with nginx port (i.e; https://jenkins.mydomain.com:2443/loginError) which is not expected.

Note:

  1. If same jenkins service port-forwarded locally, not experiencing even a single issue.
  2. Facing no issue with more than hundreds of services running behind same ingress-nginx.

This is kind of becoming blocker for us, kindly help. Let me know if further information is required.

0

There are 0 best solutions below