name: "nodeip-configuration.service"
enabled: true
contents: |
  [Unit]
  Description=Writes IP address configuration so that kubelet and crio services select a valid node IP
  # This only applies to VIP managing environments where the kubelet and crio IP
  # address picking logic is flawed and may end up selecting an address from a
  # different subnet or a deprecated address
  Wants=network-online.target
  After=network-online.target ignition-firstboot-complete.service
  Before=kubelet.service crio.service

  [Service]
  # Need oneshot to delay kubelet
  Type=oneshot
  ExecStart=/usr/bin/podman run --rm \
    --authfile /var/lib/kubelet/config.json \
    --volume /etc/systemd/system:/etc/systemd/system:z \
    --net=host \
    {{ .Images.baremetalRuntimeCfgImage }} \
    node-ip \
    set --retry-on-failure \
    {{.Infra.Status.PlatformStatus.OpenStack.APIServerInternalIP }}

  {{if .Proxy -}}
  {{if .Proxy.HTTPProxy -}}
  Environment=HTTP_PROXY={{.Proxy.HTTPProxy}}
  {{end -}}
  {{if .Proxy.HTTPSProxy -}}
  Environment=HTTPS_PROXY={{.Proxy.HTTPSProxy}}
  {{end -}}
  {{if .Proxy.NoProxy -}}
  Environment=NO_PROXY={{.Proxy.NoProxy}}
  {{end -}}
  {{end -}}

  [Install]
  WantedBy=multi-user.target

