prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Import specific keys from a config map to a deployment's environment variables. | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/global-config 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 ... |
Create a cluster role named "view" with the following permissions: allow proxy access and access to configmaps with the resource names "identity-provider" and "prod-api-gateway" | Command:
```bash
kubectl create clusterrole view --verb=proxy --resource=configmaps --resource-name=identity-provider --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... |
List the resource(s) of type "rc" with the names "web", "service/security-service-rc", and "pods/api-service-pod" | Command:
```bash
kubectl get rc/web service/security-service-rc pods/api-service-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 n... |
Create a cron job named backup-job that runs the command "psql" using the "postgres" image every minute | Command:
```bash
kubectl create cronjob backup-job --image=postgres --schedule="*/1 * * * *" -- psql
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "defa... |
Forward traffic from local port 8088 to port 5432 in the backend-pod pod. Make sure to listen on all addresses. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/backend-pod 8088:5432
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will ... |
Execute the 'mongo' command inside the first container of the first pod of the load-balancer-deployment deployment. | Command:
```bash
kubectl exec deploy/load-balancer-deployment -- 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, use... |
Create a pod named "hazelcast" with the image "confluentinc/cp-kafka" and expose port 5000. | Command:
```bash
kubectl run hazelcast --image=confluentinc/cp-kafka --port=5000
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flag... |
Create a new secret named encryption-key-secret from the environment variables stored in the settings.env file | Command:
```bash
kubectl create secret generic encryption-key-secret --from-env-file=path/to/settings.env
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, the key will default to th... |
Create a cluster role named "foo" with the verb "get" and the non-resource URL "/metrics" specified. | Command:
```bash
kubectl create clusterrole "foo" --verb=get --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": "... |
Forward local ports to a pod selected by a deployment | Command:
```bash
kubectl port-forward deployment/search-engine-deployment 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 wil... |
Create a pod disruption budget named monitoring-pdb that will select all pods with the app=rails label and require at least one of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget monitoring-pdb --selector=app=rails --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-available=N [--dr... |
Copy the local file /tmp/foo to the remote pod named task-processor-pod-17 in the prometheus namespace, and place it in the /etc/kubernetes directory. | Command:
```bash
kubectl cp /tmp/foo prometheus/task-processor-pod-17:/etc/kubernetes
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, us... |
Create a new ExternalName service named external-email-service | Command:
```bash
kubectl create service externalname external-email-service --external-name news-demo.news
```
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 service... |
Update the pod 'database' with the annotation 'contact-email' and the value 'support@example.com'. | Command:
```bash
kubectl annotate pods database contact-email=support@example.com
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and inc... |
Create an ingress called 'internal-ingress' with a rule that directs requests to testing.com/module and points to the service 'svc1' on port 8080 | Command:
```bash
kubectl create ingress internal-ingress --rule="testing.com/module=svc1:8080,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": "", "... |
Check if the user can list the specified job in the specified namespace. | Command:
```bash
kubectl auth can-i list jobs.batch/notification-sender-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 partia... |
Forward local port 3000 to port 8088 in the api-service-pod pod | Command:
```bash
kubectl port-forward pod/api-service-pod 3000:8088
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected au... |
Create a single ingress called 'app-proxy-ingress' that directs requests to foo.com/bar to svc1:8080 with a tls secret "my-cert" | Command:
```bash
kubectl create ingress app-proxy-ingress --rule="foo.com/bar=svc1:8080,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 config map named namespace-config by providing specific file paths for the keys instead of using file basenames on disk | Command:
```bash
kubectl create configmap namespace-config --from-file=conf=/path/to/profiles/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 a... |
Rename a context in your kubeconfig file | Command:
```bash
kubectl config rename-context testing-context team-beta-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... |
Copy the /tmp/foo_dir file on your local machine to the /tmp/bar_dir directory inside the kube-flannel/database-pod-2 pod in the kube-flannel namespace. | Command:
```bash
kubectl cp /tmp/foo_dir kube-flannel/database-pod-2:/tmp/bar_dir
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use th... |
Retrieve the deployments in the "dev-2.2.0" version of the "external-apps" API group and display them in YAML output format. | Command:
```bash
kubectl get deployments.dev-2.2.0.external-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 yo... |
Delete the pod named "cdn-service-pod" and wait for it to be deleted, with a timeout of 60 seconds. | Command:
```bash
kubectl delete pod/cdn-service-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 resour... |
Forward all traffic from port 5000 on all IP addresses to port 6379 in the 'proxy-server-pod' pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/proxy-server-pod 5000: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 ... |
Import the 'secret_key' key from the 'db-config' config map into the 'monitoring-stack-deployment' deployment. | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/db-config deployment/monitoring-stack-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definiti... |
Start a pod named "hazelcast" using the image "mcr.microsoft.com/dotnet/core/runtime" and expose port 8082 | Command:
```bash
kubectl run hazelcast --image=mcr.microsoft.com/dotnet/core/runtime --port=8082
```
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...... |
List the resources of specified types and names. | Command:
```bash
kubectl get rc/web service/e-commerce-rc pods/log-aggregator-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 name... |
Embed the certificate authority data for the dev-cluster cluster entry | Command:
```bash
kubectl config set-cluster dev-cluster --embed-certs --certificate-authority=~/.kube/star-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-... |
Add a taint with key 'workload' on nodes having the label 'owner' set to 'john-doe' | Command:
```bash
kubectl taint node -l owner=john-doe workload=testing-node-11:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
Edit the last-applied-configuration annotations of a deployment named 'python' using YAML | Command:
```bash
kubectl apply edit-last-applied deployment/python
```
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 edit... |
Import environment variables from a secret to a deployment named backend-microservice-deployment | Command:
```bash
kubectl set env --from=secret/api-secret-key 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 definitions in one o... |
Create a new config map named global-config with the specified keys by using files instead of file basenames on disk | Command:
```bash
kubectl create configmap global-config --from-file=properties=/path/to/data/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 creating ... |
Set the service account of the "load-balancer-deployment" deployment to "dashboard" | Command:
```bash
kubectl set serviceaccount deployment load-balancer-deployment dashboard
```
What it does:
Update the service account of pod template resources.
Possible resources (case insensitive) can be:
replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset
Syntax:
`ku... |
Copy the file /tmp/foo from the remote pod "logging/load-balancer-pod-9" to the local location /tmp/bar. | Command:
```bash
kubectl cp logging/load-balancer-pod-9:/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 kubec... |
Import the 'MAX_CONNECTIONS' key from the 'app-config' config map into the 'web-app-deployment' deployment | Command:
```bash
kubectl set env --keys=MAX_CONNECTIONS --from=configmap/app-config deployment/web-app-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions... |
Create a pod disruption budget named "web-app-pdb" that selects all pods with the label "env=production" and requires a minimum of four of them to be available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget web-app-pdb --selector=env=production --min-available=4
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N [--... |
Set the service account of the deployment "backend-microservice-deployment" to "istio" | Command:
```bash
kubectl set serviceaccount deployment backend-microservice-deployment istio
```
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:
... |
Expose the php deployment as a service on port 8081, connecting to the containers on port 9092 | Command:
```bash
kubectl expose deployment php --port=8081 --target-port=909200
```
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 ... |
Create a service for the replicated 'alpine' pods, which serves on port 7000 and connects to the containers on port 8000. | Command:
```bash
kubectl expose rc alpine --port=7000 --target-port=800000
```
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.... |
Copy the kube config file from your local machine to the `/tmp/bar` directory in the `istio-system/payment-gateway-pod-19` pod in the `default` namespace. | Command:
```bash
kubectl cp ~/.config/kube istio-system/payment-gateway-pod-19:/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, ... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=CONFIG_FILE_PATH --from=configmap/kube-system-config 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... |
Start a pod using the golang image, keep it running in the foreground, and do not restart it if it exits. | Command:
```bash
kubectl run -i -t busybox --image=golang --restart=Never
```
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:
"fla... |
Create and run a PHP pod, exposing port 8084 | Command:
```bash
kubectl run hazelcast --image=php --port=8084
```
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": "--file... |
Forward traffic from port 9090 on all addresses to port 3000 in the chat-app-pod pod's network | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/chat-app-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 pod will... |
Import specific keys from a config map into the environment variables of a deployment. | Command:
```bash
kubectl set env --keys=MAX_CONNECTIONS --from=configmap/namespace-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 ... |
Forward local ports 8081 to 8080 on the pod with the name "security-service-pod" | Command:
```bash
kubectl port-forward pod/security-service-pod 8081 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 select... |
Forward local port 3000 to port 8080 in the pod named "web-app-pod" | Command:
```bash
kubectl port-forward pod/web-app-pod 3000: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 automa... |
Create a deployment named 'app' that runs the 'python' image and exposes port 9000 | Command:
```bash
kubectl create deployment app --image=python --port=9000
```
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... |
Set the cluster field in the user-a-context context to staging-cluster | Command:
```bash
kubectl config set contexts.user-a-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 yo... |
Forward traffic from all addresses on port 9090 to port 8080 in the pod named "mypod". | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/mypod 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 sel... |
Import specific keys from a config map into a deployment's environment variables | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/db-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 one... |
Forward port 8000 in the pod named "analytics-pod" to port 8888 on all addresses. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/analytics-pod 8888: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 wil... |
Create a pod disruption budget named 'web-app-pdb' that will select all pods with the 'project=my-project' label and require at least four of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget web-app-pdb --selector=project=my-project --min-available=4
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N... |
Copy the contents of '/var/run/secrets/kubernetes.io/serviceaccount/' directory from the remote pod named 'file-server-pod-14' in the default namespace to the '/tmp/bar' directory on your local machine. | Command:
```bash
kubectl cp default/file-server-pod-14:/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": "Cont... |
Create a cluster role named "bar" with specific SubResources allowed. | Command:
```bash
kubectl create clusterrole bar --verb=patch,proxy,delete --resource=endpoints,endpoints/status
```
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":... |
Add a taint with key 'app' on nodes having label role=database, with the value 'dev-node-4' and the effect 'PreferNoSchedule'. | Command:
```bash
kubectl taint node -l role=database app=dev-node-4:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output... |
Create a pod disruption budget named messaging-pdb that will select all pods with the owner=team-1 label and require minimum 9 of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget messaging-pdb --selector=owner=team-1 --min-available=9
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N [--... |
List the replication controller with the name "web", the service with the name "email-service" and the pod with the name "security-service-pod". | Command:
```bash
kubectl get rc/web service/email-service-rc pods/security-service-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... |
Forward local ports 8088 and 6000 to ports 8081 and 6000 on the pod named api-service-pod | Command:
```bash
kubectl port-forward pod/api-service-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 be selected au... |
Get the output from the 'quantum-quark' container in the 'monitoring-pod' pod. | Command:
```bash
kubectl attach monitoring-pod -c quantum-quark
```
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,... |
Scale the replica set named 'webapp-replicaset' to a desired number of 3 replicas. | Command:
```bash
kubectl scale --replicas=3 rs/webapp-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-version is specified, it is va... |
Add a taint with key 'zone' on nodes having label zone=us-east-1 | Command:
```bash
kubectl taint node -l zone=us-east-1 zone=backup-node-14:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "... |
Import the SMTP_SERVER key from the env-vars config map and set it as an environment variable in the user-management-deployment deployment. | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/env-vars 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 definitio... |
Add a taint with key 'hardware' on nodes having label tier=frontend | Command:
```bash
kubectl taint node -l tier=frontend hardware=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... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=REDIS_HOST --from=configmap/kube-system-config deployment/user-management-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable ... |
Forward port 8088 to port 5000 in the pod "analytics-pod" | Command:
```bash
kubectl port-forward pod/analytics-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 criteria, a pod will be selected auto... |
Create a cron job named 'metrics-collection' with the command 'yum install -y aws-cli' inside a pod using the 'amazonlinux' image | Command:
```bash
kubectl create cronjob metrics-collection --image=amazonlinux --schedule="*/1 * * * *" -- yum install -y aws-cli
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag": "--... |
create a service named "frontend" that exposes the pod "payment-gateway-pod" on port 8089 | Command:
```bash
kubectl expose pod payment-gateway-pod --port=8089 --name=frontend
```
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 specif... |
Add the 'contact-email' annotation to the 'chat-app' pod with the value 'support@example.com' | Command:
```bash
kubectl annotate pods chat-app contact-email=support@example.com
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and inc... |
Forward local port 8888 to port 8088 in the frontend-pod pod. Use the command "kubectl port-forward pod/frontend-pod 8888:8088" | Command:
```bash
kubectl port-forward pod/frontend-pod 8888: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 autom... |
Forward traffic from local port 3000 to port 8081 in a pod selected by the "web-app-deployment" deployment. | Command:
```bash
kubectl port-forward deployment/web-app-deployment 3000 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 s... |
Delete the pods and services with names "gateway" and "backend" | Command:
```bash
kubectl delete pod,service gateway backend
```
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.... |
Rename the context 'old-name' to 'user-a-context' in your kubeconfig file | Command:
```bash
kubectl config rename-context old-name user-a-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 be u... |
Create a new config map named app-config-dev with the specified keys. The keys should be sourced from the given file paths. | Command:
```bash
kubectl create configmap app-config-dev --from-file=properties=/path/to/preferences/file1.txt --from-file=key1=/path/to/settings/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When cre... |
Copy a file from a remote pod to a local directory | Command:
```bash
kubectl cp default/security-scanner-pod-18:/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 th... |
Add a taint with the key 'hardware' and value 'storage-node-13' on nodes with the label 'instance=app-instance-1' | Command:
```bash
kubectl taint node -l instance=app-instance-1 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": ... |
Retrieve the previous terminated logs of the rocket-ranger container in the vpn-service-pod | Command:
```bash
kubectl logs -p -c rocket-ranger vpn-service-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container",... |
Create a pod disruption budget named payment-gateway-pdb | Command:
```bash
kubectl create poddisruptionbudget payment-gateway-pdb --selector=version=v2 --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-available=N... |
Retrieve the logs from the container backend-microservice-deployment-1 in the deployment named web-app-pod | Command:
```bash
kubectl logs deployment/backend-microservice-deployment -c web-app-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags... |
Add the taint with key 'datacenter' and value 'prod-node-5:PreferNoSchedule' on nodes having the label 'zone=us-east-1' | Command:
```bash
kubectl taint node -l zone=us-east-1 datacenter=prod-node-5: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 server field on the 'moon-cluster' cluster to use HTTPS with the address '1.2.3.4' | Command:
```bash
kubectl config set clusters.moon-cluster.server https://1.2.3.4
```
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 w... |
Create a cluster role named "custom_role" with ResourceName specified as "app-worker-1" for the "configmaps" resource | Command:
```bash
kubectl create clusterrole custom_role --verb=patch --resource=configmaps --resource-name=app-worker-1 --resource-name=app-worker-1
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|... |
Run the command 'pip --version' in the 'warp-drive' container of the 'e-commerce-pod' pod | Command:
```bash
kubectl exec e-commerce-pod -c warp-drive -- pip --version
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted... |
Delete the pods and services with the names "foo" and "chat-app" | Command:
```bash
kubectl delete pod,service foo 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 selector.
So... |
Create a single ingress called 'public-ingress' that directs requests to foo.com/bar to the service named 'svc1' with the port '3306' | Command:
```bash
kubectl create ingress public-ingress --rule="foo.com/bar=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": "", "usage": "... |
Forward traffic from port 8088 on all addresses to port 9090 in the web-app-pod pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/web-app-pod 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 ... |
Import the 'SMTP_SERVER' key from the 'env-vars' config map and set it as an environment variable for the 'load-balancer-deployment' deployment. | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/env-vars deployment/load-balancer-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... |
Add a taint with the key "hardware" and value "dev-node-4:PreferNoSchedule" on nodes that have the label "service=auth". | Command:
```bash
kubectl taint node -l service=auth hardware=dev-node-4:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Ou... |
Copy the kube config file from local machine to a specific container in a remote pod | Command:
```bash
kubectl cp ~/.config/kube auth-service-pod-11:/tmp/bar -c web-app-container
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omit... |
Execute the 'ruby --version' command in the warp-drive container of the email-service-pod pod | Command:
```bash
kubectl exec email-service-pod -c warp-drive -- ruby --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... |
Update the annotation 'env' to 'staging' for the 'api' pod, overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods api env='staging'
```
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 arbitrar... |
Run the 'go run hello.go' command inside the vpn-service-pod pod, using the first container | Command:
```bash
kubectl exec vpn-service-pod -- go run hello.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 k... |
Forward local port 3000 to port 8888 in the pod | Command:
```bash
kubectl port-forward pod/proxy-server-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 a... |
Create a new secret named encryption-key-secret in the default namespace with key1=supersecret and key2=topsecret | Command:
```bash
kubectl create secret generic encryption-key-secret --from-literal=key1=supersecret --from-literal=key2=topsecret
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, t... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/global-config 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... |
Forward port 8888 on your local machine to port 3000 in the 'analytics-pod' pod. | Command:
```bash
kubectl port-forward pod/analytics-pod 8888:3000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected auto... |
Set a custom TLS server name for the "on-prem-cluster" cluster entry. | Command:
```bash
kubectl config set-cluster on-prem-cluster --tls-server-name=data-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... |
Add a taint to a specific node in order to prevent pods from being scheduled on it. | Command:
```bash
kubectl taint nodes testing-node-11 zone: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: ... |
Check if you have permission to list the "security-scan-job" job in the "development" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/security-scan-job -n development
```
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 ... |
Copy the `~/.config/kube` file from the `istio-system/auth-service-pod-11` pod to the `/tmp/bar_dir` directory locally | Command:
```bash
kubectl cp istio-system/auth-service-pod-11:~/.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,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.