Skip to content

Commit 4273bbe

Browse files
committed
2019-02-10 完善 K8S
1 parent 1849ccc commit 4273bbe

File tree

1 file changed

+82
-6
lines changed

1 file changed

+82
-6
lines changed

markdown-file/K8S-Install-And-Usage.md

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
- <https://github.com/kubernetes-incubator/kubespray>
4949
- <https://github.com/apprenda/kismatic>
5050

51-
#### 开始安装 - Kubernetes 1.13.2 版本
51+
#### 开始安装 - Kubernetes 1.13.3 版本
5252

5353
- 三台机子:
5454
- master-1:`192.168.0.127`
@@ -133,11 +133,11 @@ scp -r /etc/yum.repos.d/kubernetes.repo root@k8s-node-2:/etc/yum.repos.d/
133133
iptables -P FORWARD ACCEPT
134134
135135
所有机子
136-
yum install -y kubelet-1.13.2 kubeadm-1.13.2 kubectl-1.13.2 --disableexcludes=kubernetes
136+
yum install -y kubelet-1.13.3 kubeadm-1.13.3 kubectl-1.13.3 --disableexcludes=kubernetes
137137
138138
139139
所有机子
140-
vim /etc/cni/net.d/10-flannel.conflist,内容
140+
mkdir -p /etc/cni/net.d && vim /etc/cni/net.d/10-flannel.conflist,内容
141141
{
142142
"name": "cbr0",
143143
"plugins": [
@@ -193,7 +193,7 @@ echo 1 > /proc/sys/net/ipv4/ip_forward
193193
kubeadm init \
194194
--image-repository registry.cn-hangzhou.aliyuncs.com/google_containers \
195195
--pod-network-cidr 10.244.0.0/16 \
196-
--kubernetes-version 1.13.2 \
196+
--kubernetes-version 1.13.3 \
197197
--service-cidr 10.96.0.0/12 \
198198
--apiserver-advertise-address=0.0.0.0 \
199199
--ignore-preflight-errors=Swap
@@ -202,6 +202,56 @@ kubeadm init \
202202
203203
这个过程会下载一些 docker 镜像,时间可能会比较久,看你网络情况。
204204
终端会输出核心内容:
205+
[init] Using Kubernetes version: v1.13.3
206+
[preflight] Running pre-flight checks
207+
[preflight] Pulling images required for setting up a Kubernetes cluster
208+
[preflight] This might take a minute or two, depending on the speed of your internet connection
209+
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
210+
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
211+
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
212+
[kubelet-start] Activating the kubelet service
213+
[certs] Using certificateDir folder "/etc/kubernetes/pki"
214+
[certs] Generating "ca" certificate and key
215+
[certs] Generating "apiserver" certificate and key
216+
[certs] apiserver serving cert is signed for DNS names [k8s-master-1 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.0.127]
217+
[certs] Generating "apiserver-kubelet-client" certificate and key
218+
[certs] Generating "front-proxy-ca" certificate and key
219+
[certs] Generating "front-proxy-client" certificate and key
220+
[certs] Generating "etcd/ca" certificate and key
221+
[certs] Generating "etcd/healthcheck-client" certificate and key
222+
[certs] Generating "apiserver-etcd-client" certificate and key
223+
[certs] Generating "etcd/server" certificate and key
224+
[certs] etcd/server serving cert is signed for DNS names [k8s-master-1 localhost] and IPs [192.168.0.127 127.0.0.1 ::1]
225+
[certs] Generating "etcd/peer" certificate and key
226+
[certs] etcd/peer serving cert is signed for DNS names [k8s-master-1 localhost] and IPs [192.168.0.127 127.0.0.1 ::1]
227+
[certs] Generating "sa" key and public key
228+
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
229+
[kubeconfig] Writing "admin.conf" kubeconfig file
230+
[kubeconfig] Writing "kubelet.conf" kubeconfig file
231+
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
232+
[kubeconfig] Writing "scheduler.conf" kubeconfig file
233+
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
234+
[control-plane] Creating static Pod manifest for "kube-apiserver"
235+
[control-plane] Creating static Pod manifest for "kube-controller-manager"
236+
[control-plane] Creating static Pod manifest for "kube-scheduler"
237+
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
238+
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
239+
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
240+
[apiclient] All control plane components are healthy after 32.002189 seconds
241+
[uploadconfig] storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
242+
[kubelet] Creating a ConfigMap "kubelet-config-1.13" in namespace kube-system with the configuration for the kubelets in the cluster
243+
[patchnode] Uploading the CRI Socket information "/var/run/dockershim.sock" to the Node API object "k8s-master-1" as an annotation
244+
[mark-control-plane] Marking the node k8s-master-1 as control-plane by adding the label "node-role.kubernetes.io/master=''"
245+
[mark-control-plane] Marking the node k8s-master-1 as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule]
246+
[bootstrap-token] Using token: 3ag6sz.y8rmcz5xec50xkz1
247+
[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles
248+
[bootstraptoken] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
249+
[bootstraptoken] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
250+
[bootstraptoken] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
251+
[bootstraptoken] creating the "cluster-info" ConfigMap in the "kube-public" namespace
252+
[addons] Applied essential addon: CoreDNS
253+
[addons] Applied essential addon: kube-proxy
254+
205255
Your Kubernetes master has initialized successfully!
206256
207257
To start using your cluster, you need to run the following as a regular user:
@@ -217,7 +267,9 @@ Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
217267
You can now join any number of machines by running the following on each node
218268
as root:
219269
220-
kubeadm join 192.168.0.127:6443 --token 6m0emc.x9uim283uzevn3pm --discovery-token-ca-cert-hash sha256:c8b1b72de1eabc71df5490afa7cd8dd1c1952234e65b30262ed5084c9d1f10c2
270+
kubeadm join 192.168.0.127:6443 --token 3ag6sz.y8rmcz5xec50xkz1 --discovery-token-ca-cert-hash sha256:912c325aee8dc7c583c36a1c15d7ef1d7a1abeea5dc8a19e96d24536c13373e6
271+
272+
221273
222274
223275
@@ -245,7 +297,31 @@ kubectl apply -f /opt/kube-flannel.yml
245297
```
246298
echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables
247299
248-
kubeadm join 192.168.0.127:6443 --token 6m0emc.x9uim283uzevn3pm --discovery-token-ca-cert-hash sha256:c8b1b72de1eabc71df5490afa7cd8dd1c1952234e65b30262ed5084c9d1f10c2
300+
kubeadm join 192.168.0.127:6443 --token 3ag6sz.y8rmcz5xec50xkz1 --discovery-token-ca-cert-hash sha256:912c325aee8dc7c583c36a1c15d7ef1d7a1abeea5dc8a19e96d24536c13373e6
301+
这时候终端会输出:
302+
303+
[preflight] Running pre-flight checks
304+
[discovery] Trying to connect to API Server "192.168.0.127:6443"
305+
[discovery] Created cluster-info discovery client, requesting info from "https://192.168.0.127:6443"
306+
[discovery] Requesting info from "https://192.168.0.127:6443" again to validate TLS against the pinned public key
307+
[discovery] Cluster info signature and contents are valid and TLS certificate validates against pinned roots, will use API Server "192.168.0.127:6443"
308+
[discovery] Successfully established connection with API Server "192.168.0.127:6443"
309+
[join] Reading configuration from the cluster...
310+
[join] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'
311+
[kubelet] Downloading configuration for the kubelet from the "kubelet-config-1.13" ConfigMap in the kube-system namespace
312+
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
313+
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
314+
[kubelet-start] Activating the kubelet service
315+
[tlsbootstrap] Waiting for the kubelet to perform the TLS Bootstrap...
316+
[patchnode] Uploading the CRI Socket information "/var/run/dockershim.sock" to the Node API object "k8s-node-1" as an annotation
317+
318+
This node has joined the cluster:
319+
* Certificate signing request was sent to apiserver and a response was received.
320+
* The Kubelet was informed of the new secure connection details.
321+
322+
Run 'kubectl get nodes' on the master to see this node join the cluster.
323+
324+
249325
250326
251327
在 master 节点上:kubectl get cs

0 commit comments

Comments
 (0)