-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Manifest resouces in different oppeartions
- Loading branch information
Showing
33 changed files
with
2,561 additions
and
276 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import enum | ||
|
||
from pydantic import Field | ||
|
||
from kpops.utils.docstring import describe_attr | ||
from kpops.utils.pydantic import DescConfigModel | ||
|
||
# Matches plain integer or numbers with valid suffixes: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory | ||
MEMORY_PATTERN = r"^\d+([EPTGMk]|Ei|Pi|Ti|Gi|Mi|Ki)?$" | ||
|
||
|
||
class ServiceType(enum.Enum): | ||
"""Represents the different Kubernetes service types. | ||
https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types | ||
""" | ||
|
||
CLUSTER_IP = "ClusterIP" | ||
NODE_PORT = "NodePort" | ||
LOAD_BALANCER = "LoadBalancer" | ||
EXTERNAL_NAME = "ExternalName" | ||
|
||
|
||
class ProtocolSchema(enum.Enum): | ||
"""Represents the different Kubernetes protocols. | ||
https://kubernetes.io/docs/reference/networking/service-protocols/ | ||
""" | ||
|
||
TCP = "TCP" | ||
UDP = "UDP" | ||
SCTP = "SCTP" | ||
|
||
|
||
class ImagePullPolicy(enum.Enum): | ||
"""Represents the different Kubernetes image pull policies. | ||
https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy | ||
""" | ||
|
||
ALWAYS = "Always" | ||
IF_NOT_PRESENT = "IfNotPresent" | ||
NEVER = "Never" | ||
|
||
|
||
class Operation(enum.Enum): | ||
EXISTS = "Exists" | ||
EQUAL = "Equal" | ||
|
||
|
||
class Effects(enum.Enum): | ||
NO_EXECUTE = "NoExecute" | ||
NO_SCHEDULE = "NoSchedule" | ||
PREFER_NO_SCHEDULE = "PreferNoSchedule" | ||
|
||
|
||
class RestartPolicy(enum.Enum): | ||
ALWAYS = "Always" | ||
ON_FAILURE = "OnFailure" | ||
NEVER = "Never" | ||
|
||
|
||
class Toleration(DescConfigModel): | ||
"""Represents the different Kubernetes tolerations. | ||
https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/ | ||
:param key: The key that the toleration applies to. | ||
:param operator: The operator ('Exists' or 'Equal'). | ||
:param value: The value to match for the key. | ||
:param effect: The effect to tolerate. | ||
:param toleration_seconds: The duration for which the toleration is valid. | ||
""" | ||
|
||
key: str = Field(default=..., description=describe_attr("key", __doc__)) | ||
|
||
operator: Operation = Field( | ||
default=Operation.EQUAL, description=describe_attr("operator", __doc__) | ||
) | ||
|
||
effect: Effects = Field(default=..., description=describe_attr("effect", __doc__)) | ||
|
||
value: str | None = Field(default=None, description=describe_attr("value", __doc__)) | ||
|
||
toleration_seconds: int | None = Field( | ||
default=None, description=describe_attr("toleration_seconds", __doc__) | ||
) | ||
|
||
|
||
class ResourceDefinition(DescConfigModel): | ||
"""Model representing the 'limits' or `request` section of Kubernetes resource specifications. | ||
:param cpu: The maximum amount of CPU a container can use, expressed in milli CPUs (e.g., '300m'). | ||
:param memory: The maximum amount of memory a container can use, with valid units such as 'Mi' or 'Gi' (e.g., '2G'). | ||
""" | ||
|
||
cpu: str | int = Field(pattern=r"^\d+m$", description=describe_attr("cpu", __doc__)) | ||
memory: str = Field( | ||
pattern=MEMORY_PATTERN, description=describe_attr("memory", __doc__) | ||
) | ||
|
||
|
||
class Resources(DescConfigModel): | ||
"""Model representing the resource specifications for a Kubernetes container. | ||
:param requests: The minimum resource requirements for the container. | ||
:param limits: The maximum resource limits for the container. | ||
""" | ||
|
||
requests: ResourceDefinition = Field(description=describe_attr("requests", __doc__)) | ||
limits: ResourceDefinition = Field(description=describe_attr("limits", __doc__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.