prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
create a configmap named "db-config" using specified keys and file paths | Command:
```bash
kubectl create configmap db-config --from-file=properties=/path/to/data/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 creating ... |
Set the cpu limits for the python deployment's nginx container to 5 and memory limits to 256Mi. | Command:
```bash
kubectl set resources deployment python -c=nginx --limits=cpu=5,memory=256Mi
```
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... |
Create a LoadBalancer service named api-service-lb | Command:
```bash
kubectl create service loadbalancer api-service-lb --tcp=8181:5432
```
What it does:
Create a LoadBalancer service with the specified name.
Syntax:
`kubectl create service loadbalancer NAME [--tcp=port:targetPort] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "def... |
Add a taint with key 'app' and value 'backend' and effect 'PreferNoSchedule' to the node worker-node-3 | Command:
```bash
kubectl taint nodes worker-node-3 app=backend: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": "Output forma... |
Import the 'log_level' key from the 'log-config' config map and apply it to the 'web-app-deployment' deployment. | Command:
```bash
kubectl set env --keys=log_level --from=configmap/log-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 on... |
Create a cron job named 'log-rotation' with the image 'ethereum/client-go' and the command 'geth' that runs every minute. | Command:
```bash
kubectl create cronjob log-rotation --image=ethereum/client-go --schedule="*/1 * * * *" -- geth
```
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":... |
Forward local port 9090 to port 5432 in the cdn-service-pod pod | Command:
```bash
kubectl port-forward pod/cdn-service-pod 9090:5432
```
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 au... |
Create a pod disruption budget named ingress-controller-pdb that will select all pods with the env=production label and require at least 9 of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget ingress-controller-pdb --selector=env=production --min-available=9
```
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-avai... |
Create a new config map named app-secrets in the default namespace, using the files file1.txt and file2.txt as the values for the keys conf and data respectively. | Command:
```bash
kubectl create configmap app-secrets --from-file=conf=/path/to/preferences/file1.txt --from-file=data=/path/to/settings/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 c... |
Import specific keys from a config map into an environment variable of a deployment | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/namespace-config 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 var... |
Create a new config map named "app-config" with specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-config --from-file=settings=/path/to/parameters/file1.txt --from-file=key2=/path/to/profiles/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... |
start a pod named 'nginx' using the 'postgres' image | Command:
```bash
kubectl run nginx --image=postgres
```
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": "--filename", "sho... |
Forward traffic from port 8000 on localhost and IP 10.19.21.23 to port 3000 of the web-app-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/web-app-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 criteri... |
Output the modified deployment in YAML format without making any changes to the actual object on the server. | Command:
```bash
kubectl set env deployment/search-engine-deployment SMTP_HOST=smtp.example.com -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 definitions in one or... |
Forward local ports 8000 and 6000 to ports 5432 and 6000 respectively in the selected pod of the deployment "analytics-platform-deployment" | Command:
```bash
kubectl port-forward deployment/analytics-platform-deployment 8000 5432
```
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... |
Update the 'notification-handler-deployment' deployment by adding a new environment variable named 'MONGO_URI' with the value 'mongodb://localhost:27017/mydb' | Command:
```bash
kubectl set env deployment/notification-handler-deployment MONGO_URI=mongodb://localhost:27017/mydb
```
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 definiti... |
Taint nodes with label 'release=beta' as 'special=node-1:PreferNoSchedule' | Command:
```bash
kubectl taint node -l release=beta special=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": "Output ... |
Expose the python deployment as a service, serving on port 8082 and forwarding traffic to the containers on port 330600 | Command:
```bash
kubectl expose deployment python --port=8082 --target-port=330600
```
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... |
Execute the 'dotnet --list-runtimes' command inside the first container of the 'proxy-service' service and display the output. | Command:
```bash
kubectl exec svc/proxy-service -- 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, ... |
Remove the label named 'unhealthy' from the 'analytics' pod if it exists | Command:
```bash
kubectl label pods analytics unhealthy-
```
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 new config map named app-secrets using specified keys and file paths | Command:
```bash
kubectl create configmap app-secrets --from-file=settings=/path/to/configs/file1.txt --from-file=key2=/path/to/profiles/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 c... |
Display the last 3 lines of logs for the pod named backend-pod | Command:
```bash
kubectl logs --tail=3 backend-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", "short": "-c",... |
Update the image of the first container in the 'gateway-pod' pod using a JSON patch, set the image to 'new image' | Command:
```bash
kubectl patch pod gateway-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 (-f ... |
Create a new config map named ui-config with specified keys by providing the paths to the files on disk. | Command:
```bash
kubectl create configmap ui-config --from-file=conf=/path/to/profiles/file1.txt --from-file=data=/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 creating a con... |
Copy the file '/tmp/foo' from the local machine to '/tmp/bar' in the 'monitoring-agent-pod-6' pod's 'auth-service' container. | Command:
```bash
kubectl cp :/tmp/foo monitoring-agent-pod-6::/tmp/bar -c auth-service
```
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, u... |
Add a taint with key 'datacenter' on nodes having label service=auth. | Command:
```bash
kubectl taint node -l service=auth datacenter=node-2: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... |
Create a new secret named tls-certificate-secret with keys for each file in the specified folder | Command:
```bash
kubectl create secret generic tls-certificate-secret --from-file=path/to/preferences
```
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 ba... |
Create a new config map named app-name-config with specified keys using files from disk | Command:
```bash
kubectl create configmap app-name-config --from-file=conf=/path/to/options/file1.txt --from-file=data=/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 creating ... |
create a service for the replication controller specified in ubuntu-controller.yaml, serving on port 5432 and connecting to the containers on port 808900 | Command:
```bash
kubectl expose -f ubuntu-controller.yaml --port=5432 --target-port=808900
```
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... |
Execute the 'bash' command inside the 'code-explorer' container of the 'frontend-pod' pod | Command:
```bash
kubectl exec frontend-pod -c code-explorer -- bash
```
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 th... |
Create a role named "foo" with the ability to create pods and specifically the resource names "machine-learning" and "dev-database". | Command:
```bash
kubectl create role foo --verb=create --resource=pods --resource-name=machine-learning --resource-name=dev-database
```
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|cl... |
Listen on port 8888 locally and forward data to/from port 5000 in the 'search-engine-deployment' deployment. | Command:
```bash
kubectl port-forward deployment/search-engine-deployment 8888 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 deployment named auth using the node image | Command:
```bash
kubectl create deployment auth --image=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|yaml|name|go... |
Forward local port 6379 to port 8088 in a pod selected by the 'search-engine-deployment' deployment. | Command:
```bash
kubectl port-forward deployment/search-engine-deployment 6379 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 wil... |
Add a taint with the key 'special' on nodes that have the label 'zone=us-east-1' | Command:
```bash
kubectl taint node -l zone=us-east-1 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": "", "us... |
Check if the user can list the job named "backup-job" in the "development" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/backup-job -n development
```
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 tha... |
Create a service for a replicated centos using replica set, which serves on port 8181 and connects to the containers on port 637900 | Command:
```bash
kubectl expose rs centos --port=8181 --target-port=637900
```
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.... |
Delete the pods and services with the names "media-stream" and "auth" | Command:
```bash
kubectl delete pod,service media-stream 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 selecto... |
Roll back the 'app-v2' daemonset to revision 1 | Command:
```bash
kubectl rollout undo daemonset/app-v2 --to-revision=1
```
What it does:
Roll back to a previous rollout.
Syntax:
`kubectl rollout undo (TYPE NAME | TYPE/NAME) [flags]`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to files identifying the ... |
Create a job that runs a command using a specific image | Command:
```bash
kubectl create job security-scan-job --image=jenkins -- jenkins-plugin-cli
```
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": "O... |
List the replication controller named 'web', the service named 'security-service-rc', and the pod named 'media-stream-pod' | Command:
```bash
kubectl get rc/web service/security-service-rc pods/media-stream-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 ... |
Forward local port 6379 to port 3000 in the pod "log-aggregator-pod" | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 6379: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 criteria, a pod will be selected... |
Copy the local kube config file to a specific directory in a remote pod in a specified namespace. | Command:
```bash
kubectl cp ~/.config/kube ingress-nginx/ingress-controller-pod-8:/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": "", "usage": "Container name. If... |
Add a taint on nodes with label 'project=project-alpha' and key 'environment' with the value 'k8s-node-1:PreferNoSchedule' | Command:
```bash
kubectl taint node -l project=project-alpha environment=k8s-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": "", ... |
Create an ingress called 'app2-ingress' that routes requests from foo.com/module to svc1:5001 with a TLS secret named "my-cert" | Command:
```bash
kubectl create ingress app2-ingress --rule="foo.com/module=svc1:5001,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 "data-processing" that runs the command "irb" every minute using the "ruby" image. | Command:
```bash
kubectl create cronjob data-processing --image=ruby --schedule="*/1 * * * *" -- irb
```
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", "defa... |
Enable a new exec auth plugin for the "cloud-user" entry by setting the exec command and the exec API version. | Command:
```bash
kubectl config set-credentials cloud-user --exec-command=/path/to/the/executable --exec-api-version=client.authentication.k8s.io/v1beta1
```
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:
... |
Apply a taint to a specific node with a key but no value | Command:
```bash
kubectl taint nodes gpu-node-12 cpu-type: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: ... |
Set the environment variable 'API_KEY' in the 'gateway-deployment' deployment by importing the value from the 'app-config' config map, and only import the keys provided in the 'API_KEY' parameter. | Command:
```bash
kubectl set env --keys=API_KEY --from=configmap/app-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 definitions in one ... |
Forward port 5432 on localhost and IP 10.19.21.23 to port 9090 in the pod named "proxy-server-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/proxy-server-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 cr... |
Create a copy of `api-service-pod` and change all container images to `mcr.microsoft.com/dotnet/core/runtime` for debugging purposes. | Command:
```bash
kubectl debug api-service-pod --copy-to=debug-image-api --set-image=*=mcr.microsoft.com/dotnet/core/runtime
```
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... |
Create a single ingress called 'rontend-ingress' that directs requests to website.com/input to svc1 with port 5000 and uses the tls secret "my-cert" | Command:
```bash
kubectl create ingress rontend-ingress --rule="website.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": "", "us... |
Create a new ClusterIP service named order-service-clusterip | Command:
```bash
kubectl create service clusterip order-service-clusterip --tcp=5001:6379
```
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", ... |
Copy the file "/tmp/foo" from the remote pod "front-end-pod-12" to the local directory "/etc/kubernetes". | Command:
```bash
kubectl cp rook-ceph/front-end-pod-12::/tmp/foo /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": "", "usage": "Container name. If omitted, use the... |
Forward local port 8088 to port 8088 in a pod selected by the email-server-deployment. | Command:
```bash
kubectl port-forward deployment/email-server-deployment 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... |
Forward the local port 8000 to port 8081 in the pod 'mypod' | Command:
```bash
kubectl port-forward pod/mypod 8000: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 pod will be selected automaticall... |
Taint nodes labeled with 'instance=app-instance-1' as 'dedicated=db-node-7:PreferNoSchedule' | Command:
```bash
kubectl taint node -l instance=app-instance-1 dedicated=db-node-7: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": "", "... |
Delete the pods and services with the names "database" and "email" | Command:
```bash
kubectl delete pod,service database email
```
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.
... |
Update the server URL for the web-cluster cluster to "https://1.2.3.4". | Command:
```bash
kubectl config set clusters.web-cluster.server https://1.2.3.4
```
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 wa... |
display the details of revision 5 of the app-v2 daemonset rollout history | Command:
```bash
kubectl rollout history daemonset/app-v2 --revision=5
```
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 URL to ... |
Assign the label 'role=cache' to the pod named 'foo' | Command:
```bash
kubectl label pods foo role=cache
```
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": "If tru... |
Set the annotation 'SLA' on the pod 'analytics' to '99.9% uptime' | Command:
```bash
kubectl annotate pods analytics 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... |
Create a deployment named gitlab that runs the node image and has 4 replicas. | Command:
```bash
kubectl create deployment gitlab --image=node --replicas=4
```
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: js... |
Update the status label of all pods in the current namespace to "unhealthy" | Command:
```bash
kubectl label pods --all status=unhealthy
```
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 deployment named 'sonarqube' using the 'node' image and pass the 'npm --version' command | Command:
```bash
kubectl create deployment sonarqube --image=node -- npm --version
```
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... |
Scale the deployment named prod-app-rs to 5 replicas, assuming its current size is 3. | Command:
```bash
kubectl scale --current-replicas=3 --replicas=5 deployment/prod-app-rs
```
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... |
Import specific keys from a config map into a deployment's environment variables | Command:
```bash
kubectl set env --keys=external_api_url --from=configmap/ui-config 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 variabl... |
Retrieve a list of deployments in the JSON output format for the "hotfix-1.1.2" version of the "testing-apps" API group. | Command:
```bash
kubectl get deployments.hotfix-1.1.2.testing-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 ... |
Copy the local file /tmp/foo_dir to the remote pod load-balancer-pod-9, specifically to the path /tmp/bar, and inside the container named api-server-container. | Command:
```bash
kubectl cp /tmp/foo_dir load-balancer-pod-9:/tmp/bar -c api-server-container
```
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 omi... |
List the deployments in the "v2.0.0" version of the "testing-apps" API group in JSON output format. | Command:
```bash
kubectl get deployments.v2.0.0.testing-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 you wi... |
Create a cron job for a cleanup task. Use the "kubectl create cronjob" command with the specified parameters. | Command:
```bash
kubectl create cronjob cleanup-task --image=amazonlinux --schedule="*/1 * * * *" -- yum install -y aws-cli
```
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... |
Display the most recent 5 lines of logs for the pod "api-service-pod" | Command:
```bash
kubectl logs --tail=5 api-service-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", "short": "... |
Forward local port 5432 to port 6379 in the pod selected by the log-aggregator-deployment deployment. | Command:
```bash
kubectl port-forward deployment/log-aggregator-deployment 5432 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 wi... |
Create a deployment called "logging" that uses the "centos" container image and has 5 replicas. | Command:
```bash
kubectl create deployment logging --image=centos --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 format. One of:... |
Forward traffic from local port 3000 to port 9090 in the pod | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 3000 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 be selected... |
Create an ingress resource called 'api-gateway-ingress' that directs requests to 'foo.com/bar' to the service 'svc1' on port 7000, using the TLS secret 'my-cert'. | Command:
```bash
kubectl create ingress api-gateway-ingress --rule="foo.com/bar=svc1:7000,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... |
Create a job with the name 'log-processing-job' using the 'busybox' image. | Command:
```bash
kubectl create job log-processing-job --image=busybox
```
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. One of:... |
Create a cron job named "log-rotation" that runs the command "gem --version" every minute, using the Ruby image. | Command:
```bash
kubectl create cronjob log-rotation --image=ruby --schedule="*/1 * * * *" -- gem --version
```
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"... |
Create a pod named 'hazelcast' using the 'php' image and expose port 3000. | Command:
```bash
kubectl run hazelcast --image=php --port=3000
```
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": "--file... |
execute the command 'node' in the first container of the first pod of the 'payment-service' service | Command:
```bash
kubectl exec svc/payment-service -- node
```
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.... |
Add a taint with key 'workload' on nodes having label 'instance=app-instance-1' | Command:
```bash
kubectl taint node -l instance=app-instance-1 workload=worker-node-3: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": ""... |
Add a taint with the key 'workload' and value 'prod-node-5:PreferNoSchedule' on all nodes that have the label 'role=database' | Command:
```bash
kubectl taint node -l role=database 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": "... |
Get the output from running the 'mongod' command in the first container of the first pod of the 'analytics-platform-deployment' deployment. | Command:
```bash
kubectl exec deploy/analytics-platform-deployment -- mongod
```
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... |
import the environment variables from the config map "app-name-config" with the prefix "MYSQL_" into the "load-balancer-deployment" deployment | Command:
```bash
kubectl set env --from=configmap/app-name-config --prefix=MYSQL_ deployment/load-balancer-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 definit... |
Listen on port 8081 on localhost and IP address 10.19.21.23, and forward the traffic to port 6379 in the 'backend-pod' pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/backend-pod 8081: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 criteri... |
Set the service account of the deployment "analytics-platform-deployment" to "tiller" | Command:
```bash
kubectl set serviceaccount deployment analytics-platform-deployment tiller
```
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:
`... |
Copy the local file "/tmp/foo" to the remote pod "auth-service-pod-11" in the "kube-dns" namespace | Command:
```bash
kubectl cp :/tmp/foo kube-dns/auth-service-pod-11::/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 kub... |
Create a single ingress called 'api-v2-ingress' that directs requests to 'foo.com/bar' to the service 'svc1' on port '9090' with a TLS secret named "my-cert" | Command:
```bash
kubectl create ingress api-v2-ingress --rule="foo.com/bar=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": "", "usage": "... |
Create a single ingress called 'external-ingress' with the rule that directs requests to website.com/module to svc1:5000, and the TLS secret "my-cert" | Command:
```bash
kubectl create ingress external-ingress --rule="website.com/module=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": "", "... |
Check if I have permission to list the job named "data-migration-job" in the "kube-system" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/data-migration-job -n kube-system
```
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... |
Execute the 'mysql' command inside the container of the pod named 'media-stream-pod' and retrieve the output | Command:
```bash
kubectl exec media-stream-pod -- mysql
```
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.ku... |
Create a copy of the 'analytics-pod' and change all container images to 'jenkins'. The new pod will be named 'debug-image-1'. | Command:
```bash
kubectl debug analytics-pod --copy-to=debug-image-1 --set-image=*=jenkins
```
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 res... |
Auto scale the replication controller "frontend" with a minimum of 1 pod and a maximum of 3 pods, targeting a CPU utilization of 20%. | Command:
```bash
kubectl autoscale rc frontend --max=3 --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 use... |
Forward port 8088 on your local machine to port 8080 in the analytics-pod | Command:
```bash
kubectl port-forward pod/analytics-pod 8088: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 be selected auto... |
Import the 'debug_mode' key from the 'log-config' config map into the 'authentication-service-deployment' deployment. | Command:
```bash
kubectl set env --keys=debug_mode --from=configmap/log-config 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 variable d... |
Create a copy of a pod with a debug container and updated container images | Command:
```bash
kubectl debug gateway-pod -it --copy-to=dgb-img --image=debian --set-image=logger=logging-app:debug,mailer=mailer:latest
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource a... |
Create a cluster role named "bar" with the ability to update pods and specifically target the "dashboard-ui" and "order-fulfillment" resources. | Command:
```bash
kubectl create clusterrole bar --verb=update --resource=pods --resource-name=dashboard-ui --resource-name=order-fulfillment
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|client|n... |
List the deployments in YAML format for the "hotfix-1.1.2" version of the "prod-apps" API group | Command:
```bash
kubectl get deployments.hotfix-1.1.2.prod-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 namespaced you... |
Copy the `~/.config/kube` file from the remote pod named `metallb-system/load-balancer-pod-9` to the local directory `/tmp/bar` | Command:
```bash
kubectl cp metallb-system/load-balancer-pod-9:~/.config/kube /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, u... |
List the deployments in the "v1.1.1" version of the "legacy-apps" API group in JSON format. | Command:
```bash
kubectl get deployments.v1.1.1.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 you wil... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.