Add kubeadm, close #438

Signed-off-by: Kang HuaiShuai <khs1994@khs1994.com>
pull/439/head
Kang HuaiShuai 2019-12-31 20:26:22 +08:00
parent bbfe14e0af
commit 0dcc67da1c
No known key found for this signature in database
GPG Key ID: 0A380828B1C243A7
8 changed files with 197 additions and 96 deletions

View File

@ -30,7 +30,7 @@ jobs:
PCIT_EMAIL: khs1994@khs1994.com
PCIT_GIT_TOKEN: ${{ secrets.PCIT_GIT_TOKEN }}
PCIT_GIT_URL: github.com/docker-practice/vuepress
PCIT_KEEP_HISTORY: "1"
PCIT_KEEP_HISTORY: "true"
PCIT_LOCAL_DIR: .vuepress/dist
PCIT_MESSAGE: Sync from yeasy/docker_practice@${{github.sha}} by PCIT
PCIT_TARGET_BRANCH: master
@ -45,7 +45,7 @@ jobs:
PCIT_EMAIL: khs1994@khs1994.com
PCIT_GIT_TOKEN: ${{ secrets.CODING_GIT_TOKEN }}
PCIT_GIT_URL: git.dev.tencent.com/khs1994/docker_practice
PCIT_KEEP_HISTORY: "1"
PCIT_KEEP_HISTORY: "true"
PCIT_LOCAL_DIR: .vuepress/dist
PCIT_MESSAGE: Sync from yeasy/docker_practice@${{github.sha}} by PCIT
PCIT_TARGET_BRANCH: master

View File

