prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Create a deployment with 5 replicas running the mongo image and name it "loadbalancer". | Command:
```bash
kubectl create deployment loadbalancer --image=mongo --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... |
Forward traffic from port 3000 on all addresses to port 8081 in the 'frontend-pod' pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/frontend-pod 3000: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... |
Copy the local file /tmp/foo to the remote pod named metrics-exporter-pod-10 in the istio-system namespace at the path /tmp/bar_dir. | Command:
```bash
kubectl cp /tmp/foo istio-system/metrics-exporter-pod-10:/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, u... |
Run 'mysql' command in the first pod of the 'gateway-deployment' deployment. | Command:
```bash
kubectl exec deploy/gateway-deployment -- 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 k... |
Check if you have the permission to list the "deploy-artifacts-job" job in the "development" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/deploy-artifacts-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 parti... |
Set a custom TLS server name for the kube-cluster-1 cluster entry. | Command:
```bash
kubectl config set-cluster kube-cluster-1 --tls-server-name=sun-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] [--certificat... |
View the most recent 23 lines of output for a specific pod | Command:
```bash
kubectl logs --tail=23 mypod
```
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", "def... |
Create a job named "certificate-renewal" with the image "alpine" and run the command "ash" inside the job container. | Command:
```bash
kubectl create job certificate-renewal --image=alpine -- ash
```
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. ... |
Forward traffic from local port 9090 to port 9090 in the frontend-pod | Command:
```bash
kubectl port-forward pod/frontend-pod 9090: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 autom... |
Edit and apply the last-applied-configuration annotations for a specific deployment. | Command:
```bash
kubectl apply edit-last-applied deployment/docker.elastic.co/elasticsearch/elasticsearch
```
What it does:
Edit the latest last-applied-configuration annotations of resources from the default editor.
The edit-last-applied command allows you to directly edit any API resource you can retrieve via the co... |
Forward local traffic on port 8080 to the targetPort of the "https" port in the "scheduler-service" service | Command:
```bash
kubectl port-forward service/scheduler-service 8080:https
```
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 sele... |
Create an ingress called 'app-loadbalancer-ingress' that forwards requests from 'site.com/input' to 'svc1:8081' with a TLS secret named "my-cert". | Command:
```bash
kubectl create ingress app-loadbalancer-ingress --rule="site.com/input=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": "... |
Display the most recent 20 lines of logs for the pod "email-service-pod" | Command:
```bash
kubectl logs --tail=20 email-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"... |
Create a pod disruption budget named monitoring-pdb that will select all pods with the app=rails label and require at least four of them to be available at any point in time | Command:
```bash
kubectl create poddisruptionbudget monitoring-pdb --selector=app=rails --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 [--dr... |
Forward port 5000 on localhost and IP 10.19.21.23 to port 9090 in the backend pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/backend-pod 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 criteri... |
Create a new config map named "app-config", and populate it with specified keys and file paths | Command:
```bash
kubectl create configmap app-config --from-file=settings=/path/to/configurations/file1.txt --from-file=key2=/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 crea... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=API_KEY --from=configmap/env-vars 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 one o... |
Create an ingress resource called 'private-ingress' that directs requests from testing.com/module to the service svc1:8082, using the TLS secret "my-cert" | Command:
```bash
kubectl create ingress private-ingress --rule="testing.com/module=svc1:8082,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... |
Check if the current user has permission to list the "cache-warming-job" job in the "staging" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/cache-warming-job -n staging
```
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 ... |
Copy the contents of the /var/run/secrets/kubernetes.io/serviceaccount/ directory from the metrics-exporter-pod-10 pod in the kube-system namespace to the /tmp/bar_dir directory on your local machine. | Command:
```bash
kubectl cp kube-system/metrics-exporter-pod-10:/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": "", "u... |
Create a service for the php deployment that serves on port 8010 and connects to the containers on port 888800 | Command:
```bash
kubectl expose deployment php --port=8010 --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 specified ... |
Create a new secret named password-secret and use each file in the folder bar as a key to store their contents | Command:
```bash
kubectl create secret generic password-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 of the ... |
Create a single ingress called 'api-gateway-ingress' with the following rules: | Command:
```bash
kubectl create ingress api-gateway-ingress --rule="foo.com/bar=svc1:5432,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... |
Update the user field of the app-1-context context entry to "cluster-admin" without modifying any other values. | Command:
```bash
kubectl config set-context app-1-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... |
Forward port 8088 on localhost and IP 10.19.21.23 to port 9090 in the chat-app-pod pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/chat-app-pod 8088: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 criter... |
Open the service "monitoring-service" for editing using the "atom" editor. | Command:
```bash
KUBE_EDITOR="atom" kubectl edit svc/monitoring-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 variab... |
Get output from 'geth attach' command running on the first pod of the deployment "notification-handler-deployment". | Command:
```bash
kubectl exec deploy/notification-handler-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... |
Create a new config map named db-config with keys "conf" and "data" using the properties files at /path/to/properties/file1.txt and /path/to/properties/file2.txt respectively. | Command:
```bash
kubectl create configmap db-config --from-file=conf=/path/to/properties/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 co... |
Provide a detailed description of the research-node-15.research-lab.local node | Command:
```bash
kubectl describe nodes research-node-15.research-lab.local
```
What it does:
Show details of a specific resource or group of resources.
Print a detailed description of the selected resources, including related resources such as events or controllers. You may select a single object by name, all objects... |
update the image version (tag) of a single-container pod to v4 | Command:
```bash
kubectl get pod database-pod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | 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
$ ... |
List the deployments in the "v1.0.0" version of the "internal-apps" API group in JSON output format. | Command:
```bash
kubectl get deployments.v1.0.0.internal-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 w... |
Create a new config map named kube-system-config in the current namespace using the specified keys and their corresponding file paths | Command:
```bash
kubectl create configmap kube-system-config --from-file=settings=/path/to/preferences/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.
Whe... |
Create a debug copy of the email-service pod by adding a debug container and changing container images. | Command:
```bash
kubectl debug email-service-pod -it --copy-to=my-custom-dbg --image=debian --set-image=app=app:debug,worker=my-custom-worker:1.2.3
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by ... |
Copy a file from a remote pod to a local directory. | Command:
```bash
kubectl cp kube-server/message-broker-pod-15:/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 ... |
Auto scale the replication controller "proxy-server" with the number of pods ranging from 1 to 7, targeting a CPU utilization of 90%. | Command:
```bash
kubectl autoscale rc proxy-server --max=7 --cpu-percent=90
```
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... |
Create a pod disruption budget named batch-processing-pdb that will select all pods with the component=web label and require at least four of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget batch-processing-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-availab... |
Scale the 'payment-service-rs' deployment to 1 replica, only if its current size is already 1. | Command:
```bash
kubectl scale --current-replicas=1 --replicas=1 deployment/payment-service-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-... |
Embed certificate authority data for the testing-cluster cluster entry | Command:
```bash
kubectl config set-cluster testing-cluster --embed-certs --certificate-authority=~/.kube/my-k8s-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 confi... |
Delete the context for a specific cluster | Command:
```bash
kubectl config delete-context dev-context
```
What it does:
Delete the specified context from the kubeconfig.
Syntax:
`kubectl config delete-context NAME` |
Embed the certificate authority data for the 'on-prem-cluster' cluster entry by running the command 'kubectl config set-cluster on-prem-cluster --embed-certs --certificate-authority=~/.kube/cluster-beta/kubernetes.ca.crt' | Command:
```bash
kubectl config set-cluster on-prem-cluster --embed-certs --certificate-authority=~/.kube/cluster-beta/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 ... |
Create a service for a replication controller specified in "nginx-controller.yaml" with the following configuration: serve on port 80 and connect to the containers on port 8000. | Command:
```bash
kubectl expose -f nginx-controller.yaml --port=8082 --target-port=844300
```
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 ... |
Add a taint with key 'hardware' on nodes having label component=proxy | Command:
```bash
kubectl taint node -l component=proxy hardware=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":... |
create a job named 'batch-processing' using the 'ethereum/client-go' image, and execute the command 'geth version' | Command:
```bash
kubectl create job batch-processing --image=ethereum/client-go -- geth version
```
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"... |
Add a taint with the key 'disktype' and the value 'prod-node-5:PreferNoSchedule' on nodes that have the label 'environment=production' | Command:
```bash
kubectl taint node -l environment=production disktype=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": "", "... |
Start a golang pod and configure the container to expose port 8888 | Command:
```bash
kubectl run hazelcast --image=golang --port=8888
```
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... |
Switch to the raw terminal mode of the auth-service-pod container named stardust-shuttle and attach to it | Command:
```bash
kubectl attach auth-service-pod -c stardust-shuttle -i -t
```
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. ... |
Create a pod disruption budget named load-balancer-pdb that will select all pods with the env=production label and require a minimum of four of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget load-balancer-pdb --selector=env=production --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... |
Create an ingress named "ingress1" with multiple hosts and the pathType set as Prefix | Command:
```bash
kubectl create ingress ingress1 --class=default \
--rule="testing.com/path*=svc:3001" \
--rule="module.com/admin*=svc2:http"
```
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": "--outpu... |
Return the snapshot logs from the container named chat-app-pod-1 of the load-balancer-deployment deployment | Command:
```bash
kubectl logs deployment/load-balancer-deployment -c chat-app-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:
"fla... |
Import environment variables from a secret to a deployment | Command:
```bash
kubectl set env --from=secret/database-secret deployment/api-server-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 more po... |
Display the last 31 lines of logs for the pod "proxy-service-pod" | Command:
```bash
kubectl logs --tail=31 proxy-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"... |
Set the CPU limit of the nginx container in the `wordpress` deployment to "200m" and the memory limit to "128Mi". | Command:
```bash
kubectl set resources deployment wordpress -c=nginx --limits=cpu=200m,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 requested, but may burst u... |
Execute the 'elasticsearch' command in the 'quantum-quark' container of the 'payment-gateway-pod' pod | Command:
```bash
kubectl exec payment-gateway-pod -c quantum-quark -- 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... |
List deployments in the "alpha-2.0" version of the "api-v1" API group in JSON output format. | Command:
```bash
kubectl get deployments.alpha-2.0.api-v1 -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 will ... |
Copy the local file ~/.config/kube to the remote pod metrics-exporter-pod-10, specifically to the container web-app-container, in the directory /tmp/bar. | Command:
```bash
kubectl cp ~/.config/kube metrics-exporter-pod-10::/tmp/bar -c web-app-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... |
Create a copy of the analytics-pod with a debug container and different container images | Command:
```bash
kubectl debug analytics-pod -it --copy-to=my-custom-dbg --image=debian --set-image=database=mysql:5.7,proxy=nginx:1.21
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and... |
Import environment variables prefixed with "MYSQL_" from a config map to a deployment | Command:
```bash
kubectl set env --from=configmap/app-config --prefix=MYSQL_ deployment/scheduler-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 ... |
Create a cluster role named "reader" with specific resource names | Command:
```bash
kubectl create clusterrole reader --verb=use --resource=services --resource-name=content-delivery --resource-name=keycloak-server
```
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 a file from a remote pod to a local directory | Command:
```bash
kubectl cp rook-ceph/payment-gateway-pod-19:/tmp/foo /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... |
Retrieve the previous logs of the terminated "code-explorer" container from the "email-service-pod" pod. | Command:
```bash
kubectl logs -p -c code-explorer email-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... |
Retrieve the previous terminated logs for the "mycontainer" container in the "api-service-pod" pod. | Command:
```bash
kubectl logs -p -c mycontainer 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", "... |
Run the 'docker run -it ubuntu' command in the lunar-launcher container of the gateway-pod and get the output. | Command:
```bash
kubectl exec gateway-pod -c lunar-launcher -- docker run -it ubuntu
```
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. I... |
Delete the pods and services with the names "frontend" and "log-aggregator" | Command:
```bash
kubectl delete pod,service frontend log-aggregator
```
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 s... |
Forward port 8081 on your local machine to port 3000 in the 'frontend-pod' pod. | Command:
```bash
kubectl port-forward pod/frontend-pod 8081: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 autom... |
Create an ingress named 'api-gateway-ingress' that maps requests from foo.com/module to svc1:27017 and use the tls certificate named "my-cert" | Command:
```bash
kubectl create ingress api-gateway-ingress --rule="foo.com/module=svc1:27017,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": "", "... |
Listen on port 8888 locally, forwarding to port 8080 in the 'api-service-pod' pod | Command:
```bash
kubectl port-forward pod/api-service-pod 8888: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 au... |
Execute the 'mysql' command in the first container of the 'frontend-deployment' deployment and display the output. | Command:
```bash
kubectl exec deploy/frontend-deployment -- 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 ... |
Run the 'irb' command in the nano-bot container of the api-service-pod pod | Command:
```bash
kubectl exec api-service-pod -c nano-bot -- irb
```
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 k... |
Forward traffic from port 5000 on all addresses to port 8081 in the pod named "e-commerce-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/e-commerce-pod 5000: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 wi... |
Watch the progress of a deployment rollout | Command:
```bash
kubectl rollout status deployment/services
```
What it does:
Show the status of the rollout.
By default 'rollout status' will watch the status of the latest rollout until it's done. If you don't want to wait for the rollout to finish then you can use --watch=false. Note that if a new rollout starts in... |
Add a taint with key 'environment' on nodes having the label 'team=devops' | Command:
```bash
kubectl taint node -l team=devops environment=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... |
Execute the 'nginx' command in the first container of the 'frontend-service' service | Command:
```bash
kubectl exec svc/frontend-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 kubect... |
Create a copy of the monitoring-pod with all container images changed to mysql. | Command:
```bash
kubectl debug monitoring-pod --copy-to=debug-image-memcached --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... |
Import specific keys from a config map to the deployment. | Command:
```bash
kubectl set env --keys=MAX_CONNECTIONS --from=configmap/namespace-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 vari... |
Create a new nginx pod using the nginx image, but customize the pod specification by providing a JSON object containing the desired changes to the "spec" field. | Command:
```bash
kubectl run nginx --image=nginx --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] -- [COMM... |
Create a new config map named app-config-prod with specific keys and files as the values | Command:
```bash
kubectl create configmap app-config-prod --from-file=properties=/path/to/parameters/file1.txt --from-file=key1=/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 cre... |
List the specified resources and their details | Command:
```bash
kubectl get rc/web service/payment-gateway-rc pods/database-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 names... |
Display only the most recent 5 lines of logs for a pod named mypod | Command:
```bash
kubectl logs --tail=5 mypod
```
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", "defa... |
Create a new config map with specific key-value pairs | Command:
```bash
kubectl create configmap log-config --from-literal=properties=config1 --from-literal=key1=config2
```
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 k... |
Copy the local file /tmp/foo to the /etc/kubernetes directory in the payment-gateway-pod-19 pod in the kube-public namespace. | Command:
```bash
kubectl cp :/tmp/foo kube-public/payment-gateway-pod-19:/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,... |
delete the pods and services named "media-stream" and "api" | Command:
```bash
kubectl delete pod,service media-stream api
```
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... |
Check if you have permission to list the "batch-processing-job" job in the "kube-public" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/batch-processing-job -n kube-public
```
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 parti... |
Create a deployment named "logging" that runs the "mysql" image and exposes port 3001. | Command:
```bash
kubectl create deployment logging --image=mysql --port=3001
```
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: j... |
Update the server field for the sun-cluster cluster entry to https://1.2.3.4 without modifying any other values. | Command:
```bash
kubectl config set-cluster sun-cluster --server=https://1.2.3.4
```
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-author... |
Create a cron job named data-sync that runs the command "docker run ubuntu echo 'Hello'" every minute. | Command:
```bash
kubectl create cronjob data-sync --image=ubuntu --schedule="*/1 * * * *" -- docker run ubuntu echo "Hello
```
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"... |
Import the MAX_CONNECTIONS key from the db-config ConfigMap and set it as an environment variable in the gateway-deployment deployment. | Command:
```bash
kubectl set env --keys=MAX_CONNECTIONS --from=configmap/db-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 ... |
Set the cpu limits of the mongo container in the deployment named "mongo" to "2" and the memory limits to "128Mi". | Command:
```bash
kubectl set resources deployment mongo -c=nginx --limits=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 requested, but may burst up to it... |
Expose a replication controller named "hazelcast" as a service, listening on port 8181 and forwarding traffic to containers on port 500100. | Command:
```bash
kubectl expose rc hazelcast --port=8181 --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 po... |
Use Atom as the editor to edit the search-service service. | Command:
```bash
KUBE_EDITOR="atom" kubectl edit svc/search-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 variables,... |
Create a new config map named 'namespace-config' using the specified files '/path/to/preferences/file1.txt' and '/path/to/preferences/file2.txt' as key-value pairs | Command:
```bash
kubectl create configmap namespace-config --from-file=settings=/path/to/preferences/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 ... |
Import the DEBUG_MODE key from the global-config config map and set it as an environment variable in the analytics-platform-deployment deployment. | Command:
```bash
kubectl set env --keys=DEBUG_MODE --from=configmap/global-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 de... |
Forward local port 8088 to the targetPort of the "https" service port in a selected pod. | Command:
```bash
kubectl port-forward service/web-service 8088:https
```
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 a... |
Import the 'smtp_server' key from the 'app-secrets' config map and set it as an environment variable for the 'cache-cluster-deployment' deployment. | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/app-secrets deployment/cache-cluster-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 definiti... |
Update the environment variables of a deployment with specific keys from a config map. | Command:
```bash
kubectl set env --keys=EXTERNAL_API_URL --from=configmap/kube-system-config deployment/user-management-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... |
Import the environment variables from the secret named "gcp-service-account-secret" into the "user-management-deployment" deployment. | Command:
```bash
kubectl set env --from=secret/gcp-service-account-secret deployment/user-management-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... |
View the logs from container frontend-pod-1 in the load-balancer-deployment-1 deployment. | Command:
```bash
kubectl logs deployment/load-balancer-deployment -c frontend-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:
"fla... |
Create an ingress named 'internal-ingress' with a rule that directs requests for 'site.com/bar' to the service 'svc1' on port '9091' | Command:
```bash
kubectl create ingress internal-ingress --rule="site.com/bar=svc1:9091,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"... |
Set the service account of the deployment "order-processing-deployment" to "fluentd" | Command:
```bash
kubectl set serviceaccount deployment order-processing-deployment fluentd
```
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:
`k... |
create a cron job named "database-maintenance" using the nginx image, with a schedule of running every minute, and executing the command "nginx". | Command:
```bash
kubectl create cronjob database-maintenance --image=nginx --schedule="*/1 * * * *" -- nginx
```
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... |
Remove the label named 'bar' from the pod 'security', if it exists | Command:
```bash
kubectl label pods security role-
```
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.