gocli
is a tiny go binary which helps managing the containerized clusters. It
can be used from a docker images, so no need to install it. You can for instance
use a bash alias:
alias gocli="docker run --net=host --privileged --rm -it -v /var/run/docker.sock:/var/run/docker.sock kubevirtci/gocli:latest"
gocli help
Start a k8s cluster which contains of one control-plane and two nodes:
gocli run --random-ports --nodes 3 --background kubevirtci/k8s-1.13.3
Find out the connection details of the cluster:
$ gocli ports k8s
33396
$ gocli scp /etc/kubernetes/admin.conf - > ./kubeconfig
$ kubectl --kubeconfig ./kubeconfig --insecure-skip-tls-verify --server https://localhost:33396 get pods -n kube-system
NAME READY STATUS RESTARTS AGE
etcd-node01 1/1 Running 0 14m
kube-apiserver-node01 1/1 Running 0 13m
kube-controller-manager-node01 1/1 Running 0 14m
kube-dns-6f4fd4bdf-mh6nb 3/3 Running 0 14m
kube-flannel-ds-4bk76 1/1 Running 0 14m
kube-flannel-ds-5zgmt 1/1 Running 1 14m
kube-flannel-ds-qbm2r 1/1 Running 1 14m
kube-proxy-gtvpb 1/1 Running 0 14m
kube-proxy-knc6p 1/1 Running 0 14m
kube-proxy-vx9t6 1/1 Running 0 14m
kube-scheduler-node01 1/1 Running 0 13m
or to permamently edit kubeconfig:
$ gocli scp /etc/kubernetes/admin.conf - > ./kubeconfig
$ kubectl --kubeconfig=./kubeconfig config set-cluster kubernetes --server=https://127.0.0.1:$(gocli ports k8s|tr -d '\r\n')
$ kubectl --kubeconfig=./kubeconfig config set-cluster kubernetes --insecure-skip-tls-verify=true
$ kubectl --kubeconfig ./kubeconfig get pods -n kube-system
NAME READY STATUS RESTARTS AGE
etcd-node01 1/1 Running 0 14m
kube-apiserver-node01 1/1 Running 0 13m
kube-controller-manager-node01 1/1 Running 0 14m
kube-dns-6f4fd4bdf-mh6nb 3/3 Running 0 14m
kube-flannel-ds-4bk76 1/1 Running 0 14m
kube-flannel-ds-5zgmt 1/1 Running 1 14m
kube-flannel-ds-qbm2r 1/1 Running 1 14m
kube-proxy-gtvpb 1/1 Running 0 14m
kube-proxy-knc6p 1/1 Running 0 14m
kube-proxy-vx9t6 1/1 Running 0 14m
kube-scheduler-node01 1/1 Running 0 13m
$ gocli rm
Make sure that node01
resolves to 127.0.0.1
and that you added --ocp-port 8443
when creatin the cluster. If you did that, you can simply access the
webconsole at https://127.0.0.1:8443
. The login credentials are
admin:admin
.
The two preconditions are necessary to make the authentication redirects work.
$ gocli rm