| 1 |
# HTTP-Connect Client using UDS Proxy with dial back Agent runs on kubernetes cluster |
| 2 |
|
| 3 |
# Push all images to container registry |
| 4 |
```console |
| 5 |
TAG=$(git rev-parse HEAD) |
| 6 |
make docker-push TAG=${TAG} |
| 7 |
``` |
| 8 |
|
| 9 |
# Start a test web-server as a kubernetes pod & service |
| 10 |
```bash |
| 11 |
kubectl apply -f examples/kubernetes/kubia.yaml |
| 12 |
``` |
| 13 |
|
| 14 |
# Initialize environment variables |
| 15 |
*CLUSTER_CERT* and *CLUSTER_KEY* are certificates used for starting [kubernetes API server](https://kubernetes.io/docs/concepts/cluster-administration/certificates/) |
| 16 |
|
| 17 |
```bash |
| 18 |
CLUSTER_IP=$(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}' | sed -n "s/https\:\/\/\(\S*\).*$/\1/p") |
| 19 |
KUBIA_IP=$(kubectl get svc kubia -o=jsonpath='{.spec.clusterIP}') |
| 20 |
PROXY_IMAGE=$(docker images | grep "proxy-server-" -m1 | awk '{print $1}') |
| 21 |
AGENT_IMAGE=$(docker images | grep "proxy-agent-" -m1 | awk '{print $1}') |
| 22 |
TEST_CLIENT_IMAGE=$(docker images | grep "proxy-test-client-" -m1 | awk '{print $1}') |
| 23 |
SERVER_TOKEN=$(./examples/kubernetes/token_generation.sh 32) |
| 24 |
CLUSTER_CERT=<yourdirectory/server.crt> |
| 25 |
CLUSTER_KEY=</yourdirectory/server.key> |
| 26 |
``` |
| 27 |
|
| 28 |
#### GCE sample configuration |
| 29 |
```bash |
| 30 |
CLUSTER_CERT=/etc/srv/kubernetes/pki/apiserver.crt |
| 31 |
CLUSTER_KEY=/etc/srv/kubernetes/pki/apiserver.key |
| 32 |
``` |
| 33 |
|
| 34 |
# Register SERVER_TOKEN in [static-token-file](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#static-token-file) |
| 35 |
Append the output of the following line to the [static-token-file](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#static-token-file) and restart **kube-apiserver** on the control plane. |
| 36 |
```bash |
| 37 |
echo "${SERVER_TOKEN},system:konnectivity-server,uid:system:konnectivity-server" |
| 38 |
``` |
| 39 |
|
| 40 |
#### GCE sample configuration |
| 41 |
1. [static-token-file](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#static-token-file) location is: **/etc/srv/kubernetes/known_tokens.csv** |
| 42 |
|
| 43 |
1. Restart kube-apiserver |
| 44 |
```bash |
| 45 |
K8S_API_PID=$(sudo crictl ps | grep kube-apiserver | awk '{ print $1; }') |
| 46 |
sudo crictl stop ${K8S_API_PID} |
| 47 |
``` |
| 48 |
|
| 49 |
# Save following config at /etc/srv/kubernetes/konnectivity-server/kubeconfig on control plane VM |
| 50 |
```bash |
| 51 |
SERVER_TOKEN=${SERVER_TOKEN} envsubst < examples/kubernetes/kubeconfig |
| 52 |
``` |
| 53 |
|
| 54 |
# Create a clusterrolebinding allowing proxy-server authenticate proxy-client |
| 55 |
```bash |
| 56 |
kubectl create clusterrolebinding --user system:konnectivity-server --clusterrole system:auth-delegator system:konnectivity-server |
| 57 |
``` |
| 58 |
|
| 59 |
# Start **proxy-server** |
| 60 |
|
| 61 |
- as a [static pod](https://kubernetes.io/docs/tasks/configure-pod-container/static-pod/) with following configuration |
| 62 |
```bash |
| 63 |
TAG=${TAG} PROXY_IMAGE=${PROXY_IMAGE} CLUSTER_CERT=${CLUSTER_CERT} CLUSTER_KEY=${CLUSTER_KEY} envsubst < examples/kubernetes/konnectivity-server.yaml |
| 64 |
``` |
| 65 |
|
| 66 |
- as a kubernetes pod with following configuration |
| 67 |
```bash |
| 68 |
TAG=${TAG} PROXY_IMAGE=${PROXY_IMAGE} CLUSTER_CERT=${CLUSTER_CERT} CLUSTER_KEY=${CLUSTER_KEY} envsubst < examples/kubernetes/konnectivity-server.yaml | kubectl apply -f - |
| 69 |
``` |
| 70 |
|
| 71 |
#### GKE specific configuration |
| 72 |
*/etc/kubernetes/manifests* is a folder where .yaml file needs to be created for static pod |
| 73 |
|
| 74 |
# Start **proxy-agent** as a kubernetes pod |
| 75 |
```bash |
| 76 |
TAG=${TAG} AGENT_IMAGE=${AGENT_IMAGE} CLUSTER_IP=${CLUSTER_IP} envsubst < examples/kubernetes/konnectivity-agent.yaml | kubectl apply -f - |
| 77 |
``` |
| 78 |
|
| 79 |
# Run **test-client** as a [static pod](https://kubernetes.io/docs/tasks/configure-pod-container/static-pod/) with following configuration on same machine where **proxy-server** runs |
| 80 |
```bash |
| 81 |
TAG=${TAG} KUBIA_IP=${KUBIA_IP} TEST_CLIENT_IMAGE=${TEST_CLIENT_IMAGE} envsubst < examples/kubernetes/konnectivity-test-client.yaml |
| 82 |
``` |
| 83 |
|
| 84 |
Last row in the following log file **/var/log/konnectivity-test-client.log** supposed to be: **You've hit kubia** |
| 85 |
|
| 86 |
#### GKE specific configuration |
| 87 |
*/etc/kubernetes/manifests* is a folder where .yaml file needs to be created for static pod |