Setting up Ingress access to Dashboard #7464
-
Hi everyone! I am quite new to Kubernetes and underlying concepts, and currently trying to setup Dashboard for our test cluster, that has 3 masters (VM), 1 external haproxy (VM) and 1 powerful worker node with GPUs. So far it is built with kubespray and has Ingress controller Nginx, version of K8s is 1.22.5. (All certificates are configured, and domain name is authentic) Installed dashboard with:
Created sample user. Went straight to setting up Ingress: After getting some 50x errors found this thread, after applying all recommendations (labels to deployment, nodeport and etc.) I finally get something but it is a blank page. Ingress config: apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: dashboard-ingress
namespace: kubernetes-dashboard
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: <mywebsite>
http:
paths:
- backend:
service:
name: kubernetes-dashboard
port:
name: dashboard-port
path: /dashboard
pathType: Prefix
tls:
- hosts:
- <mywebsite> Service config: apiVersion: v1
kind: Service
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kubernetes-dashboard
spec:
clusterIP: 172.16.8.120
clusterIPs:
- 172.16.8.120
externalTrafficPolicy: Cluster
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: dashboard-port
nodePort: 30001
port: 80
protocol: TCP
targetPort: 9090
selector:
k8s-app: kubernetes-dashboard
sessionAffinity: None
type: NodePort
status:
loadBalancer: {} Deployment config: apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "3"
generation: 3
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kubernetes-dashboard
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
k8s-app: kubernetes-dashboard
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
k8s-app: kubernetes-dashboard
spec:
containers:
- args:
- --namespace=kubernetes-dashboard
- --enable-insecure-login
- --insecure-bind-address=0.0.0.0
image: kubernetesui/dashboard:v2.6.1
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
httpGet:
path: /
port: 9090
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 30
name: kubernetes-dashboard
ports:
- containerPort: 9090
protocol: TCP
resources: {}
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsGroup: 2001
runAsUser: 1001
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /certs
name: kubernetes-dashboard-certs
- mountPath: /tmp
name: tmp-volume
dnsPolicy: ClusterFirst
nodeSelector:
kubernetes.io/os: linux
restartPolicy: Always
schedulerName: default-scheduler
securityContext:
seccompProfile:
type: RuntimeDefault
serviceAccount: kubernetes-dashboard
serviceAccountName: kubernetes-dashboard
terminationGracePeriodSeconds: 30
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
volumes:
- name: kubernetes-dashboard-certs
secret:
defaultMode: 420
secretName: kubernetes-dashboard-certs
- emptyDir: {}
name: tmp-volume
status:
availableReplicas: 1
conditions:
- lastTransitionTime: "2022-09-16T14:25:54Z"
lastUpdateTime: "2022-09-16T14:25:54Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: "True"
type: Available
- lastTransitionTime: "2022-09-16T13:59:45Z"
lastUpdateTime: "2022-09-16T14:25:54Z"
message: ReplicaSet "kubernetes-dashboard-76cf6d56fb" has successfully progressed.
reason: NewReplicaSetAvailable
status: "True"
type: Progressing
observedGeneration: 3
readyReplicas: 1
replicas: 1
updatedReplicas: 1 As result I get a blank page with some js libs: <html lang="en" dir="ltr"><head>
<meta charset="utf-8">
<title>Kubernetes Dashboard</title>
<link rel="icon" type="image/png" href="assets/images/kubernetes-logo.png">
<meta name="viewport" content="width=device-width">
<style>html,body{height:100%;margin:0}*::-webkit-scrollbar{background:transparent;height:8px;width:8px}</style><link rel="stylesheet" href="styles.243e6d874431c8e8.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles.243e6d874431c8e8.css"></noscript></head>
<body>
<kd-root></kd-root>
<script src="runtime.a00e7f3a25e7662d.js" type="module"></script>
<script src="polyfills.5c84b93f78682d4f.js" type="module"></script>
<script src="scripts.2c4f58d7c579cacb.js" defer=""></script>
<script src="en.main.14a90957c96fe789.js" type="module"></script>
</body>
</html> Should it redirect to login page automatically or I need to enter specific address? Or do I need to pass token in headers? Arguments that are being passed to the containers, is there a full list with description? So what am I doing wrong here, could't find any guide on setting up dashboard with ingress for non-minikube users, if I get this solved I would gladly contribute to writing some docs instead of link to basics of ingress setup page. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Spent half an hour for formatting discussion question just to find a resolution myself 15 minutes later. So basically problem with annotation in Ingress, after making appropriate changes, I see dashboard: annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
...
- backend:
path: /dashboard(/|$)(.*)
... So yes, need to spend some time to understand ingress annotations and how they work. |
Beta Was this translation helpful? Give feedback.
Spent half an hour for formatting discussion question just to find a resolution myself 15 minutes later. So basically problem with annotation in Ingress, after making appropriate changes, I see dashboard:
So yes, need to spend some time to understand ingress annotations and how they work.