[VMware Tanzu] Tanzu CLI

Seunghyun Moon·2022년 10월 13일
0

vmware

목록 보기
7/9
post-custom-banner

set context to a worker cluster

Tanzu CLI usage

tanzu init

Management cluster

login - select desired MC

tanzu login

create

tanzu mangement-cluster create {name} --ui

tanzu mc create {name} --file {file}

delete

seems that if not work first need to delete from config file.

tanzu mc delete {mc name}

tanzu config server list
tanzu config server delete {mc name}

location of config gile(kubeconfig)
.kube/config << for worker clusters
.kube-tkg/config << for mgmt clusters

Kubectl

check get clusters, contexts, users

[brewinstall@tanzu-bootstrap-cluster ~]$ kubectl config current-context
tce-management-cluster-admin@tce-management-cluster
[brewinstall@tanzu-bootstrap-cluster ~]$ kubectl config get-contexts
CURRENT   NAME                                                  CLUSTER                  AUTHINFO                       NAMESPACE
*         tce-management-cluster-admin@tce-management-cluster   tce-management-cluster   tce-management-cluster-admin

[brewinstall@tanzu-bootstrap-cluster ~]$ kubectl config get-clusters
NAME
tce-management-cluster
[brewinstall@tanzu-bootstrap-cluster ~]$ kubectl config get-users
NAME
tce-management-cluster-admin

how to delete clusters, contexts, users using kubectl

[brewinstall@tanzu-bootstrap-cluster ~]$ kubectl config delete-context tce-mgmt-cluster-admin@tce-mgmt-cluster
deleted context tce-mgmt-cluster-admin@tce-mgmt-cluster from /home/brewinstall/.kube/config
[brewinstall@tanzu-bootstrap-cluster ~]$
[brewinstall@tanzu-bootstrap-cluster ~]$ vi /home/brewinstall/.kube/config
[brewinstall@tanzu-bootstrap-cluster ~]$ kubectl config delete-cluster tce-mgmt-cluster-admin@tce-mgmt-cluster
error: cannot delete cluster tce-mgmt-cluster-admin@tce-mgmt-cluster, not in /home/brewinstall/.kube/config
[brewinstall@tanzu-bootstrap-cluster ~]$ vi /home/brewinstall/.kube/config
[brewinstall@tanzu-bootstrap-cluster ~]$ kubectl config delete-cluster tce-mgmt-cluster
deleted cluster tce-mgmt-cluster from /home/brewinstall/.kube/config
[brewinstall@tanzu-bootstrap-cluster ~]$ vi /home/brewinstall/.kube/config
[brewinstall@tanzu-bootstrap-cluster ~]$ kubectl config delete-user tce-mgmt-cluster-admin
deleted user tce-mgmt-cluster-admin from /home/brewinstall/.kube/config

context switch

kubectl config use-context my-cluster-admin@my-cluster

get cluster info

kubectl cluster-info

when can't connect to api server

[ec2-user@ip-10-0-31-78 ~]$ kubectl get po

The connection to the server localhost:8080 was refused - did you specify the right host or port?

[ec2-user@ip-10-0-31-78 ~]$ kubectl api-versions
error: couldn't get available api versions from server: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused

resolution

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
profile
I live fullest
post-custom-banner

0개의 댓글