Skip to content

Commit

Permalink
fix hcloud types
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Paskal <[email protected]>
  • Loading branch information
maksim-paskal committed Apr 14, 2024
1 parent 2c7036f commit 5f93c70
Showing 1 changed file with 60 additions and 50 deletions.
110 changes: 60 additions & 50 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -995,25 +995,28 @@ func (api *ApplicationAPI) CreateFirewall(ctx context.Context, createControlPlan

sharedRules := []hcloud.FirewallRule{
{
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*anyIPv4, *anyIPv6},
Protocol: "tcp",
Port: hcloud.Ptr("22"),
Description: hcloud.Ptr("SSH to server"),
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*anyIPv4, *anyIPv6},
DestinationIPs: []net.IPNet{},
Protocol: "tcp",
Port: hcloud.Ptr("22"),
Description: hcloud.Ptr("SSH to server"),
},
{
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*clusterNetwork},
Protocol: "udp",
Port: hcloud.Ptr("8285"),
Description: hcloud.Ptr("flannel overlay network - udp backend"),
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*clusterNetwork},
DestinationIPs: []net.IPNet{},
Protocol: "udp",
Port: hcloud.Ptr("8285"),
Description: hcloud.Ptr("flannel overlay network - udp backend"),
},
{
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*clusterNetwork},
Protocol: "udp",
Port: hcloud.Ptr("8472"),
Description: hcloud.Ptr("flannel overlay network - vxlan backend"),
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*clusterNetwork},
DestinationIPs: []net.IPNet{},
Protocol: "udp",
Port: hcloud.Ptr("8472"),
Description: hcloud.Ptr("flannel overlay network - vxlan backend"),
},
}

Expand All @@ -1033,39 +1036,44 @@ func (api *ApplicationAPI) CreateFirewall(ctx context.Context, createControlPlan
},
Rules: append(sharedRules, []hcloud.FirewallRule{
{
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*anyIPv4, *anyIPv6}, // flannel do not start if only clusternetwork
Protocol: "tcp",
Port: hcloud.Ptr("6443"),
Description: hcloud.Ptr("Kubernetes API server"),
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*anyIPv4, *anyIPv6}, // flannel do not start if only clusternetwork
DestinationIPs: []net.IPNet{},
Protocol: "tcp",
Port: hcloud.Ptr("6443"),
Description: hcloud.Ptr("Kubernetes API server"),
},
{
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*anyIPv4, *anyIPv6}, // other master nodes can not connect if only clusternetwork
Protocol: "tcp",
Port: hcloud.Ptr("2379-2380"),
Description: hcloud.Ptr("etcd server client API"),
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*anyIPv4, *anyIPv6}, // other master nodes can not connect if only clusternetwork
DestinationIPs: []net.IPNet{},
Protocol: "tcp",
Port: hcloud.Ptr("2379-2380"),
Description: hcloud.Ptr("etcd server client API"),
},
{
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*clusterNetwork},
Protocol: "tcp",
Port: hcloud.Ptr("10250"),
Description: hcloud.Ptr("Kubelet API"),
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*clusterNetwork},
DestinationIPs: []net.IPNet{},
Protocol: "tcp",
Port: hcloud.Ptr("10250"),
Description: hcloud.Ptr("Kubelet API"),
},
{
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*clusterNetwork},
Protocol: "tcp",
Port: hcloud.Ptr("10259"),
Description: hcloud.Ptr("kube-scheduler"),
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*clusterNetwork},
DestinationIPs: []net.IPNet{},
Protocol: "tcp",
Port: hcloud.Ptr("10259"),
Description: hcloud.Ptr("kube-scheduler"),
},
{
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*clusterNetwork},
Protocol: "tcp",
Port: hcloud.Ptr("10257"),
Description: hcloud.Ptr("kube-controller-manager"),
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*clusterNetwork},
DestinationIPs: []net.IPNet{},
Protocol: "tcp",
Port: hcloud.Ptr("10257"),
Description: hcloud.Ptr("kube-controller-manager"),
},
}...),
}
Expand All @@ -1085,18 +1093,20 @@ func (api *ApplicationAPI) CreateFirewall(ctx context.Context, createControlPlan
},
Rules: append(sharedRules, []hcloud.FirewallRule{
{
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*clusterNetwork},
Protocol: "tcp",
Port: hcloud.Ptr("10250"),
Description: hcloud.Ptr("Kubelet API"),
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*clusterNetwork},
DestinationIPs: []net.IPNet{},
Protocol: "tcp",
Port: hcloud.Ptr("10250"),
Description: hcloud.Ptr("Kubelet API"),
},
{
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*clusterNetwork},
Protocol: "tcp",
Port: hcloud.Ptr("30000-32767"),
Description: hcloud.Ptr("NodePort Services"),
Direction: hcloud.FirewallRuleDirectionIn,
SourceIPs: []net.IPNet{*clusterNetwork},
DestinationIPs: []net.IPNet{},
Protocol: "tcp",
Port: hcloud.Ptr("30000-32767"),
Description: hcloud.Ptr("NodePort Services"),
},
}...),
}
Expand Down

0 comments on commit 5f93c70

Please sign in to comment.