Exemplo n.º 1
0
    def setUp(self):
        self.name = 'testname123'
        self.namespace = 'testnamespace456'

        svc_list = client.V1ServiceList(items=[])
        svc = client.V1Service()
        svc.metadata = client.V1ObjectMeta(name=self.name,
                                           namespace=self.namespace)
        svc.metadata.labels = {
            'operated-by': 'memcached.operator.kubestack.com',
            'heritage': 'kubestack.com',
            'cluster': self.name
        }
        svc_list.items = [svc]
        self.correct_svc_list = svc_list

        cm_list = client.V1ConfigMapList(items=[])
        cm = client.V1ConfigMap()
        cm.metadata = client.V1ObjectMeta(name=self.name,
                                          namespace=self.namespace)
        cm.metadata.labels = {
            'operated-by': 'memcached.operator.kubestack.com',
            'heritage': 'kubestack.com',
            'cluster': self.name
        }
        cm_list.items = [cm]
        self.correct_cm_list = cm_list

        deploy_list = client.AppsV1beta1DeploymentList(items=[])
        memcached_deploy = client.AppsV1beta1Deployment()
        memcached_deploy.metadata = client.V1ObjectMeta(
            name=self.name, namespace=self.namespace)
        memcached_deploy.metadata.labels = {
            'operated-by': 'memcached.operator.kubestack.com',
            'heritage': 'kubestack.com',
            'cluster': self.name
        }
        mcrouter_deploy = client.AppsV1beta1Deployment()
        mcrouter_deploy.metadata = client.V1ObjectMeta(
            name='{}-router'.format(self.name), namespace=self.namespace)
        mcrouter_deploy.metadata.labels = {
            'operated-by': 'memcached.operator.kubestack.com',
            'heritage': 'kubestack.com',
            'cluster': self.name
        }
        deploy_list.items = [memcached_deploy, mcrouter_deploy]
        self.correct_deploy_list = deploy_list
Exemplo n.º 2
0
    def setUp(self):
        self.name = 'testname123'
        self.namespace = 'testnamespace456'

        svc_list = client.V1ServiceList()
        svc = client.V1Service()
        svc.metadata = client.V1ObjectMeta(name=self.name,
                                           namespace=self.namespace)
        svc_list.items = [svc]
        self.correct_svc_list = svc_list

        deploy_list = client.V1beta1DeploymentList()
        deploy = client.V1beta1Deployment()
        deploy.metadata = client.V1ObjectMeta(name=self.name,
                                              namespace=self.namespace)
        deploy_list.items = [deploy]
        self.correct_deploy_list = deploy_list
Exemplo n.º 3
0
 def _mock_list_services(services):
     services_list = client.V1ServiceList(items=services)
     get_k8s().v1api.list_namespaced_service = unittest.mock.Mock(
         return_value=services_list)
     return services
Exemplo n.º 4
0
#!/usr/bin/python
import os
import sys
import re
import yaml

from kubernetes import client, config

config.load_kube_config()
v1 = client.V1ServiceList()

ret = v1.V1ServiAceList()
print(ret)
#for i in ret.items:
#    print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))