|
8 | 8 | "google.golang.org/api/compute/v1" |
9 | 9 |
|
10 | 10 | "github.com/openshift/installer/pkg/infrastructure/clusterapi" |
| 11 | + "github.com/openshift/installer/pkg/types" |
11 | 12 | ) |
12 | 13 |
|
13 | 14 | func getControlPlanePorts() []*compute.FirewallAllowed { |
@@ -108,6 +109,20 @@ func getInternalNetworkPorts() []*compute.FirewallAllowed { |
108 | 109 | } |
109 | 110 | } |
110 | 111 |
|
| 112 | +func getBootstrapSSHPorts() []*compute.FirewallAllowed { |
| 113 | + return []*compute.FirewallAllowed{ |
| 114 | + { |
| 115 | + IPProtocol: "tcp", |
| 116 | + Ports: []string{ |
| 117 | + "22", // SSH |
| 118 | + }, |
| 119 | + }, |
| 120 | + { |
| 121 | + IPProtocol: "icmp", |
| 122 | + }, |
| 123 | + } |
| 124 | +} |
| 125 | + |
111 | 126 | // addFirewallRule creates the firewall rule and adds it the compute's firewalls. |
112 | 127 | func addFirewallRule(ctx context.Context, name, network, projectID string, ports []*compute.FirewallAllowed, srcTags, targetTags, srcRanges []string) error { |
113 | 128 | service, err := NewComputeService() |
@@ -146,7 +161,7 @@ func addFirewallRule(ctx context.Context, name, network, projectID string, ports |
146 | 161 | return nil |
147 | 162 | } |
148 | 163 |
|
149 | | -// createFirewallRules creates the rules needed between tthe worker and master nodes. |
| 164 | +// createFirewallRules creates the rules needed between the worker and master nodes. |
150 | 165 | func createFirewallRules(ctx context.Context, in clusterapi.InfraReadyInput, network string) error { |
151 | 166 | projectID := in.InstallConfig.Config.Platform.GCP.ProjectID |
152 | 167 | workerTag := fmt.Sprintf("%s-worker", in.InfraID) |
@@ -189,3 +204,20 @@ func createFirewallRules(ctx context.Context, in clusterapi.InfraReadyInput, net |
189 | 204 |
|
190 | 205 | return err |
191 | 206 | } |
| 207 | + |
| 208 | +// createBootstrapFirewallRules creates the rules needed for the bootstrap node. |
| 209 | +func createBootstrapFirewallRules(ctx context.Context, in clusterapi.InfraReadyInput, network string) error { |
| 210 | + projectID := in.InstallConfig.Config.Platform.GCP.ProjectID |
| 211 | + firewallName := fmt.Sprintf("%s-bootstrap-in-ssh", in.InfraID) |
| 212 | + srcTags := []string{} |
| 213 | + bootstrapTag := fmt.Sprintf("%s-control-plane", in.InfraID) |
| 214 | + targetTags := []string{bootstrapTag} |
| 215 | + var srcRanges []string |
| 216 | + if in.InstallConfig.Config.Publish == types.ExternalPublishingStrategy { |
| 217 | + srcRanges = []string{"0.0.0.0/0"} |
| 218 | + } else { |
| 219 | + machineCIDR := in.InstallConfig.Config.Networking.MachineNetwork[0].CIDR.String() |
| 220 | + srcRanges = []string{machineCIDR} |
| 221 | + } |
| 222 | + return addFirewallRule(ctx, firewallName, network, projectID, getBootstrapSSHPorts(), srcTags, targetTags, srcRanges) |
| 223 | +} |
0 commit comments