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

Allow user defined endpoint to host action for Canal #3272

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
6 changes: 5 additions & 1 deletion pkg/apis/kops/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ type CalicoNetworkingSpec struct {
CrossSubnet bool `json:"crossSubnet,omitempty"` // Enables Calico's cross-subnet mode when set to true
}

// Canal declares that we want Canal networking
// CanalNetworkingSpec declares that we want Canal networking
type CanalNetworkingSpec struct {
// DefaultEndpointToHostAction allows users to configure the default behaviour
// for traffic between pod to host after calico rules have been processed.
// Default: ACCEPT (other options: DROP, RETURN)
DefaultEndpointToHostAction string `json:"defaultEndpointToHostAction,omitempty"`
}

// Kuberouter declares that we want Kube-router networking
Expand Down
6 changes: 5 additions & 1 deletion pkg/apis/kops/v1alpha1/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ type CalicoNetworkingSpec struct {
CrossSubnet bool `json:"crossSubnet,omitempty"` // Enables Calico's cross-subnet mode when set to true
}

// Canal declares that we want Canal networking
// CanalNetworkingSpec declares that we want Canal networking
type CanalNetworkingSpec struct {
// DefaultEndpointToHostAction allows users to configure the default behaviour
// for traffic between pod to host after calico rules have been processed.
// Default: ACCEPT (other options: DROP, RETURN)
DefaultEndpointToHostAction string `json:"defaultEndpointToHostAction,omitempty"`
}

// Kuberouter declares that we want Canal networking
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha1/zz_generated.conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ func Convert_kops_CalicoNetworkingSpec_To_v1alpha1_CalicoNetworkingSpec(in *kops
}

func autoConvert_v1alpha1_CanalNetworkingSpec_To_kops_CanalNetworkingSpec(in *CanalNetworkingSpec, out *kops.CanalNetworkingSpec, s conversion.Scope) error {
out.DefaultEndpointToHostAction = in.DefaultEndpointToHostAction
return nil
}

Expand All @@ -370,6 +371,7 @@ func Convert_v1alpha1_CanalNetworkingSpec_To_kops_CanalNetworkingSpec(in *CanalN
}

func autoConvert_kops_CanalNetworkingSpec_To_v1alpha1_CanalNetworkingSpec(in *kops.CanalNetworkingSpec, out *CanalNetworkingSpec, s conversion.Scope) error {
out.DefaultEndpointToHostAction = in.DefaultEndpointToHostAction
return nil
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/apis/kops/v1alpha2/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ type CalicoNetworkingSpec struct {
CrossSubnet bool `json:"crossSubnet,omitempty"` // Enables Calico's cross-subnet mode when set to true
}

// Canal declares that we want Canal networking
// CanalNetworkingSpec declares that we want Canal networking
type CanalNetworkingSpec struct {
// DefaultEndpointToHostAction allows users to configure the default behaviour
// for traffic between pod to host after calico rules have been processed.
// Default: ACCEPT (other options: DROP, RETURN)
DefaultEndpointToHostAction string `json:"defaultEndpointToHostAction,omitempty"`
}

// Kuberouter declares that we want Canal networking
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ func Convert_kops_CalicoNetworkingSpec_To_v1alpha2_CalicoNetworkingSpec(in *kops
}

func autoConvert_v1alpha2_CanalNetworkingSpec_To_kops_CanalNetworkingSpec(in *CanalNetworkingSpec, out *kops.CanalNetworkingSpec, s conversion.Scope) error {
out.DefaultEndpointToHostAction = in.DefaultEndpointToHostAction
return nil
}

Expand All @@ -398,6 +399,7 @@ func Convert_v1alpha2_CanalNetworkingSpec_To_kops_CanalNetworkingSpec(in *CanalN
}

func autoConvert_kops_CanalNetworkingSpec_To_v1alpha2_CanalNetworkingSpec(in *kops.CanalNetworkingSpec, out *CanalNetworkingSpec, s conversion.Scope) error {
out.DefaultEndpointToHostAction = in.DefaultEndpointToHostAction
return nil
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/kops/validation/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ func ValidateCluster(c *kops.Cluster, strict bool) *field.Error {
}
}

// Check Canal Networking Spec if used
if c.Spec.Networking.Canal != nil {
action := c.Spec.Networking.Canal.DefaultEndpointToHostAction
switch action {
case "", "ACCEPT", "DROP", "RETURN":
default:
return field.Invalid(fieldSpec.Child("Networking", "Canal", "DefaultEndpointToHostAction"), action, fmt.Sprintf("Unsupported value: %s, supports ACCEPT, DROP or RETURN", action))
}
}

// Check ClusterCIDR
if c.Spec.KubeControllerManager != nil {
var clusterCIDR *net.IPNet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ spec:
fieldPath: spec.nodeName
# Set Felix endpoint to host default action to ACCEPT.
- name: FELIX_DEFAULTENDPOINTTOHOSTACTION
value: "ACCEPT"
value: "{{- or .Networking.Canal.DefaultEndpointToHostAction "ACCEPT" }}"
securityContext:
privileged: true
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ spec:
fieldPath: spec.nodeName
# Set Felix endpoint to host default action to ACCEPT.
- name: FELIX_DEFAULTENDPOINTTOHOSTACTION
value: "ACCEPT"
value: "{{- or .Networking.Canal.DefaultEndpointToHostAction "ACCEPT" }}"
securityContext:
privileged: true
resources:
Expand Down
2 changes: 2 additions & 0 deletions upup/pkg/fi/cloudup/populatecluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func buildMinimalCluster() *api.Cluster {
// TODO: Mock cloudprovider
c.Spec.DNSZone = "test.com"

c.Spec.Networking = &api.NetworkingSpec{}

return c
}

Expand Down