コード例 #1
0
ファイル: v1.py プロジェクト: machinezone/kubespec
from kubespec import context
from kubespec import types
from kubespec.k8s import base
from kubespec.k8s import v1 as k8sv1
from kubespec.k8s.meta import v1 as metav1
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional, Union

# Policy Type string describes the NetworkPolicy type
# This type is beta-level in 1.8
PolicyType = base.Enum(
    "PolicyType",
    {
        # Egress is a NetworkPolicy that affects egress traffic on selected pods
        "Egress": "Egress",
        # Ingress is a NetworkPolicy that affects ingress traffic on selected pods
        "Ingress": "Ingress",
    },
)


class IPBlock(types.Object):
    """
    IPBlock describes a particular CIDR (Ex. "192.168.1.1/24") that is allowed to the pods
    matched by a NetworkPolicySpec's podSelector. The except entry describes CIDRs that should
    not be included within this rule.
    """
    @context.scoped
    @typechecked
    def __init__(self, cidr: str = "", except_: List[str] = None):
コード例 #2
0
from kubespec import context
from kubespec import types
from kubespec.k8s import base
from kubespec.k8s import v1 as k8sv1
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional

# VolumeBindingMode indicates how PersistentVolumeClaims should be bound.
VolumeBindingMode = base.Enum(
    "VolumeBindingMode",
    {
        # Immediate indicates that PersistentVolumeClaims should be
        # immediately provisioned and bound.  This is the default mode.
        "Immediate": "Immediate",
        # WaitForFirstConsumer indicates that PersistentVolumeClaims
        # should not be provisioned and bound until the first Pod is created that
        # references the PeristentVolumeClaim.  The volume provisioning and
        # binding will occur during Pod scheduing.
        "WaitForFirstConsumer": "WaitForFirstConsumer",
    },
)


class VolumeNodeResources(types.Object):
    """
    VolumeNodeResources is a set of resource limits for scheduling of volumes.
    """
    @context.scoped
    @typechecked
    def __init__(self, count: int = None):
コード例 #3
0
ファイル: v1beta2.py プロジェクト: machinezone/kubespec
# license that can be found in the LICENSE file.

from kubespec import context
from kubespec import types
from kubespec.k8s import base
from kubespec.k8s import runtime
from kubespec.k8s import v1 as k8sv1
from kubespec.k8s.meta import v1 as metav1
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional, Union

DaemonSetUpdateStrategyType = base.Enum(
    "DaemonSetUpdateStrategyType",
    {
        # Replace the old daemons only when it's killed
        "OnDelete": "OnDelete",
        # Replace the old daemons by new ones using rolling update i.e replace them on each node one after the other.
        "RollingUpdate": "RollingUpdate",
    },
)

DeploymentStrategyType = base.Enum(
    "DeploymentStrategyType",
    {
        # Kill all existing pods before creating new ones.
        "Recreate": "Recreate",
        # Replace the old ReplicaSets by new one using rolling update i.e gradually scale down the old ReplicaSets and scale up the new one.
        "RollingUpdate": "RollingUpdate",
    },
)
コード例 #4
0
ファイル: v1beta1.py プロジェクト: machinezone/kubespec
from kubespec import context
from kubespec import types
from kubespec.k8s import base
from kubespec.k8s import v1 as k8sv1
from kubespec.k8s.meta import v1 as metav1
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional, Union

# FSGroupStrategyType denotes strategy types for generating FSGroup values for a
# SecurityContext
FSGroupStrategyType = base.Enum(
    "FSGroupStrategyType",
    {
        # MayRunAs means that container does not need to have FSGroup of X applied.
        # However, when FSGroups are specified, they have to fall in the defined range.
        "MayRunAs": "MayRunAs",
        # MustRunAs meant that container must have FSGroup of X applied.
        "MustRunAs": "MustRunAs",
        # RunAsAny means that container may make requests for any FSGroup labels.
        "RunAsAny": "RunAsAny",
    },
)

