Reputation: 19
Minikube is deployed in EC2 Instance. Kubernetes dashboard is deployed as cluster ip service in Minikube
Nginx-Ingress-Controller is deployed as NodePort service. Ingress YAML file is below:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: kubernetes-dashboard
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: "/$1"
name: ingress-resource
spec:
rules:
- http:
paths:
- path: /kubedashboard
pathType: Prefix
backend:
service:
name: kubernetes-dashboard
port:
number: 443
Ingress address is:
Minikube IP is:
Minikube IP and Ingress Address are different. I did not mention any host in Ingress.yaml.
Ingress and Kubernetes dashboard are deployed in same namespace: kubernetes-dashboard.
How should I access kubernetes dashboard through Ingress?
I want to access with below :
curl https://localhost:NodePort/kubedashboard --insecure
or
curl https://MinikubeIP:NodePort/kubedashboard --insecure
or
curl https://EC2PublicIP:NodePort/kubedashboard --insecure
Upvotes: 0
Views: 397
Reputation: 877
you don't need ingress, ingress
is only used for ports 80 and 443, if you want to use node port to access dashboard, just set dashboard service type to NodePort.
Then you should be able to access with curl https://localhost:NodePort/ --insecure
kubectl patch service kubernetes-dashboard -n kubernetes-dashboard -p '{"spec": {"type": "NodePort"}}'
kubectl get service kubernetes-dashboard -n kubernetes-dashboard
If you really want to use ingress. Use below ingress, then you can access from https://localhost/kubedashboard/
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: kubernetes-dashboard
annotations:
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
nginx.ingress.kubernetes.io/rewrite-target: /$2
nginx.ingress.kubernetes.io/configuration-snippet: |
rewrite ^(/kubedashboard)$ $1/ redirect;
namespace: kubernetes-dashboard
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /kubedashboard(/|$)(.*)
pathType: ImplementationSpecific
backend:
service:
name: kubernetes-dashboard
port:
number: 443
Upvotes: 0