I am trying to use metrics server on kubeadm with one head-node and two worker nodes but i keep getting an unknown hostAliases error
.........................................................................
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
Your YAML file structure seems wrong, HostAliases should be in a structure like this
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"
Notice that after hostAliases entry you should put - ip: "127.0.0.1"
and right after you put the hostnames that will be resolved to this ip.
Your YAML is
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"
Here you can find more about https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/