Last active
June 5, 2018 07:50
-
-
Save cyrildiagne/bbb586632f6ef2f8bf82f420bb054a58 to your computer and use it in GitHub Desktop.
Kubernetes cluster with KubeADM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo kubeadm reset | |
sudo curl -L git.io/weave -o /usr/local/bin/weave | |
sudo chmod a+x /usr/local/bin/weave | |
sudo weave reset | |
rm ~/.kube/config | |
sudo systemctl restart docker | |
sudo systemctl restart kubelet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "password" | sudo -S ls | |
for i in {1..200}; do sudo swapoff -a && sleep 0.1; done & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for i in {1..200}; do sudo swapoff -a && sleep 0.1; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt remove -qy kubelet kubeadm kubectl | |
# Based on https://stackoverflow.com/questions/49721708/how-to-install-specific-version-of-kubernetes | |
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - && \ | |
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list && \ | |
sudo apt-get update -q && \ | |
sudo apt-get install -qy kubelet=1.9.6-00 kubectl=1.9.6-00 kubeadm=1.9.6-00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo -i | |
apt-get update | |
apt-get install -y apt-transport-https | |
apt-get install -y curl | |
# add repo | |
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | |
cat <<EOF > /etc/apt/sources.list.d/kubernetes.list | |
deb http://apt.kubernetes.io/ kubernetes-xenial main | |
EOF | |
# update repo list | |
apt-get update | |
# install docker | |
apt-get install -y docker.io | |
# install kubernetes tools | |
apt-get install -y kubelet kubeadm kubectl kubernetes-cni | |
# init kubeadm | |
kubeadm init | |
# make kubectl work for your non-root user | |
exit | |
mkdir -p $HOME/.kube | |
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | |
sudo chown $(id -u):$(id -g) $HOME/.kube/config | |
# setup pod network Weavenet | |
export kubever=$(kubectl version | base64 | tr -d '\n') | |
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$kubever" | |
systemctl restart docker && systemctl restart kubelet | |
# ADD K8-nvidia plugin: | |
kubectl create -f https://raw.githubusercontent.com/NVIDIA/k8s-device-plugin/v1.9/nvidia-device-plugin.yml | |
# Add Dashboard | |
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml | |
# Add metrics collection | |
kubectl create -f https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/influxdb.yaml | |
kubectl create -f https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/grafana.yaml | |
kubectl create -f https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/heapster.yaml | |
kubectl create -f https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/rbac/heapster-rbac.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get update | |
apt-get install -y \ | |
apt-transport-https \ | |
ca-certificates \ | |
curl \ | |
software-properties-common | |
# | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
add-apt-repository \ | |
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) \ | |
stable" | |
# Add the package repositories | |
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \ | |
sudo apt-key add - | |
curl -s -L https://nvidia.github.io/nvidia-docker/ubuntu16.04/amd64/nvidia-docker.list | \ | |
sudo tee /etc/apt/sources.list.d/nvidia-docker.list | |
apt-get update | |
# Install nvidia-docker2 and reload the Docker daemon configuration | |
apt-get install -y docker-ce=17.12.0~ce-0~ubuntu nvidia-docker2=2.0.2+docker17.12.0-1 | |
pkill -SIGHUP dockerd | |
# add repo | |
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | |
cat <<EOF > /etc/apt/sources.list.d/kubernetes.list | |
deb http://apt.kubernetes.io/ kubernetes-xenial main | |
EOF | |
# update repo list | |
apt-get update | |
# install kubernetes tools | |
apt-get install -y kubelet kubeadm kubectl kubernetes-cni | |
cat <<EOM > /etc/docker/daemon.json | |
{ | |
"default-runtime": "nvidia", | |
"runtimes": { | |
"nvidia": { | |
"path": "/usr/bin/nvidia-container-runtime", | |
"runtimeArgs": [] | |
} | |
} | |
} | |
EOM | |
# sudo vim /etc/systemd/system/kubelet.service.d/10-kubeadm.conf | |
# Environment="KUBELET_EXTRA_ARGS=--feature-gates=DevicePlugins=true" | |
# systemctl restart docker && systemctl restart kubelet | |
# init kubeadm | |
# kubeadm join <TOKEN> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment