remove extra title kubectl cheatsheet
This commit is contained in:
@@ -12,17 +12,11 @@ card:
|
|||||||
|
|
||||||
<!-- overview -->
|
<!-- overview -->
|
||||||
|
|
||||||
See also: [Kubectl Overview](/docs/reference/kubectl/overview/) and [JsonPath Guide](/docs/reference/kubectl/jsonpath).
|
This page contains a list of commonly used `kubectl` commands and flags.
|
||||||
|
|
||||||
This page is an overview of the `kubectl` command.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- body -->
|
<!-- body -->
|
||||||
|
|
||||||
# kubectl - Cheat Sheet
|
## Kubectl autocomplete
|
||||||
|
|
||||||
## Kubectl Autocomplete
|
|
||||||
|
|
||||||
### BASH
|
### BASH
|
||||||
|
|
||||||
@@ -45,7 +39,7 @@ source <(kubectl completion zsh) # setup autocomplete in zsh into the current s
|
|||||||
echo "[[ $commands[kubectl] ]] && source <(kubectl completion zsh)" >> ~/.zshrc # add autocomplete permanently to your zsh shell
|
echo "[[ $commands[kubectl] ]] && source <(kubectl completion zsh)" >> ~/.zshrc # add autocomplete permanently to your zsh shell
|
||||||
```
|
```
|
||||||
|
|
||||||
## Kubectl Context and Configuration
|
## Kubectl context and configuration
|
||||||
|
|
||||||
Set which Kubernetes cluster `kubectl` communicates with and modifies configuration
|
Set which Kubernetes cluster `kubectl` communicates with and modifies configuration
|
||||||
information. See [Authenticating Across Clusters with kubeconfig](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) documentation for
|
information. See [Authenticating Across Clusters with kubeconfig](/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) documentation for
|
||||||
@@ -81,10 +75,11 @@ kubectl config set-context gce --user=cluster-admin --namespace=foo \
|
|||||||
kubectl config unset users.foo # delete user foo
|
kubectl config unset users.foo # delete user foo
|
||||||
```
|
```
|
||||||
|
|
||||||
## Apply
|
## Kubectl apply
|
||||||
|
|
||||||
`apply` manages applications through files defining Kubernetes resources. It creates and updates resources in a cluster through running `kubectl apply`. This is the recommended way of managing Kubernetes applications on production. See [Kubectl Book](https://kubectl.docs.kubernetes.io).
|
`apply` manages applications through files defining Kubernetes resources. It creates and updates resources in a cluster through running `kubectl apply`. This is the recommended way of managing Kubernetes applications on production. See [Kubectl Book](https://kubectl.docs.kubernetes.io).
|
||||||
|
|
||||||
## Creating Objects
|
## Creating objects
|
||||||
|
|
||||||
Kubernetes manifests can be defined in YAML or JSON. The file extension `.yaml`,
|
Kubernetes manifests can be defined in YAML or JSON. The file extension `.yaml`,
|
||||||
`.yml`, and `.json` can be used.
|
`.yml`, and `.json` can be used.
|
||||||
@@ -138,7 +133,7 @@ EOF
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Viewing, Finding Resources
|
## Viewing, finding resources
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Get commands with basic output
|
# Get commands with basic output
|
||||||
@@ -206,8 +201,7 @@ kubectl get events --sort-by=.metadata.creationTimestamp
|
|||||||
kubectl diff -f ./my-manifest.yaml
|
kubectl diff -f ./my-manifest.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
## Updating Resources
|
## Updating resources
|
||||||
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl set image deployment/frontend www=image:v2 # Rolling update "www" containers of "frontend" deployment, updating the image
|
kubectl set image deployment/frontend www=image:v2 # Rolling update "www" containers of "frontend" deployment, updating the image
|
||||||
@@ -234,7 +228,7 @@ kubectl annotate pods my-pod icon-url=http://goo.gl/XXBTWq # Add an annota
|
|||||||
kubectl autoscale deployment foo --min=2 --max=10 # Auto scale a deployment "foo"
|
kubectl autoscale deployment foo --min=2 --max=10 # Auto scale a deployment "foo"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Patching Resources
|
## Patching resources
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Partially update a node
|
# Partially update a node
|
||||||
@@ -253,7 +247,8 @@ kubectl patch deployment valid-deployment --type json -p='[{"op": "remove", "
|
|||||||
kubectl patch sa default --type='json' -p='[{"op": "add", "path": "/secrets/1", "value": {"name": "whatever" } }]'
|
kubectl patch sa default --type='json' -p='[{"op": "add", "path": "/secrets/1", "value": {"name": "whatever" } }]'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Editing Resources
|
## Editing resources
|
||||||
|
|
||||||
Edit any API resource in your preferred editor.
|
Edit any API resource in your preferred editor.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -261,7 +256,7 @@ kubectl edit svc/docker-registry # Edit the service named d
|
|||||||
KUBE_EDITOR="nano" kubectl edit svc/docker-registry # Use an alternative editor
|
KUBE_EDITOR="nano" kubectl edit svc/docker-registry # Use an alternative editor
|
||||||
```
|
```
|
||||||
|
|
||||||
## Scaling Resources
|
## Scaling resources
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl scale --replicas=3 rs/foo # Scale a replicaset named 'foo' to 3
|
kubectl scale --replicas=3 rs/foo # Scale a replicaset named 'foo' to 3
|
||||||
@@ -270,7 +265,7 @@ kubectl scale --current-replicas=2 --replicas=3 deployment/mysql # If the deplo
|
|||||||
kubectl scale --replicas=5 rc/foo rc/bar rc/baz # Scale multiple replication controllers
|
kubectl scale --replicas=5 rc/foo rc/bar rc/baz # Scale multiple replication controllers
|
||||||
```
|
```
|
||||||
|
|
||||||
## Deleting Resources
|
## Deleting resources
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl delete -f ./pod.json # Delete a pod using the type and name specified in pod.json
|
kubectl delete -f ./pod.json # Delete a pod using the type and name specified in pod.json
|
||||||
@@ -306,7 +301,7 @@ kubectl exec my-pod -c my-container -- ls / # Run command in existing po
|
|||||||
kubectl top pod POD_NAME --containers # Show metrics for a given pod and its containers
|
kubectl top pod POD_NAME --containers # Show metrics for a given pod and its containers
|
||||||
```
|
```
|
||||||
|
|
||||||
## Interacting with Nodes and Cluster
|
## Interacting with Nodes and cluster
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
kubectl cordon my-node # Mark my-node as unschedulable
|
kubectl cordon my-node # Mark my-node as unschedulable
|
||||||
@@ -386,17 +381,12 @@ Verbosity | Description
|
|||||||
`--v=8` | Display HTTP request contents.
|
`--v=8` | Display HTTP request contents.
|
||||||
`--v=9` | Display HTTP request contents without truncation of contents.
|
`--v=9` | Display HTTP request contents without truncation of contents.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## {{% heading "whatsnext" %}}
|
## {{% heading "whatsnext" %}}
|
||||||
|
|
||||||
|
* Read the [kubectl overview](/docs/reference/kubectl/overview/) and learn about [JsonPath](/docs/reference/kubectl/jsonpath).
|
||||||
* Learn more about [Overview of kubectl](/docs/reference/kubectl/overview/).
|
|
||||||
|
|
||||||
* See [kubectl](/docs/reference/kubectl/kubectl/) options.
|
* See [kubectl](/docs/reference/kubectl/kubectl/) options.
|
||||||
|
|
||||||
* Also [kubectl Usage Conventions](/docs/reference/kubectl/conventions/) to understand how to use it in reusable scripts.
|
* Also read [kubectl Usage Conventions](/docs/reference/kubectl/conventions/) to understand how to use kubectl in reusable scripts.
|
||||||
|
|
||||||
* See more community [kubectl cheatsheets](https://github.com/dennyzhang/cheatsheet-kubernetes-A4).
|
* See more community [kubectl cheatsheets](https://github.com/dennyzhang/cheatsheet-kubernetes-A4).
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user