prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Retrieve the previous terminated logs from the "nebula-navigator" container in the "frontend-pod" pod. | Command:
```bash
kubectl logs -p -c nebula-navigator 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",... |
Create a copy of the 'e-commerce-pod' pod, changing all container images to 'jenkins'. Name the new pod 'dgb-img'. | Command:
```bash
kubectl debug e-commerce-pod --copy-to=dgb-img --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 resource... |
Add the client certificate data from the file located at ~/.kube/admin.crt to the "api-user" entry. | Command:
```bash
kubectl config set-credentials api-user --client-certificate=~/.kube/admin.crt --embed-certs=true
```
What it does:
Set a user entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values.
Client-certificate flags:
--client-certificate=certfile --client-... |
Create an ingress named 'web-ingress' with a routing rule that directs requests from testing.com/bar to the service named 'svc1' on port 7000 | Command:
```bash
kubectl create ingress web-ingress --rule="testing.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": "", "usage": ... |
Set the service account of the deployment "backend-microservice-deployment" to "dashboard" | Command:
```bash
kubectl set serviceaccount deployment backend-microservice-deployment dashboard
```
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
Synt... |
Create a service for a replication controller using the provided configuration file, specifying the port numbers for communication. | Command:
```bash
kubectl expose -f python-controller.yaml --port=8084 --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... |
Copy the "/var/run/secrets/kubernetes.io/serviceaccount/" file from the local machine to the "/tmp/bar_dir" directory inside the "api-server-container" container of the "task-processor-pod-17" pod. | Command:
```bash
kubectl cp /var/run/secrets/kubernetes.io/serviceaccount/ task-processor-pod-17:/tmp/bar_dir -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", "defaul... |
Forward traffic from port 8081 on all addresses to port 9090 in the web-app-pod pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/web-app-pod 8081: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 ... |
Create a new config map named api-config with specified keys and file paths | Command:
```bash
kubectl create configmap api-config --from-file=properties=/path/to/settings/file1.txt --from-file=key1=/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 con... |
Create a deployment named 'nats' using the 'alpine' image and expose port 8443. | Command:
```bash
kubectl create deployment nats --image=alpine --port=8443
```
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: jso... |
Add a taint with the key 'app' and value 'app-node-6:PreferNoSchedule' on nodes having the label 'project=project-alpha'. | Command:
```bash
kubectl taint node -l project=project-alpha app=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":... |
Create an ingress called 'website-ingress' that redirects requests to a specific service and port, with TLS encryption using a specified secret | Command:
```bash
kubectl create ingress website-ingress --rule="site.com/module=svc1:9092,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 an ingress called 'app-proxy-ingress' that directs requests from 'foo.com/bar' to the service 'svc1' on port 9000 | Command:
```bash
kubectl create ingress app-proxy-ingress --rule="foo.com/bar=svc1:9000,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"... |
Add a taint with the key 'zone' on nodes having the label 'tier=frontend' | Command:
```bash
kubectl taint node -l tier=frontend zone=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": "", "usage": "Ou... |
Roll back the daemonset named 'prod' to revision 1 | Command:
```bash
kubectl rollout undo daemonset/prod --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 re... |
Create a new config map named namespace-config with specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap namespace-config --from-file=conf=/path/to/preferences/file1.txt --from-file=data=/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 creatin... |
Delete the pod specified in the config.json file. | Command:
```bash
kubectl delete -f ./config.json
```
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 resou... |
Create an ingress called 'web-ingress' that directs requests to testing.com/input to svc1:8888 with the TLS secret "my-cert" | Command:
```bash
kubectl create ingress web-ingress --rule="testing.com/input=svc1:8888,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"... |
Import specific keys from a config map to an environment variable of a deployment | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/app-config deployment/email-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 definition... |
Start a pod named "hazelcast" using the centos image and expose port 8081 | Command:
```bash
kubectl run hazelcast --image=centos --port=8081
```
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... |
Add a taint with the key 'cpu-type' and the value 'db-node-7:PreferNoSchedule' on nodes that have the label 'service=auth'. | Command:
```bash
kubectl taint node -l service=auth cpu-type=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": "", "usage": "Out... |
Attach to a running pod and get output | Command:
```bash
kubectl attach e-commerce-pod
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.... |
Forward local port 6379 to port 8888 in the selected pod of the monitoring-stack-deployment deployment | Command:
```bash
kubectl port-forward deployment/monitoring-stack-deployment 6379 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 criteria, a pod ... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/app-name-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 v... |
Update the pod 'foo' by setting the annotation 'deployment-script' to 'https://example.com/deploy.sh', overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods foo 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 lar... |
Update the image of a specific container in a pod | Command:
```bash
kubectl patch pod payment-gateway-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve-hostname","image":"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 nginx pod with custom overrides specified in JSON format | Command:
```bash
kubectl run nginx --image=nginx --overrides='{ "apiVersion": "legacy-1.0.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [C... |
Assign a label 'role=frontend' to the pod named 'api' | Command:
```bash
kubectl label pods api role=frontend
```
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 ... |
Forward local port 8888 to port 3000 in the pod 'cdn-service-pod' | Command:
```bash
kubectl port-forward pod/cdn-service-pod 8888: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 au... |
Set the service account for the deployment "gateway-deployment" to "jenkins" | Command:
```bash
kubectl set serviceaccount deployment gateway-deployment jenkins
```
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 se... |
Embed the certificate authority data for the 'cloud-cluster' cluster entry by running the command 'kubectl config set-cluster cloud-cluster --embed-certs --certificate-authority=~/.kube/cluster-gamma/kubernetes.ca.crt' | Command:
```bash
kubectl config set-cluster cloud-cluster --embed-certs --certificate-authority=~/.kube/cluster-gamma/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 s... |
Set the resource request and limits for all containers in the Jenkins deployment. | Command:
```bash
kubectl set resources deployment jenkins --limits=cpu=200m,memory=512Mi --requests=cpu=500m,memory=64Mi
```
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 reque... |
Create an ingress named 'api-v2-ingress' that routes requests from 'website.com/example' to 'svc1:8088' using the TLS secret 'my-cert' | Command:
```bash
kubectl create ingress api-v2-ingress --rule="website.com/example=svc1:8088,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "u... |
Set the client-key-data field for the 'dev-user' user with the provided certificate data using the --set-raw-bytes=true option. | Command:
```bash
kubectl config set users.dev-user.client-key-data cert_data_here --set-raw-bytes=true
```
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 ... |
Import the SECRET_KEY key from the app-name-config ConfigMap into the environment variables of the proxy-service-deployment deployment. | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/app-name-config deployment/proxy-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 defin... |
Create a single ingress called 'api-gateway-ingress' that directs requests to foo.com/example to the service named 'svc1' on port 8181, and use the TLS secret named "my-cert". | Command:
```bash
kubectl create ingress api-gateway-ingress --rule="foo.com/example=svc1:8181,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "... |
Create a new config map named "env-vars" with the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap env-vars --from-file=properties=/path/to/configs/file1.txt --from-file=key1=/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 creating a ... |
Forward traffic from port 8888 on all addresses to port 6379 in the e-commerce-pod pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/e-commerce-pod 8888: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 job for the deployment rollout with a specific command. | Command:
```bash
kubectl create job deployment-rollout-job --image=docker.elastic.co/elasticsearch/elasticsearch -- elasticsearch-plugin --list
```
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": "... |
List all deployments in the "v2.0.0" version of the "mobile-apps" API group, and display the output in YAML format. | Command:
```bash
kubectl get deployments.v2.0.0.mobile-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 wil... |
Create a job named "audit-job" using the "golang" image, and run the command "go" inside the job | Command:
```bash
kubectl create job audit-job --image=golang -- go
```
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: jso... |
Forward traffic from local port 3000 to port 8888 in a pod selected by the deployment named "mydeployment" | Command:
```bash
kubectl port-forward deployment/mydeployment 3000 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 criteria, a pod will be selecte... |
Open the 'scheduler-service' service for editing using the 'code' editor | Command:
```bash
KUBE_EDITOR="code" kubectl edit svc/scheduler-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 variabl... |
Copy the local file /tmp/foo_dir to a remote pod named auth-service-pod-11 at the path /tmp/bar_dir | Command:
```bash
kubectl cp /tmp/foo_dir auth-service-pod-11:/tmp/bar_dir -c load-balancer
```
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 omitte... |
Retrieve the logs from the container named payment-processor-deployment-1 in the deployment named proxy-server-pod. | Command:
```bash
kubectl logs deployment/payment-processor-deployment -c proxy-server-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 fla... |
Listen on port 8000 locally, and forward data to/from port 8888 in the security-service-pod. | Command:
```bash
kubectl port-forward pod/security-service-pod 8000 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 criteria, a pod will be select... |
Rename context in kubeconfig file | Command:
```bash
kubectl config rename-context local-context app-1-context
```
What it does:
Renames a context from the kubeconfig file.
CONTEXT_NAME is the context name that you want to change.
NEW_NAME is the new name you want to set.
Note: If the context being renamed is the 'current-context', this field will also ... |
Create an ingress called 'external-ingress' that directs requests to testing.com/bar to svc1:8443 with a tls secret named "my-cert" | Command:
```bash
kubectl create ingress external-ingress --rule="testing.com/bar=svc1:8443,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usa... |
Forward traffic from localhost port 8080 to port 8081 in the pod "api-service-pod" | Command:
```bash
kubectl port-forward pod/api-service-pod 8080: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 au... |
Retrieve the previous terminated logs of the code-explorer container from the vpn-service-pod pod | Command:
```bash
kubectl logs -p -c code-explorer vpn-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",... |
Create an ingress named 'api-gateway-ingress' that forwards requests from site.com/input to svc1:9091 with a TLS secret named "my-cert" | Command:
```bash
kubectl create ingress api-gateway-ingress --rule="site.com/input=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": "", "u... |
Create a new ExternalName service named 'external-geolocation-service' with the external name 'sample-domain.net' | Command:
```bash
kubectl create service externalname external-geolocation-service --external-name sample-domain.net
```
What it does:
Create an ExternalName service with the specified name.
ExternalName service references to an external DNS address instead of only pods, which will allow application authors to referenc... |
Forward traffic from local port 5000 to the targetPort of the 'https' service port in a pod selected by the 'payment-service' service | Command:
```bash
kubectl port-forward service/payment-service 5000: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 select... |
Import specific keys from a config map for a deployment. | Command:
```bash
kubectl set env --keys=api_key --from=configmap/log-config 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 i... |
Copy the local file /tmp/foo_dir to the remote pod backend-pod-13:/tmp/bar in the security-scanner container | Command:
```bash
kubectl cp /tmp/foo_dir backend-pod-13::/tmp/bar -c security-scanner
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, us... |
Listen on port 5000 locally and forward the traffic to port 8000 in the "api-service-pod" pod. | Command:
```bash
kubectl port-forward pod/api-service-pod 5000: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 au... |
Execute the 'kafka-console-producer --broker-list localhost:9092 --topic test' command in the rocket-ranger container of the proxy-server-pod pod and get the output. | Command:
```bash
kubectl exec proxy-server-pod -c rocket-ranger -- kafka-console-producer --broker-list localhost:9092 --topic test
```
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": "... |
List deployments in YAML output format for the "feature-branch-2.3.0" version of the "internal-apps" API group | Command:
```bash
kubectl get deployments.feature-branch-2.3.0.internal-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... |
Import the 'debug_mode' key from the 'db-config' config map into the 'log-aggregator-deployment' deployment. | Command:
```bash
kubectl set env --keys=debug_mode --from=configmap/db-config deployment/log-aggregator-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definition... |
Create a copy of the auth-service-pod, replacing the original container with a debug container, and changing the container image to "debian". | Command:
```bash
kubectl debug auth-service-pod -it --copy-to=dgb-img --image=debian --set-image=app=app:debug,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 resource and name. Pods... |
Import the `max_connections` key from the `app-config-dev` ConfigMap and set it as an environment variable in the `search-engine-deployment` deployment. | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/app-config-dev deployment/search-engine-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... |
Begin streaming the logs of the time-machine container in pod chat-app-pod | Command:
```bash
kubectl logs -f -c time-machine chat-app-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", "sh... |
Create a secret named "app-config-secret" from an environment file | Command:
```bash
kubectl create secret generic app-config-secret --from-env-file=path/to/options.env
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, the key will default to the bas... |
Add a taint with the key 'app' on each node that has the label 'feature=feature-xyz' | Command:
```bash
kubectl taint node -l feature=feature-xyz app=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": ... |
Display only the most recent 12 lines of output from the logs of the 'backend-pod' pod | Command:
```bash
kubectl logs --tail=12 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"... |
Create a debug copy of the backend pod by adding a debug container and changing the container images. | Command:
```bash
kubectl debug backend-pod -it --copy-to=dgb-img --image=debian --set-image=database=mysql:5.7,database=mysql:5.7
```
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.... |
Listen on a random port locally, forwarding to port 5432 in the 'proxy-server-pod' pod | Command:
```bash
kubectl port-forward pod/proxy-server-pod :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 autom... |
Create a Pod Disruption Budget with a specific label selector and minimum availability requirement. | Command:
```bash
kubectl create poddisruptionbudget cache-cluster-pdb --selector=component=web --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-available=... |
Execute the 'irb' command in the first container of the first pod of the 'proxy-service' service. | Command:
```bash
kubectl exec svc/proxy-service -- 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 kubectl.kub... |
Import specific keys from a config map to an environment variable in a deployment | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/kube-system-config deployment/proxy-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 def... |
Set environment variable from a secret for a deployment | Command:
```bash
kubectl set env --from=secret/password-secret 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 one or more pod t... |
Retrieve snapshot logs from container cdn-service-pod-1 of deployment gateway-deployment | Command:
```bash
kubectl logs deployment/gateway-deployment -c cdn-service-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:
"flag":... |
Forward traffic from port 5432 on localhost and IP 10.19.21.23 to port 8088 in the pod named "security-service-pod". | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/security-service-pod 5432: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 th... |
Create a pod disruption budget named critical-services-pdb that will select all pods with the release=1.0.0 label and require at least four of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget critical-services-pdb --selector=release=1.0.0 --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-availa... |
Create a new secret named 'git-credentials-secret' using the environment variables from the 'path/to/parameters.env' file | Command:
```bash
kubectl create secret generic git-credentials-secret --from-env-file=path/to/parameters.env
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, the key will default to... |
Start a pod named 'nginx' using the 'amazonlinux' image, but customize the pod spec by providing a partial set of values parsed from a JSON file | Command:
```bash
kubectl run nginx --image=amazonlinux --overrides='{ "apiVersion": "stable-2.0.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command]... |
Scale the mysql deployment to 3 replicas if the db-migration-replicaset deployment's current size is already 3 | Command:
```bash
kubectl scale --current-replicas=3 --replicas=3 deployment/db-migration-replicaset
```
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 --reso... |
Forward port 8080 on all addresses to port 8088 in the pod named "web-app-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/web-app-pod 8080: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 ... |
Create a service for a replicated Ubuntu container, serving on port 8089 and connecting to the containers on port 900000 | Command:
```bash
kubectl expose rc ubuntu --port=8089 --target-port=900000
```
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.... |
Create a deployment named "db" that uses the "centos" image | Command:
```bash
kubectl create deployment db --image=centos
```
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... |
Create a job called "monitoring-job" with the image "docker.elastic.co/elasticsearch/elasticsearch" and run the command "elasticsearch-plugin --list" within the job. | Command:
```bash
kubectl create job monitoring-job --image=docker.elastic.co/elasticsearch/elasticsearch -- elasticsearch-plugin --list
```
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... |
Remove the existing taint with key 'disktype' and effect 'NoSchedule' from the node 'db-node-7' if it exists. | Command:
```bash
kubectl taint nodes db-node-7 disktype: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: j... |
Retrieve the snapshot logs from container gateway-deployment-1 of the deployment named mypod. | Command:
```bash
kubectl logs deployment/gateway-deployment -c mypod-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:
"flag": "--contai... |
Display only the most recent 31 lines of output for the pod named "cdn-service-pod" | Command:
```bash
kubectl logs --tail=31 cdn-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 traffic from port 8081 on all addresses to port 5000 in the pod named api-service-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/api-service-pod 8081: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 w... |
Forward local ports 8088 and 6000 to ports 8081 and 6000 respectively on a pod selected by the deployment named monitoring-stack-deployment | Command:
```bash
kubectl port-forward deployment/monitoring-stack-deployment 8088 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 ... |
Retrieve the snapshot logs from the container named 'database-pod-1' in the deployment named 'analytics-platform-deployment'. | Command:
```bash
kubectl logs deployment/analytics-platform-deployment -c database-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:... |
Add a taint with key 'dedicated' on nodes having label release=beta | Command:
```bash
kubectl taint node -l release=beta dedicated=backup-node-14: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"... |
Add a taint on nodes with the label app=web-app | Command:
```bash
kubectl taint node -l app=web-app environment=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": "", "usage"... |
Update the image of all containers in the 'namespace-2' daemonset to 'golang:1.17' | Command:
```bash
kubectl set image daemonset namespace-2 *=golang:1.17
```
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:
`... |
Add the taint with key 'disktype' on nodes having label tier=frontend with the value 'web-node-8:PreferNoSchedule' | Command:
```bash
kubectl taint node -l tier=frontend disktype=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... |
Create a new ClusterIP service named 'auth-service-clusterip' and map the port 5432 to the port 8089 | Command:
```bash
kubectl create service clusterip auth-service-clusterip --tcp=5432:8089
```
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", "... |
Taint nodes with label 'myLabel' and add a new taint with the key 'datacenter' and value 'node-1' to prevent scheduling by default | Command:
```bash
kubectl taint node -l myLabel datacenter=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 fo... |
List the deployments in YAML output format, specifically for the "dev-2.2.0" version of the "my-apps" API group. | Command:
```bash
kubectl get deployments.dev-2.2.0.my-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 will... |
Remove the 'description' annotation from the pod named 'log-aggregator' if it exists | Command:
```bash
kubectl annotate pods log-aggregator description-
```
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 an autoscaling policy for the 'cdn' deployment | Command:
```bash
kubectl autoscale deployment cdn --min=5 --max=15
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that uses the... |
Set the resource limits and requests for all containers in the php deployment | Command:
```bash
kubectl set resources deployment php --limits=cpu=200m,memory=512Mi --requests=cpu=500m,memory=64Mi
```
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... |
Listen on a random port locally and forward the traffic to port 5432 in the 'cdn-service-pod' pod | Command:
```bash
kubectl port-forward pod/cdn-service-pod :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 automa... |
Copy the kube config file from a remote pod to a local directory | Command:
```bash
kubectl cp kube-server/web-app-pod-1:~/.config/kube /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... |
Update the label of the pod 'media-stream' with the key 'env' and the value 'development' | Command:
```bash
kubectl label pods media-stream env=development
```
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", "u... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.