Skip to content

Commit 38e50dc

Browse files
authored
Merge pull request #1459 from Starnop/cri-doc
doc: Modify the document about Kubernetes&pouch to make it friendly
2 parents 00a3631 + 06ac782 commit 38e50dc

File tree

7 files changed

+452
-225
lines changed

7 files changed

+452
-225
lines changed

docs/kubernetes/pouch_with_kubernetes_deploying.md

Lines changed: 78 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Deploy Kubernetes With Pouch
22

3-
Updated: 2018.3.30
3+
Updated: 2018.6.1
44

55
- [Pouch deploying](#pouch-with-kubernetes-deploying)
66
- [Overview](#overview)
77
- [Restriction](#restriction)
88
- [Install and Configure](#install-and-configure)
99
- [Install Pouch](#install-pouch)
10-
- [Install CNI](#install-cni)
10+
- [Setup Repo](#setup-repo)
1111
- [Install Kubernetes Components](#install-kubernetes-components)
12+
- [Install CNI](#install-cni)
1213
- [Setting up the master node](#setting-up-the-master-node)
1314
- [Setting up the minion nodes](#setting-up-the-minion-nodes)
14-
- [Setting up CNI network routes](#setting-up-cni-network-routes)
1515
- [Run and Verify](#run-and-verify)
1616
- [Troubleshooting](#troubleshooting)
1717

@@ -25,15 +25,14 @@ This document shows how to easily install a Kubernetes cluster with Pouch as the
2525

2626
Kubernetes: Version 1.5+ is recommanded.
2727

28-
Pouch: Version 0.4.0 is recommended.
28+
NOTE: PouchContainer version prior to 0.5.x (including version 0.5.0) did not support configuring CNI network plugin with flannel. If you want to do that, use the latest code from the branch of master, refer to [Developer Quick-Start](https://github.com/alibaba/pouch/blob/master/INSTALLATION.md#developer-quick-start)
2929

3030
## Install and Configure
3131

3232
An all-in-one kubernetes cluster with pouch runtime could be deployed by running:
3333

3434
```
3535
hack/kubernetes/allinone.sh
36-
3736
```
3837

3938
Please refer to [allinone](https://github.com/alibaba/pouch/blob/master/hack/kubernetes/allinone.sh) .
@@ -46,21 +45,27 @@ You can easily setup a basic Pouch environment, see [INSTALLATION.md](../../INST
4645

4746
On Ubuntu 16.04+:
4847

48+
NOTE: If you'd like to use Kubernetes 1.10+, CRI_VERSION should be "v1alpha2"
49+
4950
```
50-
sed -i 's/ExecStart=\/usr\/bin\/pouchd/ExecStart=\/usr\/bin\/pouchd --enable-cri=true/g' /usr/lib/systemd/system/pouch.service
51+
CRI_VERSION="v1alpha1"
52+
sed -i 's/ExecStart=\/usr\/bin\/pouchd/ExecStart=\/usr\/bin\/pouchd --enable-cri=true --cri-version=${CRI_VERSION}/g' /usr/lib/systemd/system/pouch.service
5153
systemctl daemon-reload
5254
systemctl restart pouch
5355
```
5456

5557
On CentOS 7:
5658

59+
NOTE: If you'd like to use Kubernetes 1.10+, CRI_VERSION should be "v1alpha2"
60+
5761
```
58-
sed -i 's/ExecStart=\/usr\/local\/bin\/pouchd/ExecStart=\/usr\/local\/bin\/pouchd --enable-cri=true/g' /lib/systemd/system/pouch.service
62+
CRI_VERSION="v1alpha1"
63+
sed -i 's/ExecStart=\/usr\/local\/bin\/pouchd/ExecStart=\/usr\/local\/bin\/pouchd --enable-cri=true --cri-version=${CRI_VERSION}/g' /lib/systemd/system/pouch.service
5964
systemctl daemon-reload
6065
systemctl restart pouch
6166
```
6267

63-
### Install CNI
68+
### Setup Repo
6469

6570
On Ubuntu 16.04+:
6671

@@ -71,7 +76,6 @@ cat <<EOF > /etc/apt/sources.list.d/kubernetes.list
7176
deb http://apt.kubernetes.io/ kubernetes-xenial main
7277
EOF
7378
apt-get update
74-
apt-get install -y kubernetes-cni
7579
```
7680

7781
On CentOS 7:
@@ -87,55 +91,22 @@ repo_gpgcheck=1
8791
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
8892
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
8993
EOF
90-
setenforce 0
91-
yum install -y kubernetes-cni
92-
```
93-
94-
Configure CNI networks:
95-
96-
- If you want to use CNI plugins like Flannel, Weave, Calico etc, please skip this section.
97-
- Otherwise, you can use **bridge** network plugin, it's the simplest way.
98-
- Subnets should be different on different nodes. e.g. `10.244.1.0/24` for the master node and `10.244.2.0/24` for the first minion node.
99-
100-
```sh
101-
mkdir -p /etc/cni/net.d
102-
cat >/etc/cni/net.d/10-mynet.conf <<-EOF
103-
{
104-
"cniVersion": "0.3.0",
105-
"name": "mynet",
106-
"type": "bridge",
107-
"bridge": "cni0",
108-
"isGateway": true,
109-
"ipMasq": true,
110-
"ipam": {
111-
"type": "host-local",
112-
"subnet": "10.244.1.0/24",
113-
"routes": [
114-
{ "dst": "0.0.0.0/0" }
115-
]
116-
}
117-
}
118-
EOF
119-
cat >/etc/cni/net.d/99-loopback.conf <<-EOF
120-
{
121-
"cniVersion": "0.3.0",
122-
"type": "loopback"
123-
}
124-
EOF
12594
```
12695

12796
### Install Kubernetes Components
12897

12998
On Ubuntu 16.04+:
13099

131100
```sh
132-
apt-get install -y kubelet kubeadm kubectl
101+
RELEASE="1.9.4-00"
102+
apt-get -y install kubelet=${RELEASE} kubeadm=${RELEASE} kubectl=${RELEASE}
133103
```
134104

135105
On CentOS 7:
136106

137107
```sh
138-
yum install -y kubelet kubeadm kubectl
108+
RELEASE="1.9.4-0.x86_64"
109+
yum install -y kubelet-${RELEASE} kubeadm-${RELEASE} kubectl-${RELEASE}
139110
```
140111

141112
Configure kubelet with Pouch as its runtime:
@@ -147,20 +118,46 @@ systemctl daemon-reload
147118

148119
For more details, please check [install kubelet](https://kubernetes.io/docs/setup/independent/install-kubeadm/#installing-kubeadm-kubelet-and-kubectl).
149120

121+
### Install CNI
122+
123+
On Ubuntu 16.04+:
124+
125+
```
126+
apt-get install -y kubernetes-cni
127+
```
128+
129+
On CentOS 7:
130+
131+
```
132+
setenforce 0
133+
yum install -y kubernetes-cni
134+
```
135+
150136
### Setting up the master node
151137

152138
For more detailed Kubernetes cluster installation, please check [Using kubeadm to Create a Cluster](https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/)
153139

154140
```
155-
kubeadm init
141+
kubeadm init --pod-network-cidr 10.244.0.0/16 --ignore-preflight-errors=all
142+
```
143+
144+
Set the KUBECONFIG environment variable
145+
146+
```sh
147+
export KUBECONFIG=/etc/kubernetes/admin.conf
148+
```
149+
150+
Configure CNI network plugin with [flannel](https://github.com/coreos/flannel)
151+
152+
```
153+
kubectl create -f https://github.com/coreos/flannel/raw/master/Documentation/kube-flannel.yml
156154
```
157155

158-
NOTE: If you want to use CNI plugin other than bridge, please check [Installing a pod network](https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/#pod-network).
156+
NOTE: For other plugins, please check [Installing a pod network](https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/#pod-network).
159157

160158
Optional: enable schedule pods on the master node
161159

162160
```sh
163-
export KUBECONFIG=/etc/kubernetes/admin.conf
164161
kubectl taint nodes --all node-role.kubernetes.io/master:NoSchedule-
165162
```
166163

@@ -175,27 +172,9 @@ as root:
175172
kubeadm join --token $token ${master_ip:port} --discovery-token-ca-cert-hash $ca-cert
176173
```
177174

178-
Copy & Run it in all your minion nodes.
179-
180-
### Setting up CNI network routes
181-
182-
If your CNI plugin is bridge, you could use direct routes to connect the containers across multi-node.Suppose you have one master node and one minion node:
183-
184-
```
185-
NODE IP_ADDRESS CONTAINER_CIDR
186-
master 10.148.0.1 10.244.1.0/24
187-
minion 10.148.0.2 10.244.2.0/24
188-
```
189-
190-
Setting up routes:
175+
NOTE: Because kubeadm still assumes docker as the only container runtime ,Use the flag `--ignore-preflight-errors=all` to skip the check.
191176

192-
```
193-
# master node
194-
ip route add 10.244.2.0/24 via 10.148.0.2
195-
196-
# minion node
197-
ip route add 10.244.1.0/24 via 10.148.0.1
198-
```
177+
Copy & Run it in all your minion nodes.
199178

200179
## Run and Verify
201180

@@ -220,7 +199,9 @@ spec:
220199
spec:
221200
containers:
222201
- name: pouch
223-
image: docker.io/library/busybox:latest
202+
image: docker.io/library/nginx:latest
203+
ports:
204+
- containerPort: 80
224205

225206
# kubectl create -f pouch.yaml
226207
deployment "pouch" created
@@ -232,21 +213,37 @@ Confirm the pod of deployment is really running:
232213
# kubectl get pods -o wide
233214
NAME READY STATUS RESTARTS AGE IP NODE
234215
pouch-7dcd875d69-gq5r9 1/1 Running 0 44m 10.244.1.4 master
235-
# ping 10.244.1.4
236-
PING 10.244.1.4 (10.244.1.4) 56(84) bytes of data.
237-
64 bytes from 10.244.1.4: icmp_seq=1 ttl=64 time=0.065 ms
238-
64 bytes from 10.244.1.4: icmp_seq=2 ttl=64 time=0.068 ms
239-
64 bytes from 10.244.1.4: icmp_seq=3 ttl=64 time=0.041 ms
240-
64 bytes from 10.244.1.4: icmp_seq=4 ttl=64 time=0.047 ms
241-
^C
242-
--- 10.244.1.4 ping statistics ---
243-
4 packets transmitted, 4 received, 0% packet loss, time 3048ms
244-
rtt min/avg/max/mdev = 0.041/0.055/0.068/0.012 ms
216+
# curl 10.244.1.4
217+
<!DOCTYPE html>
218+
<html>
219+
<head>
220+
<title>Welcome to nginx!</title>
221+
<style>
222+
body {
223+
width: 35em;
224+
margin: 0 auto;
225+
font-family: Tahoma, Verdana, Arial, sans-serif;
226+
}
227+
</style>
228+
</head>
229+
<body>
230+
<h1>Welcome to nginx!</h1>
231+
<p>If you see this page, the nginx web server is successfully installed and
232+
working. Further configuration is required.</p>
233+
234+
<p>For online documentation and support please refer to
235+
<a href="http://nginx.org/">nginx.org</a>.<br/>
236+
Commercial support is available at
237+
<a href="http://nginx.com/">nginx.com</a>.</p>
238+
239+
<p><em>Thank you for using nginx.</em></p>
240+
</body>
241+
</html>
245242
```
246243

247244
## Troubleshooting
248245

249-
- Because `kubeadm` still assumes docker as the only container runtime which can be used with kubernetes. When you use `kubeadm` to initialize the master node or join the minion node to the cluster, you may encounter the following error message:`[ERROR SystemVerification]: failed to get docker info: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?`. Use the flag `--skip-preflight-checks` to skip the check, like `kubeadm init --skip-preflight-checks`.
246+
- Because `kubeadm` still assumes docker as the only container runtime which can be used with kubernetes. When you use `kubeadm` to initialize the master node or join the minion node to the cluster, you may encounter the following error message:`[ERROR SystemVerification]: failed to get docker info: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?`. Use the flag `--ignore-preflight-errors=all` to skip the check, like `kubeadm init --ignore-preflight-errors=all`.
250247

251248
- By default Pouch will support CRI v1alpha2,which means that using a version of Kubernetes prior to 1.10 will not work. As the NOTE mentioned above, we could start pouchd with the configuration like `pouchd --cri-version v1alpha1` to specify the version of CRI to support the version of Kubernetes below 1.10.
252249

0 commit comments

Comments
 (0)