# FSType gives strong typing to different file systems that are used by volumes.
FSType = base.Enum(
    "FSType",
    {
        "AWSElasticBlockStore": "awsElasticBlockStore",
        "All": "*",
        "AzureDisk": "azureDisk",
        "AzureFile": "azureFile",
        "CSI": "csi",
コード例 #5
0
ファイル: v2beta1.py プロジェクト: machinezone/kubespec
from typing import Any, Dict, List, Optional


# MetricSourceType indicates the type of metric.
MetricSourceType = base.Enum(
    "MetricSourceType",
    {
        # External is a global metric that is not associated
        # with any Kubernetes object. It allows autoscaling based on information
        # coming from components running outside of cluster
        # (for example length of queue in cloud messaging service, or
        # QPS from loadbalancer running outside of cluster).
        "External": "External",
        # Object is a metric describing a kubernetes object
        # (for example, hits-per-second on an Ingress object).
        "Object": "Object",
        # Pods is a metric describing each pod in the current scale
        # target (for example, transactions-processed-per-second).  The values
        # will be averaged together before being compared to the target value.
        "Pods": "Pods",
        # Resource is a resource metric known to Kubernetes, as
        # specified in requests and limits, describing each pod in the current
        # scale target (e.g. CPU or memory).  Such metrics are built in to
        # Kubernetes, and have special scaling options on top of those available
        # to normal per-pod metrics (the "pods" source).
        "Resource": "Resource",
    },
)


class CrossVersionObjectReference(types.Object):
    """
コード例 #6
0
# Code is generated: DO NOT EDIT

# Copyright 2019 Machine Zone, Inc. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

from kubespec import context
from kubespec import types
from kubespec.certmanager.acme import v1alpha3 as acmev1alpha3
from kubespec.k8s import base
from kubespec.k8s import v1 as k8sv1
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional

KeyAlgorithm = base.Enum("KeyAlgorithm", {"ECDSA": "ecdsa", "RSA": "rsa"})

KeyEncoding = base.Enum("KeyEncoding", {"PKCS1": "pkcs1", "PKCS8": "pkcs8"})

# KeyUsage specifies valid usage contexts for keys.
# See: https://tools.ietf.org/html/rfc5280#section-4.2.1.3
#      https://tools.ietf.org/html/rfc5280#section-4.2.1.12
# Valid KeyUsage values are as follows:
# "signing",
# "digital signature",
# "content commitment",
# "key encipherment",
# "key agreement",
# "data encipherment",
# "cert sign",
# "crl sign",
# "encipher only",
コード例 #7
0
# Copyright 2019 Machine Zone, Inc. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.


from kubespec import context
from kubespec import types
from kubespec.k8s import base
from kubespec.k8s.apiextensions import v1beta1 as apiextensionsv1beta1
from kubespec.k8s.meta import v1 as metav1
from typeguard import check_type, typechecked
from typing import Any, Dict, Optional


ChallengeAction = base.Enum(
    "ChallengeAction", {"CleanUp": "CleanUp", "Present": "Present"}
)


class ChallengeRequest(types.Object):
    """
    ChallengeRequest is a payload that can be sent to external ACME webhook
    solvers in order to 'Present' or 'CleanUp' a challenge with an ACME server.
    """

    @context.scoped
    @typechecked
    def __init__(
        self,
        uid: str = "",
        action: ChallengeAction = None,
コード例 #8
0
from kubespec import types
from kubespec.k8s import base
from kubespec.k8s import runtime
from kubespec.k8s.authentication import v1 as authenticationv1
from kubespec.k8s.meta import v1 as metav1
from typeguard import check_type, typechecked
from typing import Any, Dict, Optional

# Operation is the type of resource operation being checked for admission control
Operation = base.Enum(
    "Operation",
    {
        # Operation constants
        "Connect": "CONNECT",
        # Operation constants
        "Create": "CREATE",
        # Operation constants
        "Delete": "DELETE",
        # Operation constants
        "Update": "UPDATE",
    },
)

# PatchType is the type of patch being used to represent the mutated object
PatchType = base.Enum(
    "PatchType",
    {
        # PatchType constants.
        "JSONPatch": "JSONPatch"
    },
)
コード例 #9
0
# Code is generated: DO NOT EDIT

# Copyright 2019 Machine Zone, Inc. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

from kubespec import context
from kubespec import types
from kubespec.k8s import base
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional

# EgressNetworkPolicyRuleType indicates whether an EgressNetworkPolicyRule allows or denies traffic
EgressNetworkPolicyRuleType = base.Enum("EgressNetworkPolicyRuleType", {
    "Allow": "Allow",
    "Deny": "Deny"
})


class ClusterNetworkEntry(types.Object):
    """
    ClusterNetworkEntry defines an individual cluster network. The CIDRs cannot overlap with other cluster network CIDRs, CIDRs reserved for external ips, CIDRs reserved for service networks, and CIDRs reserved for ingress ips.
    """
    @context.scoped
    @typechecked
    def __init__(self, cidr: str = "", host_subnet_length: int = 0):
        super().__init__()
        self.__cidr = cidr
        self.__host_subnet_length = host_subnet_length

    @typechecked
コード例 #10
0
from kubespec.k8s import base
from kubespec.k8s import runtime
from kubespec.k8s.authentication import v1 as authenticationv1
from kubespec.k8s.meta import v1 as metav1
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional

# Level defines the amount of information logged during auditing
Level = base.Enum(
    "Level",
    {
        # Metadata provides the basic level of auditing.
        "Metadata": "Metadata",
        # None disables auditing
        "None": "None",
        # Request provides Metadata level of auditing, and additionally
        # logs the request object (does not apply for non-resource requests).
        "Request": "Request",
        # RequestResponse provides Request level of auditing, and additionally
        # logs the response object (does not apply for non-resource requests).
        "RequestResponse": "RequestResponse",
    },
)

# Stage defines the stages in request handling that audit events may be generated.
Stage = base.Enum(
    "Stage",
    {
        # The stage for events generated when a panic occurred.
        "Panic": "Panic",
        # The stage for events generated as soon as the audit handler receives the request, and before it
コード例 #11
0
ファイル: v1alpha1.py プロジェクト: machinezone/kubespec
from kubespec import types
from kubespec.k8s import base
from kubespec.k8s import v1 as k8sv1
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional

# AddressType represents the type of address referred to by an endpoint.
AddressType = base.Enum(
    "AddressType",
    {
        # FQDN represents a FQDN.
        "FQDN": "FQDN",
        # IP represents an IP Address.
        # This address type has been deprecated and has been replaced by the IPv4
        # and IPv6 adddress types. New resources with this address type will be
        # considered invalid. This will be fully removed in 1.18.
        # +deprecated
        "IP": "IP",
        # IPv4 represents an IPv4 Address.
        "IPv4": "IPv4",
        # IPv6 represents an IPv6 Address.
        "IPv6": "IPv6",
    },
)


class EndpointConditions(types.Object):
    """
    EndpointConditions represents the current condition of an endpoint.
    """
    @context.scoped
コード例 #12
0
ファイル: resource.py プロジェクト: machinezone/kubespec
import re
from copy import copy
from typing import Dict, Union, Tuple

from kubespec.k8s import base
from kubespec import types
from typeguard import typechecked

# Format lists the three possible formattings of a quantity.
Format = base.Enum(
    "Format",
    {
        # e.g., 12Mi (12 * 2^20)
        "BinarySI": "BinarySI",
        # e.g., 12e6
        "DecimalExponent": "DecimalExponent",
        # e.g., 12M  (12 * 10^6)
        "DecimalSI": "DecimalSI",
    },
)


_suffixes: Dict[str, Tuple[int, int, Format]] = {  # str -> (base, exp, fmt)
    # Decimal
    "": (10, 0, Format.DecimalSI),
    "n": (10, -9, Format.DecimalSI),
    "u": (10, -6, Format.DecimalSI),
    "m": (10, -3, Format.DecimalSI),
    "k": (10, 3, Format.DecimalSI),
    "M": (10, 6, Format.DecimalSI),
コード例 #13
0
# license that can be found in the LICENSE file.

from kubespec import context
from kubespec import types
from kubespec.k8s import base
from kubespec.k8s import v1 as k8sv1
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional

# FSGroupStrategyType denotes strategy types for generating FSGroup values for a
# SecurityContext
FSGroupStrategyType = base.Enum(
    "FSGroupStrategyType",
    {
        # container must have FSGroup of X applied.
        "MustRunAs": "MustRunAs",
        # container may make requests for any FSGroup labels.
        "RunAsAny": "RunAsAny",
    },
)

# FS Type gives strong typing to different file systems that are used by volumes.
FSType = base.Enum(
    "FSType",
    {
        "AWSElasticBlockStore": "awsElasticBlockStore",
        "All": "*",
        "AzureDisk": "azureDisk",
        "AzureFile": "azureFile",
        "CSI": "csi",
        "CephFS": "cephFS",
コード例 #14
0
from kubespec import context
from kubespec import types
from kubespec.k8s import base
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional, Union


# InsecureEdgeTerminationPolicyType dictates the behavior of insecure
# connections to an edge-terminated route.
InsecureEdgeTerminationPolicyType = base.Enum(
    "InsecureEdgeTerminationPolicyType",
    {
        # Allow allows insecure connections for an edge-terminated route.
        "Allow": "Allow",
        # None disables insecure connections for an edge-terminated route.
        "None": "None",
        # Redirect redirects insecure connections for an edge-terminated route.
        # As an example, for routers that support HTTP and HTTPS, the
        # insecure HTTP connections will be redirected to use HTTPS.
        "Redirect": "Redirect",
    },
)


# TLSTerminationType dictates where the secure communication will stop
# TODO: Reconsider this type in v2
TLSTerminationType = base.Enum(
    "TLSTerminationType",
    {
        # Edge terminate encryption at the edge router.
        "Edge": "edge",
コード例 #15
0
# license that can be found in the LICENSE file.

from kubespec import context
from kubespec import types
from kubespec.k8s import base
from kubespec.k8s import runtime
from kubespec.openshift.config import v1 as configv1
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional

GrantHandlerType = base.Enum(
    "GrantHandlerType",
    {
        # auto auto-approves client authorization grant requests
        "Auto": "auto",
        # deny auto-denies client authorization grant requests
        "Deny": "deny",
        # prompt prompts the user to approve new client authorization grant requests
        "Prompt": "prompt",
    },
)


class AllowAllPasswordIdentityProvider(base.TypedObject):
    """
    AllowAllPasswordIdentityProvider provides identities for users authenticating using non-empty passwords
    """
    @context.scoped
    @typechecked
    def __init__(self):
        super().__init__(
コード例 #16
0
ファイル: v1.py プロジェクト: machinezone/kubespec
from kubespec import context
from kubespec import types
from kubespec.k8s import base
from kubespec.k8s.meta import v1 as metav1
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional

# ConsoleLinkLocationSelector is a set of possible menu targets to which a link may be appended.
ConsoleLinkLocation = base.Enum(
    "ConsoleLinkLocation",
    {
        # ApplicationMenu indicates that the link should appear inside the application menu of the console.
        "ApplicationMenu": "ApplicationMenu",
        # HelpMenu indicates that the link should appear in the help menu in the console.
        "HelpMenu": "HelpMenu",
        # NamespaceDashboard indicates that the link should appear in the namespaced dashboard of the console.
        "NamespaceDashboard": "NamespaceDashboard",
        # UserMenu indicates that the link should appear in the user menu in the console.
        "UserMenu": "UserMenu",
    },
)

# ConsoleNotificationLocationSelector is a set of possible notification targets
# to which a notification may be appended.
ConsoleNotificationLocation = base.Enum(
    "ConsoleNotificationLocation",
    {
        # BannerBottom indicates that the notification should appear at the bottom of the console.
        "BannerBottom": "BannerBottom",
        # BannerTop indicates that the notification should appear at the top of the console.
コード例 #17
0
ファイル: v1beta1.py プロジェクト: machinezone/kubespec
# Copyright 2019 Machine Zone, Inc. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

from kubespec import context
from kubespec import types
from kubespec.k8s import base
from kubespec.k8s.meta import v1 as metav1
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional

FailurePolicyType = base.Enum(
    "FailurePolicyType",
    {
        # Fail means that an error calling the webhook causes the admission to fail.
        "Fail": "Fail",
        # Ignore means that an error calling the webhook is ignored.
        "Ignore": "Ignore",
    },
)

# MatchPolicyType specifies the type of match policy
MatchPolicyType = base.Enum(
    "MatchPolicyType",
    {
        # Equivalent means requests should be sent to the webhook if they modify a resource listed in rules via another API group or version.
        "Equivalent": "Equivalent",
        # Exact means requests should only be sent to the webhook if they exactly match a given rule
        "Exact": "Exact",
    },
)
コード例 #18
0
# occurred in a status response. An operation may have multiple causes for a
# status (whether Failure or Success).
CauseType = base.Enum(
    "CauseType",
    {
        # FieldManagerConflict is used to report when another client claims to manage this field,
        # It should only be returned for a request using server-side apply.
        "FieldManagerConflict": "FieldManagerConflict",
        # FieldValueDuplicate is used to report collisions of values that must be
        # unique (e.g. unique IDs).
        "FieldValueDuplicate": "FieldValueDuplicate",
        # FieldValueInvalid is used to report malformed values (e.g. failed regex
        # match).
        "FieldValueInvalid": "FieldValueInvalid",
        # FieldValueNotFound is used to report failure to find a requested value
        # (e.g. looking up an ID).
        "FieldValueNotFound": "FieldValueNotFound",
        # FieldValueNotSupported is used to report valid (as per formatting rules)
        # values that can not be handled (e.g. an enumerated string).
        "FieldValueNotSupported": "FieldValueNotSupported",
        # FieldValueRequired is used to report required values that are not
        # provided (e.g. empty strings, null values, or empty arrays).
        "FieldValueRequired": "FieldValueRequired",
        # UnexpectedServerResponse is used to report when the server responded to the client
        # without the expected return type. The presence of this cause indicates the error may be
        # due to an intervening proxy or the server software malfunctioning.
        "UnexpectedServerResponse": "UnexpectedServerResponse",
    },
)

# DeletionPropagation decides if a deletion will propagate to the dependents of
コード例 #19
0
# license that can be found in the LICENSE file.

from kubespec import context
from kubespec import types
from kubespec.k8s import base
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional

# FlowDistinguisherMethodType is the type of flow distinguisher method
FlowDistinguisherMethodType = base.Enum(
    "FlowDistinguisherMethodType",
    {
        # ByNamespace specifies that the flow distinguisher is the namespace of the
        # object that the request acts upon. If the object is not namespaced, or if the request is a non-resource
        # request, then the distinguisher will be the empty string. An example usage of this type is to provide
        # some insulation between tenants in a situation where there are multiple tenants and each namespace
        # is dedicated to a tenant.
        "ByNamespace": "ByNamespace",
        # ByUser specifies that the flow distinguisher is the username in the request.
        # This type is used to provide some insulation between users.
        "ByUser": "******",
    },
)

# LimitResponseType identifies how a Limited priority level handles a request that can not be executed right now
LimitResponseType = base.Enum(
    "LimitResponseType",
    {
        # Queue means that requests that can not be executed right now are queued until they can be executed or a queuing limit is hit
        "Queue": "Queue",
        # Reject means that requests that can not be executed right now are rejected
        "Reject": "Reject",
コード例 #20
0
ファイル: v2alpha1.py プロジェクト: machinezone/kubespec
from kubespec import types
from kubespec.k8s import base
from kubespec.k8s.batch import v1 as batchv1
from typeguard import check_type, typechecked
from typing import Any, Dict, Optional

# ConcurrencyPolicy describes how the job will be handled.
# Only one of the following concurrent policies may be specified.
# If none of the following policies is specified, the default one
# is AllowConcurrent.
ConcurrencyPolicy = base.Enum(
    "ConcurrencyPolicy",
    {
        # Allow allows CronJobs to run concurrently.
        "Allow": "Allow",
        # Forbid forbids concurrent runs, skipping next run if previous
        # hasn't finished yet.
        "Forbid": "Forbid",
        # Replace cancels currently running job and replaces it with a new one.
        "Replace": "Replace",
    },
)


class JobTemplateSpec(base.NamespacedMetadataObject):
    """
    JobTemplateSpec describes the data a Job should have when created from a template
    """
    @context.scoped
    @typechecked
    def __init__(
        self,
コード例 #21
0
ファイル: v1.py プロジェクト: machinezone/kubespec
from kubespec import context
from kubespec import types
from kubespec.k8s import base
from kubespec.k8s import v1 as k8sv1
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional, Union


# DeploymentStrategyType refers to a specific DeploymentStrategy implementation.
DeploymentStrategyType = base.Enum(
    "DeploymentStrategyType",
    {
        # Custom is a user defined strategy.
        "Custom": "Custom",
        # Recreate is a simple strategy suitable as a default.
        "Recreate": "Recreate",
        # Rolling uses the Kubernetes RollingUpdater.
        "Rolling": "Rolling",
    },
)


# DeploymentTriggerType refers to a specific DeploymentTriggerPolicy implementation.
DeploymentTriggerType = base.Enum(
    "DeploymentTriggerType",
    {
        # ConfigChange will create new deployments in response to changes to
        # the ControllerTemplate of a DeploymentConfig.
        "ConfigChange": "ConfigChange",
        # ImageChange will create new deployments in response to updated tags from
コード例 #22
0
from kubespec import context
from kubespec import types
from kubespec.k8s import base
from kubespec.k8s import v1 as k8sv1
from typeguard import check_type, typechecked
from typing import Any, Dict, List, Optional

# VolumeBindingMode indicates how PersistentVolumeClaims should be bound.
VolumeBindingMode = base.Enum(
    "VolumeBindingMode",
    {
        # Immediate indicates that PersistentVolumeClaims should be
        # immediately provisioned and bound.  This is the default mode.
        "Immediate": "Immediate",
        # WaitForFirstConsumer indicates that PersistentVolumeClaims
        # should not be provisioned and bound until the first Pod is created that
        # references the PeristentVolumeClaim.  The volume provisioning and
        # binding will occur during Pod scheduing.
        "WaitForFirstConsumer": "WaitForFirstConsumer",
    },
)

# VolumeLifecycleMode is an enumeration of possible usage modes for a volume
# provided by a CSI driver. More modes may be added in the future.
VolumeLifecycleMode = base.Enum(
    "VolumeLifecycleMode",
    {
        # Ephemeral indicates that the driver can be used for
        # ephemeral inline volumes. Such volumes are specified inside the pod
        # spec with a CSIVolumeSource and, as far as Kubernetes is concerned, have