Kubernetes学习总结(14)—— Kubernetes 实用命令总结
一、Pods
1、Get all pods in the current namespace
kubectl get pods
2、Get pods in all namespaces
kubectl get pods --all-namespaces
3、Get pods with more details
kubectl get pods -o wide
4、Get the yaml for a pod
kubectl get pod <pod> -o yaml
5、Inspect a pod
kubectl describe pods <pod>
6、Get pods sorted by a metric
kubectl get pods --sort-by='.status.containerStatuses[0].restartCount'
7、Get pods with their labels
kubectl get pods --show-labels
8、Get pods that match a label
kubectl get pods -l <label>=<value>
9、Forward traffic from a localhost port to a pod port
kubectl port-forward <pod> <localhost-port>:<pod-port>
10、Run a command on a pod
kubectl exec <pod> -- <command>
11、Run a command on a container in a pod
kubectl exec <pod> -c <container> -- <command>
二、Secrets
1、Get all secrets in the current namespace
kubectl get secrets
2、Get secrets in all namespaces
kubectl get secrets --all-namespaces
3、Get secrets with more details
kubectl get secrets -o wide
4、Get the contents of a secret
kubectl get secrets <secret> -o yaml
三、Services
1、Get all services in the current namespace
kubectl get services
2、Get services in all namespaces
kubectl get service --all-namespaces
3、Get services with more details
kubectl get service -o wide
4、Get the yaml for a services
kubectl get service <service> -o yaml
5、Inspect a service
kubectl describe service <service>
6、Get service's labels
kubectl get service --show-labels
7、Get services that match a label
kubectl get service -l <label>=<value>
四、Updating Resources
1、Roll a new version of a deployment
kubectl set image deployment/<deployment> <containername>=image:<version>
2、Check the deployment history
kubectl rollout history deployment/<deployment>
3、Rollback a deployment
kubectl rollout undo deployment/<deployment>
4、Rollback to a specific version
kubectl rollout undo deployment/<deployment> --to-revision=2
5、Watch a rolling update
kubectl rollout status -w deployment/<deployment>
6、Restart the rolling deploy
kubectl rollout restart deployment/<deployment>
7、Edit a resource’s yaml
kubectl edit deployment/<deployment>
8、Scale a deployment to 3 pods
kubectl scale --replicas=3 deployment/<deployment>
9、Delete a pod
kubectl delete pod <pod>
五、Context
1、Show contexts
kubectl config get-contexts
2、Show current context
kubectl config current-context
3、Switch context to another cluster
kubectl config use-context <my-cluster-name>
4、Change Namespace
kubectl config set-context --current --namespace=<namespace>
六、Logs
1、Show logs (stdout) of a pod
kubectl logs <pod>
2、Show logs (stdout) of pods that match a label
kubectl logs -l <label>=<value>
3、Show logs of a previous instantiation of a container
kubectl logs <pod> --previous
4、Show logs for a specific container in a pod (i.e. init container)
kubectl logs <pod> -c <container>
5、Following logs from a pod
kubectl logs -f <pod>
6、Follow all logs from a pod that match a label
kubectl logs -f -l <label>=<value> --all-containers
7、Show logs with verbosity level of logs from 0 - 9
kubectl logs <pod> --v=<0:9>
七、Deployments
1、Get all deployments in the current namespace
kubectl get deployment
2、Get deployments in all namespaces
kubectl get deployment --all-namespaces
3、Get deployments with more details
kubectl get deployment -o wide
4、Get the yaml for a deployment
kubectl get deployment <deployment> -o yaml
5、Inspect a deployment
kubectl describe deployment <deployment>
6、Get deployment's labels
kubectl get deployment --show-labels
7、Get deployments that match a label
kubectl get deployment -l <label>=<value>
八、Ingress
1、Get all ingress in the current namespace
kubectl get ingress
2、Get ingress in all namespaces
kubectl get ingress --all-namespaces
3、Get ingress with more details
kubectl get ingress -o wide
4、Get the yaml for a ingress
kubectl get ingress <ingress> -o yaml
5、Inspect a ingress
kubectl describe ingress <ingress>
6、Get ingress labels
kubectl get ingress --show-labels
7、Get ingress that match a label
kubectl get ingress -l <label>=<value>
九、Creating Resources
1、Create a kubernetes resource from a file
kubectl apply -f ./<manifest>.yaml
2、Create kubernetes resources from multiple files
kubectl apply -f ./<manifest>.yaml -f ./<manifest>.yaml
3、Create resources from all manifest files in a directory
kubectl apply -f ./<directory>
4、Create resource from a url
kubectl apply -f <url_to_manifest>
5、Start a single instance of an image
kubectl create deployment <deployment_name> --image=<image>
十、Nodes
1、Mark node as unschedulable
kubectl cordon <node>
2、Drain a node for maintenance
kubectl drain <node>
3、Mark node as schedulable
kubectl uncordon <node>
4、Show ‘top’ metrics for a node
kubectl top node <node>
5、Display addresses of the master and services
kubectl cluster-info
6、ump current cluster state to stdout
kubectl cluster-info dump
7、Show a list of eligible kube resource (i.e. pods, service, pv, etc)
kubectl api-resources
8、Show a list of eligible kube resources in your namespace
kubectl api-resources --namespaced=true
Kubernetes学习总结(14)—— Kubernetes 实用命令总结相关推荐
- 14: linux实用命令
1.1 基本实用命令整理 1.查找大文件文件 du -sh ./*|grep G # 查看当前目录下个文件大于1G的文件夹 2.查找日志文件中 5xx数量,并进行排序 ...
- Linux系统学习 超详细常见实用命令
文章目录 常见目录介绍 系统操作 帮助命令 man 帮助 help 帮助 info 帮助 显示当前的目录名称 文件查看 建立目录 删除空目录 复制文件 移动文件 删除文件 查找文件 find 文件路径 ...
- kubernetes学习:4.安装kubectl命令
kubernetes学习:安装kubectl命令 kubectl是k8s的集群命令的管理工具,通过kubectl可以完成对k8s各种资源的操作(查看.添加.修改等).在管理工具界面使用kubectl语 ...
- K8s命令篇-Kubernetes工作实用命令集结号
K8s命令篇-Kubernetes工作实用命令集结号 1.kubectl命令概述 kubectl作为客户端CLI工具,可以让用户通过命令行对Kubernetes集 群进行操作.在实际工作中熟练的使用这 ...
- Kubernetes学习前的必知知识点
Table of Contents DevOps详解 到底该如何理解DevOps 持续集成,持续交付,持续部署(CI/CD)简介 在有关微服务.DevOps.Cloud-native.系统部署等的讨论 ...
- Kubernetes学习笔记三:Docker安装,Docker使用,编写Dockerfile,制作容器镜像,上传docker镜像
文章目录 Docker的安装 Docker的使用:docker run命令 查看本地存在的镜像:docker images命令 编写Dockerfile,制作容器镜像 docker build制作镜像 ...
- Kubernetes学习总结(16)—— Kubernetes 实战之部署 Redis 集群
一.问题分析 本质上来说在 k8s 上部署一个 redis 集群和部署一个普通应用没有什么太大的区别,但需要注意下面几个问题: Redis 是一个有状态应用:这是部署 redis 集群时我们最需要注意 ...
- Kubernetes学习-K8S安装篇-Kubeadm安装高可用K8S集群
Kubernetes学习-K8S安装篇-Kubeadm高可用安装K8S集群 1. Kubernetes 高可用安装 1.1 kubeadm高可用安装k8s集群1.23.1 1.1.1 基本环境配置 1 ...
- Kubernetes学习二:资源管理及入门实战
此部分上接kubernetes学习一:https://blog.csdn.net/weixin_43155804/article/details/125831675?spm=1001.2014.300 ...
- Kubernetes学习
发展历史 Infrastructure as a Service 阿里云 platform as a Service 新浪云 Software as Service Office365 资源管理器 A ...
最新文章
- STM32-USART接收程序
- 一文了解5G是什么,将如何影响我们的未来
- 深度学习笔记7 Working with Large Images 卷积特征提取
- js ie 6,7,8 使用不了 firstElementChild
- mysql中nvl_Mysql中类似于oracle中nvl()函数的ifnull()函数
- (Oracle)DDL及其数据泵导入导出(impdp/expdp)
- JavaScript 如何打败众语言,成为 Node 的实现语言?
- 支付宝集五福活动参与人数超4.5亿 你分到了多少?
- 【MySQL运维】MySQL5.1升级到MySQ 5.5实战
- 学术必备 | 论文写作中注意这些细节,能显著提升成稿质量
- 对抗机器学习—— 迭代FGSM
- ECharts异步数据获取
- c语言盆子接球游戏,适合幼儿园孩子的70个感统训练游戏(开发右脑)
- c语言 aligned,“__attribute __((packed,aligned(4)))”的含义是什么意思?
- [转]下载安装IDM Integration Module和其使用方法
- 大专毕业,从6个月开发转入测试岗位的一些感悟——写在测试岗位3年之际
- 为什么说python是最好的语言!学校_为什么说python语言是最好的选择?老男孩教育...
- 5款小巧有趣的微信小程序,个个让你心花怒放!
- 智能优化算法(源码)-食肉植物算法(Carnivorous Plant Algorithm ,CPA)
- java 手机声音提醒功能_Android基于广播事件机制实现简单定时提醒功能代码
热门文章
- java file.length 单位_Java.io.File.length()返回0
- linux lsm模块,Linux安全模块LSM研究及改进
- 苹果自带相册打马赛克_哥们被绿?iOS 13惊现漏洞,马赛克去除
- java socket client_java socket client
- QT每日一练day5:QLabel和按钮窗口打印功能
- java 配置文件加载_java加载配置文件信息
- 2012高等学校计算机等级考试试卷二级 vb.net程序设计,2012上海市高等校计算机等级考试试卷二级VBNET程序设计.docx...
- spring容器_Spring容器文档阅读要点记录
- java删除多选项_java – 选项菜单默认灰色边框删除
- linux设置ntp开机同步时间同步,linux ntp时间同步