prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Create a new config map named "app-name-config" with specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-name-config --from-file=conf=/path/to/preferences/file1.txt --from-file=data=/path/to/parameters/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creati... |
Partially update the kube-proxy-config.yaml file by changing the replicas value to 3 using a strategic merge patch. | Command:
```bash
kubectl patch -f kube-proxy-config.yaml -p '{"spec":{"replicas":3}'
```
What it does:
Update fields of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.
JSON and YAML formats are accepted.
Syntax:
`kubectl patch (-f FILENAME | TYPE NAME) [-p PATCH|--patch-file FILE]`
Helpf... |
Copy a directory, /tmp/foo_dir, from a remote pod, openfaas/ingress-controller-pod-8, to the local machine at /tmp/bar. | Command:
```bash
kubectl cp openfaas/ingress-controller-pod-8:/tmp/foo_dir :/tmp/bar
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use... |
Create an ingress resource called 'app2-ingress' that routes requests from foo.com/input to svc1:5000 with the TLS secret "my-cert" | Command:
```bash
kubectl create ingress app2-ingress --rule="foo.com/input=svc1:5000,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "... |
Create a cron job named "monthly-audit" using the "alpine" image | Command:
```bash
kubectl create cronjob monthly-audit --image=alpine --schedule="*/1 * * * *" -- apk add curl
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-... |
Create an ingress resource named 'service-ingress' that maps incoming requests from site.com/input to the service 'svc1' on port 8010 | Command:
```bash
kubectl create ingress service-ingress --rule="site.com/input=svc1:8010,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage... |
Create an ingress rule for 'website.com/input' directing traffic to 'svc1:9090' with a TLS secret 'my-cert' | Command:
```bash
kubectl create ingress default-ingress --rule="website.com/input=svc1:9090,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "us... |
Get the snapshot logs from the container named payment-gateway-pod-1 in the deployment proxy-service-deployment. | Command:
```bash
kubectl logs deployment/proxy-service-deployment -c payment-gateway-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flag... |
Copy the file '/tmp/foo' from the pod 'database-pod-2' in the 'ingress-nginx' namespace to the file '/tmp/bar' locally. | Command:
```bash
kubectl cp ingress-nginx/database-pod-2:/tmp/foo /tmp/bar
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubec... |
Create a single ingress called 'api-gateway-ingress' that directs requests to website.com/bar to svc1:8010 with a tls secret "my-cert" | Command:
```bash
kubectl create ingress api-gateway-ingress --rule="website.com/bar=svc1:8010,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "... |
Check if you have permission to list the "report-generation-job" in the "default" namespace. | Command:
```bash
kubectl auth can-i list jobs.batch/report-generation-job -n default
```
What it does:
Check whether an action is allowed.
VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is a partial ... |
Return the logs from the container 'order-processing-deployment-1' in the deployment 'analytics-pod' | Command:
```bash
kubectl logs deployment/order-processing-deployment -c analytics-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
... |
Create an ingress called 'public-api-ingress' with a specific rule that directs requests to a service | Command:
```bash
kubectl create ingress public-api-ingress --rule="foo.com/example=svc1:8081,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "u... |
Run the 'nginx' command in the first container of the first pod of the scheduler-service service and display the output. | Command:
```bash
kubectl exec svc/scheduler-service -- nginx
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubec... |
Install the curl package in cyber-sleuth container of the log-aggregator-pod and retrieve the output. | Command:
```bash
kubectl exec log-aggregator-pod -c cyber-sleuth -- apk add curl
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If om... |
Set the username and password for the "security-user" entry in the Kubernetes configuration to "admin" and "uXFGweU9l35qcif" respectively. | Command:
```bash
kubectl config set-credentials security-user --username=admin --password=uXFGweU9l35qcif
```
What it does:
Set a user entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values.
Client-certificate flags:
--client-certificate=certfile --client-key=keyfi... |
Create a single ingress called 'app2-ingress' that directs requests to foo.com/example to the service named svc1 with port 3000, using the TLS secret named "my-cert" | Command:
```bash
kubectl create ingress app2-ingress --rule="foo.com/example=svc1:3000,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage":... |
Delete pods and services with the label "project=project-alpha" | Command:
```bash
kubectl delete pods,services -l project=project-alpha
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and labe... |
Copy the "/tmp/foo_dir" directory from the remote pod named "auth-service-pod-11" in the "ingress-nginx" namespace to the local directory "/tmp/bar". | Command:
```bash
kubectl cp ingress-nginx/auth-service-pod-11:/tmp/foo_dir :/tmp/bar
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use... |
Import the environment variables from the 'tls-certificate-secret' secret and set them on the 'notification-handler-deployment' deployment. | Command:
```bash
kubectl set env --from=secret/tls-certificate-secret deployment/notification-handler-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions ... |
Create a deployment named 'mattermost' using the 'mysql' image | Command:
```bash
kubectl create deployment mattermost --image=mysql
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json|yaml|... |
Auto scale the deployment "auth" with the following specifications: minimum 4 pods, maximum 12 pods, and a default autoscaling policy based on CPU utilization. | Command:
```bash
kubectl autoscale deployment auth --min=4 --max=12
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that uses th... |
Get the output from running the 'geth attach' command on the first pod of the 'proxy-service-deployment' deployment. | Command:
```bash
kubectl exec deploy/proxy-service-deployment -- geth attach
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitte... |
Create a config map named global-config from the key=value pairs in the specified file | Command:
```bash
kubectl create configmap global-config --from-file=path/to/profiles
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a config map based on a file, the key will default to the basenam... |
Create a new secret named gcp-service-account-secret from an environment file | Command:
```bash
kubectl create secret generic gcp-service-account-secret --from-env-file=path/to/settings.env
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, the key will default ... |
Forward traffic from port 5432 on localhost and IP address 10.19.21.23 to port 8888 in the analytics-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/analytics-pod 5432:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the crite... |
Check if you have the ability to create pods in any namespace | Command:
```bash
kubectl auth can-i create pods --all-namespaces
```
What it does:
Check whether an action is allowed.
VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is a partial URL that starts with... |
Create an ingress named 'private-service-ingress' that routes requests from testing.com/bar to svc1:8010 using the TLS secret "my-cert" | Command:
```bash
kubectl create ingress private-service-ingress --rule="testing.com/bar=svc1:8010,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "... |
Create a deployment named logging with 5 replicas of the confluentinc/cp-kafka image | Command:
```bash
kubectl create deployment logging --image=confluentinc/cp-kafka --replicas=5
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output ... |
View the details of a specific revision in a daemonset's rollout history | Command:
```bash
kubectl rollout history daemonset/development --revision=7
```
What it does:
View previous rollout revisions and configurations.
Syntax:
`kubectl rollout history (TYPE NAME | TYPE/NAME) [flags]`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or UR... |
Update the 'api' pod by adding the annotation 'custom-label' with the value 'my-custom-value' | Command:
```bash
kubectl annotate pods api custom-label=my-custom-value
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include arbit... |
create a cron job called "cron-task" that runs the "node" command every minute | Command:
```bash
kubectl create cronjob cron-task --image=node --schedule="*/1 * * * *" -- node
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default":... |
Create a new config map named db-config with specified keys from file paths | Command:
```bash
kubectl create configmap db-config --from-file=conf=/path/to/data/file1.txt --from-file=data=/path/to/data/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a config map bas... |
Import specific keys from a config map into a deployment. | Command:
```bash
kubectl set env --keys=API_KEY --from=configmap/app-config-prod deployment/gateway-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in... |
Print the supported namespaced resources | Command:
```bash
kubectl api-resources --groupspaced=true
```
What it does:
Print the supported API resources on the server.
Syntax:
`kubectl api-resources`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: wide|name. " |
Create a new NodePort service named log-aggregator-nodeport that maps port 5000 on the host to port 8888 on the container. | Command:
```bash
kubectl create service nodeport log-aggregator-nodeport --tcp=5000:8888
```
What it does:
Create a NodePort service with the specified name.
Syntax:
`kubectl create service nodeport NAME [--tcp=port:targetPort] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "defaul... |
Add a taint with key 'hardware' on nodes that have the label 'stack=tech-stack' | Command:
```bash
kubectl taint node -l stack=tech-stack hardware=node-1:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Ou... |
Forward traffic from port 5000 on all addresses to port 5000 in the pod named "analytics-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/analytics-pod 5000:5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod wil... |
Create a cron job named alerts-cleanup using the golang image, with a schedule set to run every minute, and the command to execute is "go run hello.go" | Command:
```bash
kubectl create cronjob alerts-cleanup --image=golang --schedule="*/1 * * * *" -- go run hello.go
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short"... |
Add the label 'release' with the value 'v2.0' to the pod named 'security' | Command:
```bash
kubectl label pods security release=v2.0
```
What it does:
Update the labels on a resource.
Syntax:
`kubectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]`
Helpful flags:
"flag": "--all-namespaces", "short": "-A", "default": "false", "usage": ... |
Create a pod named "hazelcast" using the Alpine image and expose port 5001. | Command:
```bash
kubectl run hazelcast --image=alpine --port=5001
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--f... |
Output the modified authentication-service-deployment in YAML format, with the updated GOOGLE_API_KEY environment variable value set to "your-google-api-key" | Command:
```bash
kubectl set env deployment/authentication-service-deployment GOOGLE_API_KEY=your-google-api-key -o yaml
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defi... |
Partially update the node identified in the "node.json" file by using a strategic merge patch with the new value of "newValue" for the field specified in the patch file. | Command:
```bash
kubectl patch -f 10-mynet.conf -p '{"spec":{"someField":"newValue"}'
```
What it does:
Update fields of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.
JSON and YAML formats are accepted.
Syntax:
`kubectl patch (-f FILENAME | TYPE NAME) [-p PATCH|--patch-file FILE]`
Help... |
Create a service called 'hazelcast' which runs on port 9000 and connects to the containers on port 8084. | Command:
```bash
kubectl expose deployment hazelcast --port=9000 --target-port=808400
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the spec... |
Create a new config map named api-config with specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap api-config --from-file=settings=/path/to/configurations/file1.txt --from-file=key2=/path/to/properties/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When crea... |
Rename the context 'staging-context' to 'app-1-context' in your kubeconfig file | Command:
```bash
kubectl config rename-context staging-context app-1-context
```
What it does:
Renames a context from the kubeconfig file.
CONTEXT_NAME is the context name that you want to change.
NEW_NAME is the new name you want to set.
Note: If the context being renamed is the 'current-context', this field will als... |
Delete the pods and services with the names "media-stream" and "security" | Command:
```bash
kubectl delete pod,service media-stream security
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label sel... |
Execute the 'redis-cli' command inside the first pod of the 'notification-handler-deployment' deployment and retrieve the output. | Command:
```bash
kubectl exec deploy/notification-handler-deployment -- redis-cli
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If o... |
import the DEBUG_MODE key from the log-config config map and set it as an environment variable in the backend-microservice-deployment deployment. | Command:
```bash
kubectl set env --keys=DEBUG_MODE --from=configmap/log-config deployment/backend-microservice-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable def... |
Unset the namespace in the staging-context context | Command:
```bash
kubectl config unset contexts.staging-context.namespace
```
What it does:
Unset an individual value in a kubeconfig file.
PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.
Syntax:
`kubectl config unset PROPERTY_NAM... |
Open the "email-service" service resource for editing using the "sublime" editor. | Command:
```bash
KUBE_EDITOR="sublime" kubectl edit svc/email-service
```
What it does:
Edit a resource from the default editor.
The edit command allows you to directly edit any API resource you can retrieve via the command-line tools. It will open the editor defined by your KUBE_EDITOR, or EDITOR environment variable... |
Delete pods and services named "web" and "database" | Command:
```bash
kubectl delete pod,service web database
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label selector.
So... |
Delete the pods and services with the names "database" and "proxy" | Command:
```bash
kubectl delete pod,service database proxy
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label selector.
... |
Create an ingress called 'website-ingress' that directs requests to `foo.com/example` to service `svc1` on port `8088` with a TLS secret named "my-cert" | Command:
```bash
kubectl create ingress website-ingress --rule="foo.com/example=svc1:8088,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
get the output from the 'rocket-ranger' container in the 'monitoring-pod' pod | Command:
```bash
kubectl attach monitoring-pod -c rocket-ranger
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted,... |
Create a service for the replication controller specified in the "centos-controller.yaml" file | Command:
```bash
kubectl expose -f centos-controller.yaml --port=5432 --target-port=808000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/db-config deployment/database-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in o... |
Import the 'log_level' key from the 'app-config-prod' config map to the environment variables of the 'authentication-service-deployment' deployment. | Command:
```bash
kubectl set env --keys=log_level --from=configmap/app-config-prod deployment/authentication-service-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variab... |
Create a pod named 'hazelcast' using the 'amazonlinux' image and expose port 8010. | Command:
```bash
kubectl run hazelcast --image=amazonlinux --port=8010
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
"flag":... |
import the API_KEY key from the log-config config map and set it as an environment variable in the payment-processor-deployment deployment. | Command:
```bash
kubectl set env --keys=API_KEY --from=configmap/log-config deployment/payment-processor-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitio... |
Create a debug pod named debug-image-1 by copying the mypod pod, and change all container images to mysql | Command:
```bash
kubectl debug mypod --copy-to=debug-image-1 --set-image=*=mysql
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by default if no resource is s... |
Start a ruby pod with the name 'nginx' and the image 'ruby', but override the pod spec with a partial set of values parsed from the provided JSON data | Command:
```bash
kubectl run nginx --image=ruby --overrides='{ "apiVersion": "v2.0.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND]... |
Copy the file "/tmp/foo" from the local machine to the "/etc/kubernetes" directory inside the "task-processor-pod-17" pod in the container named "security-scanner". | Command:
```bash
kubectl cp :/tmp/foo task-processor-pod-17:/etc/kubernetes -c security-scanner
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If o... |
Listen on all addresses on port 5432, forwarding to port 9090 in the 'log-aggregator-pod' pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/log-aggregator-pod 5432:9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a po... |
Get the output from running the 'geth' command in the first container of the first pod of the 'api-service' service. | Command:
```bash
kubectl exec svc/api-service -- geth
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.kube... |
List the specified resources by their type and names. | Command:
```bash
kubectl get rc/web service/vpn-service-rc pods/log-aggregator-pod
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is nam... |
Create a pod disruption budget named database-pdb that will select all pods with the component=web label and require a minimum of four of them to be available at any point in time | Command:
```bash
kubectl create poddisruptionbudget database-pdb --selector=component=web --min-available=4
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N [--... |
Import specific keys from a config map to an environment variable in a deployment. | Command:
```bash
kubectl set env --keys=api_key --from=configmap/app-config-dev deployment/mydeployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or... |
Get the output from running the 'elasticsearch-plugin --list' command in the time-machine container of the media-stream-pod pod. | Command:
```bash
kubectl exec media-stream-pod -c time-machine -- elasticsearch-plugin --list
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Containe... |
Update the image of the first container in the e-commerce-pod pod to "new image" using a JSON patch with positional arrays. | Command:
```bash
kubectl patch pod e-commerce-pod --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"new image"}]'
```
What it does:
Update fields of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.
JSON and YAML formats are accepted.
Syntax:
`kubectl patch (... |
Create a service for the `ubuntu` deployment, which serves on port 3306 and connects to the containers on port 888800. | Command:
```bash
kubectl expose deployment ubuntu --port=3306 --target-port=888800
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specifi... |
Set environment variables in a deployment using specific keys from a config map. | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/log-config deployment/log-aggregator-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definition... |
Update the annotation 'custom-label' of the pod 'proxy-server' with the value 'my-custom-value' | Command:
```bash
kubectl annotate pods proxy-server custom-label=my-custom-value
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and incl... |
Set the "client-key" field on the "security-user" entry to "~/.kube/admin.key" without modifying any other values. | Command:
```bash
kubectl config set-credentials security-user --client-key=~/.kube/admin.key
```
What it does:
Set a user entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values.
Client-certificate flags:
--client-certificate=certfile --client-key=keyfile
Bearer tok... |
Create a role named "bar" with the ability to watch pods and specific resource names like "identity-provider" and "database-master" | Command:
```bash
kubectl create role bar --verb=watch --resource=pods --resource-name=identity-provider --resource-name=database-master
```
What it does:
Create a role with single rule.
Syntax:
`kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run=server... |
List the specified resources by their types and names | Command:
```bash
kubectl get rc/web service/backend-rc pods/e-commerce-pod
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced ... |
Create a single ingress called 'app2-ingress' that directs requests to site.com/module to the svc1 service on port 3306, using the 'my-cert' secret for TLS encryption. | Command:
```bash
kubectl create ingress app2-ingress --rule="site.com/module=svc1:3306,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage":... |
Forcefully drain the node "kube-master-9" even if it has pods that are not managed by a replication controller, replica set, job, daemon set, or stateful set. | Command:
```bash
kubectl drain kube-master-9 --force
```
What it does:
Drain node in preparation for maintenance.
The given node will be marked unschedulable to prevent new pods from arriving. 'drain' evicts the pods if the API server supports https://kubernetes.io/docs/concepts/workloads/pods/disruptions/ . Otherwise... |
Add a taint with the key 'hardware' and value 'storage-node-13:PreferNoSchedule' on nodes having the label 'version=v1.0.0'. | Command:
```bash
kubectl taint node -l version=v1.0.0 hardware=storage-node-13:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
Scale the deployment named 'baz' to a replica count of 3, if the current replica count is 7. | Command:
```bash
kubectl scale --current-replicas=7 --replicas=3 deployment/baz
```
What it does:
Set a new size for a deployment, replica set, replication controller, or stateful set.
Scale also allows users to specify one or more preconditions for the scale action.
If --current-replicas or --resource-version is spec... |
Expose a replica set as a service on port 8888, which connects to the containers on port 30000 | Command:
```bash
kubectl expose rs nginx --port=8888 --target-port=300000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port. ... |
Copy the local file /tmp/foo_dir to /tmp/bar in the remote pod named monitoring-agent-pod-6 in the velero namespace. | Command:
```bash
kubectl cp /tmp/foo_dir velero/monitoring-agent-pod-6::/tmp/bar
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the... |
Embed certificate authority data for the moon-cluster cluster entry | Command:
```bash
kubectl config set-cluster moon-cluster --embed-certs --certificate-authority=~/.kube/web-cluster/kubernetes.ca.crt
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-... |
Forward traffic from port 5432 on all addresses to port 8081 in the log-aggregator-pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/log-aggregator-pod 5432:8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a po... |
Add an annotation to the 'gateway' pod with the key 'SLA' and the value '99.9% uptime'. | Command:
```bash
kubectl annotate pods gateway SLA='99.9% uptime'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include arbitrary s... |
Taint nodes with label "service=auth" by adding a taint with key "app" and value "kube-master-9:PreferNoSchedule" | Command:
```bash
kubectl taint node -l service=auth app=kube-master-9:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Outp... |
Copy the /var/run/secrets/kubernetes.io/serviceaccount/ directory from a remote pod named security-scanner-pod-18 in the istio-system namespace to the /etc/kubernetes directory locally. | Command:
```bash
kubectl cp istio-system/security-scanner-pod-18:/var/run/secrets/kubernetes.io/serviceaccount/ /etc/kubernetes
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": ""... |
Add a taint with the key 'special' to nodes that have the label 'instance=app-instance-1' | Command:
```bash
kubectl taint node -l instance=app-instance-1 special=gpu-node-12:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "... |
Update the user field of the local-context context entry to "cluster-admin" without modifying any other values | Command:
```bash
kubectl config set-context local-context --user=cluster-admin
```
What it does:
Set a context entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-context [NAME | --current] [--cluster=cluster_nickname... |
Get the output from running the 'redis-server' command in the chat-app-pod pod, using the first container by default. | Command:
```bash
kubectl exec chat-app-pod -- redis-server
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl... |
Create a deployment named "ingress" with an image named "node" and a command named "node" | Command:
```bash
kubectl create deployment ingress --image=node -- node
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json|y... |
Scale the replica set named 'bar' to 5 replicas | Command:
```bash
kubectl scale --replicas=5 rs/bar
```
What it does:
Set a new size for a deployment, replica set, replication controller, or stateful set.
Scale also allows users to specify one or more preconditions for the scale action.
If --current-replicas or --resource-version is specified, it is validated before... |
Create an ingress called 'internal-ingress' with a rule that directs requests from foo.com/example to svc1:6379 with a tls certificate named "my-cert" | Command:
```bash
kubectl create ingress internal-ingress --rule="foo.com/example=svc1:6379,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usa... |
Deny a Certificate Signing Request 'csr-backend-5' | Command:
```bash
kubectl certificate deny csr-backend-5
```
What it does:
Deny a certificate signing request.
kubectl certificate deny allows a cluster admin to deny a certificate signing request (CSR). This action tells a certificate signing controller to not to issue a certificate to the requestor.
Syntax:
`kubectl... |
Copy the local file "/tmp/foo" to the remote pod named "istio-system/logging-agent-pod-7" in the "istio-system" namespace, and place it in the "/tmp/bar_dir" directory. | Command:
```bash
kubectl cp /tmp/foo istio-system/logging-agent-pod-7:/tmp/bar_dir
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use t... |
Create a role named "admin_role" and specify the resource name as "auth-service" and "load-balancer" with the ability to perform the "watch" action on the "pods" resource. | Command:
```bash
kubectl create role admin_role --verb=watch --resource=pods --resource-name=auth-service --resource-name=load-balancer
```
What it does:
Create a role with single rule.
Syntax:
`kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run=server... |
Create a deployment named prometheus using the wordpress image and expose port 8088. | Command:
```bash
kubectl create deployment prometheus --image=wordpress --port=8088
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. On... |
Import specific keys from a config map into the environment variables of a deployment | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/global-config deployment/backend-microservice-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable ... |
Auto scale the deployment "media-stream" with the number of pods between 3 and 15. | Command:
```bash
kubectl autoscale deployment media-stream --min=3 --max=15
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that... |
Set the exec auth plugin environment variables for the "operator" entry | Command:
```bash
kubectl config set-credentials operator --exec-env=key1=val1 --exec-env=key2=val2
```
What it does:
Set a user entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values.
Client-certificate flags:
--client-certificate=certfile --client-key=keyfile
Bear... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.