Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignition does not set the vm ip address #2684

Closed
xsen84 opened this issue Feb 1, 2024 · 10 comments
Closed

Ignition does not set the vm ip address #2684

xsen84 opened this issue Feb 1, 2024 · 10 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@xsen84
Copy link

xsen84 commented Feb 1, 2024

/kind bug

What steps did you take and what happened:
Deploying flatcar vm and configuring via ignition does not set the ip address as passed through the guestinfo.metadata.
Image used: flatcar-stable-3510.2.4-kube-v1.27.3

What did you expect to happen:
Set the ip as defined in guestinfo.metadata > network.

Anything else you would like to add:
This works if using ubuntu with cloud-init.
Image used: ubuntu-1804-kube-v1.17.3

Environment:

  • Cluster-api-provider-vsphere version: v1.9.0
  • Kubernetes version: (use kubectl version): v1.27.3
  • OS (e.g. from /etc/os-release): flatcar/coreos 3510.2.4
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Feb 1, 2024
@chrischdi
Copy link
Member

chrischdi commented Feb 1, 2024

Could you please provide details about the yaml's you are using?

How are you setting the ip address (using an IPAM provider?)?

@chrischdi
Copy link
Member

chrischdi commented Feb 1, 2024

First idea: ignition may not support the format for static IP's we use when providing the guestinfo.metadata information.

@chrischdi
Copy link
Member

Would be awesome to see the relevant logs for ignition.

@chrischdi
Copy link
Member

Note: flatcar does not seem to support the guestinfo.metadata format in the flatcar version you are referencing above.

It may be worth to try the latest verison of flatcar (https://www.flatcar.org/releases#release-3760.2.0) which includes afterburn in v5.5.0 which should include this implementation of support for the format: coreos/afterburn#888 .

@vgromanov
Copy link

vgromanov commented Feb 3, 2024

We also ran into this issue and as a workaround had to use a crude shell script which parses netplan yaml into a systemd network unit:

#!/bin/bash
PATH=$PATH:/bin
function yaml_to_vars {
   # find input file
   for f in "$1" "$1.yay" "$1.yml"
   do
     [[ -f "$f" ]] && input="$f" && break
   done
   [[ -z "$input" ]] && exit 1

   # use given dataset prefix or imply from file name
   [[ -n "$2" ]] && local prefix="$2" || {
     local prefix=$(basename "$input"); prefix=${prefix%.*}; prefix="${prefix//-/_}_";
   }

   local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
   sed -ne "s|,$s\]$s\$|]|" \
        -e ":1;s|^\($s\)\($w\)$s:$s\[$s\(.*\)$s,$s\(.*\)$s\]|\1\2: [\3]\n\1  - \4|;t1" \
        -e "s|^\($s\)\($w\)$s:$s\[$s\(.*\)$s\]|\1\2:\n\1  - \3|;p" $1 | \
   sed -ne "s|,$s}$s\$|}|" \
        -e ":1;s|^\($s\)-$s{$s\(.*\)$s,$s\($w\)$s:$s\(.*\)$s}|\1- {\2}\n\1  \3: \4|;t1" \
        -e    "s|^\($s\)-$s{$s\(.*\)$s}|\1-\n\1  \2|;p" | \
   sed -ne "s|^\($s\):|\1|" \
        -e "s|^\($s\)-$s[\"']\(.*\)[\"']$s\$|\1$fs$fs\2|p" \
        -e "s|^\($s\)-$s\(.*\)$s\$|\1$fs$fs\2|p" \
        -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
        -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" | \
   awk -F$fs '{
      indent = length($1)/2;
      vname[indent] = $2;
      for (i in vname) {if (i > indent) {delete vname[i]; idx[i]=0}}
      if(length($2)== 0){  vname[indent]= ++idx[indent] };
      if (length($3) > 0) {
         vn=""; for (i=0; i<indent; i++) { vn=(vn)(vname[i])("_")}
         printf("%s%s%s=\"%s\"\n", "'$prefix'",vn, vname[indent], $3);
      }
   }'
}

/usr/share/oem/bin/vmtoolsd --cmd "info-get guestinfo.metadata" | /bin/base64 --decode > /tmp/netplan.yaml
cat /tmp/netplan.yaml
yaml_to_vars /tmp/netplan.yaml
eval $(yaml_to_vars /tmp/netplan.yaml)
/bin/cat > /etc/systemd/network/10-ipam.network << EOF
[Match]
MACAddress=$netplan_network_ethernets_id0_match_macaddress

