prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Set the annotation 'git-repo' with the value 'https://github.com/example/my-app' for the pod 'log-aggregator' | Command:
```bash
kubectl annotate pods log-aggregator 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 th... |
List deployments in YAML output format for a specific version and API group | Command:
```bash
kubectl get deployments.feature-branch-2.3.0.api-v1 -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 namespace... |
Update the 'prod-cluster' cluster entry by setting the 'server' field to 'https://1.2.3.4'. | Command:
```bash
kubectl config set-cluster prod-cluster --server=https://1.2.3.4
```
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] [--certificate-autho... |
Set the cluster field in the prod-context context to kube-cluster-1. | Command:
```bash
kubectl config set contexts.prod-context.cluster kube-cluster-1
```
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... |
Import the 'config_file_path' key from the 'api-config' config map and set it as an environment variable in the 'gateway-deployment' deployment. | Command:
```bash
kubectl set env --keys=config_file_path --from=configmap/api-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 definition... |
Forward traffic from port 8080 on localhost and IP 10.19.21.23 to port 8000 in the pod named "mypod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/mypod 8080: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 p... |
Create an ingress that routes requests from foo.com/bar to a service, and use a TLS secret for encryption. | Command:
```bash
kubectl create ingress app-gateway-ingress --rule="foo.com/bar=svc1:9091,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
Create a job named "log-processing-job" with the Ubuntu image, and run the command "docker run -d ubuntu sleep 3600" | Command:
```bash
kubectl create job log-processing-job --image=ubuntu -- docker run -d ubuntu sleep 3600
```
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": ""... |
Add a taint with the key 'hardware' and value 'kube-master-9:PreferNoSchedule' on nodes with the label 'role=database' | Command:
```bash
kubectl taint node -l role=database hardware=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 the local file "/tmp/foo_dir" to the remote pod "cert-manager/image-resizer-pod-20" in the "/tmp/bar" directory in the specified namespace. | Command:
```bash
kubectl cp /tmp/foo_dir cert-manager/image-resizer-pod-20::/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... |
Copy the local file "/tmp/foo" to the remote pod named "auth-service-pod-11" in the "monitoring" namespace, and place it in the "/tmp/bar" directory. | Command:
```bash
kubectl cp /tmp/foo monitoring/auth-service-pod-11:/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... |
Import the 'log_level' key from the 'kube-system-config' config map and set it as an environment variable in the 'payment-processor-deployment' deployment. | Command:
```bash
kubectl set env --keys=log_level --from=configmap/kube-system-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... |
Create an ingress that directs requests to a specific service and uses TLS encryption. | Command:
```bash
kubectl create ingress app-loadbalancer-ingress --rule="website.com/bar=svc1:6379,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": ... |
Create an ingress resource called 'default-ingress' with a rule that directs requests from 'site.com/input' to the service 'svc1' on port 9092 | Command:
```bash
kubectl create ingress default-ingress --rule="site.com/input=svc1:9092,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage... |
Forward traffic from port 3000 on all addresses to port 8080 on the backend-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/backend-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 ... |
Create an ingress called 'website-ingress' that sends requests to website.com/module to service svc1 on port 8888, and configure TLS encryption using the secret "my-cert" | Command:
```bash
kubectl create ingress website-ingress --rule="website.com/module=svc1:8888,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... |
Expose replica set hazelcast with port 8089 and target port 801000 | Command:
```bash
kubectl expose rs hazelcast --port=8089 --target-port=801000
```
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 po... |
Retrieve the output from running the command 'gem --version' inside the stardust-shuttle container of the payment-gateway-pod. | Command:
```bash
kubectl exec payment-gateway-pod -c stardust-shuttle -- gem --version
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name.... |
List deployments in the "custom-deployments" API group with the version "v3.0.0" and output it in JSON format. | Command:
```bash
kubectl get deployments.v3.0.0.custom-deployments -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 ... |
Create an ingress called 'app-gateway-ingress' that directs requests to 'foo.com/module' to service 'svc1:8088' with a TLS secret named 'my-cert'. | Command:
```bash
kubectl create ingress app-gateway-ingress --rule="foo.com/module=svc1:8088,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... |
Set the exec auth plugin environment variables for the "web-app" entry by running the command `kubectl config set-credentials web-app --exec-env=key1=val1 --exec-env=key2=val2` | Command:
```bash
kubectl config set-credentials web-app --exec-env=key1=val1 --exec-env=key2=val2
```
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
Beare... |
Forward local ports to a pod | Command:
```bash
kubectl port-forward pod/e-commerce-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 aut... |
Forward local port 8080 to port 5432 in the 'backend-pod' pod and listen on ports 8080 and 6000 locally, forwarding data to/from ports 5432 and 6000 in the pod. | Command:
```bash
kubectl port-forward pod/backend-pod 8080 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... |
Create a service for the python replica set, which serves on port 6379 and connects to the containers on target port 500100 | Command:
```bash
kubectl expose rs python --port=6379 --target-port=500100
```
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.... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/api-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 defin... |
Add a taint to nodes with the label 'tier=frontend' with the key 'zone' and value 'k8s-node-1:PreferNoSchedule' | Command:
```bash
kubectl taint node -l tier=frontend zone=k8s-node-1:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Outpu... |
Set the label 'component=api' for the pod 'database' | Command:
```bash
kubectl label pods database component=api
```
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":... |
Retrieve the output from running the 'gem --version' command in the 'nebula-navigator' container of the 'mypod' pod. | Command:
```bash
kubectl exec mypod -c nebula-navigator -- gem --version
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, u... |
Create a Pod Disruption Budget (PDB) named 'load-balancer-pdb' that selects all pods with the label 'app=nginx' and requires at least 50% of the selected pods to be available at any point in time. | Command:
```bash
kubectl create pdb load-balancer-pdb --selector=app=nginx --min-available=50%
```
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 [--dry-run=serve... |
Create a role named "foo" with "patch" permissions on the "pods" resource, specifically for the "queue-consumer" and "web-frontend" resources. | Command:
```bash
kubectl create role foo --verb=patch --resource=pods --resource-name=queue-consumer --resource-name=web-frontend
```
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... |
Roll back the daemonset named "prod" to revision 5. | Command:
```bash
kubectl rollout undo daemonset/prod --to-revision=5
```
What it does:
Roll back to a previous rollout.
Syntax:
`kubectl rollout undo (TYPE NAME | TYPE/NAME) [flags]`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to files identifying the re... |
Create a new config map named app-config-dev using specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-config-dev --from-file=conf=/path/to/options/file1.txt --from-file=data=/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 a ... |
Output the modified deployment in YAML format without making any changes to the object on the server | Command:
```bash
kubectl set env deployment/cache-cluster-deployment DB_USER=username -o yaml
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more pod ... |
Update the pod 'log-aggregator' with the annotation 'security-scan-status' and set the value as 'pass'. | Command:
```bash
kubectl annotate pods log-aggregator 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 inclu... |
Create a service for the replicated WordPress application, which serves on port 8088 and connects to the containers on port 909000. | Command:
```bash
kubectl expose rc wordpress --port=8088 --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 specified po... |
Forward traffic from port 8000 to port 3000 in the specified pod, allowing connections from all addresses. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/cdn-service-pod 8000: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 w... |
Display only the last 5 lines of logs from the frontend-pod | Command:
```bash
kubectl logs --tail=5 frontend-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"... |
Update the 'database-deployment' deployment by adding a new environment variable 'GOOGLE_API_KEY' with the value 'your-google-api-key' | Command:
```bash
kubectl set env deployment/database-deployment GOOGLE_API_KEY=your-google-api-key
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more... |
Create a new NodePort service named "e-commerce-nodeport" with port mapping from 9091 to 27017. | Command:
```bash
kubectl create service nodeport e-commerce-nodeport --tcp=9091:27017
```
What it does:
Create a NodePort service with the specified name.
Syntax:
`kubectl create service nodeport NAME [--tcp=port:targetPort] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "default":... |
List the resources of different types by their names | Command:
```bash
kubectl get rc/web service/media-stream-rc pods/cdn-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 names... |
Create an ingress named 'app1-ingress' with a rule that directs requests to 'site.com/input' to 'svc1:9090' and uses the TLS secret 'my-cert' | Command:
```bash
kubectl create ingress app1-ingress --rule="site.com/input=svc1:9090,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": ... |
Update the cluster field of the my-context context to kube-cluster-2. | Command:
```bash
kubectl config set contexts.client-1-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 y... |
Create a copy of the e-commerce-pod, changing all container images to "mongo" | Command:
```bash
kubectl debug e-commerce-pod --copy-to=my-custom-dbg --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 reso... |
Create a cron job called "metrics-collection" using the alpine image, scheduled to run every minute | Command:
```bash
kubectl create cronjob metrics-collection --image=alpine --schedule="*/1 * * * *" -- apk add curl
```
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... |
Copy the local file '/tmp/foo_dir' to '/tmp/bar_dir' inside the 'image-resizer-pod-20' pod, specifically in the 'file-server' container. | Command:
```bash
kubectl cp /tmp/foo_dir image-resizer-pod-20:/tmp/bar_dir -c file-server
```
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... |
Set the cpu limits of the 'mysql' deployment's nginx container to "500m" and memory limits to "256Mi" | Command:
```bash
kubectl set resources deployment mysql -c=nginx --limits=cpu=500m,memory=256Mi
```
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... |
Create an ingress called 'api-v1-ingress' that directs requests from testing.com/input to service 'svc1' on port 8888, using the TLS secret 'my-cert' | Command:
```bash
kubectl create ingress api-v1-ingress --rule="testing.com/input=svc1:8888,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usa... |
Forward traffic from local port 8000 to port 8080 within the pod named "web-app-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/web-app-pod 8000:8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will ... |
run the 'nginx' command in the first container of the api-service service | Command:
```bash
kubectl exec svc/api-service -- nginx
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.kub... |
Forward local ports 5000 and 6000 to the pod selected by the deployment 'email-server-deployment' | Command:
```bash
kubectl port-forward deployment/email-server-deployment 5000 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... |
Update the label of the pod 'monitoring' with the value 'unhealthy', overwriting any existing label value. | Command:
```bash
kubectl label --overwrite pods monitoring status=unhealthy
```
What it does:
Update the labels on a resource.
Syntax:
`kubectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]`
Helpful flags:
"flag": "--all-namespaces", "short": "-A", "default": ... |
Create a copy of a pod with a debug container and modified container images | Command:
```bash
kubectl debug gateway-pod -it --copy-to=dgb-img --image=debian --set-image=app=app:debug,api=api:v2
```
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... |
Auto scale the "gateway" replication controller to maintain the number of pods between 1 and 3, with a target CPU utilization of 81%. | Command:
```bash
kubectl autoscale rc gateway --max=3 --cpu-percent=81
```
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... |
List specified resources by their type and names | Command:
```bash
kubectl get rc/web service/database-rc pods/proxy-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 namespa... |
Forward local ports 8888 and 6000 to the corresponding ports in the pod "proxy-server-pod" | Command:
```bash
kubectl port-forward pod/proxy-server-pod 8888 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... |
Listen on port 8088 on all addresses and forward the traffic to port 8888 in the pod named 'security-service-pod'. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/security-service-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 ... |
Check the rollout status of the daemonset "namespace-1" | Command:
```bash
kubectl rollout status daemonset/namespace-1
```
What it does:
Manage the rollout of a resource.
Valid resource types include:
Syntax:
`kubectl rollout SUBCOMMAND` |
Create a new LoadBalancer service named 'frontend-lb' and map the port 6379 to the port 9092 | Command:
```bash
kubectl create service loadbalancer frontend-lb --tcp=6379:9092
```
What it does:
Create a LoadBalancer service with the specified name.
Syntax:
`kubectl create service loadbalancer NAME [--tcp=port:targetPort] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "defaul... |
Forward local port 8000 to port 5000 in the specified pod | Command:
```bash
kubectl port-forward pod/cdn-service-pod 8000: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... |
import specific keys from a config map | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/ui-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 definition... |
Get output from running 'irb' command in lunar-launcher container of e-commerce-pod | Command:
```bash
kubectl exec e-commerce-pod -c lunar-launcher -- irb
```
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 ... |
Forward local port 8888 to port 8080 in the pod "log-aggregator-pod". | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 8888 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... |
Create a new ExternalName service named "external-monitoring-service" that points to the external domain "tutorial-ai.ai" | Command:
```bash
kubectl create service externalname external-monitoring-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 se... |
Import environment variables from a config map with a prefix
General idea: Import environment from a config map with a prefix | Command:
```bash
kubectl set env --from=configmap/global-config --prefix=MYSQL_ 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 definitio... |
Create an ingress resource named 'rontend-ingress' that directs requests to 'testing.com/bar' to the service 'svc1' on port '8443' with the TLS secret named "my-cert". | Command:
```bash
kubectl create ingress rontend-ingress --rule="testing.com/bar=svc1:8443,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": "", "usag... |
Attach to a running pod and get its output | Command:
```bash
kubectl attach vpn-service-pod
```
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, use the kubectl... |
Create a single ingress called 'private-ingress' that directs requests to testing.com/bar to svc1:9090 | Command:
```bash
kubectl create ingress private-ingress --rule="testing.com/bar=svc1:9090,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": "", "usag... |
Add a taint with key 'zone' on nodes having label cluster=my-cluster | Command:
```bash
kubectl taint node -l cluster=my-cluster zone=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": "O... |
Create an ingress resource called 'myapp-ingress' that directs requests from foo.com/module to the 'svc1' service on port 3000, using the 'my-cert' TLS secret. | Command:
```bash
kubectl create ingress myapp-ingress --rule="foo.com/module=svc1:3000,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 LoadBalancer service named web-app-lb that will map port 8443 on the LoadBalancer to port 7000 on the pods. | Command:
```bash
kubectl create service loadbalancer web-app-lb --tcp=8443:7000
```
What it does:
Create a LoadBalancer service with the specified name.
Syntax:
`kubectl create service loadbalancer NAME [--tcp=port:targetPort] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "default... |
Add a taint with the key 'cpu-type' on nodes that have the label 'role=database'. | Command:
```bash
kubectl taint node -l role=database cpu-type=node-2:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Outpu... |
List the specified resources by their types and names. | Command:
```bash
kubectl get rc/web service/payment-gateway-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 ... |
Add or update an annotation on the 'vpn' pod with the key 'contact-email' and the value 'support@example.com', replacing any existing value | Command:
```bash
kubectl annotate --overwrite pods vpn 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 label... |
Create a new LoadBalancer service with the name 'proxy-service-lb' that maps port 6379 to port 8088 | Command:
```bash
kubectl create service loadbalancer proxy-service-lb --tcp=6379:8088
```
What it does:
Create a LoadBalancer service with the specified name.
Syntax:
`kubectl create service loadbalancer NAME [--tcp=port:targetPort] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "d... |
Retrieve the logs from the container named auth-service-pod-1 in the backend-microservice-deployment deployment. | Command:
```bash
kubectl logs deployment/backend-microservice-deployment -c auth-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 ... |
Create a deployment named "registry" with the image "postgres" and execute the command "psql" inside the container | Command:
```bash
kubectl create deployment registry --image=postgres -- psql
```
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: j... |
Retrieve the logs of the previous terminated 'quantum-quark' container from the 'proxy-service-pod' pod. | Command:
```bash
kubectl logs -p -c quantum-quark proxy-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 new config map named global-config from the key=value pairs in a file | Command:
```bash
kubectl create configmap global-config --from-file=path/to/configurations
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a config map based on a file, the key will default to the b... |
Create a copy of the vpn-service-pod with all container images changed to mongo | Command:
```bash
kubectl debug vpn-service-pod --copy-to=debug-image-memcached --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 i... |
create a service for the replication controller specified in the "centos-controller.yaml" file, which serves on port 8083 and connects to the containers on port 844300 | Command:
```bash
kubectl expose -f centos-controller.yaml --port=8083 --target-port=844300
```
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 custom TLS server name for the "sun-cluster" cluster entry | Command:
```bash
kubectl config set-cluster sun-cluster --tls-server-name=sun-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] [--certificate-a... |
List the name of the container and the image of the backend-pod in custom columns | Command:
```bash
kubectl get pod backend-pod -o custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image
```
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 --sel... |
Switch to the raw terminal mode for the 'nano-bot' container in the 'e-commerce-pod' pod. | Command:
```bash
kubectl attach e-commerce-pod -c nano-bot -i -t
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted... |
Listen on port 8081 on your local machine and forward the traffic to port 9090 in the pod named 'chat-app-pod' | Command:
```bash
kubectl port-forward pod/chat-app-pod 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 autom... |
Copy the local file /tmp/foo to the remote pod openfaas/auth-service-pod-11 in the /tmp/bar directory. | Command:
```bash
kubectl cp /tmp/foo openfaas/auth-service-pod-11:/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... |
Update the deployment 'cache-cluster-deployment' by adding a new environment variable 'LOG_LEVEL' with the value 'info' | Command:
```bash
kubectl set env deployment/cache-cluster-deployment LOG_LEVEL=info
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more pod templates ... |
Set cpu and memory limits for a container in a deployment named "golang" | Command:
```bash
kubectl set resources deployment golang -c=nginx --limits=cpu=50m,memory=2Gi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to i... |
Add a taint with key 'dedicated' and value 'app-node-6:PreferNoSchedule' on nodes having label 'service=auth' | Command:
```bash
kubectl taint node -l service=auth dedicated=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... |
Create a new config map named monitoring-config using specified files | Command:
```bash
kubectl create configmap monitoring-config --from-file=settings=/path/to/options/file1.txt --from-file=key2=/path/to/parameters/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When crea... |
Copy the local file "/tmp/foo" to the remote pod "front-end-pod-12" in the "/etc/kubernetes" directory, specifically in the "task-processor" container | Command:
```bash
kubectl cp /tmp/foo front-end-pod-12:/etc/kubernetes -c task-processor
```
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, ... |
Retrieve the logs from container "monitoring-pod-1" in deployment "mydeployment" | Command:
```bash
kubectl logs deployment/mydeployment -c monitoring-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": "--con... |
Create a service for the replicated 'hazelcast' resource | Command:
```bash
kubectl expose rc hazelcast --port=5000 --target-port=818100
```
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 po... |
Import the 'log_level' key from the 'configmap/env-vars' into the 'proxy-service-deployment' deployment. | Command:
```bash
kubectl set env --keys=log_level --from=configmap/env-vars deployment/proxy-service-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions i... |
Taint nodes with the label "namespace=mynamespace" with the taint "dedicated=app-node-6:PreferNoSchedule" | Command:
```bash
kubectl taint node -l namespace=mynamespace dedicated=app-node-6:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "u... |
Open a raw terminal connection to the web-app-pod pod and attach it to the rocket-ranger container. | Command:
```bash
kubectl attach web-app-pod -c rocket-ranger -i -t
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitt... |
Check if you have permission to list the job named "cache-warming-job" in the "cert-manager" namespace. | Command:
```bash
kubectl auth can-i list jobs.batch/cache-warming-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 partial... |
Create a single ingress called 'api-ingress' that directs requests to foo.com/module to svc1:7000 with a tls secret "my-cert" | Command:
```bash
kubectl create ingress api-ingress --rule="foo.com/module=svc1:7000,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": "... |
Copy the file '/tmp/foo' from the 'ingress-controller-pod-8' pod in the 'default' namespace to the '/tmp/bar' directory locally. | Command:
```bash
kubectl cp default/ingress-controller-pod-8::/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... |
Execute the 'node' command in the 'warp-drive' container of the 'database-pod' pod | Command:
```bash
kubectl exec database-pod -c warp-drive -- node
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the k... |
Set the custom TLS server name to 'on-prem-cluster' for the 'on-prem-cluster' cluster entry | Command:
```bash
kubectl config set-cluster on-prem-cluster --tls-server-name=on-prem-cluster
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-cluster NAME [--server=server] [--certi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.