prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Execute the 'mongod' command in the 'code-explorer' container of the 'log-aggregator-pod' pod and get the output. | Command:
```bash
kubectl exec log-aggregator-pod -c code-explorer -- mongod
```
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... |
Forward traffic from port 8081 on your local machine to port 5432 in the frontend-pod, and also forward traffic from port 6000 on your local machine to port 6000 in the frontend-pod. | Command:
```bash
kubectl port-forward pod/frontend-pod 8081 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 autom... |
Forward local ports 8088 and 6000 to ports 8080 and 6000 respectively in the e-commerce-pod pod | Command:
```bash
kubectl port-forward pod/e-commerce-pod 8088 8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected aut... |
Remove the label 'tier' from the pod 'chat-app' | Command:
```bash
kubectl label pods chat-app tier-
```
What it does:
Update the labels on a resource.
Syntax:
`kubectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]`
Helpful flags:
"flag": "--all-namespaces", "short": "-A", "default": "false", "usage": "If tru... |
Create a new config map named ui-config with the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap ui-config --from-file=properties=/path/to/configurations/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 cre... |
Set cpu and memory limits for a deployment's php container | Command:
```bash
kubectl set resources deployment php -c=nginx --limits=cpu=50m,memory=128Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to it... |
Create a new config map named 'app-settings' with the contents of the specified files | Command:
```bash
kubectl create configmap app-settings --from-file=settings=/path/to/configs/file1.txt --from-file=key2=/path/to/preferences/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating... |
Create a pod disruption budget named auth-service-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 auth-service-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 [--... |
Import the 'redis_host' key from the 'log-config' config map into the 'gateway-deployment' deployment. | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/log-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 o... |
Import environment variables from a secret into a deployment | Command:
```bash
kubectl set env --from=secret/ssh-key-secret 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 definitions in one or more ... |
Create a debug copy of the e-commerce-pod, adding a debian based container with the app container changed to the debug version and the scheduler container changed to version 1.0 of my-scheduler, name the new pod debug-image-1 | Command:
```bash
kubectl debug e-commerce-pod -it --copy-to=debug-image-1 --image=debian --set-image=app=app:debug,scheduler=my-scheduler:1.0
```
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 new LoadBalancer service named ingress-controller-lb | Command:
```bash
kubectl create service loadbalancer ingress-controller-lb --tcp=9092:8083
```
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... |
Display the most recent 20 lines of logs for the pod named 'cdn-service-pod' | Command:
```bash
kubectl logs --tail=20 cdn-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", "short": ... |
Add a taint with key 'datacenter' and no value to the node 'app-node-6' | Command:
```bash
kubectl taint nodes app-node-6 datacenter: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:... |
Embed the certificate authority data for the "testing-cluster" cluster entry. | Command:
```bash
kubectl config set-cluster testing-cluster --embed-certs --certificate-authority=~/.kube/e2e/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-clust... |
Retrieve the logs from the container 'cdn-service-pod-1' in the deployment 'notification-handler-deployment' | Command:
```bash
kubectl logs deployment/notification-handler-deployment -c cdn-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 f... |
Remove the label named 'bar' from pod 'frontend' | Command:
```bash
kubectl label pods frontend app-
```
What it does:
Update the labels on a resource.
Syntax:
`kubectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]`
Helpful flags:
"flag": "--all-namespaces", "short": "-A", "default": "false", "usage": "If true... |
List deployments in YAML output format, using the "legacy-1.0.0" version of the "api-v1" API group. | Command:
```bash
kubectl get deployments.legacy-1.0.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 namespaced you wi... |
Add a taint with the key 'environment' on nodes having the label environment=production | Command:
```bash
kubectl taint node -l environment=production environment=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": "... |
Create a new ClusterIP service called database-service-clusterip and expose port 8083 on the service to port 9092 on the target | Command:
```bash
kubectl create service clusterip database-service-clusterip --tcp=8083:9092
```
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... |
Remove an exec auth plugin environment variable for the "system" entry | Command:
```bash
kubectl config set-credentials system --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:
... |
Get the output from running the 'geth attach' command in the stardust-shuttle container of the proxy-service-pod pod. | Command:
```bash
kubectl exec proxy-service-pod -c stardust-shuttle -- geth attach
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If ... |
Copy the ~/.config/kube local file to the /etc/kubernetes directory in the monitoring/security-scanner-pod-18 pod in the default namespace. | Command:
```bash
kubectl cp ~/.config/kube monitoring/security-scanner-pod-18:/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 omi... |
Forward traffic from port 8000 on your local machine to port 5432 in the pod called "api-service-pod" | Command:
```bash
kubectl port-forward pod/api-service-pod 8000: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 au... |
Forward the traffic from port 8081 on localhost and IP 10.19.21.23 to port 8088 in the 'frontend-pod' pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/frontend-pod 8081: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 criter... |
Auto scale the replication controller named "monitoring" with a maximum of 2 pods and a target CPU utilization of 20%. | Command:
```bash
kubectl autoscale rc monitoring --max=2 --cpu-percent=20
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that u... |
List all allowed actions in the "kube-ingress" namespace | Command:
```bash
kubectl auth can-i --list --namespace=kube-ingress
```
What it does:
Check whether an action is allowed.
VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is a partial URL that starts w... |
Set the service account of the deployment named 'log-aggregator-deployment' to 'kube-controller-manager' | Command:
```bash
kubectl set serviceaccount deployment log-aggregator-deployment kube-controller-manager
```
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), statefuls... |
Create a debug copy of e-commerce-pod by adding a debug container and changing container images. | Command:
```bash
kubectl debug e-commerce-pod -it --copy-to=debug-image-memcached --image=debian --set-image=proxy=nginx:1.21,web=nginx:latest
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resou... |
Import the specific key "LOG_LEVEL" from the "db-config" ConfigMap into the "analytics-platform-deployment" deployment. | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/db-config deployment/analytics-platform-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definit... |
Import the specified keys (secret_key) from the app-secrets config map into the deployment (mydeployment) | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/app-secrets 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... |
Start a python pod and customize its spec using a JSON override | Command:
```bash
kubectl run nginx --image=python --overrides='{ "apiVersion": "v1.1.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAN... |
View the logs of container "vpn-service-pod-1" from the deployment "mydeployment" | Command:
```bash
kubectl logs deployment/mydeployment -c vpn-service-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--co... |
create a service for the centos-controller replication controller by specifying a port number of 3001 for the service and a target port number of 909100 for the containers. | Command:
```bash
kubectl expose -f centos-controller.yaml --port=3001 --target-port=909100
```
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... |
Begin streaming the logs of the "astro-container" container in the "monitoring-pod" pod. | Command:
```bash
kubectl logs -f -c astro-container monitoring-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"... |
Access the pod named vpn-service-pod and execute the command 'geth version' in the rocket-ranger container to retrieve its output. | Command:
```bash
kubectl exec vpn-service-pod -c rocket-ranger -- geth 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 omit... |
Create a new config map named 'api-config' using the specified keys and file paths (/path/to/settings/file1.txt and /path/to/configs/file2.txt) | Command:
```bash
kubectl create configmap api-config --from-file=settings=/path/to/settings/file1.txt --from-file=key2=/path/to/configs/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a co... |
Create a single ingress called 'private-service-ingress' that directs requests to website.com/input to svc # svc1:6379 with a tls secret named "my-cert" | Command:
```bash
kubectl create ingress private-service-ingress --rule="website.com/input=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":... |
Forward traffic from port 3000 on localhost and IP 10.19.21.23 to port 5000 in the pod named log-aggregator-pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/log-aggregator-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 ... |
Forward local port 9090 to port 5000 in the pod named "mypod" | Command:
```bash
kubectl port-forward pod/mypod 9090: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 automaticall... |
Get the specified resources by their type and names | Command:
```bash
kubectl get rc/web service/vpn-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 n... |
Create a job named "report-generation-job" using the "php" image, and run the command "composer --version" inside the job container. | Command:
```bash
kubectl create job report-generation-job --image=php -- composer --version
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "O... |
Enable the Google Compute Platform auth provider for the "dev-user" entry by executing the "kubectl config set-credentials dev-user --auth-provider=gcp" command. | Command:
```bash
kubectl config set-credentials dev-user --auth-provider=gcp
```
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:
--to... |
Create a role named "reader" with specific resource names. | Command:
```bash
kubectl create role reader --verb=proxy --resource=pods --resource-name=monitoring-prometheus --resource-name=queue-consumer
```
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=... |
Open the 'backend-service' service for editing using the 'vi' editor. | Command:
```bash
KUBE_EDITOR="vi" kubectl edit svc/backend-service
```
What it does:
Edit a resource from the default editor.
The edit command allows you to directly edit any API resource you can retrieve via the command-line tools. It will open the editor defined by your KUBE_EDITOR, or EDITOR environment variables, ... |
Create a job named "database-seeding-job" using the Alpine image, and run the "ash" command inside the job. | Command:
```bash
kubectl create job database-seeding-job --image=alpine -- ash
```
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.... |
Import the specific keys from a config map to a deployment's environment variables. | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/app-settings 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... |
List deployments in YAML format for the "legacy-1.0.0" version of the "mobile-apps" API group | Command:
```bash
kubectl get deployments.legacy-1.0.0.mobile-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 y... |
create a job named backup, using the elasticsearch image from docker.elastic.co/elasticsearch/elasticsearch, with the command "elasticsearch --version" | Command:
```bash
kubectl create job backup --image=docker.elastic.co/elasticsearch/elasticsearch -- elasticsearch --version
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": ... |
Create a new ExternalName service named external-logging-service, with the external name as "illustration-shop.shop" | Command:
```bash
kubectl create service externalname external-logging-service --external-name illustration-shop.shop
```
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 referen... |
Add a taint with the key 'datacenter' and value 'backup-node-14:PreferNoSchedule' on the nodes that have the label 'zone=us-east-1' | Command:
```bash
kubectl taint node -l zone=us-east-1 datacenter=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": "", "usa... |
Import environment from the docker-registry-secret secret to the load-balancer-deployment deployment | Command:
```bash
kubectl set env --from=secret/docker-registry-secret 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 in one ... |
Forward local port 6379 to port 8080 in the pod named 'chat-app-pod' | Command:
```bash
kubectl port-forward pod/chat-app-pod 6379:8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected autom... |
Delete the pods and services with the names "chat-app" and "security". | Command:
```bash
kubectl delete pod,service chat-app security
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label selecto... |
Apply a taint on nodes with the team=devops label | Command:
```bash
kubectl taint node -l team=devops app=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": "Output fo... |
Execute the 'redis-server' command inside the pod named log-aggregator-pod and capture the output | Command:
```bash
kubectl exec log-aggregator-pod -- redis-server
```
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... |
Create a new ClusterIP service named cache-service-clusterip with a TCP port forwarding from port 8082 to port 3306. | Command:
```bash
kubectl create service clusterip cache-service-clusterip --tcp=8082:3306
```
What it does:
Create a ClusterIP service with the specified name.
Syntax:
`kubectl create service clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", ... |
list the replication controller named proxy-server-rc in the ps output format | Command:
```bash
kubectl get replicationcontroller proxy-server-rc
```
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 pod named "hazelcast" using the "node" image, and expose port 3306 | Command:
```bash
kubectl run hazelcast --image=node --port=3306
```
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": "--fil... |
Create a new LoadBalancer service named auth-service-lb with a port mapping of TCP 9000 to 8081 | Command:
```bash
kubectl create service loadbalancer auth-service-lb --tcp=9000:8081
```
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", "de... |
forward traffic from port 3000 on all addresses to port 3000 in the 'web-app-pod' pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/web-app-pod 3000: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 ... |
Set the CPU limits for the 'centos' deployment's 'nginx' container to "10" and the memory limits to "512Mi" | Command:
```bash
kubectl set resources deployment centos -c=nginx --limits=cpu=10,memory=512Mi
```
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 ... |
Add a taint with the key 'hardware' on nodes having the label feature=feature-xyz, and specify the node 'db-node-7' with the taint 'PreferNoSchedule'. | Command:
```bash
kubectl taint node -l feature=feature-xyz hardware=db-node-7:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage... |
Create a debug container in gateway-pod, using the Debian image and changing the container images to mysql:5.7 for the database container and nginx:1.21 for the proxy container. | Command:
```bash
kubectl debug gateway-pod -it --copy-to=dgb-img --image=debian --set-image=database=mysql:5.7,proxy=nginx:1.21
```
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. P... |
Expose a replicated centos pod as a service on port 5432, with communication to the pod containers on port 818100 | Command:
```bash
kubectl expose rc centos --port=5432 --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 port.... |
Return the logs of container cache-cluster-deployment-1 from the deployment named payment-gateway-pod | Command:
```bash
kubectl logs deployment/cache-cluster-deployment -c payment-gateway-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 flag... |
Return logs from container in a deployment | Command:
```bash
kubectl logs deployment/user-management-deployment -c log-aggregator-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful fla... |
Create an ingress to handle requests for a specific endpoint. | Command:
```bash
kubectl create ingress public-api-ingress --rule="website.com/example=svc1:9000,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": ""... |
Copy the local file /tmp/foo to the remote pod logging-agent-pod-7 in the /etc/kubernetes directory | Command:
```bash
kubectl cp /tmp/foo logging-agent-pod-7:/etc/kubernetes -c cache-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 omitt... |
Create a copy of the 'security-service-pod' pod, and launch an interactive shell in the 'time-machine' container | Command:
```bash
kubectl debug security-service-pod -it --copy-to=debug-image-api --container=time-machine -- sh
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be use... |
Import the DEBUG_MODE key from the config map "env-vars" and set it as an environment variable in the "payment-processor-deployment" deployment. | Command:
```bash
kubectl set env --keys=DEBUG_MODE --from=configmap/env-vars 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... |
Get the version of Elasticsearch running in the 'code-explorer' container of the pod 'web-app-pod' | Command:
```bash
kubectl exec web-app-pod -c code-explorer -- elasticsearch --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. ... |
Add the label 'app=myapp' to the pod 'proxy-server' | Command:
```bash
kubectl label pods proxy-server app=myapp
```
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":... |
undo the rollout of the daemonset named 'prod' and roll back to revision 3 | Command:
```bash
kubectl rollout undo daemonset/prod --to-revision=3
```
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 role named "admin_role" with permissions to patch pods with resource names "cache-redis" and "content-delivery". | Command:
```bash
kubectl create role admin_role --verb=patch --resource=pods --resource-name=cache-redis --resource-name=content-delivery
```
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=serv... |
List the replica controller "web", service "monitoring-rc", and pod "vpn-service-pod" | Command:
```bash
kubectl get rc/web service/monitoring-rc pods/vpn-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... |
Copy the file /tmp/foo from the remote pod named auth-service-pod-11 in the velero namespace to the local directory /tmp/bar. | Command:
```bash
kubectl exec -n velero auth-service-pod-11 -- tar cf - /tmp/foo | tar xf - -C /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 na... |
Set the CPU limit of the alpine container in the nginx deployment to "2" and the memory limit to "4Gi" | Command:
```bash
kubectl set resources deployment alpine -c=nginx --limits=cpu=2,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, but may burst up to its... |
Create a config map named app-secrets and include specified files with custom key names | Command:
```bash
kubectl create configmap app-secrets --from-file=properties=/path/to/preferences/file1.txt --from-file=key1=/path/to/configs/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creatin... |
Create a service for an nginx deployment, specifying the port on which the service listens and the port on which the containers are running | Command:
```bash
kubectl expose deployment nginx --port=9000 --target-port=700000
```
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 specifie... |
Forward traffic from port 5432 on localhost and IP 10.19.21.23 to port 6379 in the 'e-commerce-pod' pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/e-commerce-pod 5432: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 crit... |
Update the image of all containers in the daemonset named "namespace-2" to "httpd:2.4.48" | Command:
```bash
kubectl set image daemonset namespace-2 *=httpd:2.4.48
```
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:
... |
Import environment variables from a config map with a specific prefix for a deployment. | Command:
```bash
kubectl set env --from=configmap/log-config --prefix=MYSQL_ deployment/analytics-platform-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definit... |
Get the output from running the 'mongod' command in the 'cosmic-container' from the pod 'auth-service-pod' | Command:
```bash
kubectl exec auth-service-pod -c cosmic-container -- mongod
```
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 omitte... |
import the `api_key` key from the `log-config` ConfigMap and set it as an environment variable in the `gateway-deployment` Deployment. | Command:
```bash
kubectl set env --keys=api_key --from=configmap/log-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 traffic from port 8000 on your local machine to port 8080 in the proxy-server-pod pod | Command:
```bash
kubectl port-forward pod/proxy-server-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 be selected a... |
Execute an interactive shell command in the nano-bot container of the mypod pod. | Command:
```bash
kubectl exec mypod -c nano-bot -- 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 the kubectl.kub... |
List the replication controller 'web', service 'cdn-service-rc', and pod 'chat-app-pod' | Command:
```bash
kubectl get rc/web service/cdn-service-rc pods/chat-app-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 namespace... |
Forward local port 8000 to port 5432 in the api-service-pod pod | Command:
```bash
kubectl port-forward pod/api-service-pod 8000 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 au... |
Forward local port 6379 to port 8000 in the pod named api-service-pod | Command:
```bash
kubectl port-forward pod/api-service-pod 6379:8000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected au... |
Update the pod named 'frontend' by adding an annotation with the key 'owner' and the value 'alice smith' | Command:
```bash
kubectl annotate pods frontend owner='alice smith'
```
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... |
Create a debug copy of the gateway-pod and change all container images to docker.elastic.co/elasticsearch/elasticsearch | Command:
```bash
kubectl debug gateway-pod --copy-to=my-custom-dbg --set-image=*=docker.elastic.co/elasticsearch/elasticsearch
```
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. Po... |
Create a job named indexing using the ruby image, and run the gem --version command inside the job. | Command:
```bash
kubectl create job indexing --image=ruby -- gem --version
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One... |
Retrieve the deployment resources in the "v3.0.0" version of the "backup-apps" API group and display them in YAML format. | Command:
```bash
kubectl get deployments.v3.0.0.backup-apps -o yaml
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you wil... |
Taint nodes with label 'app-type=microservice' for workload kube-master-9 | Command:
```bash
kubectl taint node -l app-type=microservice workload=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": "", ... |
Set the cluster field in the 'cloud-context' context to 'kube-cluster-1' | Command:
```bash
kubectl config set contexts.cloud-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 ... |
Start a pod with the specified image and override the spec values using a JSON file. | Command:
```bash
kubectl run nginx --image=docker.elastic.co/elasticsearch/elasticsearch --overrides='{ "apiVersion": "beta-1.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--over... |
Execute the 'redis-server' command in the backend-pod container | Command:
```bash
kubectl exec backend-pod -- redis-server
```
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.... |
Get the output of the 'node --version' command in the cyber-sleuth container running in the pod proxy-service-pod. | Command:
```bash
kubectl exec proxy-service-pod -c cyber-sleuth -- node --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 o... |
Create a new secret named 'encryption-key-secret' using the values from the env file located at 'path/to/data.env' | Command:
```bash
kubectl create secret generic encryption-key-secret --from-env-file=path/to/data.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 the ba... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.