[Network]
DHCP=no
DNS=$netplan_network_ethernets_id0_nameservers_1
DNS=$netplan_network_ethernets_id0_nameservers_2
DNS=$netplan_network_ethernets_id0_nameservers_3
Address=$netplan_network_ethernets_id0_1
Gateway=$netplan_network_ethernets_id0_gateway4
EOF

Yeah. It is ugly.

Update: as for afterburn in latest flatcar version - it is pretty much useless. It is only capable of burping out netplan config which makes no point.

@xsen84
Copy link
Author

xsen84 commented Feb 5, 2024

We also ran into this issue and as a workaround had to use a crude shell script which parses netplan yaml into a systemd network unit:

#!/bin/bash
PATH=$PATH:/bin
function yaml_to_vars {
   # find input file
   for f in "$1" "$1.yay" "$1.yml"
   do
     [[ -f "$f" ]] && input="$f" && break
   done
   [[ -z "$input" ]] && exit 1

   # use given dataset prefix or imply from file name
   [[ -n "$2" ]] && local prefix="$2" || {
     local prefix=$(basename "$input"); prefix=${prefix%.*}; prefix="${prefix//-/_}_";
   }

   local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
   sed -ne "s|,$s\]$s\$|]|" \
        -e ":1;s|^\($s\)\($w\)$s:$s\[$s\(.*\)$s,$s\(.*\)$s\]|\1\2: [\3]\n\1  - \4|;t1" \
        -e "s|^\($s\)\($w\)$s:$s\[$s\(.*\)$s\]|\1\2:\n\1  - \3|;p" $1 | \
   sed -ne "s|,$s}$s\$|}|" \
        -e ":1;s|^\($s\)-$s{$s\(.*\)$s,$s\($w\)$s:$s\(.*\)$s}|\1- {\2}\n\1  \3: \4|;t1" \
        -e    "s|^\($s\)-$s{$s\(.*\)$s}|\1-\n\1  \2|;p" | \
   sed -ne "s|^\($s\):|\1|" \
        -e "s|^\($s\)-$s[\"']\(.*\)[\"']$s\$|\1$fs$fs\2|p" \
        -e "s|^\($s\)-$s\(.*\)$s\$|\1$fs$fs\2|p" \
        -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
        -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" | \
   awk -F$fs '{
      indent = length($1)/2;
      vname[indent] = $2;
      for (i in vname) {if (i > indent) {delete vname[i]; idx[i]=0}}
      if(length($2)== 0){  vname[indent]= ++idx[indent] };
      if (length($3) > 0) {
         vn=""; for (i=0; i<indent; i++) { vn=(vn)(vname[i])("_")}
         printf("%s%s%s=\"%s\"\n", "'$prefix'",vn, vname[indent], $3);
      }
   }'
}

/usr/share/oem/bin/vmtoolsd --cmd "info-get guestinfo.metadata" | /bin/base64 --decode > /tmp/netplan.yaml
cat /tmp/netplan.yaml
yaml_to_vars /tmp/netplan.yaml
eval $(yaml_to_vars /tmp/netplan.yaml)
/bin/cat > /etc/systemd/network/10-ipam.network << EOF
[Match]
MACAddress=$netplan_network_ethernets_id0_match_macaddress

[Network]
DHCP=no
DNS=$netplan_network_ethernets_id0_nameservers_1
DNS=$netplan_network_ethernets_id0_nameservers_2
DNS=$netplan_network_ethernets_id0_nameservers_3
Address=$netplan_network_ethernets_id0_1
Gateway=$netplan_network_ethernets_id0_gateway4
EOF

Yeah. It is ugly.

Update: as for afterburn in latest flatcar version - it is pretty much useless. It is only capable of burping out netplan config which makes no point.

Thanks a lot. It worked. I ended up using only this, as it looks a little better:

address=$(echo $encoded | base64 -d | awk -F'"' '/addresses:/{getline; gsub(/^[ \t"-]+|[ \t"-]+$/,""); print}')
gateway=$(echo $encoded | base64 -d | awk -F'"' '/gateway4:/{gsub(/^[ \t"-]+|[ \t"-]+$/,""); print $2}')
macaddr=$(echo $encoded | base64 -d | awk -F'"' '/macaddress:/{gsub(/^[ \t"-]+|[ \t"-]+$/,""); print $2}')

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 5, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 4, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue with /reopen
  • Mark this issue as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

5 participants