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

[WIP]feat: Add k8s-install-docs #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Binary file added assets/images/recommand-book.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions assets/mathjax.js
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()
})
1 change: 1 addition & 0 deletions assets/output/chtml.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/output/chtml/fonts/tex.js

Large diffs are not rendered by default.

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.
1 change: 1 addition & 0 deletions assets/output/svg.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/output/svg/fonts/tex.js

Large diffs are not rendered by default.

95 changes: 95 additions & 0 deletions assets/polyfill.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/tex-mml-chtml.js

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions assets/util.css
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;
}
30 changes: 30 additions & 0 deletions assets/util.js
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)
16 changes: 16 additions & 0 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@

101 (pronounced ONE-oh-ONE) is a slang term for the most basic knowledge in some subject, as in "boiling potatoes is cooking 101".

## Base

本Repo的内容将以《Kubernetes生产化实践之路》(孟凡杰、苏菲、谢文利、李建强 著)作为理论基调,提供对应内容的实践指南。

全部内容都会经过原作者孟凡杰的Review,内容质量有保障。

在实践每一个模块之前,都可以先去阅读《Kubernetes生产化实践之路》补充对应的理论知识。

另外,您也无需担心该书收费而无法阅读等情况。

**得益于微信读书的运营策略,您几乎可以在微信读书上面免费阅读该书。**

欢迎大家购买实体书支持一下作者。[京东购书](https://item.jd.com/13036516.html)

![recommend-book](assets/images/recommand-book.jpg){ width=300 }

## A basic instruction for Kubernetes setup and understanding

| Module ID | Module | Guide |
Expand Down
8 changes: 0 additions & 8 deletions k8s-install/1.2.kind-setup.md

This file was deleted.

228 changes: 228 additions & 0 deletions k8s-install/k8s-by-kubeadm/index.md
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
```
Loading