prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/app-config-dev deployment/api-server-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defin... |
Create a new config map named app-secrets using the contents of the profiles.env file located at path/to/profiles.env | Command:
```bash
kubectl create configmap app-secrets --from-env-file=path/to/profiles.env
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a config map based on a file, the key will default to the b... |
Add a taint with the key 'cpu-type' and the value 'web-node-8:PreferNoSchedule' on nodes that have the label 'team=devops' | Command:
```bash
kubectl taint node -l team=devops 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": "", "usage": "Out... |
Create a deployment named logging with the php image | Command:
```bash
kubectl create deployment logging --image=php
```
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|... |
Attach to the 'rocket-ranger' container in the 'mypod' pod and switch to raw terminal mode | Command:
```bash
kubectl attach mypod -c rocket-ranger -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 omitted, us... |
Set resource limits and requests for the nginx deployment containers. | Command:
```bash
kubectl set resources deployment nginx --limits=cpu=200m,memory=512Mi --requests=cpu=500m,memory=2Gi
```
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... |
Create a debug container using the e-commerce-pod as a template, with all container images changed to mongo | Command:
```bash
kubectl debug e-commerce-pod --copy-to=my-debugger --set-image=*=mongo
```
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 resour... |
Create a new config map called "api-config" using specified files and keys | Command:
```bash
kubectl create configmap api-config --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 ... |
Create a debuggable copy of the "e-commerce-pod" by changing all container images to "golang" | Command:
```bash
kubectl debug e-commerce-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 r... |
Scale the deployment named app-v2-replicaset to 5 replicas, if its current size is also 5 | Command:
```bash
kubectl scale --current-replicas=5 --replicas=5 deployment/app-v2-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 --resource-v... |
Forward connections from port 8000 on all addresses to port 8080 in the pod "mypod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/mypod 8000: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 sel... |
Update the environment variables of the "frontend-deployment" deployment with the values of the keys "API_KEY" from the "app-secrets" config map. | Command:
```bash
kubectl set env --keys=API_KEY --from=configmap/app-secrets 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 on... |
Delete the pods and services named "security" and "payment" | Command:
```bash
kubectl delete pod,service security payment
```
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... |
Create a deployment named "ingress" with the nginx image. | Command:
```bash
kubectl create deployment ingress --image=nginx
```
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|nam... |
Add a taint with the key 'dedicated' on nodes having the label cluster=my-cluster | Command:
```bash
kubectl taint node -l cluster=my-cluster dedicated=node-2:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": ... |
Execute the "wp" command inside the first container of the pod of the "api-service" service and display the output. | Command:
```bash
kubectl exec svc/api-service -- 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 the kubectl.kubern... |
restart a deployment | Command:
```bash
kubectl rollout restart deployment/my-deployment
```
What it does:
Restart a resource.
Resource rollout will be restarted.
Syntax:
`kubectl rollout restart RESOURCE`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to files identifying the re... |
Import environment variables from a config map and prefix them in a deployment | Command:
```bash
kubectl set env --from=configmap/api-config --prefix=MYSQL_ 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 definition... |
Create a service for an nginx replication controller, serving on port 8080 and connecting to the containers on port 637900 | Command:
```bash
kubectl expose rc nginx --port=8080 --target-port=637900
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port. ... |
Add a taint with the key 'disktype' and value 'gpu-node-12:PreferNoSchedule' on nodes that have the label 'app-type=microservice'. | Command:
```bash
kubectl taint node -l app-type=microservice disktype=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": "", "u... |
Edit the configuration of a service using the "gedit" editor. | Command:
```bash
KUBE_EDITOR="gedit" kubectl edit svc/proxy-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,... |
Delete all pods and services with the label "team=devops" | Command:
```bash
kubectl delete pods,services -l team=devops
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label selector... |
Check if you have permission to list the job named "log-analysis-job" in the "default" namespace using the command `kubectl auth can-i list jobs.batch/log-analysis-job -n default`. | Command:
```bash
kubectl auth can-i list jobs.batch/log-analysis-job -n default
```
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... |
Print the YAML-formatted result of updating the nginx deployment with the service account from the local file "nginx-deployment.yaml", without actually hitting the API server | Command:
```bash
kubectl set sa -f nginx-deployment.yaml serviceaccount1 --local --dry-run=client -o yaml
```
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), stateful... |
Create a job named "image-build-job" using the image "mongo" and execute the command "mongo --version" within the job | Command:
```bash
kubectl create job image-build-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": "Output f... |
Apply a taint with the key 'app' and value 'monitoring-node-15:PreferNoSchedule' on all nodes with the label component=proxy. | Command:
```bash
kubectl taint node -l component=proxy app=monitoring-node-15:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage... |
Create a new config map named "kube-system-config" with the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap kube-system-config --from-file=properties=/path/to/preferences/file1.txt --from-file=key1=/path/to/preferences/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
W... |
Get output from running the 'geth attach' command in the container named mycontainer from the pod named proxy-service-pod. | Command:
```bash
kubectl exec proxy-service-pod -c mycontainer -- geth attach
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitt... |
Create a job called "batch-processing" using the container image "golang" and run the command "go run hello.go" inside the job. | Command:
```bash
kubectl create job batch-processing --image=golang -- go run hello.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... |
Add the annotation 'last-deployment' with the value '2023-03-15' to the pod named 'database' | Command:
```bash
kubectl annotate pods database 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 ar... |
Open the 'email-service' service for editing using the 'code' editor. | Command:
```bash
KUBE_EDITOR="code" kubectl edit svc/email-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, ... |
Check if you have the permission to list the "certificates-renewal-job" job in the "testing" namespace. | Command:
```bash
kubectl auth can-i list jobs.batch/certificates-renewal-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 parti... |
Create a service for the replication controller specified in "ubuntu-controller.yaml" file, which serves on port 8083 and connects to the containers on port 808800. | Command:
```bash
kubectl expose -f ubuntu-controller.yaml --port=8083 --target-port=808800
```
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... |
Create an ingress called 'app2-ingress' that directs requests to a specific service and port, with TLS encryption using a specified certificate secret | Command:
```bash
kubectl create ingress app2-ingress --rule="testing.com/example=svc1:8084,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... |
Create a single ingress called 'web-ingress' that directs requests to site.com/example to svc1:8082 with a tls secret "my-cert" | Command:
```bash
kubectl create ingress web-ingress --rule="site.com/example=svc1:8082,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage":... |
Set the custom TLS server name to "star-cluster" for the kube-cluster-1 cluster entry | Command:
```bash
kubectl config set-cluster kube-cluster-1 --tls-server-name=star-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] [--certifica... |
Expose a replica set as a service, serving on port 5001 and connecting to the containers on port 808800 | Command:
```bash
kubectl expose rs php --port=5001 --target-port=808800
```
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 ... |
Remove the taint with key 'special' and effect 'NoSchedule' from the node 'web-node-8' if one exists | Command:
```bash
kubectl taint nodes web-node-8 special: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... |
Start a pod named "hazelcast" using the "wordpress" image and expose port 8010. | Command:
```bash
kubectl run hazelcast --image=wordpress --port=8010
```
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": "... |
Run a proxy to the Kubernetes API server, serving static content from a specified directory. | Command:
```bash
kubectl proxy --port=5000 --www=./local/www/
```
What it does:
Creates a proxy server or application-level gateway between localhost and the Kubernetes API server. It also allows serving static content over specified HTTP path. All incoming data enters through one port and gets forwarded to the remote... |
Edit the last-applied-configuration annotations of a resource using a JSON file. | Command:
```bash
kubectl apply edit-last-applied -f params.yaml -o json
```
What it does:
Edit the latest last-applied-configuration annotations of resources from the default editor.
The edit-last-applied command allows you to directly edit any API resource you can retrieve via the command-line tools. It will open the... |
Specify which keys from a config map should be imported for a deployment | Command:
```bash
kubectl set env --keys=debug_mode --from=configmap/kube-system-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 def... |
Create a service for the replication controller specified in the "ubuntu-controller.yaml" file | Command:
```bash
kubectl expose -f ubuntu-controller.yaml --port=9090 --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... |
Add a taint with the key 'app' and the value 'web-node-8:PreferNoSchedule' on nodes that have the label 'version=v1.0.0'. | Command:
```bash
kubectl taint node -l version=v1.0.0 app=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": "Outpu... |
Update the 'analytics-platform-deployment' deployment by setting the environment variable 'DB_PASSWORD' to 'secretpassword' | Command:
```bash
kubectl set env deployment/analytics-platform-deployment DB_PASSWORD=secretpassword
```
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... |
Create a new pod named debug-image-1 by making a copy of api-service-pod | Command:
```bash
kubectl debug api-service-pod --copy-to=debug-image-1 --set-image=*=hazelcast/hazelcast
```
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 def... |
Copy a file named "foo" from a remote pod to your local machine under the /tmp/bar directory. | Command:
```bash
kubectl cp monitoring/image-resizer-pod-20:/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 ku... |
Set the client-key field for the app-service entry without modifying any other values. | Command:
```bash
kubectl config set-credentials app-service --client-key=~/.kube/admin.key
```
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-key=keyfile
Bearer token... |
Autoscale the replication controller "gateway" to have a minimum of 1 pod and a maximum of 8 pods, with a target CPU utilization of 60%. | Command:
```bash
kubectl autoscale rc gateway --max=8 --cpu-percent=60
```
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... |
Configure autoscaling for the "email" deployment, with a minimum of 3 pods and a maximum of 13 pods. | Command:
```bash
kubectl autoscale deployment email --min=3 --max=13
```
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 t... |
Forward local port 5432 to pod port 9090 of the chat-app-pod | Command:
```bash
kubectl port-forward pod/chat-app-pod 5432 9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected autom... |
Listen on ports 9090 and 6000 locally, forwarding data to/from ports 8888 and 6000 in a pod selected by the search-engine-deployment deployment. | Command:
```bash
kubectl port-forward deployment/search-engine-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 pod wil... |
Listen on port 8081 locally and forward data to/from port 8000 in the 'log-aggregator-pod' pod | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 8081 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... |
Create an ingress named 'public-api-ingress' that routes requests from website.com/bar to svc1:9091, using the TLS secret 'my-cert'. | Command:
```bash
kubectl create ingress public-api-ingress --rule="website.com/bar=svc1:9091,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "u... |
Update the annotation of a pod with a specific value, overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods email 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 i... |
Remove the label named 'env' from the pod 'media-stream' if it exists | Command:
```bash
kubectl label pods media-stream env-
```
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 ... |
Create a new ClusterIP service named catalog-service-clusterip that forwards traffic from port 3306 externally to port 3306 internally. | Command:
```bash
kubectl create service clusterip catalog-service-clusterip --tcp=3306:3306
```
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"... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=MAX_CONNECTIONS --from=configmap/kube-system-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 var... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/app-config deployment/payment-processor-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defini... |
List the replication controllers with the name 'web', services with the name 'chat-app-rc', and pods with the name 'e-commerce-pod' | Command:
```bash
kubectl get rc/web service/chat-app-rc pods/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... |
Edit the deployment 'notification-handler-deployment' in YAML format and save the modified configuration in its annotation. | Command:
```bash
kubectl edit deployment/notification-handler-deployment -o yaml --save-config
```
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 ED... |
View the metrics for pods that have the label "stack" set to "tech-stack" | Command:
```bash
kubectl top pod -l stack=tech-stack
```
What it does:
Display resource (CPU/memory) usage of pods.
The 'top pod' command allows you to see the resource consumption of pods.
Due to the metrics pipeline delay, they may be unavailable for a few minutes since pod creation.
Syntax:
`kubectl top pod [NAME ... |
Import specific keys from a config map into the environment variables of a deployment. | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/namespace-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 def... |
setup scaling for a replication controller named "gateway" based on CPU utilization | Command:
```bash
kubectl autoscale rc gateway --max=5 --cpu-percent=50
```
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... |
update the deployment 'user-management-deployment' with the new environment variable DEBUG=true. | Command:
```bash
kubectl set env deployment/user-management-deployment DEBUG=true
```
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 (w... |
Create a debug copy of the chat-app-pod by adding a debug container and changing the container images. | Command:
```bash
kubectl debug chat-app-pod -it --copy-to=debug-image-memcached --image=debian --set-image=app=app:debug,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... |
Set the resource request and limits for all containers in the kafka deployment | Command:
```bash
kubectl set resources deployment kafka --limits=cpu=200m,memory=512Mi --requests=cpu=1,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... |
Display the most recent 20 lines of logs for the gateway-pod pod. | Command:
```bash
kubectl logs --tail=20 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", "short": "-c"... |
Forward port 8088 on all addresses to port 8081 in the pod "chat-app-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/chat-app-pod 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 will... |
Import specific keys from a config map to a deployment's environment variables | Command:
```bash
kubectl set env --keys=api_key --from=configmap/app-secrets deployment/payment-processor-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definiti... |
Forward port 5000 on localhost and IP 10.19.21.23 to port 8081 in the 'analytics-pod' pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/analytics-pod 5000:8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the crite... |
Delete the pods and services named "monitoring" and "security" | Command:
```bash
kubectl delete pod,service monitoring security
```
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... |
Delete the pods and services with the names "database" and "database" | Command:
```bash
kubectl delete pod,service database 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 selecto... |
Create a service for a replication controller specified in "wordpress-controller.yaml" that serves on port 8084 and connects to containers on port 300000 | Command:
```bash
kubectl expose -f wordpress-controller.yaml --port=8084 --target-port=300000
```
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 ... |
Forward local port 9090 to pod port 8080 | Command:
```bash
kubectl port-forward pod/cdn-service-pod 9090 8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected au... |
Forward traffic from a local port to a specific port in a pod | Command:
```bash
kubectl port-forward pod/frontend-pod :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 automatic... |
Forward traffic from port 9090 on your local machine to port 8080 in the pod named 'chat-app-pod' | Command:
```bash
kubectl port-forward pod/chat-app-pod 9090: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 autom... |
Retrieve the logs from the container "log-aggregator-pod-1" of the deployment named "email-server-deployment". | Command:
```bash
kubectl logs deployment/email-server-deployment -c log-aggregator-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:... |
Update the label of the 'gateway' pod to have the label 'env' with the value 'production' | Command:
```bash
kubectl label pods gateway env=production
```
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":... |
Attach to the 'astro-container' within the 'email-service-pod' to get the output | Command:
```bash
kubectl attach email-service-pod -c astro-container
```
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 omi... |
Import the value of the 'debug_mode' key from the 'app-settings' config map into the environment variables of the 'log-aggregator-deployment' deployment. | Command:
```bash
kubectl set env --keys=debug_mode --from=configmap/app-settings 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 definit... |
Remove the namespace setting for the local-context context. | Command:
```bash
kubectl config unset contexts.local-context.namespace
```
What it does:
Unset 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.
Syntax:
`kubectl config unset PROPERTY_NAME` |
Mark the node named "node-2" as unschedulable. | Command:
```bash
kubectl cordon node-2
```
What it does:
Mark node as unschedulable.
Syntax:
`kubectl cordon NODE`
Helpful flags:
"flag": "--selector", "short": "-l", "default": "", "usage": "Selector (label query) to filter on " |
Start a pod with the image 'mcr.microsoft.com/dotnet/core/runtime' and expose port 5001 | Command:
```bash
kubectl run hazelcast --image=mcr.microsoft.com/dotnet/core/runtime --port=5001
```
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...... |
Copy the local file /tmp/foo_dir to the remote pod argocd/web-app-pod-1 in the /tmp/bar_dir directory. | Command:
```bash
kubectl cp /tmp/foo_dir argocd/web-app-pod-1:/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 the kubec... |
Update the 'search-engine-deployment' deployment with a new environment variable 'MAX_CONNECTIONS' set to '100' | Command:
```bash
kubectl set env deployment/search-engine-deployment MAX_CONNECTIONS=100
```
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 templ... |
Create a service for the replicated ruby using the replica set 'ruby' serving on port 9092, which connects to the containers on port 330600. | Command:
```bash
kubectl expose rs ruby --port=9092 --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... |
Retrieve the logs of the previous terminated "time-machine" container from the "chat-app-pod" pod. | Command:
```bash
kubectl logs -p -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... |
Start a postgres pod named 'nginx' with the 'postgres' image and customize the pod's specifications using the values provided in the JSON object. | Command:
```bash
kubectl run nginx --image=postgres --overrides='{ "apiVersion": "v2.1.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMM... |
Create a Jenkins pod with labels "app=jenkins" and "env=prod" | Command:
```bash
kubectl run hazelcast --image=jenkins --labels="app=jenkins,env=prod"
```
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...]`
Helpfu... |
Update the deployment 'user-management-deployment' by adding a new environment variable 'CACHE_SIZE' with a value of '64MB'. | Command:
```bash
kubectl set env deployment/user-management-deployment CACHE_SIZE=64MB
```
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 templat... |
Execute the 'python --version' command within the pod named vpn-service-pod, using the warp-drive container. | Command:
```bash
kubectl exec vpn-service-pod -c warp-drive -- python --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 omi... |
Create a new config map named app-config-dev in the current namespace, using the specified files as values for the properties and key1 keys | Command:
```bash
kubectl create configmap app-config-dev --from-file=properties=/path/to/profiles/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 creati... |
Copy the ~/.config/kube directory from the 'front-end-pod-12' pod in the 'logging' namespace to the /tmp/bar_dir directory locally. | Command:
```bash
kubectl cp logging/front-end-pod-12:~/.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 the... |
Create a debug copy of the 'cdn-service-pod' with a container named 'my-debugger' | Command:
```bash
kubectl debug cdn-service-pod -it --copy-to=my-debugger --image=debian --set-image=cache=redis:alpine,logger=logging-app:debug
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by reso... |
Import the 'redis_host' key from the 'app-name-config' ConfigMap and set it as an environment variable for the 'analytics-platform-deployment' deployment. | Command:
```bash
kubectl set env --keys=redis_host --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 variable ... |
Embed certificate authority data for the "web-cluster" cluster entry. | Command:
```bash
kubectl config set-cluster web-cluster --embed-certs --certificate-authority=~/.kube/cloud-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... |
Update the image of a container in a pod by patching the pod's spec | Command:
```bash
kubectl patch pod media-stream-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 FIL... |
Execute the 'jenkins-plugin-cli' command in the 'time-machine' container of the 'frontend-pod' pod | Command:
```bash
kubectl exec frontend-pod -c time-machine -- jenkins-plugin-cli
```
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... |
Add a taint on nodes with specific label | Command:
```bash
kubectl taint node -l version=v1.0.0 workload=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": "... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.