Package org.cdk8s.plus24.k8s
Class NetworkPolicySpec.Builder
- java.lang.Object
-
- org.cdk8s.plus24.k8s.NetworkPolicySpec.Builder
-
- All Implemented Interfaces:
software.amazon.jsii.Builder<NetworkPolicySpec>
- Enclosing interface:
- NetworkPolicySpec
@Stability(Stable) public static final class NetworkPolicySpec.Builder extends Object implements software.amazon.jsii.Builder<NetworkPolicySpec>
A builder forNetworkPolicySpec
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NetworkPolicySpec
build()
Builds the configured instance.NetworkPolicySpec.Builder
egress(List<? extends NetworkPolicyEgressRule> egress)
Sets the value ofNetworkPolicySpec.getEgress()
NetworkPolicySpec.Builder
ingress(List<? extends NetworkPolicyIngressRule> ingress)
Sets the value ofNetworkPolicySpec.getIngress()
NetworkPolicySpec.Builder
podSelector(LabelSelector podSelector)
Sets the value ofNetworkPolicySpec.getPodSelector()
NetworkPolicySpec.Builder
policyTypes(List<String> policyTypes)
Sets the value ofNetworkPolicySpec.getPolicyTypes()
-
-
-
Method Detail
-
podSelector
@Stability(Stable) public NetworkPolicySpec.Builder podSelector(LabelSelector podSelector)
Sets the value ofNetworkPolicySpec.getPodSelector()
- Parameters:
podSelector
- Selects the pods to which this NetworkPolicy object applies. This parameter is required. The array of ingress rules is applied to any pods selected by this field. Multiple network policies can select the same set of pods. In this case, the ingress rules for each are combined additively. This field is NOT optional and follows standard label selector semantics. An empty podSelector matches all pods in this namespace.- Returns:
this
-
egress
@Stability(Stable) public NetworkPolicySpec.Builder egress(List<? extends NetworkPolicyEgressRule> egress)
Sets the value ofNetworkPolicySpec.getEgress()
- Parameters:
egress
- List of egress rules to be applied to the selected pods. Outgoing traffic is allowed if there are no NetworkPolicies selecting the pod (and cluster policy otherwise allows the traffic), OR if the traffic matches at least one egress rule across all of the NetworkPolicy objects whose podSelector matches the pod. If this field is empty then this NetworkPolicy limits all outgoing traffic (and serves solely to ensure that the pods it selects are isolated by default). This field is beta-level in 1.8- Returns:
this
-
ingress
@Stability(Stable) public NetworkPolicySpec.Builder ingress(List<? extends NetworkPolicyIngressRule> ingress)
Sets the value ofNetworkPolicySpec.getIngress()
- Parameters:
ingress
- List of ingress rules to be applied to the selected pods. Traffic is allowed to a pod if there are no NetworkPolicies selecting the pod (and cluster policy otherwise allows the traffic), OR if the traffic source is the pod's local node, OR if the traffic matches at least one ingress rule across all of the NetworkPolicy objects whose podSelector matches the pod. If this field is empty then this NetworkPolicy does not allow any traffic (and serves solely to ensure that the pods it selects are isolated by default)- Returns:
this
-
policyTypes
@Stability(Stable) public NetworkPolicySpec.Builder policyTypes(List<String> policyTypes)
Sets the value ofNetworkPolicySpec.getPolicyTypes()
- Parameters:
policyTypes
- List of rule types that the NetworkPolicy relates to. Valid options are ["Ingress"], ["Egress"], or ["Ingress", "Egress"]. If this field is not specified, it will default based on the existence of Ingress or Egress rules; policies that contain an Egress section are assumed to affect Egress, and all policies (whether or not they contain an Ingress section) are assumed to affect Ingress. If you want to write an egress-only policy, you must explicitly specify policyTypes [ "Egress" ]. Likewise, if you want to write a policy that specifies that no egress is allowed, you must specify a policyTypes value that include "Egress" (since such a policy would not include an Egress section and would otherwise default to just [ "Ingress" ]). This field is beta-level in 1.8- Returns:
this
-
build
@Stability(Stable) public NetworkPolicySpec build()
Builds the configured instance.- Specified by:
build
in interfacesoftware.amazon.jsii.Builder<NetworkPolicySpec>
- Returns:
- a new instance of
NetworkPolicySpec
- Throws:
NullPointerException
- if any required attribute was not provided
-
-