17.10.18

local-up-cluster.sh w/ crio

From zero

download `go`, and lets install `gimme` as well as `rsync` - critical tools for building kubernetes from scratch.

- https://github.com/travis-ci/gimme is a fast way to install go, after which you can run 'gimme 1.11.1', and copy the output into your terminal.

- export GOPATH=~/go/ # make this an absolute path.  ~ wont work.

- `mkdir -p ~/go/src/github.com/kubernetes/ && cd ~/go/src/github.com/kubernetes/ && git clone https://github.com/kubernetes/kubernetes`

- cd to ~/go/src/github.com/kubernetes/kubernetes

- Now, attempt to run `hack/local-up-cluster.sh`.  First, we setup some CRIO
hacks - which will swap out your container runtime.

```
CGROUP_DRIVER=systemd

CONTAINER_RUNTIME=remote

CONTAINER_RUNTIME_ENDPOINT='unix:///var/run/crio/crio.sock  --runtime-request-timeout=15m'
```

Now, run local-up-cluster.  This will actually compile the kubernetes binaries,
and then run kubernetes from source.

```
./hack/local-up-cluster.sh
```

Once your cluster is up and running , you should be able to run:

```
$GOPATH/src/github.com/k8s.io/kubernetes/_output/local/bin/linux/amd64/kubectl get ns --all-namespaces
NAMESPACE     NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)         AGE
default       kubernetes   ClusterIP   10.0.0.1             443/TCP         1m
kube-system   kube-dns     ClusterIP   10.0.0.10            53/UDP,53/TCP   1m
```

Its assumed that you can alias the above kubectl command so that you don't have to type the full path every time:)

Congratulations : You've just built and deployed kuberenetes locally using an alternative container runtime !


To confirm that your alternate runtime is *actually* being used, lets go back to our friend *jorunald*, and look at the crio
logs:
```
Oct 18 04:24:32 localhost.localdomain crio[1399]: time="2018-10-18 04:24:32.085801416Z" level=info msg="Running conmon under slice kubepods-burstable-podb20a1f8a_d28d_11e8_a869_080027f9fb68.slice and unitName crio-
Oct 18 04:24:32 localhost.localdomain crio[1399]: time="2018-10-18 04:24:32.234287081Z" level=info msg="Got pod network {Name:kube-dns-7d689dcfd8-rggt2 Namespace:kube-system ID:1dcbc756f74f9b0ccdddd8ed3501f17561414
Oct 18 04:24:32 localhost.localdomain crio[1399]: time="2018-10-18 04:24:32.234320632Z" level=info msg="About to add CNI network cni-loopback (type=loopback)"
Oct 18 04:24:32 localhost.localdomain crio[1399]: time="2018-10-18 04:24:32.258630991Z" level=info msg="Got pod network {Name:kube-dns-7d689dcfd8-rggt2 Namespace:kube-system ID:1dcbc756f74f9b0ccdddd8ed3501f17561414
Oct 18 04:24:32 localhost.localdomain crio[1399]: time="2018-10-18 04:24:32.258962606Z" level=info msg="About to add CNI network crio-bridge (type=bridge)"
```

We can see indeed that CRIO has actually done the hard work of starting the container for the kube-dns pod yay

No comments:

Post a Comment