2017-08-29 00:19:25 +03:00
# Configuring kubectl for Remote Access
In this lab you will generate a kubeconfig file for the `kubectl` command line utility based on the `admin` user credentials.
> Run the commands in this lab from the same directory used to generate the admin client certificates.
## The Admin Kubernetes Configuration File
Each kubeconfig requires a Kubernetes API Server to connect to. To support high availability the IP address assigned to the external load balancer fronting the Kubernetes API Servers will be used.
Generate a kubeconfig file suitable for authenticating as the `admin` user:
```
2018-05-12 19:54:18 +03:00
{
2019-03-20 07:34:49 +03:00
KUBERNETES_LB_ADDRESS=192.168.5.30
2017-08-29 00:19:25 +03:00
2018-05-12 19:54:18 +03:00
kubectl config set-cluster kubernetes-the-hard-way \
2019-03-20 07:34:49 +03:00
--certificate-authority=ca.crt \
2018-05-12 19:54:18 +03:00
--embed-certs=true \
2019-03-20 07:34:49 +03:00
--server=https://${KUBERNETES_LB_ADDRESS}:6443
2017-08-29 00:19:25 +03:00
2018-05-12 19:54:18 +03:00
kubectl config set-credentials admin \
2019-03-20 07:34:49 +03:00
--client-certificate=admin.crt \
--client-key=admin.key
2017-08-29 00:19:25 +03:00
2018-05-12 19:54:18 +03:00
kubectl config set-context kubernetes-the-hard-way \
--cluster=kubernetes-the-hard-way \
--user=admin
kubectl config use-context kubernetes-the-hard-way
}
2017-08-29 00:19:25 +03:00
```
## Verification
Check the health of the remote Kubernetes cluster:
```
kubectl get componentstatuses
```
> output
```
2018-05-12 19:54:18 +03:00
NAME STATUS MESSAGE ERROR
2017-09-04 00:18:03 +03:00
controller-manager Healthy ok
scheduler Healthy ok
2018-05-12 19:54:18 +03:00
etcd-1 Healthy {"health":"true"}
etcd-0 Healthy {"health":"true"}
2017-08-29 00:19:25 +03:00
```
List the nodes in the remote Kubernetes cluster:
```
kubectl get nodes
```
> output
```
2018-09-30 22:35:05 +03:00
NAME STATUS ROLES AGE VERSION
2019-06-16 12:53:30 +03:00
worker-1 NotReady < none > 118s v1.13.0
worker-2 NotReady < none > 118s v1.13.0
2017-08-29 00:19:25 +03:00
```
2019-06-16 12:53:30 +03:00
Note: It is OK for the worker node to be in a `NotReady` state. Worker nodes will come into `Ready` state once networking is configured.
2017-08-29 00:19:25 +03:00
2019-03-20 07:34:49 +03:00
Next: [Deploy Pod Networking ](12-configure-pod-networking.md )