prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Copy the ~/.config/kube file to /tmp/bar directory in the remote pod named database-pod-2 in the default namespace. | Command:
```bash
kubectl cp ~/.config/kube default/database-pod-2:/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... |
Add a new environment variable 'SMTP_USERNAME' with the value 'your-username' to the 'order-processing-deployment' deployment | Command:
```bash
kubectl set env deployment/order-processing-deployment SMTP_USERNAME=your-username
```
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 mor... |
Update pod 'chat-app' with a label 'status=unhealthy' only if the pod's resource version is unchanged from version 1 | Command:
```bash
kubectl label pods chat-app status=unhealthy --resource-version=1
```
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", "def... |
Delete both the "payment" pod and "payment" service, as well as the "analytics" pod and "analytics" service. | Command:
```bash
kubectl delete pod,service payment 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... |
Create a copy of the 'email-service-pod' with a debug container and different container images | Command:
```bash
kubectl debug email-service-pod -it --copy-to=dgb-img --image=debian --set-image=logger=logging-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 resour... |
Create a job called 'deployment-rollout-job' with the image 'php' | Command:
```bash
kubectl create job deployment-rollout-job --image=php --
```
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 ... |
Remove the "var-to-remove" environment variable for the "api-user" entry in the exec auth plugin configuration. | Command:
```bash
kubectl config set-credentials api-user --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 flags:
... |
Copy the contents of /var/run/secrets/kubernetes.io/serviceaccount/ from the auth-service-pod-11 pod in the kube-system namespace to the /tmp/bar directory on your local machine. | Command:
```bash
kubectl cp kube-system/auth-service-pod-11:/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": "... |
Expose the container port 8082 as port 443 for the service "node" and name it "nginx-https" | Command:
```bash
kubectl expose service node --port=443 --target-port=8082 --name=nginx-https
```
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 ... |
Create an ingress called 'www-ingress' with a rule that directs requests to site.com/module to svc1:8083 | Command:
```bash
kubectl create ingress www-ingress --rule="site.com/module=svc1:8083,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": ... |
Add a taint with key 'workload' and value 'web-node-8:PreferNoSchedule' on nodes having the label 'version=v1.0.0' | Command:
```bash
kubectl taint node -l version=v1.0.0 workload=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": "... |
Import specific keys from a config map into a deployment's environment variables | Command:
```bash
kubectl set env --keys=log_level --from=configmap/env-vars 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 one or mor... |
Delete the pods and services with the names "payment" and "proxy" | Command:
```bash
kubectl delete pod,service payment proxy
```
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.
S... |
Add the annotation 'security-scan-status=pass' to the pod 'media-stream' | Command:
```bash
kubectl annotate pods media-stream security-scan-status=pass
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include... |
Run the 'geth' command in the quantum-quark container of the gateway-pod pod and get the output | Command:
```bash
kubectl exec gateway-pod -c quantum-quark -- geth
```
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... |
Update the image of all containers in the 'services' daemonset to 'mongo:5.0.2' | Command:
```bash
kubectl set image daemonset services *=mongo:5.0.2
```
What it does:
Update existing container image(s) of resources.
Possible resources include (case insensitive):
pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), statefulset (sts), cronjob (cj), replicaset (rs)
Syntax:
`kub... |
Create a copy of the 'database-pod' and change all container images to 'mcr.microsoft.com/dotnet/core/runtime' | Command:
```bash
kubectl debug database-pod --copy-to=my-custom-dbg --set-image=*=mcr.microsoft.com/dotnet/core/runtime
```
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... |
Return snapshot logs from all containers in the 'frontend-pod' pod | Command:
```bash
kubectl logs frontend-pod --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": "--container", ... |
Set the resource request and limits for all containers in the amazonlinux deployment. | Command:
```bash
kubectl set resources deployment amazonlinux --limits=cpu=200m,memory=512Mi --requests=cpu=100m,memory=1Gi
```
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 re... |
Create a new ExternalName service with the name "external-notification-service" that maps to the external name "tutorial-ai.ai" | Command:
```bash
kubectl create service externalname external-notification-service --external-name tutorial-ai.ai
```
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 ... |
Delete pods and services with the names "analytics" and "frontend" | Command:
```bash
kubectl delete pod,service analytics frontend
```
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 select... |
Forward local port 9090 to pod port 8888 in the deployment "email-server-deployment" | Command:
```bash
kubectl port-forward deployment/email-server-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 will... |
Create a service for a replication controller identified by type and name specified in "php-controller.yaml" | Command:
```bash
kubectl expose -f php-controller.yaml --port=8084 --target-port=808900
```
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 sp... |
Forward local traffic on port 3000 to port 5000 in the pod named "api-service-pod" | Command:
```bash
kubectl port-forward pod/api-service-pod 3000: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 au... |
Forward port 6379 on your local machine to port 8081 in the analytics-pod pod | Command:
```bash
kubectl port-forward pod/analytics-pod 6379: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... |
Update the pod named 'api' with the annotation 'release-notes' and the value 'https://example.com/release-notes/v2.5.1' | Command:
```bash
kubectl annotate --overwrite pods api release-notes='https://example.com/release-notes/v2.5.1'
```
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... |
Set up autoscaling for the deployment "media-stream", with a minimum of 4 pods and a maximum of 11 pods | Command:
```bash
kubectl autoscale deployment media-stream --min=4 --max=11
```
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... |
Create a new ExternalName service named "external-analytics-service" pointing to the external domain "demo-service.dev". | Command:
```bash
kubectl create service externalname external-analytics-service --external-name demo-service.dev
```
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 s... |
Update the 'auth' pod with the annotation 'git-repo' and the value 'https://github.com/example/my-app', overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods auth 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 ... |
Forward port 8000 of the pod named "web-app-pod" to port 8888 on all addresses | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/web-app-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 will ... |
Start streaming the logs of the "cyber-sleuth" container in the "mypod" pod. | Command:
```bash
kubectl logs -f -c cyber-sleuth mypod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "short": "... |
Create a service for the python deployment, which serves on port 8443 and connects to the containers on port 808900. | Command:
```bash
kubectl expose deployment python --port=8443 --target-port=808900
```
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... |
Import the `api_key` key from the `app-config-prod` config map to the `cache-cluster-deployment` deployment | Command:
```bash
kubectl set env --keys=api_key --from=configmap/app-config-prod deployment/cache-cluster-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... |
Listen on port 3000 locally and forward data to/from port 5432 in the 'web-app-pod' pod. | Command:
```bash
kubectl port-forward pod/web-app-pod 3000 5432
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automa... |
Listen on port 8080 locally and forward data to/from port 8088 in the frontend-pod. | Command:
```bash
kubectl port-forward pod/frontend-pod 8080 8088
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected autom... |
Forward local port 8081 to port 8888 in the pod called proxy-server-pod | Command:
```bash
kubectl port-forward pod/proxy-server-pod 8081: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... |
Retrieve the logs from the container named security-service-pod-1 in the log-aggregator-deployment deployment | Command:
```bash
kubectl logs deployment/log-aggregator-deployment -c security-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 fl... |
List the deployments in JSON output format using the "v1.1.1" version of the "extensions" API group. | Command:
```bash
kubectl get deployments.v1.1.1.extensions -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... |
Create a new ClusterIP service named billing-service-clusterip with port mapping from port 5000 to port 8081 | Command:
```bash
kubectl create service clusterip billing-service-clusterip --tcp=5000:8081
```
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"... |
Set the custom TLS server name to "prod-cluster" for the "galaxy-cluster" cluster entry. | Command:
```bash
kubectl config set-cluster galaxy-cluster --tls-server-name=prod-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... |
Edit the job 'certificates-renewal-job' in the v1 API format using JSON. | Command:
```bash
kubectl edit job.v1.batch/certificates-renewal-job -o json
```
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 va... |
import specific keys from a config map for a deployment | Command:
```bash
kubectl set env --keys=DEBUG_MODE --from=configmap/env-vars deployment/order-processing-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitio... |
Forward all traffic to port 6379 on all addresses to port 5000 in the 'analytics-pod' pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/analytics-pod 6379: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 wil... |
Create a new config map named app-secrets and associate it with two files, properties and key1 | Command:
```bash
kubectl create configmap app-secrets --from-file=properties=/path/to/options/file1.txt --from-file=key1=/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 con... |
Create a pod using the centos image and expose port 5432 | Command:
```bash
kubectl run hazelcast --image=centos --port=5432
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--f... |
Get the output from running the 'redis-server --version' command on the first pod of the 'cache-service' service. | Command:
```bash
kubectl exec svc/cache-service -- redis-server --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, ... |
Create a new ClusterIP service named monitoring-service-clusterip that maps the port 8443 to the port 27017 | Command:
```bash
kubectl create service clusterip monitoring-service-clusterip --tcp=8443:27017
```
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": ... |
Forward local port 8088 to port 8888 in the pod named log-aggregator-pod | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 8088: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... |
Remove the 'description' annotation from the 'cdn' pod. | Command:
```bash
kubectl annotate pods cdn description-
```
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 arbitrary string valu... |
Create a service for the replication controller identified by the type and name specified in "centos-controller.yaml" | Command:
```bash
kubectl expose -f centos-controller.yaml --port=9092 --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... |
Set the service account of the deployment "scheduler-app-deployment" to "tiller" | Command:
```bash
kubectl set serviceaccount deployment scheduler-app-deployment tiller
```
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:
`kubec... |
Embed the certificate authority data for the 'star-cluster' cluster entry by running the command 'kubectl config set-cluster star-cluster --embed-certs --certificate-authority=~/.kube/data-cluster/kubernetes.ca.crt' | Command:
```bash
kubectl config set-cluster star-cluster --embed-certs --certificate-authority=~/.kube/data-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... |
Create a cluster role named "foo" with specified resource names | Command:
```bash
kubectl create clusterrole foo --verb=watch --resource=services --resource-name=app-worker-1 --resource-name=backup-service
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|client|n... |
Create a new pod using the python image and set the labels "app=python" and "env=prod" | Command:
```bash
kubectl run hazelcast --image=python --labels="app=python,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...]`
Helpful ... |
Forward local port 8081 to port 5000 in the log-aggregator-pod pod | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 8081:5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected... |
Import the 'REDIS_HOST' key from the 'app-config-dev' ConfigMap into the environment variables of the 'log-aggregator-deployment' Deployment. | Command:
```bash
kubectl set env --keys=REDIS_HOST --from=configmap/app-config-dev 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 defin... |
Create a service named "php" that serves on port 8010 and connects to the containers on port 808400. | Command:
```bash
kubectl expose deployment php --port=8010 --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 specified ... |
Remove the annotation named 'description' from the pod 'media-stream' | Command:
```bash
kubectl annotate pods media-stream description-
```
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 arbitrary st... |
import specific keys from a config map for a deployment | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/app-secrets deployment/web-app-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in ... |
Import the key `smtp_server` from the `env-vars` config map and set it as environment variable in 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... |
Create a copy of the cdn-service-pod with all container images changed to mongo | Command:
```bash
kubectl debug cdn-service-pod --copy-to=debug-image-1 --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 res... |
Check if you have permission to list the job named "queue-processing-job" in the "cert-manager" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/queue-processing-job -n cert-manager
```
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 part... |
Run the 'yum install -y wget' command in the code-explorer container of the proxy-service-pod and retrieve the output. | Command:
```bash
kubectl exec proxy-service-pod -c code-explorer -- yum install -y wget
```
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... |
Import the 'smtp_server' key from the 'ui-config' config map and set it as an environment variable in the 'mydeployment' deployment. | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/ui-config deployment/mydeployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or ... |
Remove a taint with the given key and effect from a specific node. | Command:
```bash
kubectl taint nodes storage-node-13 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 ... |
Import specific keys from a config map into a deployment: | Command:
```bash
kubectl set env --keys=CONFIG_FILE_PATH --from=configmap/db-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 defini... |
Import specific keys from a config map for a deployment: | Command:
```bash
kubectl set env --keys=debug_mode --from=configmap/db-config 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 definitions... |
Check if the current user has permission to list the job named "certificates-renewal-job" in the "development" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/certificates-renewal-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 p... |
Create an ingress called 'website-ingress' that directs requests to website.com/example to the service 'svc1' on port 8083, and use the TLS secret 'my-cert'. | Command:
```bash
kubectl create ingress website-ingress --rule="website.com/example=svc1:8083,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": "", "... |
Update the pod named 'monitoring' with the annotation 'git-repo' and set its value to 'https://github.com/example/my-app', overwriting any existing value. | Command:
```bash
kubectl annotate --overwrite pods monitoring 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 l... |
Create a role named "reader" with permissions to patch pods and specifically target the "web-frontend" and "app-worker-2" resources. | Command:
```bash
kubectl create role reader --verb=patch --resource=pods --resource-name=web-frontend --resource-name=app-worker-2
```
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|clie... |
Set the resource request and limits for all containers in a deployment called "runtime" | Command:
```bash
kubectl set resources deployment runtime --limits=cpu=200m,memory=512Mi --requests=cpu=1,memory=4Gi
```
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... |
Add a taint with the key 'datacenter' and value 'testing-node-11:PreferNoSchedule' on nodes that have the label 'team=devops' | Command:
```bash
kubectl taint node -l team=devops datacenter=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": "", "usage... |
Expose the replica set "php" as a service using port 9091, with the target port set to 808800. | Command:
```bash
kubectl expose rs php --port=9091 --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 ... |
import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=log_level --from=configmap/ui-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 definiti... |
Copy the file ~/.config/kube from a remote pod named velero/task-processor-pod-17 to the local directory /tmp/bar | Command:
```bash
kubectl cp velero/task-processor-pod-17:~/.config/kube /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... |
delete all pods and services with the label namespace=mynamespace | Command:
```bash
kubectl delete pods,services -l namespace=mynamespace
```
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 labe... |
Import the specific key "database_url" from the config map "app-secrets" into the deployment "authentication-service-deployment". | Command:
```bash
kubectl set env --keys=database_url --from=configmap/app-secrets 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 variabl... |
Forward local port 8000 to port 8888 in the pod "proxy-server-pod" | Command:
```bash
kubectl port-forward pod/proxy-server-pod 8000: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... |
Add a taint with the key 'special' on nodes having the label 'instance=app-instance-1' using the command 'kubectl taint node -l instance=app-instance-1 special=edge-node-10:PreferNoSchedule' | Command:
```bash
kubectl taint node -l instance=app-instance-1 special=edge-node-10:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", ... |
Copy the local directory "/tmp/foo_dir_dir" to the remote pod "metrics-exporter-pod-10" in the "/tmp/bar_dir" directory in the default namespace. | Command:
```bash
kubectl cp /tmp/foo_dir_dir metrics-exporter-pod-10:/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... |
Forward port 3000 on all addresses to port 8000 in the frontend-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/frontend-pod 3000: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... |
Create a deployment named 'jenkins' using the 'postgres' image and expose port 9091 | Command:
```bash
kubectl create deployment jenkins --image=postgres --port=9091
```
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... |
Taint nodes with the label "role=database" with the taint "cpu-type=storage-node-13:PreferNoSchedule" | Command:
```bash
kubectl taint node -l role=database cpu-type=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... |
Check if the current user has permission to list the job named "batch-processing-job" in the "monitoring" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/batch-processing-job -n monitoring
```
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... |
List deployments in the "hotfix-1.1.2" version of the "prod-apps" API group in JSON output format. | Command:
```bash
kubectl get deployments.hotfix-1.1.2.prod-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... |
View the resource utilization metrics for all pods in a specific namespace. | Command:
```bash
kubectl top pod --namespace=external-database-service
```
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:
`kube... |
Add a taint on nodes matching a label | Command:
```bash
kubectl taint node -l namespace=mynamespace environment=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": "", ... |
Set the custom TLS server name to "kube-cluster-2" for validation for the "edge-cluster" cluster entry | Command:
```bash
kubectl config set-cluster edge-cluster --tls-server-name=kube-cluster-2
```
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... |
Set the resource limits of the ruby container within the deployment named 'ruby' to "200m" for CPU and "1Gi" for memory | Command:
```bash
kubectl set resources deployment ruby -c=nginx --limits=cpu=200m,memory=1Gi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to it... |
Copy a file from a remote pod to your local machine | Command:
```bash
kubectl cp kube-server/front-end-pod-12::/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 kub... |
Create a service for the replication controller specified in "ruby-controller.yaml", serving on port 8082 and connecting to containers on port 909000 | Command:
```bash
kubectl expose -f ruby-controller.yaml --port=8082 --target-port=909000
```
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... |
List all deployments in the "custom-version" version of the "legacy-apps" API group and output them in YAML format | Command:
```bash
kubectl get deployments.custom-version.legacy-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... |
Forward local port 8888 to port 6379 in the 'cdn-service-pod' pod | Command:
```bash
kubectl port-forward pod/cdn-service-pod 8888:6379
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected au... |
Import environment variables from a secret into a deployment. | Command:
```bash
kubectl set env --from=secret/ssh-key-secret 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 definitions in one or m... |
Import environment variables from the 'monitoring-config' config map and with the prefix 'MYSQL_' into the 'log-aggregator-deployment' deployment | Command:
```bash
kubectl set env --from=configmap/monitoring-config --prefix=MYSQL_ 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 defi... |
Add a taint with key 'app' and no value to the 'prod-node-5' node. | Command:
```bash
kubectl taint nodes prod-node-5 app: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: json|... |
Import the 'smtp_server' key from the 'app-name-config' config map into the 'frontend-deployment' deployment. | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/app-name-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 definitio... |
Create a pod named 'hazelcast' with the 'mongo' image and expose port 8081 | Command:
```bash
kubectl run hazelcast --image=mongo --port=8081
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--fi... |
Create a role named "bar" with specific resource names | Command:
```bash
kubectl create role bar --verb=patch --resource=pods --resource-name=machine-learning --resource-name=prod-api-gateway
```
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.