Documentation ¶
Index ¶
- Variables
- func ExtendPeers(ingressPol []networkingv1.NetworkPolicyPeer, ...) error
- func RemoveOldLabels(oldLabels map[string][]string, ...)
- type Handler
- func (h *Handler) AppendLabelsToPeers(targetPodLabels map[string][]string) (ingressPeers []networkingv1.NetworkPolicyPeer, ...)
- func (h *Handler) GetPolicyByPodLabels(namespace string, podLabels map[string]string) (*networkingv1.NetworkPolicy, error)
- func (h *Handler) NewPolicy(name string, namespace string, podSelectorLabels map[string]string, ...) (*networkingv1.NetworkPolicy, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ExtendPeers ¶
func ExtendPeers(ingressPol []networkingv1.NetworkPolicyPeer, egressPol []networkingv1.NetworkPolicyPeer, p *networkingv1.NetworkPolicy) error
ExtendPeers loops through the ingress and egress peers of an existing policy, and appends all the elements from ingressPol and egressPol to the existing NetworkPolicyPeers.
func RemoveOldLabels ¶
func RemoveOldLabels(oldLabels map[string][]string, ingressRules []networkingv1.NetworkPolicyIngressRule, egressRules []networkingv1.NetworkPolicyEgressRule)
Types ¶
type Handler ¶
type Handler struct {
Client kubernetes.Interface
}
func (*Handler) AppendLabelsToPeers ¶
func (h *Handler) AppendLabelsToPeers(targetPodLabels map[string][]string) (ingressPeers []networkingv1.NetworkPolicyPeer, egressPeers []networkingv1.NetworkPolicyPeer, err error)
appendLabelsToPeers appends the default supported labels (such as Ingress controller pod labels and DNS pod labels which come from DefaultLabels) and targetedPodLabels one by one to ingressPeers and egressPeers.
func (*Handler) GetPolicyByPodLabels ¶
func (h *Handler) GetPolicyByPodLabels(namespace string, podLabels map[string]string) (*networkingv1.NetworkPolicy, error)
GetPolicyByPodLabels returns the policy where podLabels match LabelSelectorRequirements with LabelSelectorOpIn
func (*Handler) NewPolicy ¶
func (h *Handler) NewPolicy(name string, namespace string, podSelectorLabels map[string]string, targetPodLabels map[string][]string) (*networkingv1.NetworkPolicy, error)
NewPolicy deploys a NetworkPolicy which only allows incoming/outgoing communication from pods with the same label, and to/from objects that have the labels located in the global variable DefaultLabels.