def __init__( self, egress: typing.List["NetworkPolicyEgressRule"] = None, ingress: typing.List["NetworkPolicyIngressRule"] = None, pod_selector: "LabelSelector" = None, policy_types: typing.List[str] = None, ): """Create NetworkPolicySpec instance.""" super(NetworkPolicySpec, self).__init__(api_version="networking/v1", kind="NetworkPolicySpec") self._properties = { "egress": egress if egress is not None else [], "ingress": ingress if ingress is not None else [], "podSelector": pod_selector if pod_selector is not None else LabelSelector(), "policyTypes": policy_types if policy_types is not None else [], } self._types = { "egress": (list, NetworkPolicyEgressRule), "ingress": (list, NetworkPolicyIngressRule), "podSelector": (LabelSelector, None), "policyTypes": (list, str), }
def __init__( self, env: typing.List["EnvVar"] = None, env_from: typing.List["EnvFromSource"] = None, selector: "LabelSelector" = None, volume_mounts: typing.List["VolumeMount"] = None, volumes: typing.List["Volume"] = None, ): """Create PodPresetSpec instance.""" super(PodPresetSpec, self).__init__(api_version="settings/v1alpha1", kind="PodPresetSpec") self._properties = { "env": env if env is not None else [], "envFrom": env_from if env_from is not None else [], "selector": selector if selector is not None else LabelSelector(), "volumeMounts": volume_mounts if volume_mounts is not None else [], "volumes": volumes if volumes is not None else [], } self._types = { "env": (list, EnvVar), "envFrom": (list, EnvFromSource), "selector": (LabelSelector, None), "volumeMounts": (list, VolumeMount), "volumes": (list, Volume), }
def selector(self, value: typing.Union["LabelSelector", dict]): """ Selector is a label query over a set of resources, in this case pods. Required. """ if isinstance(value, dict): value = typing.cast( LabelSelector, LabelSelector().from_dict(value), ) self._properties["selector"] = value
def __init__( self, ip_block: "IPBlock" = None, namespace_selector: "LabelSelector" = None, pod_selector: "LabelSelector" = None, ): """Create NetworkPolicyPeer instance.""" super(NetworkPolicyPeer, self).__init__(api_version="networking/v1", kind="NetworkPolicyPeer") self._properties = { "ipBlock": ip_block if ip_block is not None else IPBlock(), "namespaceSelector": namespace_selector if namespace_selector is not None else LabelSelector(), "podSelector": pod_selector if pod_selector is not None else LabelSelector(), } self._types = { "ipBlock": (IPBlock, None), "namespaceSelector": (LabelSelector, None), "podSelector": (LabelSelector, None), }
def pod_selector(self, value: typing.Union["LabelSelector", dict]): """ Selects the pods to which this NetworkPolicy object applies. 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. """ if isinstance(value, dict): value = typing.cast( LabelSelector, LabelSelector().from_dict(value), ) self._properties["podSelector"] = value
def pod_selector(self, value: typing.Union["LabelSelector", dict]): """ This is a label selector which selects Pods. This field follows standard label selector semantics; if present but empty, it selects all pods. If NamespaceSelector is also set, then the NetworkPolicyPeer as a whole selects the Pods matching PodSelector in the Namespaces selected by NamespaceSelector. Otherwise it selects the Pods matching PodSelector in the policy's own Namespace. """ if isinstance(value, dict): value = typing.cast( LabelSelector, LabelSelector().from_dict(value), ) self._properties["podSelector"] = value
def namespace_selector(self, value: typing.Union["LabelSelector", dict]): """ Selects Namespaces using cluster-scoped labels. This field follows standard label selector semantics; if present but empty, it selects all namespaces. If PodSelector is also set, then the NetworkPolicyPeer as a whole selects the Pods matching PodSelector in the Namespaces selected by NamespaceSelector. Otherwise it selects all Pods in the Namespaces selected by NamespaceSelector. """ if isinstance(value, dict): value = typing.cast( LabelSelector, LabelSelector().from_dict(value), ) self._properties["namespaceSelector"] = value