Documentation
¶
Overview ¶
pkg/resources/networkpolicies/networkpolicy.go
Index ¶
- func CopyToNamespaces(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- func Create(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- func Delete(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- func DeleteIfOwned(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- func Update(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- type ResolvedNetworkPolicySpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyToNamespaces ¶
func CopyToNamespaces( ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedNetworkPolicySpec, toNamespaces []string, ) error
CopyToNamespaces copies a NetworkPolicy to multiple target namespaces. Reads the source policy once and creates copies in each namespace. Idempotent — skips namespaces where the policy already exists.
func Create ¶
func Create(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedNetworkPolicySpec) error
Create creates a NetworkPolicy if it does not already exist. Idempotent — skips if it already exists. Owner reference set for cascade deletion.
func Delete ¶
func Delete(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedNetworkPolicySpec) error
Delete deletes the NetworkPolicy if it exists.
func DeleteIfOwned ¶
func DeleteIfOwned(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, name, namespace string) error
DeleteIfOwned deletes the NetworkPolicy only if it is owned by the CR.
func Update ¶
func Update(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedNetworkPolicySpec) error
Update reconciles an existing NetworkPolicy to match the resolved spec. If it does not exist, creates it.
Types ¶
type ResolvedNetworkPolicySpec ¶
type ResolvedNetworkPolicySpec struct {
Name string
Namespace string
PodSelector map[string]string
Ingress []orktypes.NetworkPolicyIngressRule
Egress []orktypes.NetworkPolicyEgressRule
PolicyTypes []string
FromNetworkPolicy string
FromNamespace string
Labels map[string]string
Sleep string
}
ResolvedNetworkPolicySpec is the fully resolved NetworkPolicy specification.
func Resolve ¶
func Resolve(src orktypes.NetworkPolicyTemplateSource, ownerName string, reg orktypes.ProfileRegistry) ResolvedNetworkPolicySpec
Resolve builds a ResolvedNetworkPolicySpec from a NetworkPolicyTemplateSource. Template expressions must already be evaluated by template.Resolver before calling.