prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Add a taint with the key 'environment' and value 'gpu-node-12:PreferNoSchedule' to all nodes that have the label 'app=web-app'. | Command:
```bash
kubectl taint node -l app=web-app environment=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": "", "usage": ... |
Create an ingress resource called 'app1-ingress' with a rule that directs requests to 'testing.com/bar' to the service 'svc1' on port 3306 | Command:
```bash
kubectl create ingress app1-ingress --rule="testing.com/bar=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":... |
Get the output from running the 'docker run ubuntu echo "Hello, World"' command in the quantum-quark container from the media-stream-pod pod. | Command:
```bash
kubectl exec media-stream-pod -c quantum-quark -- docker run ubuntu echo "Hello, World"
```
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"... |
Create a service for the replication controller specified in "alpine-controller.yaml" file, exposing port 9091 externally and forwarding traffic to the containers on port 909200. | Command:
```bash
kubectl expose -f alpine-controller.yaml --port=9091 --target-port=909200
```
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... |
Delete pods and services named "auth" and "auth" | Command:
```bash
kubectl delete pod,service auth auth
```
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.
Some ... |
Create a new ClusterIP service named git-service-clusterip with the mapping of TCP port 3306 on the service to port 8010 on the target | Command:
```bash
kubectl create service clusterip git-service-clusterip --tcp=3306:8010
```
What it does:
Create a ClusterIP service with the specified name.
Syntax:
`kubectl create service clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "d... |
Copy the local file "~/.config/kube" to the remote pod "logging/security-scanner-pod-18" in the namespace "logging" and place it in the "/tmp/bar" directory. | Command:
```bash
kubectl cp ~/.config/kube logging/security-scanner-pod-18::/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... |
Copy the file "/tmp/foo" from the "argocd/metrics-exporter-pod-10" pod to the local machine's "/tmp/bar" directory. | Command:
```bash
kubectl cp argocd/metrics-exporter-pod-10::/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 k... |
Add a taint with the key 'workload' on nodes having the label tier=frontend | Command:
```bash
kubectl taint node -l tier=frontend workload=prod-node-5: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": "... |
Execute the 'postgres' command in the 'rocket-ranger' container of the 'log-aggregator-pod' pod. | Command:
```bash
kubectl exec log-aggregator-pod -c rocket-ranger -- postgres
```
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 omitt... |
Delete the pods and services with the names "api" and "vpn" | Command:
```bash
kubectl delete pod,service api vpn
```
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.
Some re... |
Create a service for a replicated hazelcast, which serves on port 80 and connects to the containers on port 8000 | Command:
```bash
kubectl expose rc hazelcast --port=3306 --target-port=543200
```
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 po... |
delete the pods and services with the label instance=app-instance-1 | Command:
```bash
kubectl delete pods,services -l instance=app-instance-1
```
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 la... |
Forward traffic from port 8081 on localhost and IP 10.19.21.23 to port 8888 in the cdn-service-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/cdn-service-pod 8081: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 cri... |
Set the service account of the deployment frontend-deployment to spinnaker. | Command:
```bash
kubectl set serviceaccount deployment frontend-deployment spinnaker
```
What it does:
Update the service account of pod template resources.
Possible resources (case insensitive) can be:
replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset
Syntax:
`kubectl... |
create a job named 'certificate-renewal' using the 'mongo' image and run 'mongo' command inside the job | Command:
```bash
kubectl create job certificate-renewal --image=mongo -- mongo
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format.... |
Create a new config map named global-config with specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap global-config --from-file=conf=/path/to/settings/file1.txt --from-file=data=/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 creating a ... |
Create a service for the replicated centos using the replica set, serving on port 8181 and connecting to the containers on port 808100. | Command:
```bash
kubectl expose rs centos --port=8181 --target-port=808100
```
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.... |
Get the output from running the command 'apache2ctl -D FOREGROUND' in the container of the 'e-commerce-pod' pod. | Command:
```bash
kubectl exec e-commerce-pod -- apache2ctl -D FOREGROUND
```
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, u... |
Create a cluster role named "default_role" with ResourceName specified as "cache-redis" and "machine-learning" that allows the "watch" verb on the "pods" resource. | Command:
```bash
kubectl create clusterrole default_role --verb=watch --resource=pods --resource-name=cache-redis --resource-name=machine-learning
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|cl... |
Copy the "/tmp/foo_dir" directory from the remote pod "task-processor-pod-17" in the "kube-flannel" namespace to the "/tmp/bar" directory locally. | Command:
```bash
kubectl cp kube-flannel/task-processor-pod-17:/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, us... |
List all deployments in the "feature-branch-2.3.0" version of the "external-apps" API group in YAML output format | Command:
```bash
kubectl get deployments.feature-branch-2.3.0.external-apps -o yaml
```
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 na... |
Update the pod specified in "setup.json" by adding the annotation 'release-notes' with the value 'https://example.com/release-notes/v2.5.1' | Command:
```bash
kubectl annotate -f setup.json release-notes='https://example.com/release-notes/v2.5.1'
```
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 lar... |
Create a new config map named 'namespace-config' with the following keys: 'properties' from the file '/path/to/options/file1.txt' and 'key1' from the file '/path/to/configurations/file2.txt' | Command:
```bash
kubectl create configmap namespace-config --from-file=properties=/path/to/options/file1.txt --from-file=key1=/path/to/configurations/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... |
Import environment variables from a config map with a specified prefix into a deployment. | Command:
```bash
kubectl set env --from=configmap/app-config-dev --prefix=MYSQL_ deployment/frontend-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 i... |
Add a taint to a specific node with a key, value, and effect | Command:
```bash
kubectl taint nodes dev-node-4 dedicated=special-user:NoSchedule
```
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": "Output for... |
Create a new config map named app-settings using the specified keys instead of the file basenames on disk | Command:
```bash
kubectl create configmap app-settings --from-file=settings=/path/to/configurations/file1.txt --from-file=key2=/path/to/preferences/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 c... |
Forward local port 5000 to port 9090 in a pod selected by the api-server-deployment deployment | Command:
```bash
kubectl port-forward deployment/api-server-deployment 5000 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 pod will b... |
Create a new secret named 'payment-gateway-secret' with keys for each file in the 'path/to/data' folder. | Command:
```bash
kubectl create secret generic payment-gateway-secret --from-file=path/to/data
```
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 to the basename ... |
Update the pod 'log-aggregator' by adding the annotation 'deployment-script' with the value 'https://example.com/deploy.sh' | Command:
```bash
kubectl annotate pods log-aggregator deployment-script='https://example.com/deploy.sh'
```
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 larg... |
Create a deployment named sonarqube using the ethereum/client-go image and expose port 8080. | Command:
```bash
kubectl create deployment sonarqube --image=ethereum/client-go --port=8080
```
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 fo... |
Start a pod using the Amazon Linux image and expose port 7000 | Command:
```bash
kubectl run hazelcast --image=amazonlinux --port=7000
```
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":... |
Begin streaming the logs from all containers in pods with the 'role=database' label | Command:
```bash
kubectl logs -f -l role=database --all-containers=true
```
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:
"flag": "--conta... |
Forward traffic from port 8080 on all addresses to port 9090 in the pod named "proxy-server-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/proxy-server-pod 8080: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 pod ... |
Forward traffic from port 8000 on localhost and IP 10.19.21.23 to port 3000 in the frontend-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/frontend-pod 8000:3000
```
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 criter... |
Set the CPU and memory limits to 200 milliCPU and 512 megabytes respectively, and the CPU and memory requests to 2 CPU and 128 megabytes respectively, for all containers in the jenkins deployment. | Command:
```bash
kubectl set resources deployment jenkins --limits=cpu=200m,memory=512Mi --requests=cpu=2,memory=128Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource request... |
Create a service for a Ruby deployment, serving on port 80 and connecting to the containers on port 8000 | Command:
```bash
kubectl expose deployment ruby --port=9000 --target-port=808800
```
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... |
Create a new secret named aws-credentials-secret with keys for each file in the path/to/configurations folder. | Command:
```bash
kubectl create secret generic aws-credentials-secret --from-file=path/to/configurations
```
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 to the... |
Create a new config map named 'kube-system-config' using the files 'file1.txt' and 'file2.txt' as the values | Command:
```bash
kubectl create configmap kube-system-config --from-file=conf=/path/to/configs/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 co... |
Embed the certificate authority data for the 'my-k8s-cluster' cluster entry by executing the command: | Command:
```bash
kubectl config set-cluster my-k8s-cluster --embed-certs --certificate-authority=~/.kube/app-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 se... |
Check if the current user has permission to list the "database-indexing-job" job in the "kube-node-lease" namespace. | Command:
```bash
kubectl auth can-i list jobs.batch/database-indexing-job -n kube-node-lease
```
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 ... |
Forward traffic from port 9090 on all addresses to port 8080 in the pod named "chat-app-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/chat-app-pod 9090:8080
```
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 will... |
Create a new secret named database-secret using the files located in the "path/to/configs" folder. | Command:
```bash
kubectl create secret generic database-secret --from-file=path/to/configs
```
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 to the basename of t... |
Remove the taint with key 'workload' and effect 'NoSchedule' from the node 'node-2' if one exists | Command:
```bash
kubectl taint nodes node-2 workload:NoSchedule-
```
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": "Output format. One of: json... |
Execute the 'nginx -t' command in the code-explorer container of the chat-app-pod and retrieve the output. | Command:
```bash
kubectl exec chat-app-pod -c code-explorer -- nginx -t
```
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, us... |
Get the output from running the 'postgres' command in the 'cyber-sleuth' container from the 'email-service-pod' pod | Command:
```bash
kubectl exec email-service-pod -c cyber-sleuth -- postgres
```
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... |
Create a copy of the cdn-service-pod with a debug container and modified container images | Command:
```bash
kubectl debug cdn-service-pod -it --copy-to=debug-image-web --image=debian --set-image=scheduler=my-scheduler:1.0,app=app:debug
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by res... |
Create a single ingress called 'public-api-ingress' that directs requests to testing.com/module to the service 'svc1' on port 8089, using the TLS secret 'my-cert'. | Command:
```bash
kubectl create ingress public-api-ingress --rule="testing.com/module=svc1:8089,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": "",... |
Add a taint with key 'workload' on nodes having label release=beta | Command:
```bash
kubectl taint node -l release=beta workload=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": ... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=DATABASE_URL --from=configmap/app-config-dev 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 definitio... |
Create a single ingress called 'external-ingress' that directs requests to website.com/example to svc1:5000 with a tls secret "my-cert" | Command:
```bash
kubectl create ingress external-ingress --rule="website.com/example=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": "", ... |
Set up automatic scaling for the "security" deployment with a minimum of 6 pods and a maximum of 10 pods | Command:
```bash
kubectl autoscale deployment security --min=6 --max=10
```
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 use... |
Add a taint with key 'datacenter' on nodes with the label version=v1.0.0 | Command:
```bash
kubectl taint node -l version=v1.0.0 datacenter=app-node-6: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":... |
Open the backend-service resource for editing using the Emacs editor as the alternative. | Command:
```bash
KUBE_EDITOR="emacs" kubectl edit svc/backend-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... |
List deployments in JSON output format, specifically for the "hotfix-1.1.2" version of the "legacy-apps" API group. | Command:
```bash
kubectl get deployments.hotfix-1.1.2.legacy-apps -o json
```
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 y... |
Set the cpu limit of the redis container in the deployment named "redis" to "200m" and the memory limit to "4Gi" | Command:
```bash
kubectl set resources deployment redis -c=nginx --limits=cpu=200m,memory=4Gi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to i... |
Get the output from running the 'dotnet --list-runtimes' command inside the pod named vpn-service-pod. | Command:
```bash
kubectl exec vpn-service-pod -- dotnet --list-runtimes
```
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, us... |
Create and run a pod called "hazelcast" using the "golang" image, and expose port 8000. | Command:
```bash
kubectl run hazelcast --image=golang --port=8000
```
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... |
Delete the 'proxy' pod and 'frontend' service | Command:
```bash
kubectl delete pod,service proxy frontend
```
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.
... |
Forward traffic from local port 8088 to port 8088 in the backend-pod | Command:
```bash
kubectl port-forward pod/backend-pod 8088:8088
```
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 will be selected automa... |
Set the custom TLS server name 'data-cluster' for the 'sun-cluster' cluster entry | Command:
```bash
kubectl config set-cluster sun-cluster --tls-server-name=data-cluster
```
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-cluster NAME [--server=server] [--certificate-... |
Forward traffic from port 5000 on localhost and IP 10.19.21.23 to port 8888 in the 'cdn-service-pod' pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/cdn-service-pod 5000: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 cri... |
Copy a file named "foo" from the "/tmp" directory of a remote pod called "ingress-controller-pod-8" in the "argocd" namespace to the "/tmp" directory on your local machine. | Command:
```bash
kubectl cp argocd/ingress-controller-pod-8:/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 k... |
Listen on ports 8000 and 6379 locally, forwarding data to/from ports 6379 and 8000 in a pod selected by the api-server-deployment deployment | Command:
```bash
kubectl port-forward deployment/api-server-deployment 8000 6379
```
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 will b... |
replace a pod using the preferences.yaml file as the configuration | Command:
```bash
cat preferences.yaml | kubectl replace -f -
```
What it does:
Replace a resource by file name or stdin.
JSON and YAML formats are accepted. If replacing an existing resource, the complete resource spec must be provided. This can be obtained by
$ kubectl get TYPE NAME -o yaml
Syntax:
`kubectl replace ... |
Copy the contents of /var/run/secrets/kubernetes.io/serviceaccount/ from the pod 'database-pod-2' in the 'rook-ceph' namespace to the local directory '/tmp/bar_dir' | Command:
```bash
kubectl cp rook-ceph/database-pod-2:/var/run/secrets/kubernetes.io/serviceaccount/ /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": "Con... |
Import the 'log_level' key from the 'kube-system-config' config map into the 'gateway-deployment' deployment | Command:
```bash
kubectl set env --keys=log_level --from=configmap/kube-system-config 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 definitio... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=REDIS_HOST --from=configmap/monitoring-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 de... |
Remove all taints with the key 'environment' from the node named 'storage-node-13'. | Command:
```bash
kubectl taint nodes storage-node-13 environment-
```
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": "Output format. One of: jso... |
Taint nodes with the label "cluster=my-cluster" and add a taint with key "zone" and value "gpu-node-12" and effect "PreferNoSchedule". | Command:
```bash
kubectl taint node -l cluster=my-cluster zone=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": "", "usage": ... |
Update the image of all containers in the 'nginx' daemonset to 'mongo:5.0.2' | Command:
```bash
kubectl set image daemonset nginx *=mongo:5.0.2
```
What it does:
Update existing container image(s) of resources.
Possible resources include (case insensitive):
pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), statefulset (sts), cronjob (cj), replicaset (rs)
Syntax:
`kubect... |
Setup autoscaling for the replication controller "proxy-server" with a target CPU utilization of 20% and a pod range between 1 and 8. | Command:
```bash
kubectl autoscale rc proxy-server --max=8 --cpu-percent=20
```
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... |
Display information about the replica controller named "web", the service named "proxy-service-rc", and the pod named "api-service-pod". | Command:
```bash
kubectl get rc/web service/proxy-service-rc pods/api-service-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 name... |
Start streaming the logs of the 'mycontainer' container in the 'frontend-pod' pod | Command:
```bash
kubectl logs -f -c mycontainer frontend-pod
```
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:
"flag": "--container", "sho... |
Start a wordpress pod with custom specifications overridden from a JSON file | Command:
```bash
kubectl run nginx --image=wordpress --overrides='{ "apiVersion": "dev-2.2.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] -- [... |
Import environment from a secret for a deployment | Command:
```bash
kubectl set env --from=secret/password-secret deployment/monitoring-stack-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 one or m... |
Import the DEBUG_MODE key from the app-config config map and set it as an environment variable for the web-app-deployment deployment. | Command:
```bash
kubectl set env --keys=DEBUG_MODE --from=configmap/app-config deployment/web-app-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... |
Set the resource request and limits for all containers in the 'alpine' deployment | Command:
```bash
kubectl set resources deployment alpine --limits=cpu=200m,memory=512Mi --requests=cpu=3,memory=1Gi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested,... |
Forward traffic from port 8888 on your local machine to port 8000 in the analytics-pod pod | Command:
```bash
kubectl port-forward pod/analytics-pod 8888:8000
```
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 will be selected auto... |
Create a cron job called "alerts-cleanup" with the image "mcr.microsoft.com/dotnet/core/runtime", schedule it to run every minute, and execute the command "dotnet". | Command:
```bash
kubectl create cronjob alerts-cleanup --image=mcr.microsoft.com/dotnet/core/runtime --schedule="*/1 * * * *" -- dotnet
```
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... |
Create an ingress named 'api-ingress' that routes requests to website.com/bar to the service 'svc1' on port 6379, using the TLS secret 'my-cert' | Command:
```bash
kubectl create ingress api-ingress --rule="website.com/bar=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": "", "usage": ... |
Get logs from the container "payment-gateway-pod-1" of the deployment "gateway-deployment" | Command:
```bash
kubectl logs deployment/gateway-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 flags:
"fl... |
Set the cluster field in the specified context to the specified cluster | Command:
```bash
kubectl config set contexts.client-1-context.cluster app-cluster
```
What it does:
Set 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.
PROPERTY_VALUE is the new value you ... |
Import the environment variables from the 'aws-credentials-secret' secret into the 'mydeployment' deployment | Command:
```bash
kubectl set env --from=secret/aws-credentials-secret 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 more pod ... |
Set the CPU and memory limits for a deployment called "php" in the container named "nginx" to 10 and 4Gi respectively. | Command:
```bash
kubectl set resources deployment php -c=nginx --limits=cpu=10,memory=4Gi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to its s... |
Patch a node using a strategic merge patch with a JSON patch | Command:
```bash
kubectl patch node k8s-node-1 -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]`
Helpf... |
Update the image of all containers in the 'services' daemonset to 'debian:11.0'. | Command:
```bash
kubectl set image daemonset services *=debian:11.0
```
What it does:
Update existing container image(s) of resources.
Possible resources include (case insensitive):
pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), statefulset (sts), cronjob (cj), replicaset (rs)
Syntax:
`kub... |
Create a service for the replicated node "node" that serves on port 8888 and connects to the containers on port 500100. | Command:
```bash
kubectl expose rc node --port=8888 --target-port=500100
```
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. A... |
taint nodes with a label 'app=web-app' with a taint having key 'special' and value 'monitoring-node-15:PreferNoSchedule' | Command:
```bash
kubectl taint node -l app=web-app special=monitoring-node-15: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... |
Expose the deployment named "ubuntu" as a service on port 8010, with the containers in the deployment being accessed on port 909100. | Command:
```bash
kubectl expose deployment ubuntu --port=8010 --target-port=909100
```
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... |
Auto scale the replication controller "media-stream" to have a minimum of 1 pod and a maximum of 4 pods, with a target CPU utilization of 50%. | Command:
```bash
kubectl autoscale rc media-stream --max=4 --cpu-percent=50
```
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... |
Add a taint with the key 'special' on nodes that have the label 'owner' equal to 'john-doe' | Command:
```bash
kubectl taint node -l owner=john-doe special=web-node-8: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": "O... |
Delete the pods and services named "chat-app" and "auth" | Command:
```bash
kubectl delete pod,service chat-app auth
```
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.
S... |
Get the output of running the 'elasticsearch' command in the 'warp-drive' container inside the 'gateway-pod' pod. | Command:
```bash
kubectl exec gateway-pod -c warp-drive -- elasticsearch
```
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, u... |
Copy a local file to a remote pod in a specific namespace | Command:
```bash
kubectl cp /tmp/foo argocd/ingress-controller-pod-8:/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 th... |
Unset the namespace in the user-a-context context | Command:
```bash
kubectl config unset contexts.user-a-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_NAME... |
Import the DEBUG_MODE environment variable from the 'app-name-config' config map and set it in the 'order-processing-deployment' deployment. | Command:
```bash
kubectl set env --keys=DEBUG_MODE --from=configmap/app-name-config deployment/order-processing-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 de... |
Import specific keys from a config map into the deployment. | Command:
```bash
kubectl set env --keys=log_level --from=configmap/log-config deployment/analytics-platform-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 defini... |
Delete all pods and services with the label "role=database" | Command:
```bash
kubectl delete pods,services -l role=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 select... |
List the specified resources (replication controller, service, and pod) by their type and names. | Command:
```bash
kubectl get rc/web service/gateway-rc pods/backend-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 you... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.