Kubernetes介绍

思维导图

组件

APISERVICE:所有服务访问统一入口
replication CrontrollerManger:维持副本期望数目
Scheduler:负责介绍任务,选择合适的节点进行分配任务
ETCD:键值对数据库,存储k8s集群所有重要信息(持久化)
Kubelet:直接和容器交互实现生命周期管理
Kube_proxy:负责写入规则值IPTABLES,实现服务映射访问
COREDNS:为k8s集群中的svc创建域名与ip的对应关系
DASHBOARD:为k8s集群提供b/s结构访问体系
Ingress controller:实现七层代理
FEDERATION:提供跨集群中心多k8s统一管理功能
PROMETHEUS:提供k8s集群监控能力

k8s常用命令总结

#查询kubernets版本更新命令
$ yum list kubelet --showduplicates
#kubectl get nodes:查询所有节点
$ kubectl get nodes
NAME     STATUS   ROLES    AGE     VERSION
master   Ready    master   12h     v1.18.8
node     Ready    <none>   7h37m   v1.18.8

$ kubectl create -f xxx.yaml:以某yaml文件创建pod
$ kubectl apply -f xxx.yaml:以某yaml文件创建或更新pod
$ kubectl delete -f xxx.yaml:删除以yaml文件创建的pod

#kubectl get pods --all-namespaces:查询所有名称空间下的pod
$ kubectl get pods --all-namespaces
NAMESPACE     NAME                                READY   STATUS    RESTARTS   AGE
default       nginx-deployment-7bf9547bd6-b8j25   1/1     Running   0          5h5m
kube-system   coredns-7ff77c879f-6kxjp            1/1     Running   4          12h
kube-system   coredns-7ff77c879f-fxn84            1/1     Running   4          12h

#kubectl get pods:查询default名称空间下的pod = kubectl get pods -n default
$ kubectl get pods
NAME                                READY   STATUS    RESTARTS   AGE
nginx-deployment-7bf9547bd6-b8j25   1/1     Running   0          5h4m
$ kubectl get pods -n default
NAME                                READY   STATUS    RESTARTS   AGE
nginx-deployment-7bf9547bd6-b8j25   1/1     Running   0          5h5m

#kubectl get pods -n kube-system:指定名称空间下的pod
$ kubectl get pods -n kube-system         
NAME                             READY   STATUS    RESTARTS   AGE
coredns-7ff77c879f-6kxjp         1/1     Running   4          12h
coredns-7ff77c879f-fxn84         1/1     Running   4          12h
.......

#kubectl get pods -o wide:显示更详细的信息
$ kubectl get pods -o wide
NAME                                READY   STATUS    RESTARTS   AGE    IP           NODE   NOMINATED NODE   READINESS GATES
nginx-deployment-7bf9547bd6-b8j25   1/1     Running   0          5h9m   10.244.1.7   node   <none>           <none>  

#kubectl exec -it pod-name -- /bin/bash:进入某pod容器内部
$ kubectl exec -it nginx-deployment-7bf9547bd6-sxkvg -- /bin/bash
[root@nginx-deployment-7bf9547bd6-sxkvg /]# 

#kubectl describe pod|node pod-name|node-name:查看node或者pod的详细信息
$ kubectl describe node  master
$ kubectl describe pod  nginx-deployment-7bf9547bd6-b8j25

#kubectl logs po-name:查看pod的日志
# -c参数 指定容器名称
$ kubectl logs  nginx-deployment-7bf9547bd6-b8j25 -c test

#kubectl delete pdo po-name:删除某pod容器
$ kubectl delete pod nginx-deployment-7bf9547bd6-sxkvg
pod "nginx-deployment-7bf9547bd6-sxkvg" deleted

#kubectl delete deployment deployment-name:删除某deployment,删除后rs、pod都会被删除
$ kubectl delete pod nginx-deployment
nginx-deployment "nginx-deployment" deleted
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