Managing a Kubernetes cluster
Once you have launched a new cluster, you can interact with it using kubectl
and a kubeconfig file.
Prerequisites
You must install the Kubernetes command line tool, kubectl
, on your local computer, and run commands against your cluster.
To install kubectl
, follow the relevant Kubernetes documentation.
Extracting the kubeconfig file
Due to Magnum's security policy configuration, you cannot use the OpenStack CLI for downloading the kubeconfig of a cluster that was created with Breqwatr Cloud Management Panel, or vice versa.
To fetch your kubeconfig, you must always use the same facility that you used to deploy the cluster.
=== "Breqwatr Cloud Management Panel" In the left-hand side pane of the Breqwatr Cloud Management Panel, select Magnum → Clusters. Click on the cluster row to expand the details view, then click the KubeConfig tab. In a second or two, you will see the contents of the kubeconfig file. Click the blue Download KubeConfig button to download it locally.
![Kubeconfig view](assets/shot-07.png)
The kubeconfig file you get has a name similar to this one:
```plain
kubeconfig--<cluster_name>--<region_name>--<alphanum_id>.yaml
```
Feel free to rename it to something simpler, like `config`.
=== "OpenStack CLI" To download the kubeconfig file for your Kubernetes cluster, type the following:
```bash
openstack coe cluster config --dir=${PWD} <cluster-name>
```
After saving the kubeconfig file locally, set the value of variable
KUBECONFIG
to the full path of the file. Type, for example:
export KUBECONFIG=${PWD}/config
If you are currently managing only one cluster, and you already have its
kubeconfig file stored as ~/.kube/config
, then you do not need to set
the KUBECONFIG
variable.
Accessing the Kubernetes cluster with kubectl
You may now use kubectl
to run commands against your cluster. See, for
instance, all cluster nodes...
kubectl get nodes
NAME STATUS ROLES AGE VERSION
bangor-id6nijycp2wy-master-0 Ready master 113m v1.18.6
bangor-id6nijycp2wy-node-0 Ready <none> 111m v1.18.6
...or all running pods in every namespace:
kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-786ffb7797-tw2hg 1/1 Running 0 167m
kube-system coredns-786ffb7797-vbqwn 1/1 Running 0 167m
kube-system csi-cinder-controllerplugin-0 5/5 Running 0 167m
kube-system csi-cinder-nodeplugin-4nr69 2/2 Running 0 166m
kube-system csi-cinder-nodeplugin-vtwqf 2/2 Running 0 167m
kube-system dashboard-metrics-scraper-6b4884c9d5-4mlrg 1/1 Running 0 167m
kube-system k8s-keystone-auth-wk5v2 1/1 Running 0 167m
kube-system kube-dns-autoscaler-75859754fd-2wsd9 1/1 Running 0 167m
kube-system kube-flannel-ds-7z9dp 1/1 Running 0 167m
kube-system kube-flannel-ds-dmvk6 1/1 Running 0 166m
kube-system kubernetes-dashboard-c98496485-stn42 1/1 Running 0 167m
kube-system magnum-metrics-server-79556d6999-xdlpm 1/1 Running 0 167m
kube-system npd-5p6gk 1/1 Running 0 165m
kube-system openstack-cloud-controller-manager-44rz9 1/1 Running 0 167m