networkpolicy

package
v0.0.0-...-f843765 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyExists = errors.New("a policy with this name already exists")
	ErrEmptyParam    = errors.New("a required parameter is empty")
	ErrNotFound      = errors.New("policy not found")
)

Functions

func ExtendPeers

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL