当我创建treafik入口时,会引发此错误:
{"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"}
这是treafik定义的kubernetes-dashboard-route.yaml文件:
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: kubernetes-dashboard-route
spec:
entryPoints:
- websecure
tls:
secretName: cloud-mydlq-tls
routes:
- match: Host(`kubernetes.balabala.com`)
kind: Rule
services:
- name: kubernetes-dashboard
port: 8443
这是kubernetes仪表板文件:
{
"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"
}
}
我的配置有什么问题,kubernetes仪表板配置位于8443端口?并在同一个名称空间中,为什么给端口未找到异常?
答案 0 :(得分:2)
端口8443是容器端口,无法在容器外部访问。您应使用此命令查找集群服务端口:
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
端口443是treafik可以访问的群集端口。将容器端口8443更改为端口443。