当前位置:网站首页>The most complete kubernetes core command of the latest version so far
The most complete kubernetes core command of the latest version so far
2022-06-26 11:29:00 【BOGO】
Put your years of k8s The operation command is contributed by taking notes , I hope I can help you !
# View all namespace Of pods Operation of the
kubectl get pods --all-namespaces
# Check the details pods, Remember to follow namespace Name
kubectl get pods kubernetes-dashboard-76479d66bb-nj8wr --namespace=kube-system
# see pods Specific information
kubectl get pods -o wide kubernetes-dashboard-76479d66bb-nj8wr --namespace=kube-system
# View cluster health status
kubectl get cs
# Get all deployment
kubectl get deployment --all-namespaces
# List the namespace All in pod Include uninitialized
kubectl get pods --include-uninitialized
# see deployment()
kubectl get deployment nginx-app
# see rc and servers
kubectl get rc,services
# see pods structural information ( a key , Through this to see the log analysis error )
# For controllers and services ,node Equally effective
kubectl describe pods xxxxpodsname --namespace=xxxnamespace
# Other controllers are similar , Namely kubectl get controller The specific name of the controller
# see pod journal
kubectl logs $POD_NAME
# see pod Variable
kubectl exec my-nginx-5j8ok -- printenv | grep SERVICE
# colony
kubectl get cs # Cluster health
kubectl cluster-info # The operation of cluster core components
kubectl get namespaces # Table space name
kubectl version # edition
kubectl api-versions # API
kubectl get events # Check out the events
kubectl get nodes // Get all nodes
kubectl delete node k8s2 // Delete node
kubectl rollout status deploy nginx-test
# establish
kubectl create -f ./nginx.yaml # Create resources
kubectl create -f . # Create all... In the current directory yaml resources
kubectl create -f ./nginx1.yaml -f ./mysql2.yaml # Create resources with multiple files
kubectl create -f ./dir # Use all the manifest files in the directory to create resources
kubectl create -f https://git.io/vPieo # Use url To create resources
kubectl run -i --tty busybox --image=busybox ---- Create... With a terminal pod
kubectl run nginx --image=nginx # Start a nginx example
kubectl run mybusybox --image=busybox --replicas=5 ---- Start multiple pod
kubectl explain pods,svc # obtain pod and svc Documents
# to update
kubectl rolling-update python-v1 -f python-v2.json # Scroll to update pod frontend-v1
kubectl rolling-update python-v1 python-v2 --image=image:v2 # Update resource name and update image
kubectl rolling-update python --image=image:v2 # to update frontend pod In the mirror
kubectl rolling-update python-v1 python-v2 --rollback # Exit the existing rolling update in progress
cat pod.json | kubectl replace -f - # be based on stdin Input JSON Replace pod
Forced replacement , Delete and recreate resources . Can cause service disruption .
kubectl replace --force -f ./pod.json
by nginx RC Create services , Enable local 80 Port to the... On the container 8000 port
kubectl expose rc nginx --port=80 --target-port=8000
Update single container pod The mirror version of (tag) To v4
kubectl get pod nginx-pod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f -
kubectl label pods nginx-pod new-label=awesome # Add tags
kubectl annotate pods nginx-pod icon-url=http://goo.gl/XXBTWq # adding annotations
kubectl autoscale deployment foo --min=2 --max=10 # Automatic extension deployment “foo”
# Edit resources
kubectl edit svc/docker-registry # The editor's name is docker-registry Of service
KUBE_EDITOR="nano" kubectl edit svc/docker-registry # Use other editors
# Dynamic scaling pod
kubectl scale --replicas=3 rs/foo # take foo The replica set becomes 3 individual
kubectl scale --replicas=3 -f foo.yaml # The zoom “foo” The resource specified in .
kubectl scale --current-replicas=2 --replicas=3 deployment/mysql # take deployment/mysql from 2 A into 3 individual
kubectl scale --replicas=5 rc/foo rc/bar rc/baz # Change the number of multiple controllers
kubectl rollout status deploy deployment/mysql # Check the change progress
# Delete
kubectl delete -f ./pod.json # Delete pod.json Of the type and name defined in the file pod
kubectl delete pod,service baz foo # Delete the name “baz” Of pod And called “foo” Of service
kubectl delete pods,services -l name=myLabel # Delete has name=myLabel Labeled pod and serivce
kubectl delete pods,services -l name=myLabel --include-uninitialized # Delete has name=myLabel Labeled pod and service, Include uninitialized
kubectl -n my-ns delete po,svc --all # Delete my-ns namespace All under pod and serivce, Include uninitialized
kubectl delete pods prometheus-7fcfcb9f89-qkkf7 --grace-period=0 --force Mandatory deletion
# Interaction
kubectl logs nginx-pod # dump Output pod Log (stdout)
kubectl logs nginx-pod -c my-container # dump Output pod Log of the container in (stdout,pod Use when there are multiple containers in )
kubectl logs -f nginx-pod # Streaming output pod Log (stdout)
kubectl logs -f nginx-pod -c my-container # Streaming output pod Log of the container in (stdout,pod Use when there are multiple containers in )
kubectl run -i --tty busybox --image=busybox -- sh # Interactive shell How to run pod
kubectl attach nginx-pod -i # Connect to a running container
kubectl port-forward nginx-pod 5000:6000 # forward pod Medium 6000 Port to local 5000 port
kubectl exec nginx-pod -- ls / # Execute the command in an existing container ( In the case of only one container )
kubectl exec nginx-pod -c my-container -- ls / # Execute the command in an existing container (pod In the case of multiple containers )
kubectl top pod POD_NAME --containers # According to specified pod And container metrics
# Scheduling configuration
$ kubectl cordon k8s-node # Mark my-node Not schedulable
$ kubectl drain k8s-node # Empty my-node To be maintained
$ kubectl uncordon k8s-node # Mark my-node Schedulable
$ kubectl top node k8s-node # Show my-node A measure of
$ kubectl cluster-info dump # Output the current cluster state to stdout
$ kubectl cluster-info dump --output-directory=/path/to/cluster-state # Output the current cluster state to /path/to/cluster-state
# If the key and the effect of the stain (taint) Already exists , Replace... With the specified value
$ kubectl taint nodes foo dedicated=special-user:NoSchedule边栏推荐
- 9、 Beautify tables, forms, and hyperlinks
- Several problems encountered in setting up the environment in the past two days
- TCP interview
- leetcode 715. Range 模块 (hard)
- Is it safe to open a stock account by mobile phone
- HUST網絡攻防實踐|6_物聯網設備固件安全實驗|實驗二 基於 MPU 的物聯網設備攻擊緩解技術
- Will updating a large amount of data in Oracle cause the undo space to explode
- 女性科学家的流失
- 10 years' experience in programmer career - for you who are confused
- dd命令测试华为鲲鹏&宏衫固态存储磁盘读写速度
猜你喜欢

