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

GCP VM's Public IP attachment is now optional #340

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion kubernetes/machine_classes/gcp-machine-class.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ spec:
- key: my-key
value: my-value
networkInterfaces:
- network: network-name # Network name to attach the instance to
- disableExternalIP: false # If external IP is not required for the NIC, set this to true
network: network-name # Network name to attach the instance to
subnetwork: sub-net-name # Subnet name to attach the instance to
scheduling:
automaticRestart: true # Automatic restart of instance
Expand Down
5 changes: 3 additions & 2 deletions pkg/apis/machine/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1029,8 +1029,9 @@ type GCPMetadata struct {

// GCPNetworkInterface describes network interfaces for GCP
type GCPNetworkInterface struct {
Network string
Subnetwork string
DisableExternalIP bool
Network string
Subnetwork string
}

// GCPScheduling describes scheduling configuration for GCP.
Expand Down
5 changes: 3 additions & 2 deletions pkg/apis/machine/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1121,8 +1121,9 @@ type GCPMetadata struct {

// GCPNetworkInterface describes network interfaces for GCP
type GCPNetworkInterface struct {
Network string `json:"network,omitempty"`
Subnetwork string `json:"subnetwork,omitempty"`
DisableExternalIP bool `json:"disableExternalIP,omitempty"`
Network string `json:"network,omitempty"`
Subnetwork string `json:"subnetwork,omitempty"`
}

// GCPScheduling describes scheduling configuration for GCP.
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/machine/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions pkg/driver/driver_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,11 @@ func (d *GCPDriver) Create() (string, string, error) {

var networkInterfaces = []*compute.NetworkInterface{}
for _, nic := range d.GCPMachineClass.Spec.NetworkInterfaces {
computeNIC := &compute.NetworkInterface{
AccessConfigs: []*compute.AccessConfig{{}},
computeNIC := &compute.NetworkInterface{}

if nic.DisableExternalIP == false {
// When DisableExternalIP is false, implies Attach an external IP to VM
computeNIC.AccessConfigs = []*compute.AccessConfig{{}}
}
if len(nic.Network) != 0 {
computeNIC.Network = fmt.Sprintf("projects/%s/global/networks/%s", project, nic.Network)
Expand Down
6 changes: 6 additions & 0 deletions pkg/openapi/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.