markdown 在Ubuntu上安装Kubernetes集群

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 在Ubuntu上安装Kubernetes集群相关的知识,希望对你有一定的参考价值。

Install Kubernetes
==================
This part of the installation is carried out on all nodes.

Perform updates and upgrades:
```bash
apt -y update &&
apt -y full-upgrade --auto-remove &&
apt -y upgrade
```

Install, enable and start Docker:
```bash
apt install -y docker.io &&
systemctl start docker &&
systemctl enable docker
```

Install Kubernetes:
```bash
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add &&
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list &&
apt -y update &&
apt install -y kubelet kubeadm kubectl kubernetes-cni
```

Master node
-----------
This part of the installation is carried out on the **master node only**.

Initialise the master node. If the non default IP address should be used, such as for routeing the cluster node in the same datacenter using private IP addresses, then `--api-advertise-addresses` should be added:
```bash
kubeadm init --apiserver-advertise-address PRIVATE_IP
```

Copy the join command outputted (i.e.`kubeadm join ...`) so that worker nodes can join later on, then create a non-priveledged user as the output suggests (replacing `PASSWORD` as appropriate):
```bash
useradd kubernetes -G sudo -m -s /bin/bash &&
echo "kubernetes:PASSWORD" | chpasswd
```

Copy the config (password required for `sudo`):
```bash
su kubernetes &&
mkdir -p $HOME/.kube &&
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config &&
sudo chown $(id -u):$(id -g) $HOME/.kube/config
```

May not be needed now and Flannel shouldn't be used without giving args on init above. Deploy a CNI (container network interface) to deploy pods to the cluster. `Flannel` is used here, but other [cluster network technologies](https://kubernetes.io/docs/concepts/cluster-administration/networking) are avalible.
```bash
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml &&
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml
```

### Optional
By default pods can't be deployed on master nodes. To allow pods on master nodes and also allow a single node deploy:
```bash
kubectl taint nodes --all node-role.kubernetes.io/master-
```

References
----------
- https://kubernetes.io/docs/setup/independent/install-kubeadm
- https://linuxhint.com/setup-kubernetes-digitalocean
- https://www.techrepublic.com/article/how-to-quickly-install-kubernetes-on-ubuntu
- https://medium.com/@Grigorkh/install-kubernetes-on-ubuntu-1ac2ef522a36
- https://www.mirantis.com/blog/how-install-kubernetes-kubeadm

以上是关于markdown 在Ubuntu上安装Kubernetes集群的主要内容,如果未能解决你的问题,请参考以下文章

markdown 在Windows上安装ubuntu脱机

markdown 在Ubuntu上安装pyenv

markdown 使用Wine在Ubuntu上安装Safari

markdown 在ubuntu上安装casperjs的简单教程

markdown 在Ubuntu上安装Sublime Text 3。

markdown 在Ubuntu 16上安装3节点Kubernetes群集