我试图在kubeadm上使用一个头节点和两个工作节点的度量服务器,但我不断收到一个未知的hostAliases错误
.........................................................................
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
k8s-app: metrics-server
name: metrics-server
namespace: kube-system
spec:
selector:
matchLabels:
k8s-app: metrics-server
template:
metadata:
labels:
k8s-app: metrics-server
name: metrics-server
spec:
containers:
-
command:
- /metrics-server
- "--kubelet-insecure-tls"
- "--kubelet-preferred-address-types=InternalDNS,InternalIPExternalDNS,ExternalIP,Hostname"
image: "k8s.gcr.io/metrics-server-amd64:v0.3.1"
imagePullPolicy: Always
name: metrics-server
volumeMounts:
-
mountPath: /tmp
name: tmp-dir
serviceAccountName: metrics-server
volumes:
-
emptyDir: {}
hostAliases:
-
hostnames:
- k8s-head
ip: "192.168.205.10"
-
hostnames:
- k8s-node-1
ip: "192.168.205.11"
-
hostnames:
- k8s-node-2
ip: "192.168.205.12"
name: tmp-dir
您的YAML文件结构似乎有误,HostAliases应该是这样的结构
apiVersion: v1
kind: Pod
metadata:
name: hostaliases-pod
spec:
restartPolicy: Never
hostAliases:
- ip: "127.0.0.1"
hostnames:
- "foo.local"
- "bar.local"
- ip: "10.1.2.3"
hostnames:
- "foo.remote"
- "bar.remote"
请注意,在hostAliases条目之后,您应该在将要解析的主机名放到此ip之后立即放置- ip: "127.0.0.1"
。
你的YAML是
hostAliases:
- hostnames:
- k8s-head
ip: "192.168.205.10"
- hostnames:
- k8s-node-1
ip: "192.168.205.11"
- hostnames:
- k8s-node-2
ip: "192.168.205.12"
在这里您可以找到更多关于https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/的信息