When I am create treafik ingress,it throw this error:
{"ingress":"kubernetes-dashboard-route","level":"error","msg":"Cannot create service: service port not found","namespace":"kube-system","providerName":"kubernetescrd","serviceName":"kubernetes-dashboard","servicePort":8443,"time":"2020-01-30T18:12:15Z"}
{"ingress":"kubernetes-dashboard-route","level":"error","msg":"Cannot create service: service port not found","namespace":"kube-system","providerName":"kubernetescrd","serviceName":"kubernetes-dashboard","servicePort":8443,"time":"2020-01-30T18:12:17Z"}
this is the treafik define kubernetes-dashboard-route.yaml file:
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: kubernetes-dashboard-route
spec:
entryPoints:
- websecure
tls:
secretName: cloud-mydlq-tls
routes:
- match: Host(`kubernetes.ttt208.com`)
kind: Rule
services:
- name: kubernetes-dashboard
port: 8443
this is the kubernetes dashboard file:
{
"kind": "Pod",
"apiVersion": "v1",
"metadata": {
"name": "kubernetes-dashboard-6466b68b-mrrs9",
"generateName": "kubernetes-dashboard-6466b68b-",
"namespace": "kube-system",
"selfLink": "/api/v1/namespaces/kube-system/pods/kubernetes-dashboard-6466b68b-mrrs9",
"uid": "fafd91a2-6e49-4f09-8479-b593f3f1d005",
"resourceVersion": "12218565",
"creationTimestamp": "2020-01-25T16:51:10Z",
"labels": {
"k8s-app": "kubernetes-dashboard",
"pod-template-hash": "6466b68b"
},
"annotations": {
"scheduler.alpha.kubernetes.io/critical-pod": "",
"seccomp.security.alpha.kubernetes.io/pod": "docker/default"
},
"ownerReferences": [
{
"apiVersion": "apps/v1",
"kind": "ReplicaSet",
"name": "kubernetes-dashboard-6466b68b",
"uid": "3d8e2739-5113-4398-b7b8-28bda186b15e",
"controller": true,
"blockOwnerDeletion": true
}
]
},
"spec": {
"volumes": [
{
"name": "kubernetes-dashboard-certs",
"secret": {
"secretName": "kubernetes-dashboard-certs",
"defaultMode": 420
}
},
{
"name": "tmp-volume",
"emptyDir": {}
},
{
"name": "kubernetes-dashboard-token-pmxpf",
"secret": {
"secretName": "kubernetes-dashboard-token-pmxpf",
"defaultMode": 420
}
}
],
"containers": [
{
"name": "kubernetes-dashboard",
"image": "gcr.azk8s.cn/google_containers/kubernetes-dashboard-amd64:v1.10.1",
"args": [
"--auto-generate-certificates",
"--token-ttl=43200"
],
"ports": [
{
"containerPort": 8443,
"protocol": "TCP"
}
],
"resources": {
"limits": {
"cpu": "100m",
"memory": "300Mi"
},
"requests": {
"cpu": "50m",
"memory": "100Mi"
}
},
"volumeMounts": [
{
"name": "kubernetes-dashboard-certs",
"mountPath": "/certs"
},
{
"name": "tmp-volume",
"mountPath": "/tmp"
},
{
"name": "kubernetes-dashboard-token-pmxpf",
"readOnly": true,
"mountPath": "/var/run/secrets/kubernetes.io/serviceaccount"
}
],
"livenessProbe": {
"httpGet": {
"path": "/",
"port": 8443,
"scheme": "HTTPS"
},
"initialDelaySeconds": 30,
"timeoutSeconds": 30,
"periodSeconds": 10,
"successThreshold": 1,
"failureThreshold": 3
},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent"
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"serviceAccountName": "kubernetes-dashboard",
"serviceAccount": "kubernetes-dashboard",
"nodeName": "azshara-k8s01",
"securityContext": {},
"schedulerName": "default-scheduler",
"tolerations": [
{
"key": "CriticalAddonsOnly",
"operator": "Exists"
},
{
"key": "node.kubernetes.io/not-ready",
"operator": "Exists",
"effect": "NoExecute",
"tolerationSeconds": 360
},
{
"key": "node.kubernetes.io/unreachable",
"operator": "Exists",
"effect": "NoExecute",
"tolerationSeconds": 360
}
],
"priorityClassName": "system-cluster-critical",
"priority": 2000000000,
"enableServiceLinks": true
},
"status": {
"phase": "Running",
"conditions": [
{
"type": "Initialized",
"status": "True",
"lastProbeTime": null,
"lastTransitionTime": "2020-01-25T16:51:10Z"
},
{
"type": "Ready",
"status": "True",
"lastProbeTime": null,
"lastTransitionTime": "2020-01-25T16:51:24Z"
},
{
"type": "ContainersReady",
"status": "True",
"lastProbeTime": null,
"lastTransitionTime": "2020-01-25T16:51:24Z"
},
{
"type": "PodScheduled",
"status": "True",
"lastProbeTime": null,
"lastTransitionTime": "2020-01-25T16:51:10Z"
}
],
"hostIP": "172.19.104.231",
"podIP": "172.30.224.9",
"startTime": "2020-01-25T16:51:10Z",
"containerStatuses": [
{
"name": "kubernetes-dashboard",
"state": {
"running": {
"startedAt": "2020-01-25T16:51:23Z"
}
},
"lastState": {},
"ready": true,
"restartCount": 0,
"image": "gcr.azk8s.cn/google_containers/kubernetes-dashboard-amd64:v1.10.1",
"imageID": "docker-pullable://gcr.azk8s.cn/google_containers/kubernetes-dashboard-amd64@sha256:0ae6b69432e78069c5ce2bcde0fe409c5c4d6f0f4d9cd50a17974fea38898747",
"containerID": "docker://07ab8a9e93cb2f9a27194f73094ce77cb8938edf32a36fe6962737bfd16c3c38"
}
],
"qosClass": "Burstable"
}
}
what is wrong with my config,the kubernetes dashboard config is in 8443 port? and in the same namespace,why it give port not found exception?
The port 8443 is container port,could not access outside the container.You should using this command to find the cluster service port:
kubectl get svc --namespace=kube-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kube-dns ClusterIP 10.254.0.2 <none> 53/UDP,53/TCP,9153/TCP 131d
kubernetes-dashboard NodePort 10.254.75.193 <none> 443:31085/TCP 131d
traefik ClusterIP 10.254.169.66 <none> 80/TCP,443/TCP,8080/TCP 2d4h
the port 443 is the cluster port treafik could access. change container port 8443 to port 443.