Exemplo n.º 1
0
class ServiceSpec(Model):
    cluster_ip = StringField(name="clusterIP")
    external_ips = ListField(str, name="externalIPs")
    external_name = StringField(name="externalName")
    external_traffic_policy = StringField(name="externalTrafficPolicy")
    health_check_node_port = IntField(name="healthCheckNodePort")
    load_balancer_ip = StringField(name="loadBalancerIP")
    load_balancer_source_ranges = ListField(str, name="loadBalancerSourceRanges")
    ports = ListField(ServicePort)
    publish_not_ready_addresses = BoolField(name="publishNotReadyAddresses")
    selector = DictField()
    session_affinity = StringField(name="sessionAffinity")
    session_affinity_config = ModelField(
        SessionAffinityConfig, name="sessionAffinityConfig"
    )
    type = StringField()

    def add_port(
        self, port: int, target_port: int, protocol: str = None, name: str = None
    ):
        service_port = ServicePort()
        service_port.port = port
        service_port.target_port = target_port
        service_port.protocol = protocol
        service_port.name = name
        self.ports.append(service_port)
Exemplo n.º 2
0
class StatusDetails(Model):
    causes = ListField(StatusCause)
    group = StringField()
    kind = StringField()
    name = StringField()
    retry_after_seconds = IntField(name="retryAfterSeconds")
    uid = StringField()
Exemplo n.º 3
0
class ObjectMeta(Model):
    annotations = DictField()
    cluster_name = StringField(name="clusterName")
    creation_timestamp = StringField(name="creationTimestamp")
    deletion_grace_period_seconds = IntField(name="deletionGracePeriodSeconds")
    deletion_timestamp = StringField(name="deletionTimestamp")
    finalizers = ListField()
    generate_name = StringField(name="generateName")
    generation = IntField(name="generation")
    initializers = ModelField(Initializers)
    labels = DictField()
    name = StringField()
    namespace = StringField()
    owner_references = ListField(OwnerReference, name="ownerReferences")
    resource_version = StringField()
    self_link = StringField(name="selfLink")
    uid = StringField()
Exemplo n.º 4
0
class DeploymentStatus(Model):
    available_replicas = IntField(name="availableReplicas")
    collision_count = IntField(name="collisionCount")
    conditions = ListField(DeploymentCondition)
    observed_generation = IntField(name="observedGeneration")
    ready_replicas = IntField(name="readyReplicas")
    replicas = IntField()
    unavailable_replicas = IntField()
    updated_replicas = IntField()
Exemplo n.º 5
0
class Container(Model):
    args = ListField(str)
    command = ListField(str)
    env = ListField(EnvVar)
    env_from = ListField(EnvVarSource, "envFrom")
    image = StringField()
    image_pull_policy = StringField(name="imagePullPolicy")
    lifecycle = ModelField(Lifecycle)
    liveness_probe = ModelField(Probe, name="livenessProbe")
    name = StringField()
    ports = ListField(ContainerPort)  #
    readiness_probe = ModelField(Probe, name="readinessProbe")
    resources = ModelField(ResourceRequirements)
    security_context = ModelField(SecurityContext, "securityContext")
    stdin = BoolField()
    stdin_once = BoolField(name="stdinOnce")
    termination_message_path = StringField(name="terminationMessagePath")
    termination_message_policy = StringField(name="terminationMessagePolicy")
    tty = BoolField()
    volume_devices = ListField(VolumeDevices, name="volumeDevices")
    volume_mounts = ListField(VolumeMount, "volumeMounts")
    working_dir = StringField(name="workingDir")

    def add_port(
        self, name: str = None, container_port: int = None, protocol: str = None
    ):
        port = ContainerPort()
        port.name = name
        port.container_port = container_port
        port.protocol = protocol
        self.ports.append(port)

    def add_env_from(self, typename: str, name: str):
        self.env_from.append({typename: {"name": name}})

    def add_env(self, name: str, value: str):
        env = EnvVar()
        env.name = name
        env.value = value
        self.env.append(env)

    def add_volume_mount(self, name: str, mount_path: str):
        volume = VolumeMount()
        volume.name = name
        volume.mount_path = mount_path
        self.volume_mounts.append(volume)

    def set_image(self, repository: str, registry: str = None, tag: str = None):
        if (repository or repository != "docker.io") and tag:
            self.image = f"{registry}/{repository}:{tag}"
        elif repository or repository != "docker.io":
            self.image = f"{registry}/{repository}"
        elif tag:
            self.image = f"{repository}:tag"
        else:
            raise RuntimeError("This should not happen ever!")
Exemplo n.º 6
0
class PodSpec(Model):
    active_deadline_seconds = IntField(name="activeDeadlineSeconds")
    affinity = ModelField(Affinity)
    automount_service_account_token = BoolField(
        name="automountServiceAccountToken")
    containers = ListField(Container)
    dns_config = ModelField(PodDNSConfig, "dnsConfig")
    dns_policy = EnumField(
        [
            "ClusterFirst", "ClusterFirstWithHostNet", "ClusterFirst",
            "Default", "None"
        ],
        name="dnsPolicy",
    )
    host_aliases = ListField(HostAlias, "hostAliases")
    host_ipc = BoolField(name="hostIPC")
    host_network = BoolField(name="hostNetwork")
    host_pid = BoolField(name="hostPID")
    hostname = StringField()
    image_pull_secrets = ListField(LocalObjectReference, "imagePullSecrets")
    init_containers = ListField(Container, "initContainers")
    node_name = StringField(name="nodeName")
    node_selector = DictField(name="nodeSelector")
    priority = IntField()
    priority_class_name = StringField(name="priorityClassName")
    readiness_gates = ListField(PodReadlinessGate, name="readinessGates")
    restart_policy = EnumField(["Always", "OnFailure", "Never"],
                               name="restartPolicy")
    scheduler_name = StringField(name="schedulerName")
    security_context = ModelField(SecurityContext, "securityContext")
    service_account_name = StringField(name="serviceAccountName")
    share_process_namespace = BoolField(name="shareProcessNamespace")
    subdomain = StringField()
    termination_grace_period_seconds = IntField(
        name="terminationGracePeriodSeconds")
    tolerations = ListField(Toleration, "tolerations")
    volumes = ListField(Volume)
Exemplo n.º 7
0
class LabelSelectorRequirement(Model):
    key = StringField()
    operator = StringField()
    values = ListField(str)
Exemplo n.º 8
0
class Capabilities(Model):
    add = ListField(str)
    drop = ListField(str)
Exemplo n.º 9
0
class Initializers(Model):
    pending = ListField(Initializer)
    result = ModelField(Status)