mirror of
https://github.com/tldr-pages/tldr.git
synced 2026-09-21 04:36:49 +08:00
kubectl*: standardize pages (#18527)
This commit is contained in:
@@ -25,4 +25,4 @@
|
||||
|
||||
- Print the supported API resources with a specific API group:
|
||||
|
||||
`kubectl api-resources --api-group={{api_group}}`
|
||||
`kubectl api-resources --api-group {{api_group}}`
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
- Auto scale a deployment with no target CPU utilization specified:
|
||||
|
||||
`kubectl autoscale {{[deploy|deployment]}} {{deployment_name}} --min={{min_replicas}} --max={{max_replicas}}`
|
||||
`kubectl autoscale {{[deploy|deployment]}} {{deployment_name}} --min {{min_replicas}} --max {{max_replicas}}`
|
||||
|
||||
- Auto scale a deployment with target CPU utilization:
|
||||
|
||||
`kubectl autoscale {{[deploy|deployment]}} {{deployment_name}} --max={{max_replicas}} --cpu-percent={{target_cpu}}`
|
||||
`kubectl autoscale {{[deploy|deployment]}} {{deployment_name}} --max {{max_replicas}} --cpu-percent {{target_cpu}}`
|
||||
|
||||
@@ -13,15 +13,15 @@
|
||||
|
||||
- Create a deployment:
|
||||
|
||||
`kubectl create {{[deploy|deployment]}} {{deployment_name}} --image={{image}}`
|
||||
`kubectl create {{[deploy|deployment]}} {{deployment_name}} --image {{image}}`
|
||||
|
||||
- Create a deployment with replicas:
|
||||
|
||||
`kubectl create {{[deploy|deployment]}} {{deployment_name}} --image={{image}} --replicas={{number_of_replicas}}`
|
||||
`kubectl create {{[deploy|deployment]}} {{deployment_name}} --image {{image}} --replicas {{number_of_replicas}}`
|
||||
|
||||
- Create a service:
|
||||
|
||||
`kubectl create {{[svc|service]}} {{service_type}} {{service_name}} --tcp={{port}}:{{target_port}}`
|
||||
`kubectl create {{[svc|service]}} {{service_type}} {{service_name}} --tcp {{port}}:{{target_port}}`
|
||||
|
||||
- Create a namespace:
|
||||
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
|
||||
- Delete a specific pod:
|
||||
|
||||
`kubectl delete {{[po|pod]}} {{pod_name}}`
|
||||
`kubectl delete {{[po|pods]}} {{pod_name}}`
|
||||
|
||||
- Delete a specific deployment:
|
||||
|
||||
`kubectl delete {{[deploy|deployment]}} {{deployment_name}}`
|
||||
`kubectl delete {{[deploy|deployments]}} {{deployment_name}}`
|
||||
|
||||
- Delete a specific node:
|
||||
|
||||
`kubectl delete {{[no|node]}} {{node_name}}`
|
||||
`kubectl delete {{[no|nodes]}} {{node_name}}`
|
||||
|
||||
- Delete all pods in a specified namespace:
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
- Delete all deployments and services in a specified namespace:
|
||||
|
||||
`kubectl delete {{[deploy|deployment]}},{{[svc|services]}} --all {{[-n|--namespace]}} {{namespace}}`
|
||||
`kubectl delete {{[deploy|deployments]}},{{[svc|services]}} --all {{[-n|--namespace]}} {{namespace}}`
|
||||
|
||||
- Delete all nodes:
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
- Edit a pod in the default namespace:
|
||||
|
||||
`kubectl edit {{[po|pod]}}/{{pod_name}}`
|
||||
`kubectl edit {{[po|pods]}}/{{pod_name}}`
|
||||
|
||||
- Edit a deployment in the default namespace:
|
||||
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
- Create a service for a resource, which will be served from container port to node port:
|
||||
|
||||
`kubectl expose {{resource_type}} {{resource_name}} --port={{node_port}} --target-port={{container_port}}`
|
||||
`kubectl expose {{resource_type}} {{resource_name}} --port {{node_port}} --target-port {{container_port}}`
|
||||
|
||||
- Create a service for a resource identified by a file:
|
||||
|
||||
`kubectl expose {{[-f|--filename]}} {{path/to/file.yml}} --port={{node_port}} --target-port={{container_port}}`
|
||||
`kubectl expose {{[-f|--filename]}} {{path/to/file.yml}} --port {{node_port}} --target-port {{container_port}}`
|
||||
|
||||
- Create a service with a name, to serve to a node port which will be same for container port:
|
||||
|
||||
`kubectl expose {{resource_type}} {{resource_name}} --port={{node_port}} --name={{service_name}}`
|
||||
`kubectl expose {{resource_type}} {{resource_name}} --port {{node_port}} --name {{service_name}}`
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
|
||||
- Label a pod:
|
||||
|
||||
`kubectl label {{[po|pod]}} {{pod_name}} {{key}}={{value}}`
|
||||
`kubectl label {{[po|pods]}} {{pod_name}} {{key}}={{value}}`
|
||||
|
||||
- Update a pod label by overwriting the existing value:
|
||||
|
||||
`kubectl label --overwrite pod {{pod_name}} {{key}}={{value}}`
|
||||
`kubectl label {{[po|pods]}} {{pod_name}} {{key}}={{value}} --overwrite`
|
||||
|
||||
- Label all pods in the namespace:
|
||||
|
||||
`kubectl label {{[po|pods]}} --all {{key}}={{value}}`
|
||||
`kubectl label {{[po|pods]}} {{key}}={{value}} --all`
|
||||
|
||||
- Label a pod identified by the pod definition file:
|
||||
|
||||
@@ -21,4 +21,4 @@
|
||||
|
||||
- Remove the label from a pod:
|
||||
|
||||
`kubectl label {{[po|pod]}} {{pod_name}} {{key}}-`
|
||||
`kubectl label {{[po|pods]}} {{pod_name}} {{key}}-`
|
||||
|
||||
@@ -21,12 +21,12 @@
|
||||
|
||||
- Show pod logs newer than a relative time like `10s`, `5m`, or `1h`:
|
||||
|
||||
`kubectl logs --since={{relative_time}} {{pod_name}}`
|
||||
`kubectl logs --since {{relative_time}} {{pod_name}}`
|
||||
|
||||
- Show the 10 most recent logs in a pod:
|
||||
|
||||
`kubectl logs --tail={{10}} {{pod_name}}`
|
||||
`kubectl logs --tail {{10}} {{pod_name}}`
|
||||
|
||||
- Show all pod logs for a given deployment:
|
||||
|
||||
`kubectl logs deployment/{{deployment_name}}`
|
||||
`kubectl logs {{[deploy|deployment]}}/{{deployment_name}}`
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
|
||||
- Force replace, delete and then re-create the resource:
|
||||
|
||||
`kubectl replace --force {{[-f|--filename]}} {{path/to/file.yml}}`
|
||||
`kubectl replace {{[-f|--filename]}} {{path/to/file.yml}} --force`
|
||||
|
||||
@@ -5,20 +5,20 @@
|
||||
|
||||
- Run an nginx pod and expose port 80:
|
||||
|
||||
`kubectl run {{nginx-dev}} --image=nginx --port 80`
|
||||
`kubectl run {{nginx-dev}} --image nginx --port 80`
|
||||
|
||||
- Run an nginx pod, setting the TEST_VAR environment variable:
|
||||
|
||||
`kubectl run {{nginx-dev}} --image=nginx --env="{{TEST_VAR}}={{testing}}"`
|
||||
`kubectl run {{nginx-dev}} --image nginx --env "{{TEST_VAR}}={{testing}}"`
|
||||
|
||||
- Show API calls that would be made to create an nginx container:
|
||||
|
||||
`kubectl run {{nginx-dev}} --image=nginx --dry-run={{none|server|client}}`
|
||||
`kubectl run {{nginx-dev}} --image nginx --dry-run={{none|server|client}}`
|
||||
|
||||
- Run an Ubuntu pod interactively, never restart it, and remove it when it exits:
|
||||
|
||||
`kubectl run {{temp-ubuntu}} --image=ubuntu:22.04 --restart=Never --rm -- /bin/bash`
|
||||
`kubectl run {{temp-ubuntu}} --image ubuntu:22.04 --restart Never --rm -- /bin/bash`
|
||||
|
||||
- Run an Ubuntu pod, overriding the default command with echo, and specifying custom arguments:
|
||||
|
||||
`kubectl run {{temp-ubuntu}} --image=ubuntu:22.04 --command -- echo {{argument1 argument2 ...}}`
|
||||
`kubectl run {{temp-ubuntu}} --image ubuntu:22.04 --command -- echo {{argument1 argument2 ...}}`
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
|
||||
- Scale a replica set:
|
||||
|
||||
`kubectl scale --replicas={{number_of_replicas}} rs/{{replica_name}}`
|
||||
`kubectl scale --replicas {{replicas_count}} rs/{{replica_name}}`
|
||||
|
||||
- Scale a resource identified by a file:
|
||||
|
||||
`kubectl scale --replicas={{number_of_replicas}} {{[-f|--filename]}} {{path/to/file.yml}}`
|
||||
`kubectl scale --replicas {{replicas_count}} {{[-f|--filename]}} {{path/to/file.yml}}`
|
||||
|
||||
- Scale a deployment based on current number of replicas:
|
||||
|
||||
`kubectl scale --current-replicas={{current_replicas}} --replicas={{number_of_replicas}} deployment/{{deployment_name}}`
|
||||
`kubectl scale --replicas {{replicas_count}} --current-replicas {{current_replicas}} {{[deploy|deployment]}}/{{deployment_name}}`
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
- Display resource (CPU/Memory/Storage) usage of nodes or pods:
|
||||
|
||||
`kubectl top {{pod|node}}`
|
||||
`kubectl top {{pods|node}}`
|
||||
|
||||
- Print the address of the master and cluster services:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user