prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Remove the label 'component' from the 'vpn' pod | Command:
```bash
kubectl label pods vpn component-
```
What it does:
Update the labels on a resource.
Syntax:
`kubectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]`
Helpful flags:
"flag": "--all-namespaces", "short": "-A", "default": "false", "usage": "If tru... |
Create an ingress called 'api-v2-ingress' that directs requests to testing.com/example to svc1:3306 with a tls secret called "my-cert" | Command:
```bash
kubectl create ingress api-v2-ingress --rule="testing.com/example=svc1:3306,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 to nodes with a specific label | Command:
```bash
kubectl taint node -l release=beta hardware=storage-node-13: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-dev' using the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-config-dev --from-file=properties=/path/to/profiles/file1.txt --from-file=key1=/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 creatin... |
Execute the command 'apk add curl' inside the first container of the payment-service pod and retrieve the output. | Command:
```bash
kubectl exec svc/payment-service -- apk add curl
```
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 ... |
Create a cluster role binding for multiple users and groups using a specific cluster role | Command:
```bash
kubectl create clusterrolebinding reader --clusterrole=reader --user=developer3 --user=k8s-admin --group=qa-engineers
```
What it does:
Create a cluster role binding for a particular cluster role.
Syntax:
`kubectl create clusterrolebinding NAME --clusterrole=NAME [--user=username] [--group=groupname]... |
Create a pod named "hazelcast" using the image "hazelcast/hazelcast" and expose port 5001. | Command:
```bash
kubectl run hazelcast --image=hazelcast/hazelcast --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...]`
Helpful flags:... |
Create a copy of the monitoring pod with a debug container and updated container images | Command:
```bash
kubectl debug monitoring-pod -it --copy-to=debug-image-api --image=debian --set-image=api=api:v2,worker=my-custom-worker:1.2.3
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by reso... |
Update the label of the pod 'email' with the key 'env' and value 'staging' | Command:
```bash
kubectl label pods email env=staging
```
What it does:
Update the labels on a resource.
Syntax:
`kubectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]`
Helpful flags:
"flag": "--all-namespaces", "short": "-A", "default": "false", "usage": "If ... |
Forward traffic from localhost port 5432 to port 9090 in the web-app-pod pod | Command:
```bash
kubectl port-forward pod/web-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 automa... |
Start a pod named nginx with the ubuntu image, but override the specification with values parsed from a JSON file using the custom-version API version. | Command:
```bash
kubectl run nginx --image=ubuntu --overrides='{ "apiVersion": "custom-version", "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] --... |
Create a deployment named "loadbalancer" that runs the "alpine" image and exposes port 8081. | Command:
```bash
kubectl create deployment loadbalancer --image=alpine --port=8081
```
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... |
Import the environment variables from the 'api-key-secret' secret and set them in the 'authentication-service-deployment' deployment. | Command:
```bash
kubectl set env --from=secret/api-key-secret deployment/authentication-service-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one... |
Retrieve output from the time-machine container in the auth-service-pod. | Command:
```bash
kubectl attach auth-service-pod -c time-machine
```
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... |
Create a cluster role named "reader" with the ability to "use" and access the "pods" resource, specifically the "billing-service" and "prod-api-gateway" pods. | Command:
```bash
kubectl create clusterrole reader --verb=use --resource=pods --resource-name=billing-service --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=server|client... |
Add a taint with the key 'datacenter' and the value 'monitoring-node-15:PreferNoSchedule' on nodes having the label 'owner=john-doe' | Command:
```bash
kubectl taint node -l owner=john-doe datacenter=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": "", ... |
Add a taint on nodes with a specific label | Command:
```bash
kubectl taint node -l instance=app-instance-1 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... |
Set the service account of the deployment api-server-deployment to kube-scheduler | Command:
```bash
kubectl set serviceaccount deployment api-server-deployment kube-scheduler
```
What it does:
Update the service account of pod template resources.
Possible resources (case insensitive) can be:
replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset
Syntax:
`... |
Create a new secret named tls-certificate-secret with keys for each file in folder bar | Command:
```bash
kubectl create secret generic tls-certificate-secret --from-file=path/to/settings
```
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 basen... |
Set environment variables for a deployment using keys imported from a specific config map | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/app-config-prod deployment/scheduler-app-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defi... |
Create an ingress named "ingress1" with multiple hosts and the pathType set as Prefix | Command:
```bash
kubectl create ingress ingress1 --class=default \
--rule="foo.com/path*=svc:8081" \
--rule="module.com/admin*=svc2:http"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", ... |
Create a role named "reader" with the ability to proxy to pods and access specific resource names like "app-worker-2" and "identity-provider" | Command:
```bash
kubectl create role reader --verb=proxy --resource=pods --resource-name=app-worker-2 --resource-name=identity-provider
```
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... |
Taint the nodes with label 'role=database' by adding a taint with key 'workload' and value 'app-node-6:PreferNoSchedule' | Command:
```bash
kubectl taint node -l role=database workload=app-node-6:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "O... |
Copy the local file /tmp/foo to the remote pod named cache-pod-5 in the prometheus namespace, and rename it as /tmp/bar. | Command:
```bash
kubectl cp /tmp/foo prometheus/cache-pod-5:/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.kub... |
Listen on the local ports 5000 and 6000, and forward data to/from ports 8081 and 6000 in the analytics-pod. | Command:
```bash
kubectl port-forward 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 criteria, a pod will be selected auto... |
Create a config map named app-config-dev with specific keys and corresponding file paths | Command:
```bash
kubectl create configmap app-config-dev --from-file=conf=/path/to/preferences/file1.txt --from-file=data=/path/to/data/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a co... |
Forward port 3000 on localhost and IP address 10.19.21.23 to port 8888 in the chat-app-pod pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/chat-app-pod 3000:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criter... |
Copy the local file /tmp/foo_dir to the remote pod named cache-pod-5 in the default namespace and place it at /tmp/bar | Command:
```bash
kubectl cp /tmp/foo_dir default/cache-pod-5:/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.ku... |
Auto scale the deployment "auth" with a minimum of 7 and a maximum of 10 pods | Command:
```bash
kubectl autoscale deployment auth --min=7 --max=10
```
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 an ingress resource named 'www-ingress' with a rule that directs requests from 'site.com/input' to the service 'svc1' on port 8010 | Command:
```bash
kubectl create ingress www-ingress --rule="site.com/input=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": "", "usage": "... |
List all deployments in the "v2.0.0" version of the "internal-apps" API group in JSON output format. | Command:
```bash
kubectl get deployments.v2.0.0.internal-apps -o json
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you w... |
create a new config map named env-vars from the environment variables file located at path/to/data.env | Command:
```bash
kubectl create configmap env-vars --from-env-file=path/to/data.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 basename... |
Set the last-applied-configuration of a resource to match the contents of the 'setup.yaml' file. | Command:
```bash
kubectl apply set-last-applied -f setup.yaml
```
What it does:
Set the latest last-applied-configuration annotations by setting it to match the contents of a file. This results in the last-applied-configuration being updated as though 'kubectl apply -f ' was run, without updating any other parts of th... |
Copy a file named "foo" from a remote pod to a local directory named "bar_dir". | Command:
```bash
kubectl cp prometheus/file-server-pod-14::/tmp/foo /tmp/bar_dir
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the... |
Create a pod disruption budget named payment-gateway-pdb that will select all pods with the project=my-project label and require a minimum of 9 of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget payment-gateway-pdb --selector=project=my-project --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-ava... |
Forward traffic between local ports 8081 and 6000 and the ports 8081 and 6000 in the 'chat-app-pod' pod | Command:
```bash
kubectl port-forward pod/chat-app-pod 8081 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... |
Add a taint with the key 'dedicated' and value 'kube-master-9:PreferNoSchedule' on nodes that have the label 'release=beta' | Command:
```bash
kubectl taint node -l release=beta dedicated=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": "", "usage":... |
Copy a file named "foo" from a remote pod called "web-app-pod-1" in the "cert-manager" namespace to the local machine at /tmp/bar directory. | Command:
```bash
kubectl cp cert-manager/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... |
Add a taint to nodes that have the label 'component=proxy' with the key 'workload' and effect 'PreferNoSchedule' | Command:
```bash
kubectl taint node -l component=proxy workload=db-node-7:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "... |
Create a cluster role named "view" with the "patch" verb allowed for the non-resource URL "/metrics" | Command:
```bash
kubectl create clusterrole "view" --verb=patch --non-resource-url=/metrics
```
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]`
Helpful flags:
"flag": "--output", "short"... |
Update the pod 'email' with the annotation 'git-repo' and the value 'https://github.com/example/my-app' | Command:
```bash
kubectl annotate pods email git-repo='https://github.com/example/my-app'
```
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... |
Add a taint with the key 'zone' and value 'storage-node-13:PreferNoSchedule' to all nodes with the label 'service=auth' | Command:
```bash
kubectl taint node -l service=auth zone=storage-node-13:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "O... |
Forward traffic from local port 8088 to port 9090 in the pod/analytics-pod pod. | Command:
```bash
kubectl port-forward pod/analytics-pod 8088:9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected auto... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=REDIS_HOST --from=configmap/global-config 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 variable ... |
Create a service for the ubuntu deployment, serving on port 5001 and connecting to containers on port 8084. | Command:
```bash
kubectl expose deployment ubuntu --port=5001 --target-port=808400
```
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 specifi... |
List deployments from the "testing-apps" API group in JSON format | Command:
```bash
kubectl get deployments.v1.1.0.testing-apps -o json
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you wi... |
Create a job named "scaling-job" using the "jenkins" image | Command:
```bash
kubectl create job scaling-job --image=jenkins -- java -jar /usr/share/jenkins/jenkins.war
```
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":... |
Create a new secret named monitoring-credentials-secret by reading environment variables from the file at path/to/configs.env | Command:
```bash
kubectl create secret generic monitoring-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 defaul... |
Import specific keys from a config map into a deployment's environment variables | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/kube-system-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 def... |
Update the cluster field in a specific context to a specified cluster. | Command:
```bash
kubectl config set contexts.app-2-context.cluster kube-cluster-2
```
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 ... |
Forward traffic from port 8088 on all addresses to port 8080 in the 'backend-pod' pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/backend-pod 8088: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 ... |
Edit the configuration of the 'logging-service' service. | Command:
```bash
kubectl edit svc/logging-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 to '... |
Import the keys "redis_host" from the config map "app-config-prod" into the deployment "mydeployment" | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/app-config-prod 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 on... |
Auto scale the replication controller "api" with a target CPU utilization of 20% and a maximum of 2 pods | Command:
```bash
kubectl autoscale rc api --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... |
Import the 'smtp_server' key from the 'db-config' config map and set it as an environment variable in the 'frontend-deployment' deployment. | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/db-config 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 ... |
Create a debug container image of the "gateway-pod" with all container images changed to WordPress | Command:
```bash
kubectl debug gateway-pod --copy-to=debug-image-web --set-image=*=wordpress
```
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... |
Set the service account of the 'order-processing-deployment' deployment to 'prometheus'. | Command:
```bash
kubectl set serviceaccount deployment order-processing-deployment prometheus
```
What it does:
Update the service account of pod template resources.
Possible resources (case insensitive) can be:
replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset
Syntax:... |
Auto scale the "web" replication controller with a minimum of 1 pod and a maximum of 4 pods, targeting a CPU utilization of 20%. | Command:
```bash
kubectl autoscale rc web --max=4 --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... |
Create a job named 'cleanup' using the 'busybox' image | Command:
```bash
kubectl create job cleanup --image=busybox
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json|yaml|... |
Create a service for the replication controller specified in the "ruby-controller.yaml" file, serving on port 6379 and connecting to the containers on port 808100. | Command:
```bash
kubectl expose -f ruby-controller.yaml --port=6379 --target-port=808100
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the s... |
Listen on port 8081 locally and forward traffic to the pod named 'mypod' on port 9090. | Command:
```bash
kubectl port-forward pod/mypod 8081:9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automaticall... |
Create a role named "foo" with the ability to "use" and specify specific resource names "prod-api-gateway" and "dashboard-ui" for the "pods" resource type. | Command:
```bash
kubectl create role foo --verb=use --resource=pods --resource-name=prod-api-gateway --resource-name=dashboard-ui
```
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|clien... |
Import the 'LOG_LEVEL' key from the 'kube-system-config' config map into the 'monitoring-stack-deployment' deployment | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/kube-system-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 ... |
Retrieve the snapshot logs from container api-service-pod-1 of the deployment named mydeployment | Command:
```bash
kubectl logs deployment/mydeployment -c api-service-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--co... |
Import the secret_key key from the monitoring-config config map and set it as an environment variable for the log-aggregator-deployment deployment. | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/monitoring-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 de... |
List deployments in YAML output format for the specified API group version. | Command:
```bash
kubectl get deployments.beta-1.0.backup-apps -o yaml
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you w... |
Start a pod with the wordpress image and expose port 27017. | Command:
```bash
kubectl run hazelcast --image=wordpress --port=27017
```
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": ... |
Forward local port 3000 to port 8888 in the pod "log-aggregator-pod" | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 3000:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected... |
Forward local port 8000 to port 8088 on the selected pod | Command:
```bash
kubectl port-forward deployment/log-aggregator-deployment 8000 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 wi... |
Add a taint with key 'disktype' on nodes labeled owner=john-doe | Command:
```bash
kubectl taint node -l owner=john-doe 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": "", "usage": "... |
Copy the "/var/run/secrets/kubernetes.io/serviceaccount/" directory from the "message-broker-pod-15" pod in the "default" namespace to the "/tmp/bar" directory on your local machine. | Command:
```bash
kubectl cp default/message-broker-pod-15:/var/run/secrets/kubernetes.io/serviceaccount/ /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": "Co... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=API_KEY --from=configmap/monitoring-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 def... |
Remove exec auth plugin environment variables for the "app-operator" entry | Command:
```bash
kubectl config set-credentials app-operator --exec-env=var-to-remove-
```
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 fla... |
Get the output from running the 'redis-cli' command inside the 'astro-container' container of the 'database-pod' pod. | Command:
```bash
kubectl exec database-pod -c astro-container -- redis-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 omitted,... |
List all deployments in the "custom-version" version of the "third-party-apps" API group in YAML output format. | Command:
```bash
kubectl get deployments.custom-version.third-party-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 names... |
Create a new config map called app-config-prod using the 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/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 ... |
Create a pod disruption budget with a specific label and availability requirement. | Command:
```bash
kubectl create poddisruptionbudget api-service-pdb --selector=project=my-project --min-available=1
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-availab... |
Wait for the pod "payment-gateway-pod" to be deleted with a timeout of 60 seconds after running the delete command. | Command:
```bash
kubectl delete pod/payment-gateway-pod
kubectl wait --for=delete pod/busybox1 --timeout=60s
```
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 re... |
Import the specific keys CONFIG_FILE_PATH from the monitoring-config config map into the environment of the backend-microservice-deployment deployment. | Command:
```bash
kubectl set env --keys=CONFIG_FILE_PATH --from=configmap/monitoring-config 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... |
Create a new pod named 'nginx' using the 'alpine' image, but change the spec of the pod by providing values from the given JSON. | Command:
```bash
kubectl run nginx --image=alpine --overrides='{ "apiVersion": "dev-2.2.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COM... |
Create a copy of the proxy-server-pod named debug-image-memcached, but change the command to "sh" for the container named rocket-ranger | Command:
```bash
kubectl debug proxy-server-pod -it --copy-to=debug-image-memcached --container=rocket-ranger -- 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 ... |
Import specific keys from a config map into a deployment using environment variables | Command:
```bash
kubectl set env --keys=config_file_path --from=configmap/db-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 d... |
Add a label to the pod 'email' with the key 'role' and the value 'backend' | Command:
```bash
kubectl label pods email role=backend
```
What it does:
Update the labels on a resource.
Syntax:
`kubectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]`
Helpful flags:
"flag": "--all-namespaces", "short": "-A", "default": "false", "usage": "If... |
Forward local traffic from port 8000 to port 8081 in the pod named "api-service-pod" | Command:
```bash
kubectl port-forward pod/api-service-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 criteria, a pod will be selected au... |
Create an ingress resource named 'api-ingress' with a rule that directs requests for 'site.com/module' to the service 'svc1' on port 8084 | Command:
```bash
kubectl create ingress api-ingress --rule="site.com/module=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": "", "usage": ... |
Retrieve the information of the pod specified in the "setup.yaml" file in JSON format. | Command:
```bash
kubectl get -f setup.yaml -o json
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you will only see result... |
Display only the most recent 31 lines of logs for the pod 'database-pod' | Command:
```bash
kubectl logs --tail=31 database-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 local port 8000 to port 8000 in the pod | Command:
```bash
kubectl port-forward pod/web-app-pod 8000: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 automa... |
Add a taint with the key 'special' on nodes having the label 'version=v1.0.0' | Command:
```bash
kubectl taint node -l version=v1.0.0 special=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": "", "usage":... |
Specify that the cluster field in the local-context context should be set to staging-cluster | Command:
```bash
kubectl config set contexts.local-context.cluster staging-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... |
Forward port 5432 from localhost and IP address 10.19.21.23 to port 5432 in the analytics-pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/analytics-pod 5432: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 crite... |
Delete the pods and services named "analytics" | Command:
```bash
kubectl delete pod,service analytics analytics
```
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... |
remove both the backend pod and service, as well as the analytics pod and service | Command:
```bash
kubectl delete pod,service backend analytics
```
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... |
Switch to raw terminal mode and attach to the 'code-explorer' container in the 'vpn-service-pod' | Command:
```bash
kubectl attach vpn-service-pod -c code-explorer -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 o... |
Forward traffic from local port 5000 to port 5000 in the 'proxy-server-pod' pod | Command:
```bash
kubectl port-forward pod/proxy-server-pod 5000:5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected a... |
Forward traffic from port 8088 on localhost and IP 10.19.21.23 to port 5000 in the e-commerce-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/e-commerce-pod 8088: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 crit... |
stream the logs from all containers in pods labeled with customer=acme-corp | Command:
```bash
kubectl logs -f -l customer=acme-corp --all-containers=true
```
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": "--... |
Set environment variable secret_key with value from the config map app-settings for the deployment search-engine-deployment. | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/app-settings 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 definiti... |
Rename the context 'local-context' to 'admin-context' in your kubeconfig file | Command:
```bash
kubectl config rename-context local-context admin-context
```
What it does:
Renames a context from the kubeconfig file.
CONTEXT_NAME is the context name that you want to change.
NEW_NAME is the new name you want to set.
Note: If the context being renamed is the 'current-context', this field will also ... |
If the current size of the deployment named 'payment-service-rs' is 3, scale the 'mysql' deployment to 5 replicas. | Command:
```bash
kubectl scale --current-replicas=3 --replicas=5 deployment/payment-service-rs
```
What it does:
Set a new size for a deployment, replica set, replication controller, or stateful set.
Scale also allows users to specify one or more preconditions for the scale action.
If --current-replicas or --resource-... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.