diff --git a/api/v1beta1/gcpmachine_types.go b/api/v1beta1/gcpmachine_types.go index acff1ab33..2e01433d1 100644 --- a/api/v1beta1/gcpmachine_types.go +++ b/api/v1beta1/gcpmachine_types.go @@ -360,6 +360,10 @@ type GCPMachineSpec struct { // RootDiskEncryptionKey defines the KMS key to be used to encrypt the root disk. // +optional RootDiskEncryptionKey *CustomerEncryptionKey `json:"rootDiskEncryptionKey,omitempty"` + + // IPAddress is the internal ip address to assign to the machine + // +optional + IPAddress *string `json:"ipAddress,omitempty"` } // MetadataItem defines a single piece of metadata associated with an instance. diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index f4d0d0234..29864eb91 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -509,6 +509,11 @@ func (in *GCPMachineSpec) DeepCopyInto(out *GCPMachineSpec) { *out = new(CustomerEncryptionKey) (*in).DeepCopyInto(*out) } + if in.IPAddress != nil { + in, out := &in.IPAddress, &out.IPAddress + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GCPMachineSpec. diff --git a/cloud/scope/machine.go b/cloud/scope/machine.go index dba2be183..3f14d58bc 100644 --- a/cloud/scope/machine.go +++ b/cloud/scope/machine.go @@ -340,6 +340,9 @@ func (m *MachineScope) InstanceNetworkInterfaceSpec() *compute.NetworkInterface networkInterface.Subnetwork = path.Join("projects", m.ClusterGetter.NetworkProject(), "regions", m.ClusterGetter.Region(), "subnetworks", *m.GCPMachine.Spec.Subnet) } + if m.GCPMachine.Spec.IPAddress != nil { + networkInterface.NetworkIP = *m.GCPMachine.Spec.IPAddress + } return networkInterface } diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachines.yaml index eaecd1067..04abebde6 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachines.yaml @@ -221,6 +221,10 @@ spec: description: 'InstanceType is the type of instance to create. Example: n1.standard-2' type: string + ipAddress: + description: IPAddress is the internal ip address to assign to the + machine + type: string ipForwarding: default: Enabled description: |- diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachinetemplates.yaml index 1f5d0c7ec..d2d057445 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachinetemplates.yaml @@ -236,6 +236,10 @@ spec: description: 'InstanceType is the type of instance to create. Example: n1.standard-2' type: string + ipAddress: + description: IPAddress is the internal ip address to assign + to the machine + type: string ipForwarding: default: Enabled description: |-