for _, ip := range hw.Spec.Metadata.Instance.Ips {
// Public IPv4
if ip.Family == 4 && ip.Public && i.Metadata.PublicIPv4 == "" {
i.Metadata.PublicIPv4 = hw.Spec.Metadata.Instance.Ips[0].Address
}
// Private IPv4
if ip.Family == 4 && !ip.Public && i.Metadata.LocalIPv4 == "" {
i.Metadata.LocalIPv4 = hw.Spec.Metadata.Instance.Ips[0].Address
}
// Public IPv6
if ip.Family == 6 && i.Metadata.PublicIPv6 == "" {
i.Metadata.PublicIPv6 = hw.Spec.Metadata.Instance.Ips[0].Address
}
}
Possible fix
for _, ip := range hw.Spec.Metadata.Instance.Ips {
// Public IPv4
if ip.Family == 4 && ip.Public && i.Metadata.PublicIPv4 == "" {
i.Metadata.PublicIPv4 = ip.Address
}
// Private IPv4
if ip.Family == 4 && !ip.Public && i.Metadata.LocalIPv4 == "" {
i.Metadata.LocalIPv4 = ip.Address
}
// Public IPv6
if ip.Family == 6 && i.Metadata.PublicIPv6 == "" {
i.Metadata.PublicIPv6 = ip.Address
}
}
Steps to Reproduce (for bugs)
It's simple as described in the summary.
Context
Your Environment
Operating System and version (e.g. Linux, Windows, MacOS):
Linux
How are you running Tinkerbell? Using Vagrant & VirtualBox, Vagrant & Libvirt, on Packet using Terraform, or give details:
I run Tinkerbell on bare metal servers to work with CAPT.
Link to your project or a code example to reproduce issue:
In my tinkerbell stack k8s cluster for CAPT, I had a
Hardware
resource which includes the follow fields:When the hegel was called with
local-ipv4
andpublic-ipv4
, it always returns the local one10.52.107.72
.curl -v http://10.52.107.71:50061/2009-04-04/meta-data/local-ipv4
curl -v http://10.52.107.71:50061/2009-04-04/meta-data/public-ipv4
Expected Behaviour
curl -v http://10.52.107.71:50061/2009-04-04/meta-data/local-ipv4
, it should return10.52.107.72
curl -v http://10.52.107.71:50061/2009-04-04/meta-data/public-ipv4
, it should return69.19.7.42
.Current Behaviour
curl -v http://10.52.107.71:50061/2009-04-04/meta-data/local-ipv4
, it returns10.52.107.72
.curl -v http://10.52.107.71:50061/2009-04-04/meta-data/public-ipv4
, it returns10.52.107.72
.Possible Solution
In the
backend.go
file, it should take values from theip
iteratively in the loop.Current code https://github.com/tinkerbell/hegel/blob/main/internal/backend/kubernetes/backend.go#L185-L200
Possible fix
Steps to Reproduce (for bugs)
It's simple as described in the summary.
Context
Your Environment
Operating System and version (e.g. Linux, Windows, MacOS): Linux
How are you running Tinkerbell? Using Vagrant & VirtualBox, Vagrant & Libvirt, on Packet using Terraform, or give details: I run Tinkerbell on bare metal servers to work with CAPT.
Link to your project or a code example to reproduce issue: