Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ee09053

Browse files
committedMay 21, 2022
feat: Add k8s-install-docs
Signed-off-by: zsnmwy <[email protected]>
1 parent 9205882 commit ee09053

36 files changed

+466
-9
lines changed
 

‎assets/mathjax.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
window.MathJax = {
2+
tex: {
3+
inlineMath: [["\\(", "\\)"]],
4+
displayMath: [["\\[", "\\]"]],
5+
processEscapes: true,
6+
processEnvironments: true
7+
},
8+
options: {
9+
ignoreHtmlClass: ".*|",
10+
processHtmlClass: "arithmatex"
11+
}
12+
};
13+
14+
document$.subscribe(() => {
15+
MathJax.typesetPromise()
16+
})

‎assets/output/chtml.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎assets/output/chtml/fonts/tex.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
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.

‎assets/output/svg.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎assets/output/svg/fonts/tex.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎assets/polyfill.min.js

+95
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎assets/tex-mml-chtml.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎assets/util.css

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.md-nav__title {
2+
display: none;
3+
}
4+
5+
.arithmatex {
6+
font-size: 0.85rem;
7+
}
8+
9+
foreignObject > div {
10+
font-size: 0.85rem;
11+
}

‎assets/util.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
setTimeout(function () {
2+
const requestAnimationFrame = window.requestAnimationFrame;
3+
const requestIdleCallback = window.requestIdleCallback;
4+
requestIdleCallback(()=> {
5+
requestAnimationFrame(()=> {
6+
// Remove # when use markdown annotations
7+
const mdAnnotations = document.querySelectorAll(".md-annotation")
8+
for (let i = 0; i < mdAnnotations.length; i++) {
9+
let tmp = mdAnnotations[i]
10+
let parentChinldNodes = tmp.parentElement.childNodes
11+
if (parentChinldNodes[0].data === '#'){
12+
parentChinldNodes[0].remove()
13+
}
14+
}
15+
16+
// Handle tab label click
17+
const labels = document.querySelectorAll("div.tabbed-labels > label")
18+
for (let i = 0; i < labels.length; i++) {
19+
let tmp = labels[i]
20+
tmp.onclick = () => {
21+
for (const label of labels) {
22+
if (label.textContent === tmp.textContent) {
23+
label.click()
24+
}
25+
}
26+
}
27+
}
28+
})
29+
})
30+
},1)

‎k8s-install/k8s-by-kubeadm/index.md

+228
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
# Install Kubernetes Via Kubeadm In Ubuntu
2+
3+
If you are using Macbook, start from here:
4+
5+
## Download images and tools
6+
7+
### Install virtualbox
8+
9+
https://www.virtualbox.org/wiki/Downloads
10+
11+
From System Preference -> Security & Privacy, allow Oracle access
12+
13+
From Virtualbox -> File -> Host Network Manager, click Create button to create one
14+
15+
### Install ubuntu iso from below link
16+
17+
https://releases.ubuntu.com/20.04/
18+
19+
## Installation and configuration
20+
21+
### Configuration virtualbox
22+
23+
#### Open virtualbox manager console
24+
25+
#### Ensure you have correct host network manager settings
26+
27+
- properties -> vboxnet0 -> 192.168.34.1/24
28+
- If the subnet is different, you can edit and update it
29+
- Do not enable dhcp
30+
31+
### Boot new VM
32+
33+
- Click new button
34+
- Choose OS as ubuntu 64bit and 30G disk, make sure your #CPU>=2
35+
- Start VM, choose the downloaded ubuntu ISO and follow the installation wizard
36+
- Specify username/password like cadmin/cadmin
37+
- Install ssh server, enable and start the service
38+
- Do not install built-in kubenernetes
39+
- Wait enough long for the os installation complete
40+
41+
### Shutdown the OS, and set 2nd network adapter
42+
43+
- Go to VM->settings->network->adapter 2
44+
- Enable the adapter and select host only adapter, and choose vboxnet0, `vboxnet0` the host network name configured above
45+
46+
### Login to the system and set ip for second adapter
47+
48+
```sh
49+
vi /etc/netplan/00-installer-config.yaml
50+
51+
network:
52+
ethernets:
53+
enp0s3:
54+
dhcp4: true
55+
enp0s8:
56+
dhcp4: no
57+
addresses:
58+
- 192.168.34.2/24
59+
version: 2
60+
```
61+
62+
```sh
63+
netplan apply
64+
```
65+
66+
### Network configuration
67+
68+
Now your VM has two adapters:
69+
70+
- 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
71+
- One is host adapter which need create extra ip, which is configured as 192.168.34.2
72+
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)
73+
74+
### Set no password for sudo
75+
76+
```sh
77+
%sudo ALL=(ALL:ALL) NOPASSWD:ALL
78+
```
79+
80+
### Swap off
81+
82+
```sh
83+
swapoff -a
84+
vi /etc/fstab
85+
remove the line with swap keyword
86+
```
87+
88+
## Install docker
89+
90+
```sh
91+
apt install docker.io
92+
```
93+
94+
### Update cgroupdriver to systemd
95+
96+
```sh
97+
vi /etc/docker/daemon.json
98+
{
99+
"exec-opts": ["native.cgroupdriver=systemd"]
100+
}
101+
systemctl daemon-reload
102+
systemctl restart docker
103+
```
104+
105+
### Letting iptables see bridged traffic
106+
107+
```shell
108+
$ cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
109+
br_netfilter
110+
EOF
111+
112+
$ cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
113+
net.bridge.bridge-nf-call-ip6tables = 1
114+
net.bridge.bridge-nf-call-iptables = 1
115+
EOF
116+
$ sudo sysctl --system
117+
```
118+
119+
### Update the apt package index and install packages needed to use the Kubernetes apt repository:
120+
121+
```shell
122+
$ sudo apt-get update
123+
$ sudo apt-get install -y apt-transport-https ca-certificates curl
124+
```
125+
126+
## Install kubeadm
127+
128+
```shell
129+
$ sudo curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add -
130+
```
131+
132+
### Add the Kubernetes apt repository
133+
134+
```shell
135+
$ sudo tee /etc/apt/sources.list.d/kubernetes.list <<-'EOF'
136+
deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main
137+
EOF
138+
```
139+
140+
### Update apt package index, install kubelet, kubeadm and kubectl
141+
142+
```shell
143+
$ sudo apt-get update
144+
$ sudo apt-get install -y kubelet kubeadm kubectl
145+
$ sudo apt-mark hold kubelet kubeadm kubectl
146+
```
147+
148+
### kubeadm init
149+
```shell
150+
$ echo "192.168.34.2 cncamp.com" >> /etc/hosts
151+
```
152+
153+
```shell
154+
$ kubeadm init \
155+
--image-repository registry.aliyuncs.com/google_containers \
156+
--kubernetes-version v1.22.2 \
157+
--pod-network-cidr=192.168.0.0/16 \
158+
--apiserver-advertise-address=192.168.34.2
159+
```
160+
161+
### Copy kubeconfig
162+
163+
```shell
164+
$ mkdir -p $HOME/.kube
165+
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
166+
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
167+
```
168+
169+
### Untaint master
170+
171+
```shell
172+
$ kubectl taint nodes --all node-role.kubernetes.io/master-
173+
```
174+
175+
## Install calico cni plugin
176+
177+
https://docs.projectcalico.org/getting-started/kubernetes/quickstart
178+
179+
```shell
180+
$ kubectl create -f https://docs.projectcalico.org/manifests/tigera-operator.yaml
181+
$ kubectl create -f https://docs.projectcalico.org/manifests/custom-resources.yaml
182+
```
183+
184+
## if you want to enable containerd during start, set the cri-socket parameter during kubeadm init
185+
```
186+
kubeadm init \
187+
--image-repository registry.aliyuncs.com/google_containers \
188+
--kubernetes-version v1.22.2 \
189+
--pod-network-cidr=192.168.0.0/16 \
190+
--cri-socket /run/containerd/containerd.sock \
191+
--apiserver-advertise-address=192.168.34.2
192+
```
193+
194+
## Resize VM
195+
196+
### fdisk
197+
198+
```sh
199+
fdisk /dev/sda
200+
p - partition
201+
n - new
202+
```
203+
204+
### Create new pv
205+
206+
```sh
207+
pvcreate /dev/sda4
208+
vgdisplay
209+
```
210+
211+
### Add new pv to vg
212+
213+
```sh
214+
vgextend ubuntu-vg /dev/sda4
215+
```
216+
217+
### Check rootfs lv path
218+
219+
```sh
220+
vgdisplay
221+
lvdisplay
222+
```
223+
224+
### Resize root fix
225+
226+
```sh
227+
lvextend --size +19.99G --resizefs /dev/ubuntu-vg/ubuntu-lv
228+
```

‎k8s-install/kubeadm-centos7-install.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Install Kubernetes Via Kubeadm In CentOS7
2+
13
## Preparation
24
- [virtualbox6.1](https://www.virtualbox.org/)
35
- [centos iso](https://mirrors.aliyun.com/centos/7/isos/x86_64/)

‎k8s-install/readme.md

+70-8
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,87 @@
1-
### Install Kubernetes Cluster
1+
# Install Kubernetes Cluster
22

3-
### kubeadm
3+
## 一些小建议
4+
5+
众多初学者在入门Kubernetes的时候,第一步是安装Kubernetes集群,并在此过程中消耗大量的时间。但是,如果没有足够的耐心,将很有可能被各种Kubernetes的众多新概念所劝退。
6+
7+
所以在此,建议初学者先利用便捷的工具安装一个学习用的测试集群,利用测试集群先学习Kubernetes中的新概念。
8+
9+
了解核心组件的工作原理后,再尝试自行对组件进行调参。
10+
11+
## 选择合适的安装工具
12+
13+
在此小节,将会为你推荐安装集群的工具以及Kubernetes发行版本。
14+
15+
标准Kubernetes集群的最低要求:
16+
17+
1. 一个Master节点,2C4G
18+
2. 一个Node节点,2C4G
19+
20+
该配置可以满足大多数的单应用,基本满足单个模块的学习。
21+
22+
但是,无法满足多个应用同时运行或者运行监控套件的需求。
23+
24+
---
25+
26+
如果无法提供每个节点4G的资源,那么可以选择k3s或者将节点运行在Docker中。
27+
28+
**k3s在512MB的树莓派都可以跑起来。**
29+
30+
!!! tips
31+
点击名称,可直接跳转到该工具介绍
32+
33+
``` mermaid
34+
graph TB
35+
A[Start] --> B{Memory For Each Node > 4GB?};
36+
B --> |Yes| C("kubeadm (Recommend)") & J(kubekey) & K(sealyun);
37+
B --> |No| D{Running in Docker?};
38+
D --> |Yes| E("kind (Recommend)") & F(k3d) & H(minikube);
39+
D --> |No| G("k3s (Recommend)");
40+
click C "/k8s-install/readme/#kubeadm"
41+
```
42+
43+
44+
## kubeadm
445

546
通过 kubeadm 安装,需要手工安装 docker,kubelet,kubeadm 等
647

7-
- [ubuntu 安装](k8s-by-kubeadm)
8-
- [centos 安装](kubeadm-centos7-install.md) @水果爸爸
48+
- [Official Documentation](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/)
49+
- [Install Kubernetes Via Kubeadm In Ubuntu](k8s-by-kubeadm/index.md)
50+
- [Install Kubernetes Via Kubeadm In CentOS](kubeadm-centos7-install.md) @水果爸爸
951

10-
### kind
52+
## kind
1153

1254
通过 [kind](1.2.kind-setup.md) 安装,全自动,无手工步骤,快捷简单,但是节点是基于容器而不是虚拟机的。
1355

14-
### minikube
56+
## k3s
57+
58+
Lightweight Kubernetes. Production ready, easy to install, half the memory, all in a binary less than 100 MB.
59+
60+
Great for:
61+
62+
* Edge
63+
* IoT
64+
* CI
65+
* Development
66+
* ARM
67+
* Embedding k8s
68+
* Situations where a PhD in k8s clusterology is infeasible
69+
70+
## k3d
71+
72+
k3d is a lightweight wrapper to run k3s (Rancher Lab’s minimal Kubernetes distribution) in docker.
73+
74+
k3d makes it very easy to create single- and multi-node k3s clusters in docker, e.g. for local development on Kubernetes.
75+
76+
## minikube
1577

1678
通过 [minikube](1.minikube-setup.md) 安装。
1779

18-
### Vagrant
80+
## Vagrant
1981

2082
如果配置 kubeadm 有困难可参考 [Vagrantfile](Vagrantfile) @nevil
2183

22-
### 跨公网安装集群
84+
## 跨公网安装集群
2385

2486
- [利用 Kilo 跨公网组建 k3s 集群](https://zsnmwy.notion.site/Kilo-k3s-a3b5c98fab14432594f6bdbaeffb7c77)
2587
- [利用 FabEdge 跨公网组建 k3s 集群](https://zsnmwy.notion.site/FabEdge-k3s-43ef0b8662be4c70bc74185c05cd517e)

‎mkdocs.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,19 @@ markdown_extensions:
4949
linenums_style: pymdownx-inline
5050
- pymdownx.inlinehilite
5151
- pymdownx.snippets
52-
- pymdownx.superfences
52+
- pymdownx.superfences:
53+
custom_fences:
54+
- name: mermaid
55+
class: mermaid
56+
format: !!python/name:pymdownx.superfences.fence_code_format
5357
- pymdownx.tabbed:
5458
alternate_style: true
5559
repo_url: https://github.com/cncamp/101
5660
repo_name: cncamp/101
5761
nav:
5862
- Getting Started:
5963
- Introduction: index.md
64+
- Install Kubernetes Cluster:
65+
- Overview: k8s-install/readme.md
66+
- Install Kubernetes Via Kubeadm In Ubuntu: k8s-install/k8s-by-kubeadm/index.md
67+
- Install Kubernetes Via Kubeadm In CentOS: k8s-install/kubeadm-centos7-install.md

0 commit comments

Comments
 (0)
Please sign in to comment.