Esempio n. 1
0
def simple_replicaset():
    """Return the Kubernetes config matching the simple-replicaset.yaml manifest."""
    return client.V1ReplicaSet(
        api_version="apps/v1",
        kind="ReplicaSet",
        metadata=client.V1ObjectMeta(
            name="frontend",
            labels={
                "app": "guestbook",
                "tier": "frontend",
            },
        ),
        spec=client.V1ReplicaSetSpec(
            replicas=3,
            selector=client.V1LabelSelector(match_labels={
                "tier": "frontend",
            }, ),
            template=client.V1PodTemplateSpec(
                metadata=client.V1ObjectMeta(labels={
                    "tier": "frontend",
                }, ),
                spec=client.V1PodSpec(containers=[
                    client.V1Container(
                        name="php-redis",
                        image="gcr.io/google_samples/gb-frontend:v3",
                    ),
                ], ),
            ),
        ),
    )
Esempio n. 2
0
def fake_v1_replica_set_error():
    return client.V1ReplicaSet(
        api_version='apps/v1',
        kind='ReplicaSet',
        metadata=client.V1ObjectMeta(name='curry-test001',
                                     namespace='curryns'),
        status=client.V1ReplicaSetStatus(replicas=2, ready_replicas=1))
Esempio n. 3
0
def simple_replicaset():
    """Return the Kubernetes config matching the simple-replicaset.yaml manifest."""
    return client.V1ReplicaSet(
        api_version='apps/v1',
        kind='ReplicaSet',
        metadata=client.V1ObjectMeta(
            name='frontend',
            labels={
                'app': 'guestbook',
                'tier': 'frontend',
            },
        ),
        spec=client.V1ReplicaSetSpec(
            replicas=3,
            selector=client.V1LabelSelector(match_labels={
                'tier': 'frontend',
            }, ),
            template=client.V1PodTemplateSpec(
                metadata=client.V1ObjectMeta(labels={
                    'tier': 'frontend',
                }, ),
                spec=client.V1PodSpec(containers=[
                    client.V1Container(
                        name='php-redis',
                        image='gcr.io/google_samples/gb-frontend:v3',
                    ),
                ], ),
            ),
        ),
    )
Esempio n. 4
0
def construct_replica_set(name, owner_deployment=None):
    """Construct a fake ReplicaSet body"""
    if owner_deployment:
        owner_references = [
            client.V1OwnerReference(
                api_version=owner_deployment.api_version,
                uid=uuid.uuid4().hex,
                name=owner_deployment.metadata.name,
                kind='Deployment',
            )
        ]
        match_labels = owner_deployment.spec.selector.match_labels
    else:
        owner_references = []
        match_labels = {'rs-name': name}

    return client.V1ReplicaSet(
        api_version='extensions/v1beta1',
        kind='ReplicaSet',
        metadata=client.V1ObjectMeta(
            name=name,
            # Set owner reference to deployment
            owner_references=owner_references,
        ),
        spec=client.V1ReplicaSetSpec(
            replicas=1,
            selector=client.V1LabelSelector(match_labels=match_labels),
            template=client.V1PodTemplateSpec(
                spec=client.V1PodSpec(containers=[
                    client.V1Container(image="busybox",
                                       name="main",
                                       command=["sleep", "3600"])
                ]),
                metadata=client.V1ObjectMeta(labels=match_labels, name=name),
            ),
        ),
    )