Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Kubernetes-in-Kubernetes example #655

Merged
merged 1 commit into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,35 @@ kubectl create -f k8s.yaml

Watch progress of the cluster setup via the VM console:
```
kubectl attach k8s-0
kubectl attach -it k8s-0
```

After it's complete you can log into the master node:

```
virtletctl ssh ubuntu@k8s-0 -- -i examples/vmkey
virtletctl ssh root@k8s-0 -- -i examples/vmkey
```

There you can wait a bit for k8s nodes and pods to become ready.
You can list them using the following commands inside the VM:

```
kubectl get nodes -w
# Press Ctrl-C when all 3 nodes are present and Ready
kubectl get pods --all-namespaces -o wide -w
# Press Ctrl-C when all the pods are ready
```

You can then deploy and test nginx on the inner cluster:

```
kubectl run nginx --image=nginx --expose --port 80
kubectl get pods -w
# Press Ctrl-C when the pod is ready
kubectl run bbtest --rm --attach --image=docker.io/busybox --restart=Never -- wget -O - http://nginx
```

After that you can follow
[the instructions](../deploy/real-cluster.md) to install Virtlet on
the cluster, but note that you'll have to disable KVM because nested
virtualization is not yet supported by Virtlet.
the cluster if you want, but note that you'll have to disable KVM
because nested virtualization is not yet supported by Virtlet.
21 changes: 6 additions & 15 deletions examples/k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,17 @@ spec:
#!/bin/bash
set -u -e
set -o pipefail
apt-get update
apt-get install -y --force-yes apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

apt-get update
apt-get install -y --force-yes docker.io
apt-get install -y --force-yes kubelet kubeadm kubectl kubernetes-cni jq
# TODO: client-ca-file -- /etc/kubernetes/pki/ca.crt
# XXX: misplaced --feature-gates=... option, but will do for now
sed -i 's/--authorization-mode=Webhook /--feature-gates=DynamicKubeletConfig=true /' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
apt-get install -y docker.io kubelet kubeadm kubectl kubernetes-cni
sed -i 's/--cluster-dns=10\.96\.0\.10/--cluster-dns=10.97.0.10/' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
systemctl daemon-reload
# make k8s-NNN names resolvable
sed -i 's/^search /search k8s.default.svc.cluster.local default.svc.cluster.local svc.cluster.local cluster.local/' /etc/resolv.conf
if [[ $(hostname) =~ -0$ ]]; then
kubeadm init --token adcb82.4eae29627dc4c5a6 --pod-network-cidr=10.200.0.0/16 --service-cidr=10.97.0.0/16 --apiserver-cert-extra-sans=127.0.0.1,localhost
# master node
kubeadm init --token adcb82.4eae29627dc4c5a6 --pod-network-cidr=10.200.0.0/16 --service-cidr=10.97.0.0/16 --apiserver-cert-extra-sans=127.0.0.1,localhost
export KUBECONFIG=/etc/kubernetes/admin.conf
kubectl apply -f "https://git.io/weave-kube-1.6"
export kubever=$(kubectl version | base64 | tr -d '\n')
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$kubever"
while ! kubectl get pods -n kube-system -l k8s-app=kube-dns|grep ' 3/3'; do
sleep 1
done
Expand All @@ -73,9 +66,7 @@ spec:
echo "Master setup complete." >&2
else
# worker node
# FIXME: it should work without --node-name, but it doesn't
# (complains about empty node name)
kubeadm join --token adcb82.4eae29627dc4c5a6 --node-name=$(hostname) k8s-0:6443
kubeadm join --token adcb82.4eae29627dc4c5a6 --discovery-token-unsafe-skip-ca-verification k8s-0.k8s:6443
echo "Node setup complete." >&2
fi
users:
Expand Down