<p>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</p>

<p>.........................................................................</p>

<pre><code>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
</code></pre>

Deens
<p>Your YAML file structure seems wrong, HostAliases should be in a structure like this</p>

<pre><code>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"
</code></pre>

<p>Notice that after hostAliases entry you should put <code>- ip: "127.0.0.1"</code>
and right after you put the hostnames that will be resolved to this ip.</p>

<p>Your YAML is</p>

<pre><code>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" 
</code></pre>

<p>Here you can find more about <a href="https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/</a></p>
