1. Check all node node
[root@k8s-m1 ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-m1 Ready master 27h v1.15.2
k8s-n1 Ready <none> 27h v1.15.2
k8s-n2 Ready <none> 27h v1.15.2
2. View all resource types
# 第二列是缩写,一样可以被引用
[root@k8s-m1 ~]# kubectl api-resources
NAME SHORTNAMES APIGROUP NAMESPACED KIND
bindings true Binding
componentstatuses cs false ComponentStatus
configmaps cm true ConfigMap
endpoints ep true Endpoints
events ev true Event
limitranges limits true LimitRange
namespaces ns false Namespace
nodes no false Node
persistentvolumeclaims pvc true PersistentVolumeClaim
persistentvolumes pv false PersistentVolume
pods po true Pod
3. Check all namespaces resources
[root@k8s-m1 ~]# kubectl get ns
NAME STATUS AGE
default Active 28h
kube-node-lease Active 28h
kube-public Active 28h
kube-system Active 28h
4. View pod resources
# 默认查看的是default名称空间下的pod,如果查看其它名称空间需要用-n指定
[root@k8s-m1 ~]# kubectl get pods
[root@k8s-m1 ~]# kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
coredns-5c98db65d4-mzw28 1/1 Running 0 28h
coredns-5c98db65d4-zl5cs 1/1 Running 0 28h
etcd-k8s-m1 1/1 Running 0 28h
kube-apiserver-k8s-m1 1/1 Running 0 28h
kube-controller-manager-k8s-m1 1/1 Running 0 28h
kube-flannel-ds-amd64-qd5js 1/1 Running 0 28h
kube-flannel-ds-amd64-qq9td 1/1 Running 0 28h
kube-flannel-ds-amd64-xtpcg 1/1 Running 0 28h
kube-proxy-6q5dj 1/1 Running 0 28h
kube-proxy-9p5qd 1/1 Running 0 28h
kube-proxy-s97s9 1/1 Running 0 28h
kube-scheduler-k8s-m1 1/1 Running 0 28h
5. Create a deployment object named nginx-deploy the
[root@k8s-m1 ~]# kubectl run nginx-deploy --image=nginx:1.14 --replicas=2
# --image:指定镜像名字
# --replicas:为容器创建多少副本
[root@k8s-m1 ~]# kubectl get deploy -o wide
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
nginx-deploy 2/2 2 2 3d14h nginx-deploy nginx:1.14 run=nginx-deploy
# 可以看到自动分配到两个Node节点上
[root@k8s-m1 ~]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-deploy-cdb7cc65c-949kr 1/1 Running 0 3d14h 10.244.1.3 k8s-n1 <none> <none>
nginx-deploy-cdb7cc65c-hm6lh 1/1 Running 2 3d14h 10.244.2.4 k8s-n2 <none> <none>
Writing is not easy, please indicate the source, thank you ~~