一.什么是k8s:
全名kubenetes,容器编排工具,分布式的架构,能够对docker以及其他容器进行自动部署,弹性伸缩和管理
二.k8s的架构:
分布式的,一个master节点(属于是主节点)和多个node节点(计算节点),master就是领导不干实际的计算工作而是负责整体把关,node属于就是worker节点,接受指令干活的。
1、master节点包括五个大部分:
(1)kubectl:在cmd命令行操作指令的都是这个,属于是输入kubectl命令的入口
都有啥命令呢:
第一个命令
kubectl --help
然后就会显示都有啥命令如下:
Basic Commands (Beginner):
create Create a resource from a file or from stdin.
expose Take a replication controller, service, deployment or pod and expose it as a new Kubernetes Service
run Run a particular image on the cluster
set Set specific features on objects
Basic Commands (Intermediate):
explain Documentation of resources
get Display one or many resources
edit Edit a resource on the server
delete Delete resources by filenames, stdin, resources and names, or by resources and label selector
Deploy Commands:
rollout Manage the rollout of a resource
scale Set a new size for a Deployment, ReplicaSet or Replication Controller
autoscale Auto-scale a Deployment, ReplicaSet, or ReplicationController
Cluster Management Commands:
certificate Modify certificate resources.
cluster-info Display cluster info
top Display Resource (CPU/Memory/Storage) usage.
cordon Mark node as unschedulable
uncordon Mark node as schedulable
drain Drain node in preparation for maintenance
taint Update the taints on one or more nodes
Troubleshooting and Debugging Commands:
describe Show details of a specific resource or group of resources
logs Print the logs for a container in a pod
attach Attach to a running container
exec Execute a command in a container
port-forward Forward one or more local ports to a pod
proxy Run a proxy to the Kubernetes API server
cp Copy files and directories to and from containers.
auth Inspect authorization
Advanced Commands:
diff Diff live version against would-be applied version
apply Apply a configuration to a resource by filename or stdin
patch Update field(s) of a resource using strategic merge patch
replace Replace a resource by filename or stdin
wait Experimental: Wait for a specific condition on one or many resources.
convert Convert config files between different API versions
kustomize Build a kustomization target from a directory or a remote url.
Settings Commands:
label Update the labels on a resource
annotate Update the annotations on a resource
completion Output shell completion code for the specified shell (bash or zsh)
Other Commands:
alpha Commands for features in alpha
api-resources Print the supported API resources on the server
api-versions Print the supported API versions on the server, in the form of "group/version"
config Modify kubeconfig files
plugin Provides utilities for interacting with plugins.
version Print the client and server version information
一样一样来,先看最简单的-------比如查看的命令:
1.1 查询集群中的所有namespace
kubectl get namespaces
1.2 查看所有pod
kubectl get po -A
(2)Api-Server:简洁的说就是 内部外部都是它交互,具备验证和授权,只有它能和etcd交互,属于是matser的大脑
如果master是领导,那么apiserver就是老板的大脑,这个属于是k8s暴露给外部接口的组件,只有它能和etcd组件交互,所有关于资源的操作,全部通过它来调配,也可以理解为,根据这个名字,这个k8s属于一个server,然后客户端想操作k8s这个server就是http去调用接口么,后续逻辑就是内部处理了,然后Api-Server有很多机制包括:认证、授权、访问控制、api注册、发现
(3)controller-manager:k8s集群内部的所有controller的管理员,