
资源管理介绍

资源管理方式
命令式对象管理:直接用命令去操作kubernetes资源
命令式对象配置:通过命令配置和配置文件去操作kubernets资源
声明式对象配置:通过apply命令和配置文件去操作kubernets资源

命令式对象管理:
资源类型

常见命令操作

基本命令示例

创建web 控制器 pod =2 并查看

查看资源帮助

查看参数帮助

查看控制器配置
kubectl edit deployments.apps web

kubectl get deployments.apps
利用补丁更改控制器配置
kubectl patch deployments.apps web -p '{"spec":{"replicas":4}}'
删除资源
kubectl delete deployments.apps

运行和调试命令示例
运行pod
kubectl run testpod --image nginx

端口暴漏
kubectl get service
查看资源详细信息
kubectl describe pods (name)
查看资源日志
kubectl logs pods/name
高级命令示例
利用命令生成yaml文件
kubectl run testpod1 --image nginx --dry-run=client -o yaml > testpod1.yml
利用Yaml文件生成资源

kubectl appply -f testpod1.yml
管理资源标签

更改标签
kubectl label pods nginx qpp=web --overwrite
删除标签
标签控制器识别pod示例的标识

删除pod 上的标签
kubectl label pods
pod
显示较为详细的pod

利用控制器管理


为web 缩容
kubectl scale deloyment web --replicas 2
查看历史版本
kubectl rollout history deployment timinglee
版本回滚
kubectl rollout undo deployment timinglee --to-revision 1
利用yaml文件部署应用
声明式配置
清晰表达期望状态
可重复性和版本控制
团队协作
具有灵活性和可扩展性
丰富的配置选项
组合和扩展
与工具集成
与CI/CD流程集成
命令行工具支持
资源清单参数




获得资源帮助
kubectl explain pod.spec.containers
实例运行容器

同时运行多个pod

理解pod间 的网络整合

端口映射

设定环境变量

资源限制

查看资源限制
kubectl describe pods test
容器启动管理

选择运行节点

pod的生命周期

init 容器示例

探针示例

就绪探针示例
