b08ad875eb
Introduces a new sysinv config API for retrieving the Kubernetes cluster access information and security credentials (if configured). The information may be used to configure a remote Kubernetes client with the required configuration to use the Kubernetes API with administrative privileges with either client certificate authentication or token authentication for the kubernetes-admin service account. The following information is available for each cluster: Kubernetes Cluster Name (kubernetes) Kubernetes Release Version Cluster API Endpoint URL Cluster Root CA Certificate Admin Client Certificate Admin Client Key Admin User Name (kubernetes-admin) Admin service account token Story: 2008630 Task: 41836 Signed-off-by: Matt Peters <matt.peters@windriver.com> Change-Id: Ib81c7fcc3a577c1209ab3a0dd882552ba3d2b9db
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
#
|
|
# Copyright (c) 2021 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
from cgtsclient.common import utils
|
|
from cgtsclient import exc
|
|
from collections import OrderedDict
|
|
|
|
|
|
def _print_kube_cluster_show(kube_cluster):
|
|
ordereddata = OrderedDict(sorted(kube_cluster.to_dict().items(),
|
|
key=lambda t: t[0]))
|
|
utils.print_dict(ordereddata, wrap=72)
|
|
|
|
|
|
def do_kube_cluster_list(cc, args):
|
|
"""List all kubernetes clusters"""
|
|
versions = cc.kube_cluster.list()
|
|
fields = ['cluster_name', 'cluster_version', 'cluster_api_endpoint']
|
|
labels = fields
|
|
utils.print_list(versions, fields, labels, sortby=0)
|
|
|
|
|
|
@utils.arg('name', metavar="<cluster-name>",
|
|
help="Kubernetes cluster name", default=None)
|
|
def do_kube_cluster_show(cc, args):
|
|
"""Show kubernetes cluster details"""
|
|
try:
|
|
name = cc.kube_cluster.get(args.name)
|
|
_print_kube_cluster_show(name)
|
|
except exc.HTTPNotFound:
|
|
raise exc.CommandError('kubernetes cluster not found: %s' % args.name)
|