2016-07-07 23:28:46 +03:00
# Configuring the Kubernetes Client - Remote Access
2016-07-07 23:02:28 +03:00
2017-01-06 01:44:05 +03:00
Run the following commands from the machine which will be your Kubernetes Client
2016-07-07 23:26:27 +03:00
## Download and Install kubectl
2016-07-07 23:02:28 +03:00
2016-07-07 23:26:27 +03:00
### OS X
```
2017-07-11 22:05:57 +03:00
wget https://storage.googleapis.com/kubernetes-release/release/v1.7.0/bin/darwin/amd64/kubectl
2016-07-08 14:23:46 +03:00
chmod +x kubectl
2016-07-09 06:59:01 +03:00
sudo mv kubectl /usr/local/bin
2016-07-07 23:26:27 +03:00
```
### Linux
```
2017-07-11 22:05:57 +03:00
wget https://storage.googleapis.com/kubernetes-release/release/v1.7.0/bin/linux/amd64/kubectl
2016-07-08 14:23:46 +03:00
chmod +x kubectl
2016-07-09 06:59:01 +03:00
sudo mv kubectl /usr/local/bin
2016-07-07 23:26:27 +03:00
```
## Configure Kubectl
2016-07-07 23:02:28 +03:00
2016-07-11 20:47:34 +03:00
In this section you will configure the kubectl client to point to the [Kubernetes API Server Frontend Load Balancer ](04-kubernetes-controller.md#setup-kubernetes-api-server-frontend-load-balancer ).
2016-07-07 23:39:33 +03:00
```
2017-03-25 21:45:32 +03:00
KUBERNETES_PUBLIC_ADDRESS=$(gcloud compute addresses describe kubernetes-the-hard-way \
--region us-central1 \
2016-07-09 03:45:22 +03:00
--format 'value(address)')
2016-07-07 23:39:33 +03:00
```
2016-07-11 20:47:34 +03:00
Also be sure to locate the CA certificate [created earlier ](02-certificate-authority.md ). Since we are using self-signed TLS certs we need to trust the CA certificate so we can verify the remote API Servers.
2016-07-07 23:39:33 +03:00
### Build up the kubeconfig entry
The following commands will build up the default kubeconfig file used by kubectl.
2016-07-07 23:26:27 +03:00
```
kubectl config set-cluster kubernetes-the-hard-way \
--certificate-authority=ca.pem \
2016-07-09 03:46:16 +03:00
--embed-certs=true \
2016-09-11 13:53:13 +03:00
--server=https://${KUBERNETES_PUBLIC_ADDRESS}:6443
2016-07-07 23:02:28 +03:00
```
2016-07-07 23:39:33 +03:00
```
2017-03-24 05:48:14 +03:00
kubectl config set-credentials admin \
--client-certificate=admin.pem \
--client-key=admin-key.pem
2016-07-07 23:39:33 +03:00
```
2016-07-07 23:02:28 +03:00
```
2017-03-25 21:45:32 +03:00
kubectl config set-context kubernetes-the-hard-way \
2016-07-07 23:26:27 +03:00
--cluster=kubernetes-the-hard-way \
--user=admin
2016-07-07 23:02:28 +03:00
```
```
2017-03-25 21:45:32 +03:00
kubectl config use-context kubernetes-the-hard-way
2016-07-07 23:02:28 +03:00
```
2016-07-07 23:26:27 +03:00
At this point you should be able to connect securly to the remote API server:
```
kubectl get componentstatuses
```
2017-03-25 21:45:32 +03:00
2016-07-07 23:26:27 +03:00
```
NAME STATUS MESSAGE ERROR
controller-manager Healthy ok
scheduler Healthy ok
etcd-2 Healthy {"health": "true"}
etcd-0 Healthy {"health": "true"}
etcd-1 Healthy {"health": "true"}
```
```
kubectl get nodes
```
2017-03-25 21:45:32 +03:00
2016-07-07 23:02:28 +03:00
```
2017-03-24 14:08:34 +03:00
NAME STATUS AGE VERSION
2017-04-12 17:09:55 +03:00
worker0 Ready 7m v1.6.1
worker1 Ready 5m v1.6.1
worker2 Ready 2m v1.6.1
2016-07-11 20:47:34 +03:00
```