{{- if eq .Values.cloudProviderSpec.type "gcp" }}
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fix-hostname
  namespace: kube-system
  labels:
   nodeGroup: customer-gpu
spec:
  selector:
    matchLabels:
      nodeGroup: customer-gpu
  template:
    metadata:
      labels:
        nodeGroup: customer-gpu
    spec:
      nodeSelector:
        nodeGroup: customer-gpu
      hostNetwork: true
      containers:
      - image: gcr.io/google-containers/pause:3.2
        name: pause
      initContainers:
      - name: fix-hostname
        image: ubuntu
        env: [ {name: NODE_NAME, valueFrom: { fieldRef: {fieldPath: spec.nodeName } } } ]
        command:
        - /bin/bash
        - -c
        - |
          set -xeuo pipefail
          hostname $(NODE_NAME)
          cat << EOF > /host/etc/systemd/network/97-temp.network
          [Match]
          Name=eth* !eth0

          [Network]
          DHCP=yes
          IPv6AcceptRA=yes

          # non-eth0 modification
          [DHCPv4]
          RoutesToDNS=false
          RoutesToNTP=false

          [DHCP]
          UseMTU=true
          UseDomains=true

          # non-eth0 modification
          UseHostname=false
          EOF
          chroot /host networkctl reload
          echo "Success"


        securityContext: { privileged: true, capabilities: { add: [ NET_ADMIN ] } }
        volumeMounts:
          - name: host
            mountPath: /host
      tolerations:
      - effect: NoExecute
        operator: Exists
      - effect: NoSchedule
        operator: Exists
      volumes:
      - name: host
        hostPath:
          path: /
{{- end }}
