Documentation ¶
Index ¶
- Variables
- func DefaultIPBlockPeers(podIP string) []NetworkPolicyPeer
- func DefaultNamespaces() []string
- func DefaultPodPeers(podIP string) []NetworkPolicyPeer
- func DefaultPorts() []NetworkPolicyPort
- func DefaultTargets() []metav1.LabelSelector
- type Action
- func CreatePolicy(policy *networkingv1.NetworkPolicy) *Action
- func DeletePolicy(ns string, name string) *Action
- func ReadNetworkPolicies(namespaces []string) *Action
- func SetNamespaceLabels(ns string, labels map[string]string) *Action
- func SetPodLabels(namespace string, pod string, labels map[string]string) *Action
- func UpdatePolicy(policy *networkingv1.NetworkPolicy) *Action
- type ConflictGenerator
- type CreatePolicyAction
- type DeletePolicyAction
- type FragmentGenerator
- func (g *FragmentGenerator) EgressPolicies() []*NetworkPolicy
- func (g *FragmentGenerator) FragmentEgressPolicies() []*NetworkPolicy
- func (g *FragmentGenerator) FragmentIngressPolicies() []*NetworkPolicy
- func (g *FragmentGenerator) FragmentPolicies() []*NetworkPolicy
- func (g *FragmentGenerator) GenerateTestCases() []*TestCase
- func (g *FragmentGenerator) IngressEgressPolicies(allowDNS bool) []*NetworkPolicy
- func (g *FragmentGenerator) IngressPolicies() []*NetworkPolicy
- func (g *FragmentGenerator) PeerSlices() [][]NetworkPolicyPeer
- func (g *FragmentGenerator) PortSlices() [][]NetworkPolicyPort
- func (g *FragmentGenerator) RuleSlices() [][]*Rule
- func (g *FragmentGenerator) Rules() []*Rule
- type Netpol
- func AllowAllEgressDenyAllIngress(source *NetpolTarget, dest *NetpolTarget) []*Netpol
- func AllowAllIngressDenyAllEgress(source *NetpolTarget, dest *NetpolTarget) []*Netpol
- func AllowDNSPolicy(source *NetpolTarget) *Netpol
- func DenyAllEgressAllowAllEgress(source *NetpolTarget) []*Netpol
- func DenyAllEgressAllowAllEgressByIP(source *NetpolTarget) []*Netpol
- func DenyAllEgressAllowAllEgressByPod(source *NetpolTarget) []*Netpol
- func DenyAllEgressByIP(source *NetpolTarget) []*Netpol
- func DenyAllEgressByIPAllowAllEgressByPod(source *NetpolTarget) []*Netpol
- func DenyAllEgressByPod(source *NetpolTarget) []*Netpol
- func DenyAllEgressByPodAllowAllEgressByIP(source *NetpolTarget) []*Netpol
- func DenyAllIngressAllowAllIngress(dest *NetpolTarget) []*Netpol
- func DenyAllIngressAllowAllIngressByIP(source *NetpolTarget) []*Netpol
- func DenyAllIngressAllowAllIngressByPod(source *NetpolTarget) []*Netpol
- func DenyAllIngressByIP(source *NetpolTarget) []*Netpol
- func DenyAllIngressByIPAllowAllIngressByPod(source *NetpolTarget) []*Netpol
- func DenyAllIngressByPod(source *NetpolTarget) []*Netpol
- func DenyAllIngressByPodAllowAllIngressByIP(source *NetpolTarget) []*Netpol
- type NetpolPeers
- type NetpolTarget
- type ReadNetworkPoliciesAction
- type Rule
- type SetNamespaceLabelsAction
- type SetPodLabelsAction
- type TestCase
- type TestCaseGenerator
- type TestStep
- type UpdatePolicyAction
- type UpstreamE2EGenerator
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ExplicitAllowAll = &NetpolPeers{ Rules: []*Rule{ {}, }, } DenyAll = &NetpolPeers{ Rules: nil, } // DenyAll2 should be identical to DenyAll -- but just in case :) DenyAll2 = &NetpolPeers{ Rules: []*Rule{}, } AllowAllPodsRule = &Rule{ Peers: []networkingv1.NetworkPolicyPeer{ { NamespaceSelector: &metav1.LabelSelector{}, }, }, } AllowAllByPod = &NetpolPeers{ Rules: []*Rule{AllowAllPodsRule}, } AllowAllByIPRule = &Rule{ Peers: []networkingv1.NetworkPolicyPeer{ { IPBlock: &networkingv1.IPBlock{ CIDR: "0.0.0.0/0", }, }, }, } AllowAllByIP = &NetpolPeers{ Rules: []*Rule{AllowAllByIPRule}, } DenyAllByIPRule = &Rule{ Peers: []networkingv1.NetworkPolicyPeer{ { IPBlock: &networkingv1.IPBlock{ CIDR: "0.0.0.0/31", }, }, }, } DenyAllByIP = &NetpolPeers{ Rules: []*Rule{DenyAllByIPRule}, } DenyAllByPodRule = &Rule{ Peers: []networkingv1.NetworkPolicyPeer{ { PodSelector: nil, NamespaceSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{"this-will-never-happen": "qrs123"}, }, }, }, } DenyAllByPod = &NetpolPeers{ Rules: []*Rule{DenyAllByPodRule}, } )
View Source
var ( AllowDNSRule = &Rule{ Ports: []NetworkPolicyPort{ { Protocol: &udp, Port: &port53, }, }, } AllowDNSPeers = &NetpolPeers{ Rules: []*Rule{AllowDNSRule}, } )
View Source
var ( TypicalNamespace = "x" TypicalTarget = metav1.LabelSelector{ MatchLabels: map[string]string{"pod": "a"}, MatchExpressions: nil, } TypicalPorts = []NetworkPolicyPort{{Protocol: &tcp, Port: &port80}} TypicalPeers = []NetworkPolicyPeer{ { PodSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{"pod": "b"}, }, NamespaceSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{"ns": "y"}, }, }, } )
Functions ¶
func DefaultIPBlockPeers ¶
func DefaultIPBlockPeers(podIP string) []NetworkPolicyPeer
func DefaultNamespaces ¶
func DefaultNamespaces() []string
func DefaultPodPeers ¶
func DefaultPodPeers(podIP string) []NetworkPolicyPeer
func DefaultPorts ¶
func DefaultPorts() []NetworkPolicyPort
func DefaultTargets ¶
func DefaultTargets() []metav1.LabelSelector
Types ¶
type Action ¶ added in v0.1.0
type Action struct { CreatePolicy *CreatePolicyAction UpdatePolicy *UpdatePolicyAction DeletePolicy *DeletePolicyAction SetNamespaceLabels *SetNamespaceLabelsAction SetPodLabels *SetPodLabelsAction ReadNetworkPolicies *ReadNetworkPoliciesAction }
Action: exactly one field must be non-null. This models a discriminated union (sum type).
func CreatePolicy ¶ added in v0.1.0
func CreatePolicy(policy *networkingv1.NetworkPolicy) *Action
func DeletePolicy ¶ added in v0.1.0
func ReadNetworkPolicies ¶ added in v0.1.0
func SetNamespaceLabels ¶ added in v0.1.0
func SetPodLabels ¶ added in v0.1.0
func UpdatePolicy ¶ added in v0.1.0
func UpdatePolicy(policy *networkingv1.NetworkPolicy) *Action
type ConflictGenerator ¶ added in v0.0.10
type ConflictGenerator struct { AllowDNS bool Source *NetpolTarget Destination *NetpolTarget }
func (*ConflictGenerator) GenerateTestCases ¶ added in v0.1.0
func (c *ConflictGenerator) GenerateTestCases() []*TestCase
func (*ConflictGenerator) NetworkPolicies ¶ added in v0.0.10
func (c *ConflictGenerator) NetworkPolicies(source *NetpolTarget, dest *NetpolTarget) []*TestCase
type CreatePolicyAction ¶ added in v0.1.0
type CreatePolicyAction struct {
Policy *networkingv1.NetworkPolicy
}
type DeletePolicyAction ¶ added in v0.1.0
type FragmentGenerator ¶
type FragmentGenerator struct { AllowDNS bool // multidimensional generation Ports []NetworkPolicyPort PodPeers []NetworkPolicyPeer Targets []metav1.LabelSelector Namespaces []string // unidimensional typicals TypicalPorts []NetworkPolicyPort TypicalPeers []NetworkPolicyPeer TypicalTarget metav1.LabelSelector TypicalNamespace string }
func NewDefaultFragmentGenerator ¶ added in v0.0.9
func NewDefaultFragmentGenerator(allowDNS bool, namespaces []string, podIP string) *FragmentGenerator
func (*FragmentGenerator) EgressPolicies ¶
func (g *FragmentGenerator) EgressPolicies() []*NetworkPolicy
func (*FragmentGenerator) FragmentEgressPolicies ¶ added in v0.0.9
func (g *FragmentGenerator) FragmentEgressPolicies() []*NetworkPolicy
func (*FragmentGenerator) FragmentIngressPolicies ¶ added in v0.0.9
func (g *FragmentGenerator) FragmentIngressPolicies() []*NetworkPolicy
func (*FragmentGenerator) FragmentPolicies ¶ added in v0.0.9
func (g *FragmentGenerator) FragmentPolicies() []*NetworkPolicy
func (*FragmentGenerator) GenerateTestCases ¶ added in v0.1.0
func (g *FragmentGenerator) GenerateTestCases() []*TestCase
func (*FragmentGenerator) IngressEgressPolicies ¶
func (g *FragmentGenerator) IngressEgressPolicies(allowDNS bool) []*NetworkPolicy
func (*FragmentGenerator) IngressPolicies ¶
func (g *FragmentGenerator) IngressPolicies() []*NetworkPolicy
func (*FragmentGenerator) PeerSlices ¶
func (g *FragmentGenerator) PeerSlices() [][]NetworkPolicyPeer
func (*FragmentGenerator) PortSlices ¶
func (g *FragmentGenerator) PortSlices() [][]NetworkPolicyPort
func (*FragmentGenerator) RuleSlices ¶
func (g *FragmentGenerator) RuleSlices() [][]*Rule
func (*FragmentGenerator) Rules ¶
func (g *FragmentGenerator) Rules() []*Rule
type Netpol ¶
type Netpol struct { Name string Target *NetpolTarget Ingress *NetpolPeers Egress *NetpolPeers }
Netpol helps us to avoid the To/From Ingress/Egress dance. By splitting a NetworkPolicy into Target and Peers, it makes them easier to manipulate.
func AllowAllEgressDenyAllIngress ¶ added in v0.0.10
func AllowAllEgressDenyAllIngress(source *NetpolTarget, dest *NetpolTarget) []*Netpol
func AllowAllIngressDenyAllEgress ¶ added in v0.0.10
func AllowAllIngressDenyAllEgress(source *NetpolTarget, dest *NetpolTarget) []*Netpol
func AllowDNSPolicy ¶ added in v0.1.0
func AllowDNSPolicy(source *NetpolTarget) *Netpol
func DenyAllEgressAllowAllEgress ¶ added in v0.0.10
func DenyAllEgressAllowAllEgress(source *NetpolTarget) []*Netpol
func DenyAllEgressAllowAllEgressByIP ¶ added in v0.0.10
func DenyAllEgressAllowAllEgressByIP(source *NetpolTarget) []*Netpol
func DenyAllEgressAllowAllEgressByPod ¶ added in v0.0.10
func DenyAllEgressAllowAllEgressByPod(source *NetpolTarget) []*Netpol
func DenyAllEgressByIP ¶ added in v0.0.10
func DenyAllEgressByIP(source *NetpolTarget) []*Netpol
func DenyAllEgressByIPAllowAllEgressByPod ¶ added in v0.0.10
func DenyAllEgressByIPAllowAllEgressByPod(source *NetpolTarget) []*Netpol
func DenyAllEgressByPod ¶ added in v0.0.10
func DenyAllEgressByPod(source *NetpolTarget) []*Netpol
func DenyAllEgressByPodAllowAllEgressByIP ¶ added in v0.0.10
func DenyAllEgressByPodAllowAllEgressByIP(source *NetpolTarget) []*Netpol
func DenyAllIngressAllowAllIngress ¶ added in v0.0.10
func DenyAllIngressAllowAllIngress(dest *NetpolTarget) []*Netpol
func DenyAllIngressAllowAllIngressByIP ¶ added in v0.0.10
func DenyAllIngressAllowAllIngressByIP(source *NetpolTarget) []*Netpol
func DenyAllIngressAllowAllIngressByPod ¶ added in v0.0.10
func DenyAllIngressAllowAllIngressByPod(source *NetpolTarget) []*Netpol
func DenyAllIngressByIP ¶ added in v0.0.10
func DenyAllIngressByIP(source *NetpolTarget) []*Netpol
func DenyAllIngressByIPAllowAllIngressByPod ¶ added in v0.0.10
func DenyAllIngressByIPAllowAllIngressByPod(source *NetpolTarget) []*Netpol
func DenyAllIngressByPod ¶ added in v0.0.10
func DenyAllIngressByPod(source *NetpolTarget) []*Netpol
func DenyAllIngressByPodAllowAllIngressByIP ¶ added in v0.0.10
func DenyAllIngressByPodAllowAllIngressByIP(source *NetpolTarget) []*Netpol
func (*Netpol) NetworkPolicy ¶
func (n *Netpol) NetworkPolicy() *NetworkPolicy
func (*Netpol) NetworkPolicySpec ¶ added in v0.0.10
func (n *Netpol) NetworkPolicySpec() *NetworkPolicySpec
type NetpolPeers ¶ added in v0.0.10
type NetpolPeers struct {
Rules []*Rule
}
type NetpolTarget ¶ added in v0.0.10
type NetpolTarget struct { Namespace string PodSelector metav1.LabelSelector }
func NewNetpolTarget ¶ added in v0.1.0
func NewNetpolTarget(namespace string, matchLabels map[string]string, matchExpressions []metav1.LabelSelectorRequirement) *NetpolTarget
type ReadNetworkPoliciesAction ¶ added in v0.1.0
type ReadNetworkPoliciesAction struct {
Namespaces []string
}
type SetNamespaceLabelsAction ¶ added in v0.1.0
type SetPodLabelsAction ¶ added in v0.1.0
type TestCase ¶ added in v0.1.0
func NewSingleStepTestCase ¶ added in v0.1.0
func NewTestCase ¶ added in v0.1.0
type TestCaseGenerator ¶ added in v0.1.0
type TestCaseGenerator interface {
GenerateTestCases() []*TestCase
}
type UpdatePolicyAction ¶ added in v0.1.0
type UpdatePolicyAction struct {
Policy *networkingv1.NetworkPolicy
}
type UpstreamE2EGenerator ¶ added in v0.1.0
type UpstreamE2EGenerator struct{}
func (*UpstreamE2EGenerator) GenerateTestCases ¶ added in v0.1.0
func (u *UpstreamE2EGenerator) GenerateTestCases() []*TestCase
Click to show internal directories.
Click to hide internal directories.