@ -109,8 +109,9 @@ module.exports = {
collapsable: false,
children: [
"setup/",
"setup/docker",
"setup/kubeadm",
"setup/docker-desktop",
"setup/systemd",
]
},
{

View File

@ -1,5 +1,7 @@
#
* 1.2.0 2020-12-31
* 1.1.0 2019-12-31
* v19.x
* `BuildKit`

View File

@ -121,8 +121,9 @@
* [](kubernetes/concepts.md)
* [](kubernetes/design.md)
* [ Kubernetes](kubernetes/setup/README.md)
* [使 Docker ](kubernetes/setup/docker.md)
* [使 kubeadm kubernetes](kubernetes/setup/kubeadm.md)
* [ Docker Desktop 使](kubernetes/setup/docker-desktop.md)
* [ kubernetes ](kubernetes/setup/systemd.md)
* [Kubernetes kubectl](kubernetes/kubectl/README.md)
* [](cloud/README.md)
* [](cloud/intro.md)

View File

@ -4,6 +4,8 @@
使 Kubernetes
* Docker
* kubeadm
* docker-desktop
* k3s

View File

@ -1,91 +0,0 @@
# 使 Docker Kubernetes
Kubernetes Docker
使 Docker Kubernetes
![ Docker Kubernetes](_images/k8s-singlenode-docker.png)
Kubernetes Etcd
## Etcd
```bash
docker run --net=host -d gcr.io/google_containers/etcd:2.0.9 /usr/local/bin/etcd --addr=127.0.0.1:4001 --bind-addr=0.0.0.0:4001 --data-dir=/var/etcd/data
```
##
kubelet
```bash
docker run --net=host -d -v /var/run/docker.sock:/var/run/docker.sock gcr.io/google_containers/hyperkube:v0.17.0 /hyperkube kubelet --api_servers=http://localhost:8080 --v=2 --address=0.0.0.0 --enable_server --hostname_override=127.0.0.1 --config=/etc/kubernetes/manifests
```
##
```bash
docker run -d --net=host --privileged gcr.io/google_containers/hyperkube:v0.17.0 /hyperkube proxy --master=http://127.0.0.1:8080 --v=2
```
##
访 `8080`
```bash
$ curl 127.0.0.1:8080
{
"paths": [
"/api",
"/api/v1beta1",
"/api/v1beta2",
"/api/v1beta3",
"/healthz",
"/healthz/ping",
"/logs/",
"/metrics",
"/static/",
"/swagger-ui/",
"/swaggerapi/",
"/validate",
"/version"
]
}
```
##
Docker
```bash
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ee054db2516c gcr.io/google_containers/hyperkube:v0.17.0 "/hyperkube schedule 2 days ago Up 1 days k8s_scheduler.509f29c9_k8s-master-127.0.0.1_default_9941e5170b4365bd4aa91f122ba0c061_e97037f5
3b0f28de07a2 gcr.io/google_containers/hyperkube:v0.17.0 "/hyperkube apiserve 2 days ago Up 1 days k8s_apiserver.245e44fa_k8s-master-127.0.0.1_default_9941e5170b4365bd4aa91f122ba0c061_6ab5c23d
2eaa44ecdd8e gcr.io/google_containers/hyperkube:v0.17.0 "/hyperkube controll 2 days ago Up 1 days k8s_controller-manager.33f83d43_k8s-master-127.0.0.1_default_9941e5170b4365bd4aa91f122ba0c061_1a60106f
30aa7163cbef gcr.io/google_containers/hyperkube:v0.17.0 "/hyperkube proxy -- 2 days ago Up 1 days jolly_davinci
a2f282976d91 gcr.io/google_containers/pause:0.8.0 "/pause" 2 days ago Up 2 days k8s_POD.e4cc795_k8s-master-127.0.0.1_default_9941e5170b4365bd4aa91f122ba0c061_e8085b1f
c060c52acc36 gcr.io/google_containers/hyperkube:v0.17.0 "/hyperkube kubelet 2 days ago Up 1 days serene_nobel
cc3cd263c581 gcr.io/google_containers/etcd:2.0.9 "/usr/local/bin/etcd 2 days ago Up 1 days happy_turing
```
###
* `apiserver` RESTful
* `scheduler` pod
* `controller-manager` endpoint-controller pod replication-controller pod
###
* `kubelet` agent pod
* `proxy` pod 访
###
* Etcd
* `gcr.io/google_containers/pause:0.8.0` Kubernetes pull

View File

@ -0,0 +1,183 @@
# 使 kubeadm kubernetes
`kubeadm` `kubeadm init` `kubeadm join` `kubernetes`
## Docker
[ Docker](../../install) Docker
## **kubelet** **kubeadm** **kubectl**
### Ubuntu/Debian
```bash
$ apt-get update && apt-get install -y apt-transport-https
$ curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
$ cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
$ apt-get update
$ apt-get install -y kubelet kubeadm kubectl
```
### CentOS/Fedora
```bash
$ cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
$ sudo yum install -y kubelet kubeadm kubectl
```
##
```bash
$ cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF
#
$ sysctl --system
```
## kubelet
### `kubelet.service`
`/etc/systemd/system/kubelet.service.d/10-proxy-ipvs.conf`
```bash
# ipvs
[Service]
ExecStartPre=-modprobe ip_vs
ExecStartPre=-modprobe ip_vs_rr
ExecStartPre=-modprobe ip_vs_wrr
ExecStartPre=-modprobe ip_vs_sh
```
```bash
$ sudo systemctl daemon-reload
```
##
### master
```bash
$ sudo kubeadm init --image-repository gcr.azk8s.cn/google-containers \
--pod-network-cidr 10.244.0.0/16 \
--v 5 \
--ignore-preflight-errors=all
```
* `--pod-network-cidr 10.244.0.0/16` CNI `flannel`
>
```bash
...
[addons] Applied essential addon: CoreDNS
I1116 12:35:13.270407 86677 request.go:538] Throttling request took 181.409184ms, request: POST:https://192.168.199.100:6443/api/v1/namespaces/kube-system/serviceaccounts
I1116 12:35:13.470292 86677 request.go:538] Throttling request took 186.088112ms, request: POST:https://192.168.199.100:6443/api/v1/namespaces/kube-system/configmaps
[addons] Applied essential addon: kube-proxy
Your Kubernetes control-plane has initialized successfully!
To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/
Then you can join any number of worker nodes by running the following on each as root:
kubeadm join 192.168.199.100:6443 --token cz81zt.orsy9gm9v649e5lf \
--discovery-token-ca-cert-hash sha256:5edb316fd0d8ea2792cba15cdf1c899a366f147aa03cba52d4e5c5884ad836fe
```
### node
**** **** kubelet
```bash
$ kubeadm join 192.168.199.100:6443 --token cz81zt.orsy9gm9v649e5lf \
--discovery-token-ca-cert-hash sha256:5edb316fd0d8ea2792cba15cdf1c899a366f147aa03cba52d4e5c5884ad836fe
```
##
Docker
###
* `apiserver` RESTful
* `scheduler` pod
* `controller-manager` endpoint-controller pod replication-controller pod
###
* `proxy` pod 访
###
* Etcd
## 使
`/etc/kubernetes/admin.conf` `~/.kube/config`
`$ kubectl get all -A`
CNI CoreDNS 使 Kubernetes
## CNI
`flannel`
### flannel
podCIDR
```bash
$ kubectl get node -o yaml | grep CIDR
#
podCIDR: 10.244.0.0/24
podCIDRs:
```
```bash
$ kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.11.0/Documentation/kube-flannel.yml
```
## master pod
`kubeadm` 使
```bash
$ kubectl taint nodes --all node-role.kubernetes.io/master-
#
# $ kubectl taint nodes NODE_NAME node-role.kubernetes.io/master=true:NoSchedule
```

View File

@ -0,0 +1,3 @@
# kubernetes
[opsnull/follow-me-install-kubernetes-cluster](https://github.com/opsnull/follow-me-install-kubernetes-cluster) 项目一步步部署 kubernetes 集群。