Cannot access ingress on local minikube

10/21/2021

I am trying to setup a jenkins server inside of a kubernetes container with minikube. Following up the documentation for this, I have the following kubernetes configuration.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: jenkins
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jenkins
  template:
    metadata:
      labels:
        app: jenkins
    spec:
      containers:
      - name: jenkins
        image: jenkins/jenkins:lts
        ports:
          - name: http-port
            containerPort: 8080
          - name: jnlp-port
            containerPort: 50000
---
apiVersion: v1
kind: Service
metadata:
  name: jenkins-service
spec: 
  selector:
    app: jenkins
  ports: 
   - protocol: TCP
     port: 8080
     targetPort: 8080 
--- 
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata: 
  name: jenkins-ingress
  annotations:  
    nginx.ingress.kubernetes.io/default-backend: ingress-nginx-controller
    kubernetes.io/ingress.class: nginx
    ## tells ingress to check for regex in the config file
    nginx.ingress.kubernetes.io/use-regex: "true"
spec: 
  rules: 
    - http:
        paths:
        - path: /?(.*)
          pathType: Prefix
          backend:
            service:
              name: jenkins-service
              port: 
                number: 8080  

I am trying to create a deployment (pod), service for it and an ingress to expose it. I got the ip address of the ingress with kubectl get ingress and it is the following:

NAME              CLASS    HOSTS   ADDRESS   PORTS   AGE
jenkins-ingress   <none>   *                 80      5s
jenkins-ingress   <none>   *       192.168.49.2   80      5s

When I try to open 192.168.49.2 in the browser, I get timeout. The same happens when I try to ping this ip address from the terminal. The addon for ingress is enabled in minikube, and when I describe the ingress, I see the following:

Name:             jenkins-ingress
Namespace:        default
Address:          192.168.49.2
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
  Host        Path  Backends
  ----        ----  --------
  *           
              /?(.*)   jenkins-service:8080 (172.17.0.4:8080)
Annotations:  kubernetes.io/ingress.class: nginx
              nginx.ingress.kubernetes.io/default-backend: ingress-nginx-controller
              nginx.ingress.kubernetes.io/use-regex: true
Events:
  Type    Reason  Age                    From                      Message
  ----    ------  ----                   ----                      -------
  Normal  Sync    6m15s (x2 over 6m20s)  nginx-ingress-controller  Scheduled for sync

Can someone help me what I am doing wrong and how can I access the jenkins instance through the browser?

-- green
jenkins
kubernetes
kubernetes-ingress
minikube

0 Answers