Пример #1
0
    def test_list_deployments(self, mock_call):
        expected = ['get', 'deployments', '-o', 'json']
        expected_call = ['kubectl', '--namespace', 'test-space']
        expected_call.extend(expected)
        kubectl = Kubectl()
        kubectl.namespace = 'test-space'
        kubectl.list_deployments()

        mock_call.assert_called_once_with(expected_call)
Пример #2
0
    def test_list_deployments_by_selector(self, mock_call):
        expected = ['get', 'deployments', '--selector',
                    'servicegroup=twyla,mylabel=myvalue', '-o', 'json']
        expected_call = ['kubectl', '--namespace', 'test-space']
        expected_call.extend(expected)
        kubectl = Kubectl()
        kubectl.namespace = 'test-space'
        kubectl.list_deployments(selectors={'servicegroup': 'twyla',
                                            'mylabel': 'myvalue'})

        mock_call.assert_called_once_with(expected_call)
Пример #3
0
def cluster_info(dump_to: str, group: str, namespace: str):
    kubectl = Kubectl()
    kubectl.namespace = namespace

    state = kubectl.list_deployments(selectors={'servicegroup': group})
    print_cluster_info(state)

    if dump_to is not None:
        deployable = scrub_cluster_info(state)
        with open(dump_to, mode='w') as fd:
            fd.write(yaml.dump(deployable, default_flow_style=False))