3、 Linked list exercise

FasterRCNN

How to calculate flops and params in deep learning

18: Chapter 3: development of pass service: 1: SMS login & registration process, introduction; (SMS verification code is used here)

机器学习线性回归——实验报告

loggie 编码以及换行符测试

Apiccloud implements the document download and preview functions

机器学习LDA——实验报告

PC QQ大厅 上传更新 修改versionInfo

Quantitative elementary -- akshare obtains stock code, the simplest strategy
随机推荐
[deep learning theory] (7) long and short term memory network LSTM
How to prevent weight loss under Gao Bingfa?
TCP interview
再获认可!知道创宇入选“业务安全推进计划”首批成员单位
女性科学家的流失
Matlab programming example: how to count the number of elements in a cell array
Uncaught reflectionexception: class view does not exist
十大券商有哪些?手机开户安全么?
Machine learning linear regression - Experimental Report
I want to know whether flush is a stock market? Is it safe to open a mobile account?
This paper introduces the simple operation of realizing linear quadratic moving average of time series prediction that may be used in modeling and excel
哈希表的前置知识---二叉搜索树
Prospering customs through science and technology, Ronglian and Tianjin Customs jointly build a genomic database and analysis platform
介绍一下实现建模中可能用到的时间序列预测之线性二次移动平均,Excel的简单操作
Svn installation configuration
Solidworks渲染技巧如何不显示边线--显示样式设定
Pre knowledge of hash table -- binary search tree
机器学习PCA——实验报告
19: Chapter 3: develop pass service: 2: get through Alibaba cloud SMS service in the program; (it only connects with Alibaba cloud SMS server, and does not involve specific business development)
TCP面试