prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Update the 'cluster' field in the 'team-beta-context' context to 'star-cluster' | Command:
```bash
kubectl config set contexts.team-beta-context.cluster star-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 yo... |
Set a custom TLS server name for the data-cluster cluster entry | Command:
```bash
kubectl config set-cluster data-cluster --tls-server-name=on-prem-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] [--certific... |
Update the annotation of a pod named 'backend' with the key 'custom-label' and the value 'my-custom-value', replacing any existing value. | Command:
```bash
kubectl annotate --overwrite pods backend custom-label='my-custom-value'
```
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... |
Import the CONFIG_FILE_PATH key from the app-secrets ConfigMap into the environment variables of the web-app-deployment deployment. | Command:
```bash
kubectl set env --keys=CONFIG_FILE_PATH --from=configmap/app-secrets 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 definitio... |
Listen on all addresses on port 8081 and forward the traffic to port 3000 in the e-commerce-pod pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/e-commerce-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 wi... |
Roll back the daemonset 'namespace-1' to revision 3. | Command:
```bash
kubectl rollout undo daemonset/namespace-1 --to-revision=3
```
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... |
Forward local port to pod port | Command:
```bash
kubectl port-forward pod/frontend-pod :8088
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automatic... |
Forward local port 5000 to port 8088 in the 'web-app-pod' pod | Command:
```bash
kubectl port-forward pod/web-app-pod 5000:8088
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automa... |
Get the output from running the 'go' command in the first container of the 'database-pod' pod. | Command:
```bash
kubectl exec database-pod -- 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 kubectl.kubernete... |
Create a new config map named 'monitoring-config' with the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap monitoring-config --from-file=conf=/path/to/configs/file1.txt --from-file=data=/path/to/options/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 ... |
Partially update the kube-master-9 node by specifying the patch as a JSON. | Command:
```bash
kubectl patch node kube-master-9 -p '{"spec":{"replicas":3}'
```
What it does:
Update fields of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.
JSON and YAML formats are accepted.
Syntax:
`kubectl patch (-f FILENAME | TYPE NAME) [-p PATCH|--patch-file FILE]`
Helpful flag... |
Create an ingress resource called 'private-ingress' with the rule that directs requests for 'testing.com/module' to the service 'svc1' on port '9000' and use the TLS secret 'my-cert' | Command:
```bash
kubectl create ingress private-ingress --rule="testing.com/module=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": "", "u... |
Create a cluster role named "custom_role" with a resource name specified as "queue-consumer" and "prod-api-gateway" that allows the "get" verb on services. | Command:
```bash
kubectl create clusterrole custom_role --verb=get --resource=services --resource-name=queue-consumer --resource-name=prod-api-gateway
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=serve... |
Create a new ClusterIP service named frontend-service-clusterip, mapping port 5001 on the service to port 8084 on the backend | Command:
```bash
kubectl create service clusterip frontend-service-clusterip --tcp=5001:8084
```
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... |
Forward traffic from port 8080 on localhost and IP 10.19.21.23 to port 5000 in the pod "proxy-server-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/proxy-server-pod 8080: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 cr... |
Create a job called 'deployment-rollout-job' using the 'node' image, and run the command 'npm --version' within the job. | Command:
```bash
kubectl create job deployment-rollout-job --image=node -- npm --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": "Outp... |
Start a pod named 'hazelcast' with the 'python' image and expose port 8080 in the container | Command:
```bash
kubectl run hazelcast --image=python --port=8080
```
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 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=settings=/path/to/properties/file1.txt --from-file=key2=/path/to/configs/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 creat... |
Forward traffic from port 8888 on all addresses to port 3000 in the pod named "mypod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/mypod 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 sel... |
Delete the context for a cluster named local-context | Command:
```bash
kubectl config delete-context local-context
```
What it does:
Delete the specified context from the kubeconfig.
Syntax:
`kubectl config delete-context NAME` |
Copy the file named 'foo' from the '/tmp' directory on the local machine to '/tmp/bar' in the 'admin-dashboard-pod-16' pod in the 'ingress-nginx' namespace. | Command:
```bash
kubectl cp :/tmp/foo ingress-nginx/admin-dashboard-pod-16:/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 ... |
Modify the user field for a specific context without changing other values. | Command:
```bash
kubectl config set-context cluster-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_nick... |
Create a job named scaling-job using the image confluentinc/cp-kafka and run the command "kafka-console-producer --broker-list localhost:9092 --topic test". | Command:
```bash
kubectl create job scaling-job --image=confluentinc/cp-kafka -- kafka-console-producer --broker-list localhost:9092 --topic test
```
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":... |
Get the output from running the 'apache2ctl -D FOREGROUND' command in the first container of the first pod of the user-service service. | Command:
```bash
kubectl exec svc/user-service -- apache2ctl -D FOREGROUND
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted,... |
Import the environment variables from the 'docker-registry-secret' secret and set them for the 'frontend-deployment' deployment. | Command:
```bash
kubectl set env --from=secret/docker-registry-secret deployment/frontend-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or mo... |
Forward data between local ports 8080 and 6379 and the pod's ports 6000 and 6379 of the analytics-pod pod | Command:
```bash
kubectl port-forward pod/analytics-pod 8080 6379
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected auto... |
Create a new config map named "monitoring-config" with specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap monitoring-config --from-file=conf=/path/to/settings/file1.txt --from-file=data=/path/to/settings/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating ... |
Update the environment variables of the specified deployment with specific keys from a config map. | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/api-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 defini... |
Get the output from running the 'dotnet --list-runtimes' command in the container of the 'mypod' pod. | Command:
```bash
kubectl exec mypod -- dotnet --list-runtimes
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kube... |
create a service for a replicated python application that serves on port 80 and connects to the containers on port 330600 | Command:
```bash
kubectl expose rc python --port=80 --target-port=330600
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port. A... |
Get output from running 'wp' command from the first pod of the search-engine-deployment deployment. | Command:
```bash
kubectl exec deploy/search-engine-deployment -- wp
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use th... |
Create a new ClusterIP service with the name "git-service-clusterip" | Command:
```bash
kubectl create service clusterip git-service-clusterip --tcp=8888:7000
```
What it does:
Create a ClusterIP service with the specified name.
Syntax:
`kubectl create service clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "d... |
Set a taint on nodes with the label environment=production, using the key 'disktype' and the value 'app-node-6:PreferNoSchedule'. | Command:
```bash
kubectl taint node -l environment=production disktype=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": "", "u... |
Update the label of the pod 'log-aggregator' with the key 'status' and the value 'unhealthy' | Command:
```bash
kubectl label --overwrite pods log-aggregator status=unhealthy
```
What it does:
Update the labels on a resource.
Syntax:
`kubectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]`
Helpful flags:
"flag": "--all-namespaces", "short": "-A", "defaul... |
Import the 'debug_mode' key from the 'app-config' config map into the 'email-server-deployment' deployment | Command:
```bash
kubectl set env --keys=debug_mode --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 definitions... |
Mark the node with name "k8s-node-1" as ready to schedule pods. | Command:
```bash
kubectl uncordon k8s-node-1
```
What it does:
Mark node as schedulable.
Syntax:
`kubectl uncordon NODE`
Helpful flags:
"flag": "--selector", "short": "-l", "default": "", "usage": "Selector (label query) to filter on " |
Create a deployment named auth using the mongo image with 6 replicas. | Command:
```bash
kubectl create deployment auth --image=mongo --replicas=6
```
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... |
Describe the details of a specific context in your kubeconfig file | Command:
```bash
kubectl config get-contexts team-alpha-context
```
What it does:
Display one or many contexts from the kubeconfig file.
Syntax:
`kubectl config get-contexts [(-o|--output=)name)]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: name " |
Create a cluster role named "reader" with the ability to get pods and specific resources named "image-processor" and "mail-server" | Command:
```bash
kubectl create clusterrole reader --verb=get --resource=pods --resource-name=image-processor --resource-name=mail-server
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|client|none... |
Start a pod named 'hazelcast' using the 'alpine' image and ensure that the container within the pod exposes port 8081. | Command:
```bash
kubectl run hazelcast --image=alpine --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... |
Retrieve the previous terminated logs of the "stardust-shuttle" container from the "e-commerce-pod" pod | Command:
```bash
kubectl logs -p -c stardust-shuttle e-commerce-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... |
Add a taint with the key 'disktype' on nodes that have the label 'owner' set to 'john-doe' | Command:
```bash
kubectl taint node -l owner=john-doe 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": "... |
Add a taint with key 'datacenter' on nodes having label customer=acme-corp | Command:
```bash
kubectl taint node -l customer=acme-corp datacenter=edge-node-10: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... |
Update the 'vpn' pod by setting the annotation 'security-scan-status' to 'pass', overwriting any existing value. | Command:
```bash
kubectl annotate --overwrite pods vpn security-scan-status='pass'
```
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 in... |
Create a new config map named kube-system-config in the current namespace using the specified key-value pairs instead of file basenames on disk | Command:
```bash
kubectl create configmap kube-system-config --from-file=conf=/path/to/configs/file1.txt --from-file=data=/path/to/configs/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... |
Display only the most recent 43 lines of output for the 'auth-service-pod' pod | Command:
```bash
kubectl logs --tail=43 auth-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 deployment named 'loadbalancer' with the 'ethereum/client-go' image and 7 replicas. | Command:
```bash
kubectl create deployment loadbalancer --image=ethereum/client-go --replicas=7
```
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": "Outpu... |
Get the output from running the 'gem --version' command in the warp-drive container of the payment-gateway-pod pod. | Command:
```bash
kubectl exec payment-gateway-pod -c warp-drive -- gem --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 om... |
Update the taint for a specific node with the provided key, value, and effect | Command:
```bash
kubectl taint nodes monitoring-node-15 datacenter=dc-1:NoExecute
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output for... |
import the database_url key from the log-config config map and set it as an environment variable for the proxy-service-deployment deployment. | Command:
```bash
kubectl set env --keys=database_url --from=configmap/log-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 definiti... |
Add a taint on nodes labeled with team=devops | Command:
```bash
kubectl taint node -l team=devops hardware=node-1:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output ... |
Expose a replication controller as a service, serving on a specified port and connecting to the containers on a different port. | Command:
```bash
kubectl expose rc alpine --port=7000 --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 port.... |
Set the cluster field in the client-2-context context to on-prem-cluster. | Command:
```bash
kubectl config set contexts.client-2-context.cluster on-prem-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 ... |
Create a copy of the `gateway-pod` and change all container images to `golang` for debugging purposes. | Command:
```bash
kubectl debug gateway-pod --copy-to=debug-image-web --set-image=*=golang
```
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 reso... |
Set environment variables from a config map for a specific deployment | Command:
```bash
kubectl set env --keys=config_file_path --from=configmap/app-config-prod deployment/backend-microservice-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... |
Delete the pods and services named "monitoring" and "chat-app" | Command:
```bash
kubectl delete pod,service monitoring chat-app
```
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 selec... |
Display the details of the replication controller named "backend-rc" in the default output format. | Command:
```bash
kubectl get replicationcontroller backend-rc
```
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... |
Create a service for a wordpress deployment, exposing port 6379 and connecting to the containers on port 808200 | Command:
```bash
kubectl expose deployment wordpress --port=6379 --target-port=808200
```
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 spec... |
Import the 'max_connections' key from the 'db-config' config map into the 'proxy-service-deployment' deployment. | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/db-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... |
Create an ingress called 'api-gateway-ingress' that routes requests to 'website.com/bar' to service 'svc1:9092' using the TLS secret 'my-cert' | Command:
```bash
kubectl create ingress api-gateway-ingress --rule="website.com/bar=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": "", "... |
Copy the file /tmp/foo from your local machine to the /etc/kubernetes directory in the remote pod named load-balancer-pod-9, specifically in the container named logging-agent. | Command:
```bash
kubectl cp /tmp/foo load-balancer-pod-9:/etc/kubernetes -c logging-agent
```
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... |
Import the 'api_key' key from the 'app-name-config' config map and set it as an environment variable in the 'gateway-deployment' deployment. | Command:
```bash
kubectl set env --keys=api_key --from=configmap/app-name-config deployment/gateway-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in... |
Forward data between local port 8080 and the pod's port 8088 in the 'backend-pod' pod. | Command:
```bash
kubectl port-forward pod/backend-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 be selected automa... |
Edit frontend-service using the Sublime text editor | Command:
```bash
KUBE_EDITOR="sublime" 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 varia... |
Create an ingress rule named 'app1-ingress' that forwards requests from foo.com/example to the service 'svc1' on port 9091, using the TLS secret 'my-cert' | Command:
```bash
kubectl create ingress app1-ingress --rule="foo.com/example=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":... |
Update the label of pod 'web' to 'release=v1.0' | Command:
```bash
kubectl label pods web release=v1.0
```
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 t... |
Import the 'LOG_LEVEL' key from the 'kube-system-config' config map and set it as an environment variable for the 'mydeployment' deployment. | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/kube-system-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 ... |
Retrieve the documentation for the 'spec.containers' field of the 'pods' resource. | Command:
```bash
kubectl explain resource=pods.spec.containers
```
What it does:
List the fields for supported resources.
This command describes the fields associated with each supported API resource. Fields are identified via a simple JSONPath identifier:
<type>.<fieldName>[.<fieldName>]
Add the --recursive flag to d... |
Output the modified YAML file for the 'proxy-service-deployment' deployment with the DEBUG environment variable set to true | Command:
```bash
kubectl set env deployment/proxy-service-deployment DEBUG=true -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 templa... |
Add a taint with key 'cpu-type' on nodes that have the label 'app-type=microservice' | Command:
```bash
kubectl taint node -l app-type=microservice cpu-type=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": "", "us... |
Create a role named "default_role" with API Group specified | Command:
```bash
kubectl create role default_role --verb=patch,watch,exec --resource=replicasets.apps
```
What it does:
Create a role with single rule.
Syntax:
`kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run=server|client|none]`
Helpful flags:
"fl... |
Create an ingress named 'ingress1' with multiple hosts and set the pathType as Prefix | Command:
```bash
kubectl create ingress ingress1 --class=default \
--rule="testing.com/path*=svc:5000" \
--rule="bar.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": "--output",... |
Monitor the rollout status of the 'namespace-2' deployment | Command:
```bash
kubectl rollout status deployment/namespace-2
```
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... |
Execute the 'bash' command in the frontend-pod and get the output | Command:
```bash
kubectl exec frontend-pod -- bash
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.kuberne... |
Execute the 'mysqld' command on the first container of the first pod of the 'search-service' service. | Command:
```bash
kubectl exec svc/search-service -- mysqld
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl... |
Add a taint with key 'datacenter' on nodes having label instance=app-instance-1 | Command:
```bash
kubectl taint node -l instance=app-instance-1 datacenter=kube-master-9:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": ... |
Create an ingress object named 'private-api-ingress' that routes requests from 'site.com/input' to service 'svc1' on port 5000 | Command:
```bash
kubectl create ingress private-api-ingress --rule="site.com/input=svc1:5000,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "u... |
Add a taint with key 'hardware' on nodes having label project=project-alpha | Command:
```bash
kubectl taint node -l project=project-alpha hardware=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": "", "usa... |
List deployments in YAML output format for the "legacy-1.0.0" version of the "testing-apps" API group | Command:
```bash
kubectl get deployments.legacy-1.0.0.testing-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 ... |
Copy the file /tmp/foo from the pod named 'web-app-pod-1' in the 'kube-system' namespace to the local directory /tmp/bar. | Command:
```bash
kubectl cp kube-system/web-app-pod-1:/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 kubectl... |
Forward traffic from port 9090 on all addresses to port 3000 in the pod named security-service-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/security-service-pod 9090: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 ... |
Create an ExternalName service with the name external-geolocation-service that points to the external domain bar.com. | Command:
```bash
kubectl create service externalname external-geolocation-service --external-name bar.com
```
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 reference services... |
Create a single ingress named 'website-ingress' that routes requests for foo.com/bar to the service 'svc1' on port 3001 | Command:
```bash
kubectl create ingress website-ingress --rule="foo.com/bar=svc1:3001,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": ... |
Create a new secret named app-config-secret with keys for each file in the folder bar | Command:
```bash
kubectl create secret generic app-config-secret --from-file=path/to/options
```
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... |
Import environment variables from a config map with a specific prefix | Command:
```bash
kubectl set env --from=configmap/ui-config --prefix=MYSQL_ deployment/notification-handler-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defini... |
Edit the cache-service service using the emacs editor | Command:
```bash
KUBE_EDITOR="emacs" kubectl edit svc/cache-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 LoadBalancer service named 'frontend-lb' and forward traffic from port 8081 to port 8888 | Command:
```bash
kubectl create service loadbalancer frontend-lb --tcp=8081:8888
```
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", "defaul... |
Create a new secret named encryption-key-secret using the configurations from the path/to/configurations.env file | Command:
```bash
kubectl create secret generic encryption-key-secret --from-env-file=path/to/configurations.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... |
Forward local port 8000 to port 6379 in the pod named api-service-pod. | Command:
```bash
kubectl port-forward pod/api-service-pod 8000:6379
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected au... |
Retrieve the details of the e-commerce-pod in YAML format. | Command:
```bash
kubectl get -o yaml pod e-commerce-pod
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you will only see r... |
Set the resource request and limits for all containers in a deployment named "node". | Command:
```bash
kubectl set resources deployment node --limits=cpu=200m,memory=512Mi --requests=cpu=100m,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 requeste... |
Get output from running the 'node' command in the container named 'mycontainer' from the pod named 'monitoring-pod' | Command:
```bash
kubectl exec monitoring-pod -c mycontainer -- node
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use th... |
Check if the current user has the permission to list the job named "log-rotation-job" in the "staging" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/log-rotation-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 t... |
update the 'proxy-service-deployment' deployment by adding a new environment variable named ENV with the value prod | Command:
```bash
kubectl set env deployment/proxy-service-deployment ENV=prod
```
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 (withi... |
Create a new config map named ui-config with specified keys instead of file basenames on disk. | Command:
```bash
kubectl create configmap ui-config --from-file=properties=/path/to/properties/file1.txt --from-file=key1=/path/to/configurations/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When cre... |
Create an ingress named 'ingtls' with TLS enabled using the default ingress certificate | Command:
```bash
kubectl create ingress ingtls --class=default \
--rule="foo.com/=svc:https,tls" \
--rule="website.com/path/subpath*=othersvc:8080"
```
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": "-... |
Start a nginx pod with a customized set of values parsed from a JSON file | Command:
```bash
kubectl run nginx --image=nginx --overrides='{ "apiVersion": "hotfix-1.1.2", "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... |
List the details of a pod in JSON format. | Command:
```bash
kubectl get -o json pod gateway-pod
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you will only see resu... |
Set up autoscaling for the 'backend' deployment with a minimum of 7 pods and a maximum of 15 pods | Command:
```bash
kubectl autoscale deployment backend --min=7 --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... |
Get the output from the 'mongo' command in the 'time-machine' container of the 'log-aggregator-pod' pod | Command:
```bash
kubectl exec log-aggregator-pod -c time-machine -- mongo
```
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, ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.