prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Get output from running a command in a specific pod and container | Command:
```bash
kubectl exec security-service-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... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/db-config 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 definitions... |
Forward traffic from local port 3000 to port 5432 in the pod 'api-service-pod' | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/api-service-pod 3000: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 w... |
Create a new secret named ldap-credentials-secret using the environment variables from the configs.env file at the specified path. | Command:
```bash
kubectl create secret generic ldap-credentials-secret --from-env-file=path/to/configs.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 t... |
Remove the "client-secret" config value for the OpenID Connect auth provider for the "john.doe" entry. | Command:
```bash
kubectl config set-credentials john.doe --auth-provider=oidc --auth-provider-arg=client-secret-
```
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-ke... |
List deployments in YAML output format, using the "v1.1.0" version of the "extensions" API group. | Command:
```bash
kubectl get deployments.v1.1.0.extensions -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... |
Annotate pod 'cdn' with the annotation 'compliance-level' and the value 'PCI-DSS', overwriting any existing value. | Command:
```bash
kubectl annotate --overwrite pods cdn compliance-level='PCI-DSS'
```
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 inc... |
Forward local ports 3000 and 8088 to ports 3000 and 8088 in the pods selected by the deployment "mydeployment" | Command:
```bash
kubectl port-forward deployment/mydeployment 3000 8088
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selecte... |
Remove all taints with key 'environment' from node 'k8s-node-1' | Command:
```bash
kubectl taint nodes k8s-node-1 environment-
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json|yam... |
Import specific keys from a config map to a deployment's environment variables | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/monitoring-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 variable d... |
Auto scale the replication controller "cdn" with the target CPU utilization of 20% and the number of pods between 1 and 2. | Command:
```bash
kubectl autoscale rc cdn --max=2 --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 uses the... |
Remove the context for the 'app-1-context' cluster | Command:
```bash
kubectl config delete-context app-1-context
```
What it does:
Delete the specified context from the kubeconfig.
Syntax:
`kubectl config delete-context NAME` |
Forward local port 5000 to port 3000 inside the 'e-commerce-pod' pod | Command:
```bash
kubectl port-forward pod/e-commerce-pod 5000: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 aut... |
Forward local traffic from ports 8080 and 6000 to ports 8081 and 6000 of the chat-app-pod | Command:
```bash
kubectl port-forward pod/chat-app-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 autom... |
Forward local port 9090 to the port 8888 of a pod selected by the deployment "analytics-platform-deployment". | Command:
```bash
kubectl port-forward deployment/analytics-platform-deployment 9090 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 po... |
Create a copy of the media-stream-pod pod with the container code-explorer and change its command to run the 'sh' shell by using the command 'kubectl debug media-stream-pod -it --copy-to=debug-image-1 --container=code-explorer -- sh' | Command:
```bash
kubectl debug media-stream-pod -it --copy-to=debug-image-1 --container=code-explorer -- sh
```
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 ... |
Forward traffic from port 8080 on all addresses to port 5432 in the backend-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/backend-pod 8080: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 ... |
Set the client key data of the api-user in the kubeconfig file using the --set-raw-bytes flag and provide the certificate data as a raw byte string. | Command:
```bash
kubectl config set users.api-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 ... |
Taint nodes with label 'service=auth' using the key 'workload' and value 'worker-node-3:PreferNoSchedule' | Command:
```bash
kubectl taint node -l service=auth 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": "", "usage": ... |
Setup autoscaling for the "gateway" deployment with a minimum of 1 pod and a maximum of 8 pods. | Command:
```bash
kubectl autoscale deployment gateway --min=1 --max=8
```
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 ... |
Import the specific keys 'REDIS_HOST' from the 'app-config' config map and set them as environment variables for the 'analytics-platform-deployment' deployment. | Command:
```bash
kubectl set env --keys=REDIS_HOST --from=configmap/app-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 defin... |
Create a new NodePort service named monitoring-nodeport and map the port 9091 of the service to the port 9091 of the target | Command:
```bash
kubectl create service nodeport monitoring-nodeport --tcp=9091:9091
```
What it does:
Create a NodePort service with the specified name.
Syntax:
`kubectl create service nodeport NAME [--tcp=port:targetPort] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "default": ... |
Start a hazelcast pod using the "docker.elastic.co/elasticsearch/elasticsearch" image and expose port 5000 | Command:
```bash
kubectl run hazelcast --image=docker.elastic.co/elasticsearch/elasticsearch --port=5000
```
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] ... |
Create a single ingress called 'internal-ingress' that directs requests to foo.com/bar to the service svc1 on port 8088, and use the TLS secret "my-cert" | Command:
```bash
kubectl create ingress internal-ingress --rule="foo.com/bar=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": "", "usage":... |
Add a taint to nodes with label 'cluster=my-cluster' | Command:
```bash
kubectl taint node -l cluster=my-cluster special=dev-node-4: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"... |
Forward port 8888 on your local machine to port 8080 on the e-commerce-pod pod | Command:
```bash
kubectl port-forward pod/e-commerce-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 aut... |
Forward traffic from port 8081 on localhost and IP 10.19.21.23 to port 5000 in the pod named "mypod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/mypod 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 p... |
Add a taint with key 'environment' on nodes having label service=auth | Command:
```bash
kubectl taint node -l service=auth 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": "", "usage": ... |
Create a new config map named app-config-prod with specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-config-prod --from-file=properties=/path/to/preferences/file1.txt --from-file=key1=/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 cr... |
Create a deployment named 'worker' using the 'hazelcast/hazelcast' image and expose port 6379. | Command:
```bash
kubectl create deployment worker --image=hazelcast/hazelcast --port=6379
```
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 form... |
Delete the pods and services with the names "api" and "database". | Command:
```bash
kubectl delete pod,service api database
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label selector.
So... |
Create a deployment named "scheduler" with the image "mcr.microsoft.com/dotnet/core/runtime" | Command:
```bash
kubectl create deployment scheduler --image=mcr.microsoft.com/dotnet/core/runtime
```
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": "Ou... |
Forward local ports 8088 to port 5432 in the pod called frontend-pod | Command:
```bash
kubectl port-forward pod/frontend-pod 8088 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... |
Import the "debug_mode" key from the "log-config" config map into the "order-processing-deployment" deployment. | Command:
```bash
kubectl set env --keys=debug_mode --from=configmap/log-config deployment/order-processing-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definit... |
Add a taint with key 'environment' on nodes having label app-type=microservice, specifically on the node named db-node-7, with a taint effect of 'PreferNoSchedule'. | Command:
```bash
kubectl taint node -l app-type=microservice environment=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": "", "... |
Create a pod called hazelcast with the python image and expose port 3001. | Command:
```bash
kubectl run hazelcast --image=python --port=3001
```
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... |
Create an ingress called 'web-ingress' that maps requests from testing.com/example to svc1:8010, and use the tls secret "my-cert" | Command:
```bash
kubectl create ingress web-ingress --rule="testing.com/example=svc1:8010,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
Create a new service account named prometheus | Command:
```bash
kubectl create serviceaccount prometheus
```
What it does:
Create a service account with the specified name.
Syntax:
`kubectl create serviceaccount NAME [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json|yaml|name|go... |
Forward traffic from port 8000 on localhost and IP 10.19.21.23 to port 8081 on the backend-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/backend-pod 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 criteri... |
Import specific keys from a config map for a deployment. | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/monitoring-config deployment/mydeployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in ... |
Create a secret named "api-secret-key" using a file and a literal value. | Command:
```bash
kubectl create secret generic api-secret-key --from-file=ssh-privatekey=path/to/id_rsa --from-literal=passphrase=topsecret
```
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 ... |
List the resources from the directory specified by the kustomization.yaml file located at conf/ | Command:
```bash
kubectl get -k conf/
```
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 only see results in your cur... |
Add a taint with the key 'workload' and value 'testing-node-11:PreferNoSchedule' on all nodes that have the label 'app-type' set to 'microservice'. | Command:
```bash
kubectl taint node -l app-type=microservice workload=testing-node-11: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": ""... |
Copy the local file "foo" from the "/tmp" directory to the remote pod "web-app-pod-1" in the "kube-dns" namespace, and place it in the "/tmp/bar" directory. | Command:
```bash
kubectl cp :/tmp/foo kube-dns/web-app-pod-1::/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 kubectl.k... |
Edit the 'loadbalancer-service' service. | Command:
```bash
kubectl edit svc/loadbalancer-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, or fall back... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/global-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 defini... |
Execute the command 'docker run -d ubuntu sleep 3600' inside the 'nano-bot' container in the 'analytics-pod' pod and retrieve the output | Command:
```bash
kubectl exec analytics-pod -c nano-bot -- docker run -d ubuntu sleep 3600
```
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 n... |
View the details of daemonset revision 5 | Command:
```bash
kubectl rollout history daemonset/services --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 t... |
Create a single ingress called 'public-service-ingress' that directs requests to testing.com/input to svc # svc1:9091 with a tls secret "my-cert" | Command:
```bash
kubectl create ingress public-service-ingress --rule="testing.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": ... |
Copy the directory /tmp/foo_dir from the 'front-end-pod-12' pod in the 'default' namespace to the local directory /etc/kubernetes | Command:
```bash
kubectl cp default/front-end-pod-12:/tmp/foo_dir /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 th... |
Create a new secret named app-config-secret with keys for each file in the "path/to/profiles" folder | Command:
```bash
kubectl create secret generic app-config-secret --from-file=path/to/profiles
```
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 o... |
Create an ingress called 'api-v1-ingress' that routes requests from foo.com/input to svc1:8181 with a TLS certificate named "my-cert" | Command:
```bash
kubectl create ingress api-v1-ingress --rule="foo.com/input=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": "", "usage":... |
Import the key REDIS_HOST from the config map 'api-config' into the environment variables of the 'monitoring-stack-deployment' deployment. | Command:
```bash
kubectl set env --keys=REDIS_HOST --from=configmap/api-config deployment/monitoring-stack-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definit... |
Create a new config map named app-config-dev with specified keys instead of file basenames on disk. | Command:
```bash
kubectl create configmap app-config-dev --from-file=properties=/path/to/properties/file1.txt --from-file=key1=/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 cr... |
Start a PHP pod with custom arguments for the default command | Command:
```bash
kubectl run nginx --image=php -- <arg1> <arg2> ... <argN>
```
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:
"fl... |
Create a new config map named kube-system-config with specified keys and files | Command:
```bash
kubectl create configmap kube-system-config --from-file=settings=/path/to/properties/file1.txt --from-file=key2=/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.
W... |
Create a new LoadBalancer service named 'api-service-lb' that maps port 8082 to port 7000. | Command:
```bash
kubectl create service loadbalancer api-service-lb --tcp=8082:7000
```
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 'special' on nodes having label release=beta | Command:
```bash
kubectl taint node -l release=beta special=gpu-node-12:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Ou... |
Forward traffic from port 6379 on all addresses to port 9090 in the frontend-pod pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/frontend-pod 6379: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 `ui-config` using specified keys instead of file basenames on disk. | Command:
```bash
kubectl create configmap ui-config --from-file=properties=/path/to/configs/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 creating a c... |
import specific keys from a config map into the environment variables of a deployment | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/global-config deployment/order-processing-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable def... |
Embed certificate authority data for the "prod-cluster" cluster entry. | Command:
```bash
kubectl config set-cluster prod-cluster --embed-certs --certificate-authority=~/.kube/testing-cluster/kubernetes.ca.crt
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config ... |
Retrieve the output from running the 'go' command in the 'time-machine' container of the 'web-app-pod' pod. | Command:
```bash
kubectl exec web-app-pod -c time-machine -- go
```
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 ku... |
Fetch the snapshot logs from the container named 'gateway-pod-1' in the 'notification-handler-deployment' deployment | Command:
```bash
kubectl logs deployment/notification-handler-deployment -c gateway-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags... |
Check if the user has permission to list the job named "log-rotation-job" in the "testing" namespace. | Command:
```bash
kubectl auth can-i list jobs.batch/log-rotation-job -n testing
```
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 t... |
Update the annotation 'last-deployment' of the pod 'web' with the value 2023-03-15 | Command:
```bash
kubectl annotate pods web last-deployment=2023-03-15
```
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 arbitra... |
Create a new pod named 'debug-image-memcached' by making a copy of 'vpn-service-pod' and adding a debug container | Command:
```bash
kubectl debug vpn-service-pod -it --copy-to=debug-image-memcached --image=debian --set-image=web=nginx:latest,api=api:v2
```
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 an ingress called 'public-service-ingress' that directs requests to website.com/input to svc1:7000 with a tls secret called 'my-cert' | Command:
```bash
kubectl create ingress public-service-ingress --rule="website.com/input=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": ... |
Copy the file 'foo' located in the '/tmp' directory of the local machine to the '/tmp/bar_dir' directory inside the 'task-processor-pod-17' pod in the 'rook-ceph' namespace. | Command:
```bash
kubectl cp :/tmp/foo rook-ceph/task-processor-pod-17:/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... |
Wait until the pod "log-aggregator-pod" is ready | Command:
```bash
kubectl wait --for=condition=Ready pod/log-aggregator-pod
```
What it does:
Experimental: Wait for a specific condition on one or many resources.
The command takes multiple resources and waits until the specified condition is seen in the Status field of every given resource.
Alternatively, the command... |
Import the key 'SMTP_SERVER' from the 'db-config' config map into the 'monitoring-stack-deployment' deployment. | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/db-config deployment/monitoring-stack-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definit... |
Create a new secret named oauth-secret with keys for each file in the folder bar | Command:
```bash
kubectl create secret generic oauth-secret --from-file=path/to/parameters
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, the key will default to the basename of t... |
Expose a replica set named "alpine" as a service on port 3306, which will connect to the containers on port 500000. | Command:
```bash
kubectl expose rs alpine --port=3306 --target-port=500000
```
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.... |
Set the cluster field of the 'app-2-context' context to 'app-cluster' | Command:
```bash
kubectl config set contexts.app-2-context.cluster app-cluster
```
What it does:
Set an individual value in a kubeconfig file.
PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.
PROPERTY_VALUE is the new value you wan... |
Get the output of running the 'npm --version' command from the proxy-service-pod using the first container. | Command:
```bash
kubectl exec proxy-service-pod -- npm --version
```
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... |
Embed the certificate authority data for the "cluster-gamma" cluster entry | Command:
```bash
kubectl config set-cluster cluster-gamma --embed-certs --certificate-authority=~/.kube/sun-cluster/kubernetes.ca.crt
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set... |
Switch to raw terminal mode and attach to the 'mycontainer' container in the 'auth-service-pod' pod | Command:
```bash
kubectl attach auth-service-pod -c mycontainer -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. If om... |
Create a job called "monitoring-job" using the Alpine image, and execute the command "apk add curl" inside the job. | Command:
```bash
kubectl create job monitoring-job --image=alpine -- apk add curl
```
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 form... |
Create a new ExternalName service named external-monitoring-service with an external name of mockup-cloud.cloud | Command:
```bash
kubectl create service externalname external-monitoring-service --external-name mockup-cloud.cloud
```
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... |
Use a different editor to edit the configuration of a service | Command:
```bash
KUBE_EDITOR="nvim" kubectl edit svc/frontend-service
```
What it does:
Edit a resource from the default editor.
The edit command allows you to directly edit any API resource you can retrieve via the command-line tools. It will open the editor defined by your KUBE_EDITOR, or EDITOR environment variable... |
Return the snapshot of previous logs from a terminated container named "warp-drive" in the pod named "payment-gateway-pod" | Command:
```bash
kubectl logs -p -c warp-drive payment-gateway-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"... |
Import specific keys from a config map into a deployment's environment variables | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/app-name-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 varia... |
Execute the command 'node --version' inside the pod named 'payment-gateway-pod' and print the output to the console. | Command:
```bash
kubectl exec payment-gateway-pod -- node --version
```
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... |
Provide a detailed description of the load-balancer-node-17.lb-cluster.local node | Command:
```bash
kubectl describe nodes load-balancer-node-17.lb-cluster.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 obje... |
Embed the certificate authority data for the on-prem-cluster cluster entry by running the command: | Command:
```bash
kubectl config set-cluster on-prem-cluster --embed-certs --certificate-authority=~/.kube/web-cluster/kubernetes.ca.crt
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config s... |
Copy the "proxy-server-pod" and add a debug container to it | Command:
```bash
kubectl debug proxy-server-pod -it --copy-to=debug-image-app --image=debian --set-image=logger=logging-app:debug,web=nginx:latest
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by r... |
Create a secret named git-credentials-secret from an environment file | Command:
```bash
kubectl create secret generic git-credentials-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 th... |
Display the last 43 lines of logs for the 'api-service-pod' pod | Command:
```bash
kubectl logs --tail=43 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": ... |
Output the modified deployment mydeployment in YAML format by setting the environment variable ENV to prod | Command:
```bash
kubectl set env deployment/mydeployment ENV=prod -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 more pod templates (within re... |
Create an ingress named 'ingtls' using the default ingress certificate | Command:
```bash
kubectl create ingress ingtls --class=default \
--rule="testing.com/=svc:https,tls" \
--rule="foo.com/path/subpath*=othersvc:8083"
```
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": "-... |
Create a job named 'deployment-rollout-job' with the mongo image and run the 'mongo --version' command inside the pod | Command:
```bash
kubectl create job deployment-rollout-job --image=mongo -- mongo --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": "O... |
Auto scale the deployment "auth" with a minimum of 7 pods and a maximum of 14 pods. | Command:
```bash
kubectl autoscale deployment auth --min=7 --max=14
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that uses th... |
Create a debug copy of the email-service-pod with a modified command for nebula-navigator | Command:
```bash
kubectl debug email-service-pod -it --copy-to=debug-image-web --container=nebula-navigator -- sh
```
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 us... |
Start streaming the logs of the "code-explorer" container in the "gateway-pod" pod. | Command:
```bash
kubectl logs -f -c code-explorer gateway-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 debug copy of a pod, adding a container and changing container images | Command:
```bash
kubectl debug api-service-pod -it --copy-to=my-custom-dbg --image=debian --set-image=web=nginx:latest,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... |
Scale the deployment named "db-migration-replicaset" to 3 replicas, assuming its current size is 5. | Command:
```bash
kubectl scale --current-replicas=5 --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... |
Add a taint with key 'cpu-type' on nodes having label environment=production | Command:
```bash
kubectl taint node -l environment=production cpu-type=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": "", "u... |
Create a role binding for multiple users and a group, using a specific cluster role | Command:
```bash
kubectl create rolebinding custom_role --clusterrole=custom_role --user=developer3 --user=k8s-admin --group=qa-engineers
```
What it does:
Create a role binding for a particular role or cluster role.
Syntax:
`kubectl create rolebinding NAME --clusterrole=NAME|--role=NAME [--user=username] [--group=gr... |
Update the CPU and memory resource limits for the 'nginx' container in the 'node' deployment | Command:
```bash
kubectl set resources deployment node -c=nginx --limits=cpu=50m,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 i... |
Create a Pod Disruption Budget named ingress-controller-pdb that selects all pods with the app=rails label and ensures that at least 9 of them are available at any given time. | Command:
```bash
kubectl create poddisruptionbudget ingress-controller-pdb --selector=app=rails --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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.