@@ -153,7 +153,7 @@ kubectl config unset users.foo # 删除用户 foo
153
153
参见 [ Kubectl 文档] ( https://kubectl.docs.kubernetes.io ) 。
154
154
155
155
<!--
156
- ## Creating Objects
156
+ ## Creating objects
157
157
158
158
Kubernetes manifests can be defined in YAML or JSON. The file extension `.yaml`,
159
159
`.yml`, and `.json` can be used.
@@ -567,8 +567,7 @@ kubectl scale --replicas=5 rc/foo rc/bar rc/baz # 伸缩多个
567
567
kubectl delete -f ./pod.json # Delete a pod using the type and name specified in pod.json
568
568
kubectl delete pod,service baz foo # Delete pods and services with same names "baz" and "foo"
569
569
kubectl delete pods,services -l name=myLabel # Delete pods and services with label name=myLabel
570
- kubectl delete pods,services -l name=myLabel # Delete pods and services with label name=myLabel
571
- kubectl -n my-ns delete pod,svc --all # Delete all pods and services in namespace my-ns,
570
+ kubectl -n my-ns delete pod,svc --all # Delete all pods and services in namespace my-ns,
572
571
# Delete all pods matching the awk pattern1 or pattern2
573
572
kubectl get pods -n mynamespace --no-headers=true | awk '/pattern1|pattern2/{print $1}' | xargs kubectl delete -n mynamespace pod
574
573
```
@@ -599,14 +598,15 @@ kubectl logs -f my-pod # stream pod logs (stdout)
599
598
kubectl logs -f my-pod -c my-container # stream pod container logs (stdout, multi-container case)
600
599
kubectl logs -f -l name=myLabel --all-containers # stream all pods logs with label name=myLabel (stdout)
601
600
kubectl run -i --tty busybox --image=busybox -- sh # Run pod as interactive shell
602
- kubectl run nginx --image=nginx -n
601
+ kubectl run nginx --image=nginx -n
603
602
mynamespace # Run pod nginx in a specific namespace
604
603
kubectl run nginx --image=nginx # Run pod nginx and write its spec into a file called pod.yaml
605
604
--dry-run=client -o yaml > pod.yaml
606
605
607
606
kubectl attach my-pod -i # Attach to Running Container
608
607
kubectl port-forward my-pod 5000:6000 # Listen on port 5000 on the local machine and forward to port 6000 on my-pod
609
608
kubectl exec my-pod -- ls / # Run command in existing pod (1 container case)
609
+ kubectl exec --stdin --tty my-pod -- /bin/sh # Interactive shell access to a running pod (1 container case)
610
610
kubectl exec my-pod -c my-container -- ls / # Run command in existing pod (multi-container case)
611
611
kubectl top pod POD_NAME --containers # Show metrics for a given pod and its containers
612
612
```
@@ -629,6 +629,7 @@ kubectl run nginx --image=nginx # 运行 ngins Pod 并将其
629
629
kubectl attach my-pod -i # 挂接到一个运行的容器中
630
630
kubectl port-forward my-pod 5000:6000 # 在本地计算机上侦听端口 5000 并转发到 my-pod 上的端口 6000
631
631
kubectl exec my-pod -- ls / # 在已有的 Pod 中运行命令(单容器场景)
632
+ kubectl exec --stdin --tty my-pod -- /bin/sh # 使用交互 shell 访问正在运行的 Pod (一个容器场景)
632
633
kubectl exec my-pod -c my-container -- ls / # 在已有的 Pod 中运行命令(多容器场景)
633
634
kubectl top pod POD_NAME --containers # 显示给定 Pod 和其中容器的监控数据
634
635
```
@@ -661,7 +662,7 @@ kubectl cluster-info # 显示
661
662
kubectl cluster-info dump # 将当前集群状态转储到标准输出
662
663
kubectl cluster-info dump --output-directory=/path/to/cluster-state # 将当前集群状态输出到 /path/to/cluster-state
663
664
664
- # 如果已存在具有指定键和效果的污点,则替换其值为指定值
665
+ # 如果已存在具有指定键和效果的污点,则替换其值为指定值。
665
666
kubectl taint nodes foo dedicated=special-user:NoSchedule
666
667
```
667
668
0 commit comments