mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-06 05:01:19 +02:00
feat: expand platform metadata resources
* add IPv6 to the ExternalIPs resource. * platformMetadata can define Spot instances. Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev> Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
This commit is contained in:
parent
03a20da9da
commit
06fea24414
@ -54,6 +54,7 @@ message PlatformMetadataSpec {
|
|||||||
string instance_type = 5;
|
string instance_type = 5;
|
||||||
string instance_id = 6;
|
string instance_id = 6;
|
||||||
string provider_id = 7;
|
string provider_id = 7;
|
||||||
|
bool spot = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmetCondition is a failure which prevents machine from being ready at the stage.
|
// UnmetCondition is a failure which prevents machine from being ready at the stage.
|
||||||
|
@ -64,13 +64,20 @@ func (a *AWS) ParseMetadata(metadata *MetadataConfig) (*runtime.PlatformNetworkC
|
|||||||
networkConfig.Hostnames = append(networkConfig.Hostnames, hostnameSpec)
|
networkConfig.Hostnames = append(networkConfig.Hostnames, hostnameSpec)
|
||||||
}
|
}
|
||||||
|
|
||||||
if metadata.PublicIPv4 != "" {
|
publicIPs := []string{}
|
||||||
ip, err := netip.ParseAddr(metadata.PublicIPv4)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
if metadata.PublicIPv4 != "" {
|
||||||
|
publicIPs = append(publicIPs, metadata.PublicIPv4)
|
||||||
|
}
|
||||||
|
|
||||||
|
if metadata.PublicIPv6 != "" {
|
||||||
|
publicIPs = append(publicIPs, metadata.PublicIPv6)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, ipStr := range publicIPs {
|
||||||
|
if ip, err := netip.ParseAddr(ipStr); err == nil {
|
||||||
|
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
||||||
@ -81,6 +88,7 @@ func (a *AWS) ParseMetadata(metadata *MetadataConfig) (*runtime.PlatformNetworkC
|
|||||||
InstanceType: metadata.InstanceType,
|
InstanceType: metadata.InstanceType,
|
||||||
InstanceID: metadata.InstanceID,
|
InstanceID: metadata.InstanceID,
|
||||||
ProviderID: fmt.Sprintf("aws://%s/%s", metadata.Zone, metadata.InstanceID),
|
ProviderID: fmt.Sprintf("aws://%s/%s", metadata.Zone, metadata.InstanceID),
|
||||||
|
Spot: metadata.InstanceLifeCycle == "spot",
|
||||||
}
|
}
|
||||||
|
|
||||||
return networkConfig, nil
|
return networkConfig, nil
|
||||||
|
@ -14,13 +14,14 @@ import (
|
|||||||
|
|
||||||
// MetadataConfig represents a metadata AWS instance.
|
// MetadataConfig represents a metadata AWS instance.
|
||||||
type MetadataConfig struct {
|
type MetadataConfig struct {
|
||||||
Hostname string `json:"hostname,omitempty"`
|
Hostname string `json:"hostname,omitempty"`
|
||||||
InstanceID string `json:"instance-id,omitempty"`
|
InstanceID string `json:"instance-id,omitempty"`
|
||||||
InstanceType string `json:"instance-type,omitempty"`
|
InstanceType string `json:"instance-type,omitempty"`
|
||||||
PublicIPv4 string `json:"public-ipv4,omitempty"`
|
InstanceLifeCycle string `json:"instance-life-cycle,omitempty"`
|
||||||
PublicIPv6 string `json:"ipv6,omitempty"`
|
PublicIPv4 string `json:"public-ipv4,omitempty"`
|
||||||
Region string `json:"region,omitempty"`
|
PublicIPv6 string `json:"ipv6,omitempty"`
|
||||||
Zone string `json:"zone,omitempty"`
|
Region string `json:"region,omitempty"`
|
||||||
|
Zone string `json:"zone,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:gocyclo
|
//nolint:gocyclo
|
||||||
@ -53,6 +54,10 @@ func (a *AWS) getMetadata(ctx context.Context) (*MetadataConfig, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if metadata.InstanceLifeCycle, err = getMetadataKey("instance-life-cycle"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
if metadata.InstanceID, err = getMetadataKey("instance-id"); err != nil {
|
if metadata.InstanceID, err = getMetadataKey("instance-id"); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -89,18 +89,16 @@ func (a *Azure) ParseMetadata(metadata *ComputeMetadata, interfaceAddresses []Ne
|
|||||||
networkConfig.Hostnames = append(networkConfig.Hostnames, hostnameSpec)
|
networkConfig.Hostnames = append(networkConfig.Hostnames, hostnameSpec)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publicIPs := []string{}
|
||||||
|
|
||||||
// external IP
|
// external IP
|
||||||
for _, iface := range interfaceAddresses {
|
for _, iface := range interfaceAddresses {
|
||||||
for _, ipv4addr := range iface.IPv4.IPAddresses {
|
for _, ipv4addr := range iface.IPv4.IPAddresses {
|
||||||
if ip, err := netip.ParseAddr(ipv4addr.PublicIPAddress); err == nil {
|
publicIPs = append(publicIPs, ipv4addr.PublicIPAddress)
|
||||||
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ipv6addr := range iface.IPv6.IPAddresses {
|
for _, ipv6addr := range iface.IPv6.IPAddresses {
|
||||||
if ip, err := netip.ParseAddr(ipv6addr.PublicIPAddress); err == nil {
|
publicIPs = append(publicIPs, ipv6addr.PublicIPAddress)
|
||||||
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,6 +122,12 @@ func (a *Azure) ParseMetadata(metadata *ComputeMetadata, interfaceAddresses []Ne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, ipStr := range publicIPs {
|
||||||
|
if ip, err := netip.ParseAddr(ipStr); err == nil {
|
||||||
|
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
zone := metadata.FaultDomain
|
zone := metadata.FaultDomain
|
||||||
if metadata.Zone != "" {
|
if metadata.Zone != "" {
|
||||||
zone = fmt.Sprintf("%s-%s", metadata.Location, metadata.Zone)
|
zone = fmt.Sprintf("%s-%s", metadata.Location, metadata.Zone)
|
||||||
@ -137,6 +141,7 @@ func (a *Azure) ParseMetadata(metadata *ComputeMetadata, interfaceAddresses []Ne
|
|||||||
InstanceType: metadata.VMSize,
|
InstanceType: metadata.VMSize,
|
||||||
InstanceID: metadata.ResourceID,
|
InstanceID: metadata.ResourceID,
|
||||||
ProviderID: fmt.Sprintf("azure://%s", metadata.ResourceID),
|
ProviderID: fmt.Sprintf("azure://%s", metadata.ResourceID),
|
||||||
|
Spot: metadata.EvictionPolicy != "",
|
||||||
}
|
}
|
||||||
|
|
||||||
return &networkConfig, nil
|
return &networkConfig, nil
|
||||||
|
@ -47,6 +47,7 @@ type ComputeMetadata struct {
|
|||||||
ResourceID string `json:"resourceId,omitempty"`
|
ResourceID string `json:"resourceId,omitempty"`
|
||||||
VMScaleSetName string `json:"vmScaleSetName,omitempty"`
|
VMScaleSetName string `json:"vmScaleSetName,omitempty"`
|
||||||
SubscriptionID string `json:"subscriptionId,omitempty"`
|
SubscriptionID string `json:"subscriptionId,omitempty"`
|
||||||
|
EvictionPolicy string `json:"evictionPolicy,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Azure) getMetadata(ctx context.Context) (*ComputeMetadata, error) {
|
func (a *Azure) getMetadata(ctx context.Context) (*ComputeMetadata, error) {
|
||||||
|
@ -71,6 +71,8 @@ func (d *DigitalOcean) ParseMetadata(metadata *MetadataConfig) (*runtime.Platfor
|
|||||||
ConfigLayer: network.ConfigPlatform,
|
ConfigLayer: network.ConfigPlatform,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
publicIPs := []string{}
|
||||||
|
|
||||||
for _, iface := range metadata.Interfaces["public"] {
|
for _, iface := range metadata.Interfaces["public"] {
|
||||||
if iface.IPv4 != nil {
|
if iface.IPv4 != nil {
|
||||||
ifAddr, err := utils.IPPrefixFrom(iface.IPv4.IPAddress, iface.IPv4.Netmask)
|
ifAddr, err := utils.IPPrefixFrom(iface.IPv4.IPAddress, iface.IPv4.Netmask)
|
||||||
@ -78,7 +80,7 @@ func (d *DigitalOcean) ParseMetadata(metadata *MetadataConfig) (*runtime.Platfor
|
|||||||
return nil, fmt.Errorf("failed to parse ip address: %w", err)
|
return nil, fmt.Errorf("failed to parse ip address: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ifAddr.Addr())
|
publicIPs = append(publicIPs, iface.IPv4.IPAddress)
|
||||||
|
|
||||||
networkConfig.Addresses = append(networkConfig.Addresses,
|
networkConfig.Addresses = append(networkConfig.Addresses,
|
||||||
network.AddressSpecSpec{
|
network.AddressSpecSpec{
|
||||||
@ -134,6 +136,7 @@ func (d *DigitalOcean) ParseMetadata(metadata *MetadataConfig) (*runtime.Platfor
|
|||||||
return nil, fmt.Errorf("failed to parse ip address: %w", err)
|
return nil, fmt.Errorf("failed to parse ip address: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publicIPs = append(publicIPs, iface.IPv6.IPAddress)
|
||||||
networkConfig.Addresses = append(networkConfig.Addresses,
|
networkConfig.Addresses = append(networkConfig.Addresses,
|
||||||
network.AddressSpecSpec{
|
network.AddressSpecSpec{
|
||||||
ConfigLayer: network.ConfigPlatform,
|
ConfigLayer: network.ConfigPlatform,
|
||||||
@ -215,6 +218,12 @@ func (d *DigitalOcean) ParseMetadata(metadata *MetadataConfig) (*runtime.Platfor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, ipStr := range publicIPs {
|
||||||
|
if ip, err := netip.ParseAddr(ipStr); err == nil {
|
||||||
|
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
||||||
Platform: d.Name(),
|
Platform: d.Name(),
|
||||||
Hostname: metadata.Hostname,
|
Hostname: metadata.Hostname,
|
||||||
|
@ -88,6 +88,7 @@ timeServers: []
|
|||||||
operators: []
|
operators: []
|
||||||
externalIPs:
|
externalIPs:
|
||||||
- 128.199.52.32
|
- 128.199.52.32
|
||||||
|
- 2a03:b0c0:2:d0::1478:3001
|
||||||
metadata:
|
metadata:
|
||||||
platform: digital-ocean
|
platform: digital-ocean
|
||||||
hostname: debian-s-1vcpu-512mb-10gb-ams3-01
|
hostname: debian-s-1vcpu-512mb-10gb-ams3-01
|
||||||
|
@ -205,11 +205,17 @@ func (p *EquinixMetal) ParseMetadata(ctx context.Context, equinixMetadata *Metad
|
|||||||
|
|
||||||
// 2. addresses
|
// 2. addresses
|
||||||
|
|
||||||
|
publicIPs := []string{}
|
||||||
|
|
||||||
for _, addr := range equinixMetadata.Network.Addresses {
|
for _, addr := range equinixMetadata.Network.Addresses {
|
||||||
if !(addr.Enabled && addr.Management) {
|
if !(addr.Enabled && addr.Management) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if addr.Public {
|
||||||
|
publicIPs = append(publicIPs, addr.Address)
|
||||||
|
}
|
||||||
|
|
||||||
ipAddr, err := netip.ParsePrefix(fmt.Sprintf("%s/%d", addr.Address, addr.CIDR))
|
ipAddr, err := netip.ParsePrefix(fmt.Sprintf("%s/%d", addr.Address, addr.CIDR))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -232,6 +238,12 @@ func (p *EquinixMetal) ParseMetadata(ctx context.Context, equinixMetadata *Metad
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, ipStr := range publicIPs {
|
||||||
|
if ip, err := netip.ParseAddr(ipStr); err == nil {
|
||||||
|
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 3. routes
|
// 3. routes
|
||||||
|
|
||||||
for _, addr := range equinixMetadata.Network.Addresses {
|
for _, addr := range equinixMetadata.Network.Addresses {
|
||||||
|
@ -102,7 +102,9 @@ hostnames:
|
|||||||
resolvers: []
|
resolvers: []
|
||||||
timeServers: []
|
timeServers: []
|
||||||
operators: []
|
operators: []
|
||||||
externalIPs: []
|
externalIPs:
|
||||||
|
- 147.75.78.41
|
||||||
|
- 2604:1380:45d1:fd00::11
|
||||||
metadata:
|
metadata:
|
||||||
platform: equinixMetal
|
platform: equinixMetal
|
||||||
hostname: infra-green-ci
|
hostname: infra-green-ci
|
||||||
|
@ -42,12 +42,9 @@ func (e *Exoscale) ParseMetadata(metadata *MetadataConfig) (*runtime.PlatformNet
|
|||||||
}
|
}
|
||||||
|
|
||||||
if metadata.PublicIPv4 != "" {
|
if metadata.PublicIPv4 != "" {
|
||||||
ip, err := netip.ParseAddr(metadata.PublicIPv4)
|
if ip, err := netip.ParseAddr(metadata.PublicIPv4); err == nil {
|
||||||
if err != nil {
|
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"cloud.google.com/go/compute/metadata"
|
"cloud.google.com/go/compute/metadata"
|
||||||
@ -46,13 +47,10 @@ func (g *GCP) ParseMetadata(metadata *MetadataConfig) (*runtime.PlatformNetworkC
|
|||||||
networkConfig.Hostnames = append(networkConfig.Hostnames, hostnameSpec)
|
networkConfig.Hostnames = append(networkConfig.Hostnames, hostnameSpec)
|
||||||
}
|
}
|
||||||
|
|
||||||
if metadata.PublicIPv4 != "" {
|
publicIPs := []string{}
|
||||||
ip, err := netip.ParseAddr(metadata.PublicIPv4)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
if metadata.PublicIPv4 != "" {
|
||||||
|
publicIPs = append(publicIPs, metadata.PublicIPv4)
|
||||||
}
|
}
|
||||||
|
|
||||||
dns, _ := netip.ParseAddr(gcpResolverServer) //nolint:errcheck
|
dns, _ := netip.ParseAddr(gcpResolverServer) //nolint:errcheck
|
||||||
@ -73,6 +71,14 @@ func (g *GCP) ParseMetadata(metadata *MetadataConfig) (*runtime.PlatformNetworkC
|
|||||||
region = region[:idx]
|
region = region[:idx]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, ipStr := range publicIPs {
|
||||||
|
if ip, err := netip.ParseAddr(ipStr); err == nil {
|
||||||
|
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
preempted, _ := strconv.ParseBool(metadata.Preempted) //nolint:errcheck
|
||||||
|
|
||||||
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
||||||
Platform: g.Name(),
|
Platform: g.Name(),
|
||||||
Hostname: metadata.Hostname,
|
Hostname: metadata.Hostname,
|
||||||
@ -81,6 +87,7 @@ func (g *GCP) ParseMetadata(metadata *MetadataConfig) (*runtime.PlatformNetworkC
|
|||||||
InstanceType: metadata.InstanceType,
|
InstanceType: metadata.InstanceType,
|
||||||
InstanceID: metadata.InstanceID,
|
InstanceID: metadata.InstanceID,
|
||||||
ProviderID: fmt.Sprintf("gce://%s/%s/%s", metadata.ProjectID, metadata.Zone, metadata.Name),
|
ProviderID: fmt.Sprintf("gce://%s/%s/%s", metadata.ProjectID, metadata.Zone, metadata.Name),
|
||||||
|
Spot: preempted,
|
||||||
}
|
}
|
||||||
|
|
||||||
return networkConfig, nil
|
return networkConfig, nil
|
||||||
|
@ -25,6 +25,7 @@ type MetadataConfig struct {
|
|||||||
InstanceType string `json:"machine-type"`
|
InstanceType string `json:"machine-type"`
|
||||||
InstanceID string `json:"id"`
|
InstanceID string `json:"id"`
|
||||||
PublicIPv4 string `json:"external-ip"`
|
PublicIPv4 string `json:"external-ip"`
|
||||||
|
Preempted string `json:"preempted"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GCP) getMetadata(context.Context) (*MetadataConfig, error) {
|
func (g *GCP) getMetadata(context.Context) (*MetadataConfig, error) {
|
||||||
@ -66,5 +67,10 @@ func (g *GCP) getMetadata(context.Context) (*MetadataConfig, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
meta.Preempted, err = metadata.Get("instance/scheduling/preemptible")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return &meta, nil
|
return &meta, nil
|
||||||
}
|
}
|
||||||
|
@ -4,5 +4,6 @@
|
|||||||
"id": "0",
|
"id": "0",
|
||||||
"zone": "us-central1-a",
|
"zone": "us-central1-a",
|
||||||
"name": "my-server",
|
"name": "my-server",
|
||||||
"machine-type": "n1-standard-1"
|
"machine-type": "n1-standard-1",
|
||||||
}
|
"preempted": "FALSE"
|
||||||
|
}
|
@ -10,6 +10,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/cosi-project/runtime/pkg/state"
|
"github.com/cosi-project/runtime/pkg/state"
|
||||||
"github.com/siderolabs/go-procfs/procfs"
|
"github.com/siderolabs/go-procfs/procfs"
|
||||||
@ -49,10 +50,10 @@ func (h *Hcloud) ParseMetadata(unmarshalledNetworkConfig *NetworkConfig, metadat
|
|||||||
networkConfig.Hostnames = append(networkConfig.Hostnames, hostnameSpec)
|
networkConfig.Hostnames = append(networkConfig.Hostnames, hostnameSpec)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publicIPs := []string{}
|
||||||
|
|
||||||
if metadata.PublicIPv4 != "" {
|
if metadata.PublicIPv4 != "" {
|
||||||
if ip, err := netip.ParseAddr(metadata.PublicIPv4); err == nil {
|
publicIPs = append(publicIPs, metadata.PublicIPv4)
|
||||||
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ntwrk := range unmarshalledNetworkConfig.Config {
|
for _, ntwrk := range unmarshalledNetworkConfig.Config {
|
||||||
@ -85,7 +86,9 @@ func (h *Hcloud) ParseMetadata(unmarshalledNetworkConfig *NetworkConfig, metadat
|
|||||||
}
|
}
|
||||||
|
|
||||||
family := nethelpers.FamilyInet4
|
family := nethelpers.FamilyInet4
|
||||||
|
|
||||||
if ipAddr.Addr().Is6() {
|
if ipAddr.Addr().Is6() {
|
||||||
|
publicIPs = append(publicIPs, strings.SplitN(subnet.Address, "/", 2)[0])
|
||||||
family = nethelpers.FamilyInet6
|
family = nethelpers.FamilyInet6
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,6 +127,12 @@ func (h *Hcloud) ParseMetadata(unmarshalledNetworkConfig *NetworkConfig, metadat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, ipStr := range publicIPs {
|
||||||
|
if ip, err := netip.ParseAddr(ipStr); err == nil {
|
||||||
|
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
||||||
Platform: h.Name(),
|
Platform: h.Name(),
|
||||||
Hostname: metadata.Hostname,
|
Hostname: metadata.Hostname,
|
||||||
|
@ -40,6 +40,7 @@ operators:
|
|||||||
layer: platform
|
layer: platform
|
||||||
externalIPs:
|
externalIPs:
|
||||||
- 1.2.3.4
|
- 1.2.3.4
|
||||||
|
- 2a01:4f8:1:2::1
|
||||||
metadata:
|
metadata:
|
||||||
platform: hcloud
|
platform: hcloud
|
||||||
hostname: talos.fqdn
|
hostname: talos.fqdn
|
||||||
|
@ -92,8 +92,12 @@ type Bonds struct {
|
|||||||
|
|
||||||
// MetadataConfig holds meta info.
|
// MetadataConfig holds meta info.
|
||||||
type MetadataConfig struct {
|
type MetadataConfig struct {
|
||||||
Hostname string `yaml:"hostname,omitempty"`
|
Hostname string `yaml:"hostname,omitempty"`
|
||||||
InstanceID string `yaml:"instance-id,omitempty"`
|
InstanceID string `yaml:"instance-id,omitempty"`
|
||||||
|
InstanceType string `yaml:"instance-type,omitempty"`
|
||||||
|
ProviderID string `yaml:"provider-id,omitempty"`
|
||||||
|
Region string `yaml:"region,omitempty"`
|
||||||
|
Zone string `yaml:"zone,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Nocloud) configFromNetwork(ctx context.Context, metaBaseURL string) (metaConfig []byte, networkConfig []byte, machineConfig []byte, err error) {
|
func (n *Nocloud) configFromNetwork(ctx context.Context, metaBaseURL string) (metaConfig []byte, networkConfig []byte, machineConfig []byte, err error) {
|
||||||
|
@ -58,9 +58,13 @@ func (n *Nocloud) ParseMetadata(unmarshalledNetworkConfig *NetworkConfig, metada
|
|||||||
}
|
}
|
||||||
|
|
||||||
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
||||||
Platform: n.Name(),
|
Platform: n.Name(),
|
||||||
Hostname: metadata.Hostname,
|
Hostname: metadata.Hostname,
|
||||||
InstanceID: metadata.InstanceID,
|
InstanceID: metadata.InstanceID,
|
||||||
|
InstanceType: metadata.InstanceType,
|
||||||
|
ProviderID: metadata.ProviderID,
|
||||||
|
Region: metadata.Region,
|
||||||
|
Zone: metadata.Zone,
|
||||||
}
|
}
|
||||||
|
|
||||||
return networkConfig, nil
|
return networkConfig, nil
|
||||||
|
@ -34,6 +34,8 @@ func (s *Scaleway) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ParseMetadata converts Scaleway platform metadata into platform network config.
|
// ParseMetadata converts Scaleway platform metadata into platform network config.
|
||||||
|
//
|
||||||
|
//nolint:gocyclo
|
||||||
func (s *Scaleway) ParseMetadata(metadata *instance.Metadata) (*runtime.PlatformNetworkConfig, error) {
|
func (s *Scaleway) ParseMetadata(metadata *instance.Metadata) (*runtime.PlatformNetworkConfig, error) {
|
||||||
networkConfig := &runtime.PlatformNetworkConfig{}
|
networkConfig := &runtime.PlatformNetworkConfig{}
|
||||||
|
|
||||||
@ -49,13 +51,10 @@ func (s *Scaleway) ParseMetadata(metadata *instance.Metadata) (*runtime.Platform
|
|||||||
networkConfig.Hostnames = append(networkConfig.Hostnames, hostnameSpec)
|
networkConfig.Hostnames = append(networkConfig.Hostnames, hostnameSpec)
|
||||||
}
|
}
|
||||||
|
|
||||||
if metadata.PublicIP.Address != "" {
|
publicIPs := []string{}
|
||||||
ip, err := netip.ParseAddr(metadata.PublicIP.Address)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
if metadata.PublicIP.Address != "" {
|
||||||
|
publicIPs = append(publicIPs, metadata.PublicIP.Address)
|
||||||
}
|
}
|
||||||
|
|
||||||
networkConfig.Links = append(networkConfig.Links, network.LinkSpecSpec{
|
networkConfig.Links = append(networkConfig.Links, network.LinkSpecSpec{
|
||||||
@ -102,6 +101,7 @@ func (s *Scaleway) ParseMetadata(metadata *instance.Metadata) (*runtime.Platform
|
|||||||
|
|
||||||
addr := netip.PrefixFrom(ip, bits)
|
addr := netip.PrefixFrom(ip, bits)
|
||||||
|
|
||||||
|
publicIPs = append(publicIPs, metadata.IPv6.Address)
|
||||||
networkConfig.Addresses = append(networkConfig.Addresses,
|
networkConfig.Addresses = append(networkConfig.Addresses,
|
||||||
network.AddressSpecSpec{
|
network.AddressSpecSpec{
|
||||||
ConfigLayer: network.ConfigPlatform,
|
ConfigLayer: network.ConfigPlatform,
|
||||||
@ -139,6 +139,12 @@ func (s *Scaleway) ParseMetadata(metadata *instance.Metadata) (*runtime.Platform
|
|||||||
zoneParts = zoneParts[:2]
|
zoneParts = zoneParts[:2]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, ipStr := range publicIPs {
|
||||||
|
if ip, err := netip.ParseAddr(ipStr); err == nil {
|
||||||
|
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
||||||
Platform: s.Name(),
|
Platform: s.Name(),
|
||||||
Hostname: metadata.Hostname,
|
Hostname: metadata.Hostname,
|
||||||
|
@ -53,9 +53,12 @@ operators:
|
|||||||
layer: platform
|
layer: platform
|
||||||
externalIPs:
|
externalIPs:
|
||||||
- 11.22.222.222
|
- 11.22.222.222
|
||||||
|
- 2001:111:222:3333::1
|
||||||
metadata:
|
metadata:
|
||||||
platform: scaleway
|
platform: scaleway
|
||||||
hostname: scw-talos
|
hostname: scw-talos
|
||||||
|
region: zone-name
|
||||||
|
zone: zone-name-1
|
||||||
instanceType: DEV1-S
|
instanceType: DEV1-S
|
||||||
instanceId: 11111111-1111-1111-1111-111111111111
|
instanceId: 11111111-1111-1111-1111-111111111111
|
||||||
providerId: scaleway://instance//11111111-1111-1111-1111-111111111111
|
providerId: scaleway://instance/zone-name-1/11111111-1111-1111-1111-111111111111
|
||||||
|
@ -15,5 +15,8 @@
|
|||||||
"address": "2001:111:222:3333::1",
|
"address": "2001:111:222:3333::1",
|
||||||
"gateway": "2001:111:222:3333::",
|
"gateway": "2001:111:222:3333::",
|
||||||
"netmask": "64"
|
"netmask": "64"
|
||||||
|
},
|
||||||
|
"location": {
|
||||||
|
"zone_id": "zone-name-1"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -73,6 +73,7 @@ operators:
|
|||||||
layer: platform
|
layer: platform
|
||||||
externalIPs:
|
externalIPs:
|
||||||
- 185.70.197.2
|
- 185.70.197.2
|
||||||
|
- 2a04:3544:8000:1000:0:1111:2222:3333
|
||||||
metadata:
|
metadata:
|
||||||
platform: upcloud
|
platform: upcloud
|
||||||
hostname: talos
|
hostname: talos
|
||||||
|
@ -48,7 +48,10 @@ func (u *UpCloud) ParseMetadata(metadata *MetadataConfig) (*runtime.PlatformNetw
|
|||||||
networkConfig.Hostnames = append(networkConfig.Hostnames, hostnameSpec)
|
networkConfig.Hostnames = append(networkConfig.Hostnames, hostnameSpec)
|
||||||
}
|
}
|
||||||
|
|
||||||
var dnsIPs []netip.Addr
|
var (
|
||||||
|
publicIPs []string
|
||||||
|
dnsIPs []netip.Addr
|
||||||
|
)
|
||||||
|
|
||||||
firstIP := true
|
firstIP := true
|
||||||
|
|
||||||
@ -67,12 +70,7 @@ func (u *UpCloud) ParseMetadata(metadata *MetadataConfig) (*runtime.PlatformNetw
|
|||||||
|
|
||||||
for _, ip := range addr.IPAddresses {
|
for _, ip := range addr.IPAddresses {
|
||||||
if firstIP {
|
if firstIP {
|
||||||
ipAddr, err := netip.ParseAddr(ip.Address)
|
publicIPs = append(publicIPs, ip.Address)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ipAddr)
|
|
||||||
|
|
||||||
firstIP = false
|
firstIP = false
|
||||||
}
|
}
|
||||||
@ -109,7 +107,9 @@ func (u *UpCloud) ParseMetadata(metadata *MetadataConfig) (*runtime.PlatformNetw
|
|||||||
ipPrefix := netip.PrefixFrom(addr, ntwrk.Bits())
|
ipPrefix := netip.PrefixFrom(addr, ntwrk.Bits())
|
||||||
|
|
||||||
family := nethelpers.FamilyInet4
|
family := nethelpers.FamilyInet4
|
||||||
|
|
||||||
if addr.Is6() {
|
if addr.Is6() {
|
||||||
|
publicIPs = append(publicIPs, ip.Address)
|
||||||
family = nethelpers.FamilyInet6
|
family = nethelpers.FamilyInet6
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,6 +157,12 @@ func (u *UpCloud) ParseMetadata(metadata *MetadataConfig) (*runtime.PlatformNetw
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, ipStr := range publicIPs {
|
||||||
|
if ip, err := netip.ParseAddr(ipStr); err == nil {
|
||||||
|
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
networkConfig.Metadata = &runtimeres.PlatformMetadataSpec{
|
||||||
Platform: u.Name(),
|
Platform: u.Name(),
|
||||||
Hostname: metadata.Hostname,
|
Hostname: metadata.Hostname,
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
addresses:
|
addresses:
|
||||||
|
- address: 95.111.222.111/23
|
||||||
|
linkName: eth0
|
||||||
|
family: inet4
|
||||||
|
scope: global
|
||||||
|
flags: permanent
|
||||||
|
layer: platform
|
||||||
- address: 10.7.96.3/20
|
- address: 10.7.96.3/20
|
||||||
linkName: eth1
|
linkName: eth1
|
||||||
family: inet4
|
family: inet4
|
||||||
@ -20,22 +26,28 @@ links:
|
|||||||
kind: ""
|
kind: ""
|
||||||
type: netrom
|
type: netrom
|
||||||
layer: platform
|
layer: platform
|
||||||
routes: []
|
routes:
|
||||||
|
- family: inet4
|
||||||
|
dst: ""
|
||||||
|
src: ""
|
||||||
|
gateway: 95.111.222.1
|
||||||
|
outLinkName: eth0
|
||||||
|
table: main
|
||||||
|
scope: global
|
||||||
|
type: unicast
|
||||||
|
flags: ""
|
||||||
|
protocol: static
|
||||||
|
layer: platform
|
||||||
hostnames:
|
hostnames:
|
||||||
- hostname: talos
|
- hostname: talos
|
||||||
domainname: ""
|
domainname: ""
|
||||||
layer: platform
|
layer: platform
|
||||||
resolvers: []
|
resolvers: []
|
||||||
timeServers: []
|
timeServers: []
|
||||||
operators:
|
operators: []
|
||||||
- operator: dhcp4
|
|
||||||
linkName: eth0
|
|
||||||
requireUp: true
|
|
||||||
dhcp4:
|
|
||||||
routeMetric: 1024
|
|
||||||
layer: platform
|
|
||||||
externalIPs:
|
externalIPs:
|
||||||
- 1.2.3.4
|
- 95.111.222.111
|
||||||
|
- 2001:19f0:5001:2095:1111:2222:3333:4444
|
||||||
metadata:
|
metadata:
|
||||||
platform: vultr
|
platform: vultr
|
||||||
hostname: talos
|
hostname: talos
|
||||||
|
@ -7,7 +7,6 @@ package vultr
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
stderrors "errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
@ -36,13 +35,9 @@ func (v *Vultr) Name() string {
|
|||||||
// ParseMetadata converts Vultr platform metadata into platform network config.
|
// ParseMetadata converts Vultr platform metadata into platform network config.
|
||||||
//
|
//
|
||||||
//nolint:gocyclo
|
//nolint:gocyclo
|
||||||
func (v *Vultr) ParseMetadata(extIP []byte, metadata *metadata.MetaData) (*runtime.PlatformNetworkConfig, error) {
|
func (v *Vultr) ParseMetadata(metadata *metadata.MetaData) (*runtime.PlatformNetworkConfig, error) {
|
||||||
networkConfig := &runtime.PlatformNetworkConfig{}
|
networkConfig := &runtime.PlatformNetworkConfig{}
|
||||||
|
|
||||||
if ip, err := netip.ParseAddr(string(extIP)); err == nil {
|
|
||||||
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
|
||||||
}
|
|
||||||
|
|
||||||
if metadata.Hostname != "" {
|
if metadata.Hostname != "" {
|
||||||
hostnameSpec := network.HostnameSpecSpec{
|
hostnameSpec := network.HostnameSpecSpec{
|
||||||
ConfigLayer: network.ConfigPlatform,
|
ConfigLayer: network.ConfigPlatform,
|
||||||
@ -55,6 +50,8 @@ func (v *Vultr) ParseMetadata(extIP []byte, metadata *metadata.MetaData) (*runti
|
|||||||
networkConfig.Hostnames = append(networkConfig.Hostnames, hostnameSpec)
|
networkConfig.Hostnames = append(networkConfig.Hostnames, hostnameSpec)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publicIPs := []string{}
|
||||||
|
|
||||||
for i, addr := range metadata.Interfaces {
|
for i, addr := range metadata.Interfaces {
|
||||||
iface := fmt.Sprintf("eth%d", i)
|
iface := fmt.Sprintf("eth%d", i)
|
||||||
|
|
||||||
@ -71,42 +68,77 @@ func (v *Vultr) ParseMetadata(extIP []byte, metadata *metadata.MetaData) (*runti
|
|||||||
networkConfig.Links = append(networkConfig.Links, link)
|
networkConfig.Links = append(networkConfig.Links, link)
|
||||||
|
|
||||||
if addr.IPv4.Address != "" {
|
if addr.IPv4.Address != "" {
|
||||||
if addr.NetworkType != "private" {
|
if addr.NetworkType == "public" {
|
||||||
networkConfig.Operators = append(networkConfig.Operators, network.OperatorSpecSpec{
|
publicIPs = append(publicIPs, addr.IPv4.Address)
|
||||||
Operator: network.OperatorDHCP4,
|
|
||||||
LinkName: iface,
|
|
||||||
RequireUp: true,
|
|
||||||
DHCP4: network.DHCP4OperatorSpec{
|
|
||||||
RouteMetric: 1024,
|
|
||||||
},
|
|
||||||
ConfigLayer: network.ConfigPlatform,
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
ip, err := netip.ParseAddr(addr.IPv4.Address)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
netmask, err := netip.ParseAddr(addr.IPv4.Netmask)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
mask, _ := netmask.MarshalBinary() //nolint:errcheck // never fails
|
|
||||||
ones, _ := net.IPMask(mask).Size()
|
|
||||||
ipAddr := netip.PrefixFrom(ip, ones)
|
|
||||||
|
|
||||||
networkConfig.Addresses = append(networkConfig.Addresses,
|
|
||||||
network.AddressSpecSpec{
|
|
||||||
ConfigLayer: network.ConfigPlatform,
|
|
||||||
LinkName: iface,
|
|
||||||
Address: ipAddr,
|
|
||||||
Scope: nethelpers.ScopeGlobal,
|
|
||||||
Flags: nethelpers.AddressFlags(nethelpers.AddressPermanent),
|
|
||||||
Family: nethelpers.FamilyInet4,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ip, err := netip.ParseAddr(addr.IPv4.Address)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
netmask, err := netip.ParseAddr(addr.IPv4.Netmask)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
mask, _ := netmask.MarshalBinary() //nolint:errcheck // never fails
|
||||||
|
ones, _ := net.IPMask(mask).Size()
|
||||||
|
ipAddr := netip.PrefixFrom(ip, ones)
|
||||||
|
|
||||||
|
networkConfig.Addresses = append(networkConfig.Addresses,
|
||||||
|
network.AddressSpecSpec{
|
||||||
|
ConfigLayer: network.ConfigPlatform,
|
||||||
|
LinkName: iface,
|
||||||
|
Address: ipAddr,
|
||||||
|
Scope: nethelpers.ScopeGlobal,
|
||||||
|
Flags: nethelpers.AddressFlags(nethelpers.AddressPermanent),
|
||||||
|
Family: nethelpers.FamilyInet4,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
if addr.IPv4.Gateway != "" {
|
||||||
|
gw, err := netip.ParseAddr(addr.IPv4.Gateway)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
route := network.RouteSpecSpec{
|
||||||
|
ConfigLayer: network.ConfigPlatform,
|
||||||
|
Gateway: gw,
|
||||||
|
OutLinkName: iface,
|
||||||
|
Table: nethelpers.TableMain,
|
||||||
|
Protocol: nethelpers.ProtocolStatic,
|
||||||
|
Type: nethelpers.TypeUnicast,
|
||||||
|
Family: nethelpers.FamilyInet4,
|
||||||
|
}
|
||||||
|
|
||||||
|
route.Normalize()
|
||||||
|
|
||||||
|
networkConfig.Routes = append(networkConfig.Routes, route)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
networkConfig.Operators = append(networkConfig.Operators, network.OperatorSpecSpec{
|
||||||
|
Operator: network.OperatorDHCP4,
|
||||||
|
LinkName: iface,
|
||||||
|
RequireUp: true,
|
||||||
|
DHCP4: network.DHCP4OperatorSpec{
|
||||||
|
RouteMetric: 1024,
|
||||||
|
},
|
||||||
|
ConfigLayer: network.ConfigPlatform,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if addr.IPv6.Address != "" {
|
||||||
|
if addr.NetworkType == "public" {
|
||||||
|
publicIPs = append(publicIPs, addr.IPv6.Address)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, ipStr := range publicIPs {
|
||||||
|
if ip, err := netip.ParseAddr(ipStr); err == nil {
|
||||||
|
networkConfig.ExternalIPs = append(networkConfig.ExternalIPs, ip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,14 +183,7 @@ func (v *Vultr) NetworkConfiguration(ctx context.Context, _ state.State, ch chan
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
extIP, err := download.Download(ctx, VultrExternalIPEndpoint,
|
networkConfig, err := v.ParseMetadata(metadata)
|
||||||
download.WithErrorOnNotFound(errors.ErrNoExternalIPs),
|
|
||||||
download.WithErrorOnEmptyResponse(errors.ErrNoExternalIPs))
|
|
||||||
if err != nil && !stderrors.Is(err, errors.ErrNoExternalIPs) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
networkConfig, err := v.ParseMetadata(extIP, metadata)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ func TestParseMetadata(t *testing.T) {
|
|||||||
|
|
||||||
require.NoError(t, json.Unmarshal(rawMetadata, &metadata))
|
require.NoError(t, json.Unmarshal(rawMetadata, &metadata))
|
||||||
|
|
||||||
networkConfig, err := p.ParseMetadata([]byte("1.2.3.4"), &metadata)
|
networkConfig, err := p.ParseMetadata(&metadata)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
marshaled, err := yaml.Marshal(networkConfig)
|
marshaled, err := yaml.Marshal(networkConfig)
|
||||||
|
@ -396,6 +396,7 @@ type PlatformMetadataSpec struct {
|
|||||||
InstanceType string `protobuf:"bytes,5,opt,name=instance_type,json=instanceType,proto3" json:"instance_type,omitempty"`
|
InstanceType string `protobuf:"bytes,5,opt,name=instance_type,json=instanceType,proto3" json:"instance_type,omitempty"`
|
||||||
InstanceId string `protobuf:"bytes,6,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"`
|
InstanceId string `protobuf:"bytes,6,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"`
|
||||||
ProviderId string `protobuf:"bytes,7,opt,name=provider_id,json=providerId,proto3" json:"provider_id,omitempty"`
|
ProviderId string `protobuf:"bytes,7,opt,name=provider_id,json=providerId,proto3" json:"provider_id,omitempty"`
|
||||||
|
Spot bool `protobuf:"varint,8,opt,name=spot,proto3" json:"spot,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PlatformMetadataSpec) Reset() {
|
func (x *PlatformMetadataSpec) Reset() {
|
||||||
@ -479,6 +480,13 @@ func (x *PlatformMetadataSpec) GetProviderId() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *PlatformMetadataSpec) GetSpot() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.Spot
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// UnmetCondition is a failure which prevents machine from being ready at the stage.
|
// UnmetCondition is a failure which prevents machine from being ready at the stage.
|
||||||
type UnmetCondition struct {
|
type UnmetCondition struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
@ -590,7 +598,7 @@ var file_resource_definitions_runtime_runtime_proto_rawDesc = []byte{
|
|||||||
0x6c, 0x65, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20,
|
0x6c, 0x65, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20,
|
||||||
0x01, 0x28, 0x09, 0x52, 0x0e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x54,
|
0x01, 0x28, 0x09, 0x52, 0x0e, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x54,
|
||||||
0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04,
|
0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04,
|
||||||
0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0xe1, 0x01,
|
0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0xf5, 0x01,
|
||||||
0x0a, 0x14, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61,
|
0x0a, 0x14, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61,
|
||||||
0x74, 0x61, 0x53, 0x70, 0x65, 0x63, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f,
|
0x74, 0x61, 0x53, 0x70, 0x65, 0x63, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f,
|
||||||
0x72, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f,
|
0x72, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f,
|
||||||
@ -605,16 +613,17 @@ var file_resource_definitions_runtime_runtime_proto_rawDesc = []byte{
|
|||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64,
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64,
|
||||||
0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18,
|
0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18,
|
||||||
0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x49,
|
0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x49,
|
||||||
0x64, 0x22, 0x3c, 0x0a, 0x0e, 0x55, 0x6e, 0x6d, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74,
|
0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x70, 0x6f, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52,
|
||||||
0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x04, 0x73, 0x70, 0x6f, 0x74, 0x22, 0x3c, 0x0a, 0x0e, 0x55, 0x6e, 0x6d, 0x65, 0x74, 0x43, 0x6f,
|
||||||
0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f,
|
0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,
|
||||||
0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x42,
|
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72,
|
||||||
0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x69,
|
0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61,
|
||||||
0x64, 0x65, 0x72, 0x6f, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x74, 0x61, 0x6c, 0x6f, 0x73, 0x2f, 0x70,
|
0x73, 0x6f, 0x6e, 0x42, 0x4c, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
|
||||||
0x6b, 0x67, 0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x72, 0x79, 0x2f, 0x61, 0x70, 0x69,
|
0x6d, 0x2f, 0x73, 0x69, 0x64, 0x65, 0x72, 0x6f, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x74, 0x61, 0x6c,
|
||||||
0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2f, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x69,
|
0x6f, 0x73, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x72, 0x79,
|
||||||
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x62, 0x06, 0x70,
|
0x2f, 0x61, 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2f, 0x64, 0x65,
|
||||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x66, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d,
|
||||||
|
0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -373,6 +373,16 @@ func (m *PlatformMetadataSpec) MarshalToSizedBufferVT(dAtA []byte) (int, error)
|
|||||||
i -= len(m.unknownFields)
|
i -= len(m.unknownFields)
|
||||||
copy(dAtA[i:], m.unknownFields)
|
copy(dAtA[i:], m.unknownFields)
|
||||||
}
|
}
|
||||||
|
if m.Spot {
|
||||||
|
i--
|
||||||
|
if m.Spot {
|
||||||
|
dAtA[i] = 1
|
||||||
|
} else {
|
||||||
|
dAtA[i] = 0
|
||||||
|
}
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x40
|
||||||
|
}
|
||||||
if len(m.ProviderId) > 0 {
|
if len(m.ProviderId) > 0 {
|
||||||
i -= len(m.ProviderId)
|
i -= len(m.ProviderId)
|
||||||
copy(dAtA[i:], m.ProviderId)
|
copy(dAtA[i:], m.ProviderId)
|
||||||
@ -651,6 +661,9 @@ func (m *PlatformMetadataSpec) SizeVT() (n int) {
|
|||||||
if l > 0 {
|
if l > 0 {
|
||||||
n += 1 + l + sov(uint64(l))
|
n += 1 + l + sov(uint64(l))
|
||||||
}
|
}
|
||||||
|
if m.Spot {
|
||||||
|
n += 2
|
||||||
|
}
|
||||||
if m.unknownFields != nil {
|
if m.unknownFields != nil {
|
||||||
n += len(m.unknownFields)
|
n += len(m.unknownFields)
|
||||||
}
|
}
|
||||||
@ -1679,6 +1692,26 @@ func (m *PlatformMetadataSpec) UnmarshalVT(dAtA []byte) error {
|
|||||||
}
|
}
|
||||||
m.ProviderId = string(dAtA[iNdEx:postIndex])
|
m.ProviderId = string(dAtA[iNdEx:postIndex])
|
||||||
iNdEx = postIndex
|
iNdEx = postIndex
|
||||||
|
case 8:
|
||||||
|
if wireType != 0 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Spot", wireType)
|
||||||
|
}
|
||||||
|
var v int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflow
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
v |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m.Spot = bool(v != 0)
|
||||||
default:
|
default:
|
||||||
iNdEx = preIndex
|
iNdEx = preIndex
|
||||||
skippy, err := skip(dAtA[iNdEx:])
|
skippy, err := skip(dAtA[iNdEx:])
|
||||||
|
@ -33,6 +33,7 @@ type PlatformMetadataSpec struct {
|
|||||||
InstanceType string `yaml:"instanceType,omitempty" protobuf:"5"`
|
InstanceType string `yaml:"instanceType,omitempty" protobuf:"5"`
|
||||||
InstanceID string `yaml:"instanceId,omitempty" protobuf:"6"`
|
InstanceID string `yaml:"instanceId,omitempty" protobuf:"6"`
|
||||||
ProviderID string `yaml:"providerId,omitempty" protobuf:"7"`
|
ProviderID string `yaml:"providerId,omitempty" protobuf:"7"`
|
||||||
|
Spot bool `yaml:"spot,omitempty" protobuf:"8"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPlatformMetadataSpec initializes a MetadataSpec resource.
|
// NewPlatformMetadataSpec initializes a MetadataSpec resource.
|
||||||
@ -51,7 +52,24 @@ func (PlatformMetadataRD) ResourceDefinition(resource.Metadata, PlatformMetadata
|
|||||||
return meta.ResourceDefinitionSpec{
|
return meta.ResourceDefinitionSpec{
|
||||||
Type: PlatformMetadataType,
|
Type: PlatformMetadataType,
|
||||||
DefaultNamespace: NamespaceName,
|
DefaultNamespace: NamespaceName,
|
||||||
PrintColumns: []meta.PrintColumn{},
|
PrintColumns: []meta.PrintColumn{
|
||||||
|
{
|
||||||
|
Name: "Platform",
|
||||||
|
JSONPath: `{.platform}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "Type",
|
||||||
|
JSONPath: `{.instanceType}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "Region",
|
||||||
|
JSONPath: `{.region}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "Zone",
|
||||||
|
JSONPath: `{.zone}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3149,6 +3149,7 @@ PlatformMetadataSpec describes platform metadata properties.
|
|||||||
| instance_type | [string](#string) | | |
|
| instance_type | [string](#string) | | |
|
||||||
| instance_id | [string](#string) | | |
|
| instance_id | [string](#string) | | |
|
||||||
| provider_id | [string](#string) | | |
|
| provider_id | [string](#string) | | |
|
||||||
|
| spot | [bool](#bool) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user