Kubernetes入门与实战:01

1、Kubernetes基本概览

  由于Kubernetes每年三四个版本发布,官网永远是最权威的;话不多说,先提供官网地址:https://kubernetes.io/zh/docs/tutorials/kubernetes-basics/

1.1、集群与节点

  • 查看master主键角色:
1 [root@master1 ~]# kubectl get componentstatuses         #  也可以使用简写: kubectl get cs
2 Warning: v1 ComponentStatus is deprecated in v1.19+
3 NAME                 STATUS      MESSAGE                                                                                       ERROR
4 scheduler            Unhealthy   Get "http://127.0.0.1:10251/healthz": dial tcp 127.0.0.1:10251: connect: connection refused   
5 controller-manager   Healthy     ok                                                                                            
6 etcd-0               Healthy     {"health":"true","reason":""}                                                                 
7 [root@master1 ~]#
  • 查看node节点列表:
1 [root@master1 ~]# kubectl get nodes -o wide          #  也可以使用简写: kubectl get no
2 NAME      STATUS   ROLES                  AGE   VERSION   INTERNAL-IP    EXTERNAL-IP   OS-IMAGE         KERNEL-VERSION          CONTAINER-RUNTIME
3 master1   Ready    control-plane,master   44h   v1.22.2   192.168.1.66   <none>        CentOS Linux 8   4.18.0-240.el8.x86_64   docker://20.10.8
4 node1     Ready    <none>                 44h   v1.22.2   192.168.1.77   <none>        CentOS Linux 8   4.18.0-240.el8.x86_64   docker://20.10.8
5 node2     Ready    <none>                 44h   v1.22.2   192.168.1.88   <none>        CentOS Linux 8   4.18.0-240.el8.x86_64   docker://20.10.8
6 [root@master1 ~]# 
  • 查看node节点详情:
 1 [root@master1 ~]# kubectl describe nodes node2
 2 Name:               node2
 3 Roles:              <none>
 4 Labels:             beta.kubernetes.io/arch=amd64
 5                     beta.kubernetes.io/os=linux
 6                     kubernetes.io/arch=amd64
 7                     kubernetes.io/hostname=node2
 8                     kubernetes.io/os=linux
 9 Annotations:        flannel.alpha.coreos.com/backend-data: {"VNI":1,"VtepMAC":"be:68:4a:f9:ac:de"}
10                     flannel.alpha.coreos.com/backend-type: vxlan
11                     flannel.alpha.coreos.com/kube-subnet-manager: true
12                     flannel.alpha.coreos.com/public-ip: 192.168.1.88
13                     kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
14                     node.alpha.kubernetes.io/ttl: 0
15                     volumes.kubernetes.io/controller-managed-attach-detach: true
16 CreationTimestamp:  Fri, 01 Oct 2021 06:59:33 -0400
17 Taints:             <none>
18 Unschedulable:      false
19 Lease:
20   HolderIdentity:  node2
21   AcquireTime:     <unset>
22   RenewTime:       Sun, 03 Oct 2021 03:45:59 -0400
23 Conditions:
24   Type                 Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message
25   ----                 ------  -----------------                 ------------------                ------                       -------
26   NetworkUnavailable   False   Sun, 03 Oct 2021 02:47:43 -0400   Sun, 03 Oct 2021 02:47:43 -0400   FlannelIsUp                  Flannel is running on this node
27   MemoryPressure       False   Sun, 03 Oct 2021 03:42:49 -0400   Fri, 01 Oct 2021 06:59:33 -0400   KubeletHasSufficientMemory   kubelet has sufficient memory available
28   DiskPressure         False   Sun, 03 Oct 2021 03:42:49 -0400   Fri, 01 Oct 2021 06:59:33 -0400   KubeletHasNoDiskPressure     kubelet has no disk pressure
29   PIDPressure          False   Sun, 03 Oct 2021 03:42:49 -0400   Fri, 01 Oct 2021 06:59:33 -0400   KubeletHasSufficientPID      kubelet has sufficient PID available
30   Ready                True    Sun, 03 Oct 2021 03:42:49 -0400   Fri, 01 Oct 2021 07:03:54 -0400   KubeletReady                 kubelet is posting ready status
31 Addresses:        # 节点的IP地址和主机名
32   InternalIP:  192.168.1.88
33   Hostname:    node2
34 Capacity:        # 节点总资源
35   cpu:                2
36   ephemeral-storage:  17398Mi
37   hugepages-1Gi:      0
38   hugepages-2Mi:      0
39   memory:             1996236Ki
40   pods:               110
41 Allocatable:      # 节点可以分配的资源
42   cpu:                2
43   ephemeral-storage:  16418812697
44   hugepages-1Gi:      0
45   hugepages-2Mi:      0
46   memory:             1893836Ki
47   pods:               110
48 System Info:      # 系统的相关信息
49   Machine ID:                 fd49b99f63534bc9a6544ff2f1d68ef5
50   System UUID:                2a454d56-033c-c61e-c4f8-37b171f12218
51   Boot ID:                    c66bb70c-b358-4d60-b6f2-9f2cb49dad2e
52   Kernel Version:             4.18.0-240.el8.x86_64
53   OS Image:                   CentOS Linux 8
54   Operating System:           linux
55   Architecture:               amd64
56   Container Runtime Version:  docker://20.10.8
57   Kubelet Version:            v1.22.2          # kubelet版本
58   Kube-Proxy Version:         v1.22.2          # kube-proxy版本
59 PodCIDR:                      172.16.2.0/24      # pod网络
60 PodCIDRs:                     172.16.2.0/24
61 Non-terminated Pods:          (2 in total)       # 当前节点已经运行pod情况,及每个pod占用的资源情况 
62   Namespace                   Name                     CPU Requests  CPU Limits  Memory Requests  Memory Limits  Age
63   ---------                   ----                     ------------  ----------  ---------------  -------------  ---
64   kube-system                 kube-flannel-ds-zp785    100m (5%)     100m (5%)   50Mi (2%)        50Mi (2%)      44h
65   kube-system                 kube-proxy-s6ndp         0 (0%)        0 (0%)      0 (0%)           0 (0%)         53m
66 Allocated resources:    # 已分配资源情况
67   (Total limits may be over 100 percent, i.e., overcommitted.)
68   Resource           Requests   Limits
69   --------           --------   ------
70   cpu                100m (5%)  100m (5%)
71   memory             50Mi (2%)  50Mi (2%)
72   ephemeral-storage  0 (0%)     0 (0%)
73   hugepages-1Gi      0 (0%)     0 (0%)
74   hugepages-2Mi      0 (0%)     0 (0%)
75 Events:
76   Type    Reason                   Age                From     Message
77   ----    ------                   ----               ----     -------
78   Normal  Starting                 44h                kubelet  Starting kubelet.
79   Normal  NodeHasSufficientMemory  44h (x2 over 44h)  kubelet  Node node2 status is now: NodeHasSufficientMemory
80   Normal  NodeHasNoDiskPressure    44h (x2 over 44h)  kubelet  Node node2 status is now: NodeHasNoDiskPressure
81   Normal  NodeHasSufficientPID     44h (x2 over 44h)  kubelet  Node node2 status is now: NodeHasSufficientPID
82   Normal  NodeAllocatableEnforced  44h                kubelet  Updated Node Allocatable limit across pods
83   Normal  NodeReady                44h                kubelet  Node node2 status is now: NodeReady
84 [root@master1 ~]# 

 

上一篇:21201225-肖思学-2021.9.23-学习笔记


下一篇:Python编程:二进制,八进制,十六进制与十进制之间的转换