-
Notifications
You must be signed in to change notification settings - Fork 799
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: zsnmwy <[email protected]>
- Loading branch information
Showing
36 changed files
with
466 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
window.MathJax = { | ||
tex: { | ||
inlineMath: [["\\(", "\\)"]], | ||
displayMath: [["\\[", "\\]"]], | ||
processEscapes: true, | ||
processEnvironments: true | ||
}, | ||
options: { | ||
ignoreHtmlClass: ".*|", | ||
processHtmlClass: "arithmatex" | ||
} | ||
}; | ||
|
||
document$.subscribe(() => { | ||
MathJax.typesetPromise() | ||
}) |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.md-nav__title { | ||
display: none; | ||
} | ||
|
||
.arithmatex { | ||
font-size: 0.85rem; | ||
} | ||
|
||
foreignObject > div { | ||
font-size: 0.85rem; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
setTimeout(function () { | ||
const requestAnimationFrame = window.requestAnimationFrame; | ||
const requestIdleCallback = window.requestIdleCallback; | ||
requestIdleCallback(()=> { | ||
requestAnimationFrame(()=> { | ||
// Remove # when use markdown annotations | ||
const mdAnnotations = document.querySelectorAll(".md-annotation") | ||
for (let i = 0; i < mdAnnotations.length; i++) { | ||
let tmp = mdAnnotations[i] | ||
let parentChinldNodes = tmp.parentElement.childNodes | ||
if (parentChinldNodes[0].data === '#'){ | ||
parentChinldNodes[0].remove() | ||
} | ||
} | ||
|
||
// Handle tab label click | ||
const labels = document.querySelectorAll("div.tabbed-labels > label") | ||
for (let i = 0; i < labels.length; i++) { | ||
let tmp = labels[i] | ||
tmp.onclick = () => { | ||
for (const label of labels) { | ||
if (label.textContent === tmp.textContent) { | ||
label.click() | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
}) | ||
},1) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
# Install Kubernetes Via Kubeadm In Ubuntu | ||
|
||
If you are using Macbook, start from here: | ||
|
||
## Download images and tools | ||
|
||
### Install virtualbox | ||
|
||
https://www.virtualbox.org/wiki/Downloads | ||
|
||
From System Preference -> Security & Privacy, allow Oracle access | ||
|
||
From Virtualbox -> File -> Host Network Manager, click Create button to create one | ||
|
||
### Install ubuntu iso from below link | ||
|
||
https://releases.ubuntu.com/20.04/ | ||
|
||
## Installation and configuration | ||
|
||
### Configuration virtualbox | ||
|
||
#### Open virtualbox manager console | ||
|
||
#### Ensure you have correct host network manager settings | ||
|
||
- properties -> vboxnet0 -> 192.168.34.1/24 | ||
- If the subnet is different, you can edit and update it | ||
- Do not enable dhcp | ||
|
||
### Boot new VM | ||
|
||
- Click new button | ||
- Choose OS as ubuntu 64bit and 30G disk, make sure your #CPU>=2 | ||
- Start VM, choose the downloaded ubuntu ISO and follow the installation wizard | ||
- Specify username/password like cadmin/cadmin | ||
- Install ssh server, enable and start the service | ||
- Do not install built-in kubenernetes | ||
- Wait enough long for the os installation complete | ||
|
||
### Shutdown the OS, and set 2nd network adapter | ||
|
||
- Go to VM->settings->network->adapter 2 | ||
- Enable the adapter and select host only adapter, and choose vboxnet0, `vboxnet0` the host network name configured above | ||
|
||
### Login to the system and set ip for second adapter | ||
|
||
```sh | ||
vi /etc/netplan/00-installer-config.yaml | ||
|
||
network: | ||
ethernets: | ||
enp0s3: | ||
dhcp4: true | ||
enp0s8: | ||
dhcp4: no | ||
addresses: | ||
- 192.168.34.2/24 | ||
version: 2 | ||
``` | ||
|
||
```sh | ||
netplan apply | ||
``` | ||
|
||
### Network configuration | ||
|
||
Now your VM has two adapters: | ||
|
||
- One is NAT which will get an IP automatically, generally it's 10.0.2.15, this interface is for external access from your VM | ||
- One is host adapter which need create extra ip, which is configured as 192.168.34.2 | ||
the reason we need the host adapter and static IP is then we can set this static IP as k8s advertise IP and you can move your VM in different everywhere.(otherwise your VM IP would be changed in different environment) | ||
|
||
### Set no password for sudo | ||
|
||
```sh | ||
%sudo ALL=(ALL:ALL) NOPASSWD:ALL | ||
``` | ||
|
||
### Swap off | ||
|
||
```sh | ||
swapoff -a | ||
vi /etc/fstab | ||
remove the line with swap keyword | ||
``` | ||
|
||
## Install docker | ||
|
||
```sh | ||
apt install docker.io | ||
``` | ||
|
||
### Update cgroupdriver to systemd | ||
|
||
```sh | ||
vi /etc/docker/daemon.json | ||
{ | ||
"exec-opts": ["native.cgroupdriver=systemd"] | ||
} | ||
systemctl daemon-reload | ||
systemctl restart docker | ||
``` | ||
|
||
### Letting iptables see bridged traffic | ||
|
||
```shell | ||
$ cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf | ||
br_netfilter | ||
EOF | ||
|
||
$ cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf | ||
net.bridge.bridge-nf-call-ip6tables = 1 | ||
net.bridge.bridge-nf-call-iptables = 1 | ||
EOF | ||
$ sudo sysctl --system | ||
``` | ||
|
||
### Update the apt package index and install packages needed to use the Kubernetes apt repository: | ||
|
||
```shell | ||
$ sudo apt-get update | ||
$ sudo apt-get install -y apt-transport-https ca-certificates curl | ||
``` | ||
|
||
## Install kubeadm | ||
|
||
```shell | ||
$ sudo curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add - | ||
``` | ||
|
||
### Add the Kubernetes apt repository | ||
|
||
```shell | ||
$ sudo tee /etc/apt/sources.list.d/kubernetes.list <<-'EOF' | ||
deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main | ||
EOF | ||
``` | ||
|
||
### Update apt package index, install kubelet, kubeadm and kubectl | ||
|
||
```shell | ||
$ sudo apt-get update | ||
$ sudo apt-get install -y kubelet kubeadm kubectl | ||
$ sudo apt-mark hold kubelet kubeadm kubectl | ||
``` | ||
|
||
### kubeadm init | ||
```shell | ||
$ echo "192.168.34.2 cncamp.com" >> /etc/hosts | ||
``` | ||
|
||
```shell | ||
$ kubeadm init \ | ||
--image-repository registry.aliyuncs.com/google_containers \ | ||
--kubernetes-version v1.22.2 \ | ||
--pod-network-cidr=192.168.0.0/16 \ | ||
--apiserver-advertise-address=192.168.34.2 | ||
``` | ||
|
||
### Copy kubeconfig | ||
|
||
```shell | ||
$ mkdir -p $HOME/.kube | ||
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | ||
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config | ||
``` | ||
|
||
### Untaint master | ||
|
||
```shell | ||
$ kubectl taint nodes --all node-role.kubernetes.io/master- | ||
``` | ||
|
||
## Install calico cni plugin | ||
|
||
https://docs.projectcalico.org/getting-started/kubernetes/quickstart | ||
|
||
```shell | ||
$ kubectl create -f https://docs.projectcalico.org/manifests/tigera-operator.yaml | ||
$ kubectl create -f https://docs.projectcalico.org/manifests/custom-resources.yaml | ||
``` | ||
|
||
## if you want to enable containerd during start, set the cri-socket parameter during kubeadm init | ||
``` | ||
kubeadm init \ | ||
--image-repository registry.aliyuncs.com/google_containers \ | ||
--kubernetes-version v1.22.2 \ | ||
--pod-network-cidr=192.168.0.0/16 \ | ||
--cri-socket /run/containerd/containerd.sock \ | ||
--apiserver-advertise-address=192.168.34.2 | ||
``` | ||
|
||
## Resize VM | ||
|
||
### fdisk | ||
|
||
```sh | ||
fdisk /dev/sda | ||
p - partition | ||
n - new | ||
``` | ||
|
||
### Create new pv | ||
|
||
```sh | ||
pvcreate /dev/sda4 | ||
vgdisplay | ||
``` | ||
|
||
### Add new pv to vg | ||
|
||
```sh | ||
vgextend ubuntu-vg /dev/sda4 | ||
``` | ||
|
||
### Check rootfs lv path | ||
|
||
```sh | ||
vgdisplay | ||
lvdisplay | ||
``` | ||
|
||
### Resize root fix | ||
|
||
```sh | ||
lvextend --size +19.99G --resizefs /dev/ubuntu-vg/ubuntu-lv | ||
``` |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,87 @@ | ||
### Install Kubernetes Cluster | ||
# Install Kubernetes Cluster | ||
|
||
### kubeadm | ||
## 一些小建议 | ||
|
||
众多初学者在入门Kubernetes的时候,第一步是安装Kubernetes集群,并在此过程中消耗大量的时间。但是,如果没有足够的耐心,将很有可能被各种Kubernetes的众多新概念所劝退。 | ||
|
||
所以在此,建议初学者先利用便捷的工具安装一个学习用的测试集群,利用测试集群先学习Kubernetes中的新概念。 | ||
|
||
了解核心组件的工作原理后,再尝试自行对组件进行调参。 | ||
|
||
## 选择合适的安装工具 | ||
|
||
在此小节,将会为你推荐安装集群的工具以及Kubernetes发行版本。 | ||
|
||
标准Kubernetes集群的最低要求: | ||
|
||
1. 一个Master节点,2C4G | ||
2. 一个Node节点,2C4G | ||
|
||
该配置可以满足大多数的单应用,基本满足单个模块的学习。 | ||
|
||
但是,无法满足多个应用同时运行或者运行监控套件的需求。 | ||
|
||
--- | ||
|
||
如果无法提供每个节点4G的资源,那么可以选择k3s或者将节点运行在Docker中。 | ||
|
||
**k3s在512MB的树莓派都可以跑起来。** | ||
|
||
!!! tips | ||
点击名称,可直接跳转到该工具介绍 | ||
|
||
``` mermaid | ||
graph TB | ||
A[Start] --> B{Memory For Each Node > 4GB?}; | ||
B --> |Yes| C("kubeadm (Recommend)") & J(kubekey) & K(sealyun); | ||
B --> |No| D{Running in Docker?}; | ||
D --> |Yes| E("kind (Recommend)") & F(k3d) & H(minikube); | ||
D --> |No| G("k3s (Recommend)"); | ||
click C "/k8s-install/readme/#kubeadm" | ||
``` | ||
|
||
|
||
## kubeadm | ||
|
||
通过 kubeadm 安装,需要手工安装 docker,kubelet,kubeadm 等 | ||
|
||
- [ubuntu 安装](k8s-by-kubeadm) | ||
- [centos 安装](kubeadm-centos7-install.md) @水果爸爸 | ||
- [Official Documentation](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/) | ||
- [Install Kubernetes Via Kubeadm In Ubuntu](k8s-by-kubeadm/index.md) | ||
- [Install Kubernetes Via Kubeadm In CentOS](kubeadm-centos7-install.md) @水果爸爸 | ||
|
||
### kind | ||
## kind | ||
|
||
通过 [kind](1.2.kind-setup.md) 安装,全自动,无手工步骤,快捷简单,但是节点是基于容器而不是虚拟机的。 | ||
|
||
### minikube | ||
## k3s | ||
|
||
Lightweight Kubernetes. Production ready, easy to install, half the memory, all in a binary less than 100 MB. | ||
|
||
Great for: | ||
|
||
* Edge | ||
* IoT | ||
* CI | ||
* Development | ||
* ARM | ||
* Embedding k8s | ||
* Situations where a PhD in k8s clusterology is infeasible | ||
|
||
## k3d | ||
|
||
k3d is a lightweight wrapper to run k3s (Rancher Lab’s minimal Kubernetes distribution) in docker. | ||
|
||
k3d makes it very easy to create single- and multi-node k3s clusters in docker, e.g. for local development on Kubernetes. | ||
|
||
## minikube | ||
|
||
通过 [minikube](1.minikube-setup.md) 安装。 | ||
|
||
### Vagrant | ||
## Vagrant | ||
|
||
如果配置 kubeadm 有困难可参考 [Vagrantfile](Vagrantfile) @nevil | ||
|
||
### 跨公网安装集群 | ||
## 跨公网安装集群 | ||
|
||
- [利用 Kilo 跨公网组建 k3s 集群](https://zsnmwy.notion.site/Kilo-k3s-a3b5c98fab14432594f6bdbaeffb7c77) | ||
- [利用 FabEdge 跨公网组建 k3s 集群](https://zsnmwy.notion.site/FabEdge-k3s-43ef0b8662be4c70bc74185c05cd517e) |
Oops, something went wrong.