prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Set the resource request and limits for all containers in the centos deployment to cpu=100m and memory=4Gi respectively | Command:
```bash
kubectl set resources deployment centos --limits=cpu=200m,memory=512Mi --requests=cpu=100m,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 request... |
Forward local port 8081 to the targetPort of the "https" service port in the pod selected by the "gateway-service" service | Command:
```bash
kubectl port-forward service/gateway-service 8081:https
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be select... |
Return snapshot logs from container proxy-server-pod-1 of the deployment named proxy-service-deployment | Command:
```bash
kubectl logs deployment/proxy-service-deployment -c proxy-server-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:
... |
Set the server field of the 'data-cluster' cluster entry to 'https://1.2.3.4', without modifying any other values. | Command:
```bash
kubectl config set-cluster data-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... |
Create an ingress called 'web-ingress' with a rule that directs requests from site.com/module to svc1:5432 and use the tls secret "my-cert" | Command:
```bash
kubectl create ingress web-ingress --rule="site.com/module=svc1:5432,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": ... |
Set the resource request and limits for all containers in alpine to cpu=200m and memory=512Mi for limits, and cpu=200m and memory=64Mi for requests. | Command:
```bash
kubectl set resources deployment alpine --limits=cpu=200m,memory=512Mi --requests=cpu=200m,memory=64Mi
```
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 reques... |
Scale the 'dev-environment-rs' deployment to 3 replicas, considering that its current size is 5. | Command:
```bash
kubectl scale --current-replicas=5 --replicas=3 deployment/dev-environment-rs
```
What it does:
Set a new size for a deployment, replica set, replication controller, or stateful set.
Scale also allows users to specify one or more preconditions for the scale action.
If --current-replicas or --resource-... |
Display only the most recent 3 lines of logs from the mypod pod. | Command:
```bash
kubectl logs --tail=3 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": "-c", "defa... |
Create a deployment named 'wordpress' using the 'mcr.microsoft.com/dotnet/core/runtime' image, and expose port 8081 | Command:
```bash
kubectl create deployment wordpress --image=mcr.microsoft.com/dotnet/core/runtime --port=8081
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", ... |
Import the DATABASE_URL key from the 'api-config' config map into the 'payment-processor-deployment' deployment. | Command:
```bash
kubectl set env --keys=DATABASE_URL --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 defi... |
Set the service account of the "payment-processor-deployment" deployment to "cert-manager" | Command:
```bash
kubectl set serviceaccount deployment payment-processor-deployment cert-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), statefulset
Synt... |
Forward traffic from port 8000 on all addresses to port 8088 in the pod named "mypod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/mypod 8000:8088
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be sel... |
Create a cron job called "daily-report" with the image "mcr.microsoft.com/dotnet/core/runtime" running the command "dotnet" every minute. | Command:
```bash
kubectl create cronjob daily-report --image=mcr.microsoft.com/dotnet/core/runtime --schedule="*/1 * * * *" -- dotnet
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag":... |
Create an ingress named 'api-ingress' with a rule that directs requests for 'foo.com/module' to the service 'svc1' on port '8088', using the TLS secret 'my-cert' | Command:
```bash
kubectl create ingress api-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": "", "usage": "... |
Create a new secret named docker-registry-secret with keys for each file in a specified folder | Command:
```bash
kubectl create secret generic docker-registry-secret --from-file=path/to/configs
```
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 basena... |
Update the pod named 'security' with the annotation 'deployment-script' and set its value to 'https://example.com/deploy.sh'. | Command:
```bash
kubectl annotate pods security deployment-script='https://example.com/deploy.sh'
```
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 tha... |
Display the last 23 lines of logs for the pod named "frontend-pod". | Command:
```bash
kubectl logs --tail=23 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... |
Partially update a node's configuration by applying a strategic merge patch | Command:
```bash
kubectl patch -f node.json -p '{"spec":{"replicas":3}'
```
What it does:
Update fields of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.
JSON and YAML formats are accepted.
Syntax:
`kubectl patch (-f FILENAME | TYPE NAME) [-p PATCH|--patch-file FILE]`
Helpful flags:
"fl... |
Create a debug version of vpn-service-pod by adding a debug container and changing container images | Command:
```bash
kubectl debug vpn-service-pod -it --copy-to=debug-image-web --image=debian --set-image=worker=my-custom-worker:1.2.3,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 ... |
Embed the certificate authority data for the data-cluster cluster entry. | Command:
```bash
kubectl config set-cluster data-cluster --embed-certs --certificate-authority=~/.kube/sun-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 an ingress with multiple hosts and the pathType as Prefix. | Command:
```bash
kubectl create ingress ingress1 --class=default \
--rule="testing.com/path*=svc:8181" \
--rule="bar.com/admin*=svc2:http"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output",... |
Import environment variables from a secret to a deployment | Command:
```bash
kubectl set env --from=secret/api-key-secret deployment/frontend-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more pod t... |
Create a cron job named "database-maintenance" that runs the "mongod" command every minute using the "mongo" image. | Command:
```bash
kubectl create cronjob database-maintenance --image=mongo --schedule="*/1 * * * *" -- mongod
```
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": "-... |
Start a pod named nginx with the ubuntu image, but override the spec with a partial set of values parsed from the provided JSON | Command:
```bash
kubectl run nginx --image=ubuntu --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] [--overrides=inline-json] [--command] -- [COMM... |
import the MAX_CONNECTIONS key from the monitoring-config config map into the deployment/notification-handler-deployment deployment | Command:
```bash
kubectl set env --keys=MAX_CONNECTIONS --from=configmap/monitoring-config deployment/notification-handler-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment ... |
Set resource request and limits for all containers in Redis deployment. | Command:
```bash
kubectl set resources deployment redis --limits=cpu=200m,memory=512Mi --requests=cpu=100m,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 reques... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=DEBUG_MODE --from=configmap/app-config-dev 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 ... |
List deployments in the JSON output format, in the "beta-1.0" version of the "api-v2" API group. | Command:
```bash
kubectl get deployments.beta-1.0.api-v2 -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 o... |
Create a job named "report-generation-job" using the MySQL image and run the mysqld command. | Command:
```bash
kubectl create job report-generation-job --image=mysql -- mysqld
```
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 form... |
Import the "log_level" key from the "api-config" config map into the environment variables of the "notification-handler-deployment" deployment. | Command:
```bash
kubectl set env --keys=log_level --from=configmap/api-config deployment/notification-handler-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defi... |
Set custom TLS server name for cluster | Command:
```bash
kubectl config set-cluster star-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-... |
Check if you have permission to list the job named "deploy-artifacts-job" in the "production" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/deploy-artifacts-job -n production
```
What it does:
Check whether an action is allowed.
VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is a partia... |
Forward local port 8088 to port 8081 in the pod | Command:
```bash
kubectl port-forward pod/security-service-pod 8088:8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be select... |
Create a debug container by making a copy of the "payment-gateway-pod" with the container "nebula-navigator" | Command:
```bash
kubectl debug payment-gateway-pod -it --copy-to=my-custom-dbg --container=nebula-navigator -- 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 us... |
Execute the 'mongod' command inside the analytics-pod container and display the output. | Command:
```bash
kubectl exec analytics-pod -- 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, use the kubectl.kube... |
Forward port 5432 locally to port 5000 in the api-service-pod pod | Command:
```bash
kubectl port-forward pod/api-service-pod 5432: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... |
Set specific keys from a config map to the environment of a deployment | Command:
```bash
kubectl set env --keys=CONFIG_FILE_PATH --from=configmap/global-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 definit... |
Set custom TLS server name for a cluster in the kubeconfig file | Command:
```bash
kubectl config set-cluster testing-cluster --tls-server-name=cloud-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] [--certifi... |
Add a taint with key 'disktype' on nodes having the label role=database, with the taint value set to 'node-1' and scheduler preference set to 'PreferNoSchedule' | Command:
```bash
kubectl taint node -l role=database disktype=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... |
Display only the most recent 3 lines of output in pod database-pod | Command:
```bash
kubectl logs --tail=3 database-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "short": "-c"... |
Expose a replication controller (rc) named php on port 8010, which will connect to the containers on port 808000. | Command:
```bash
kubectl expose rc php --port=8010 --target-port=808000
```
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 ... |
Open the 'search-service' service for editing using the nano editor. | Command:
```bash
KUBE_EDITOR="nano" kubectl edit svc/search-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 new resource quota named object-quota with specified limits for ConfigMaps, Secrets, and PersistentVolumeClaims | Command:
```bash
kubectl create quota object-quota --hard=configmaps=5,secrets=10,persistentvolumeclaims=5
```
What it does:
Create a resource quota with the specified name, hard limits, and optional scopes.
Syntax:
`kubectl create quota NAME [--hard=key1=value1,key2=value2] [--scopes=Scope1,Scope2] [--dry-run=server... |
Update the 'frontend-deployment' deployment in the default namespace with a new environment variable named SMTP_HOST and set its value to smtp.example.com | Command:
```bash
kubectl set env deployment/frontend-deployment SMTP_HOST=smtp.example.com
```
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 tem... |
Forward local port 9090 to port 8088 in the pod named "cdn-service-pod" | Command:
```bash
kubectl port-forward pod/cdn-service-pod 9090:8088
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected au... |
Create a new python pod named nginx, using the python image, and override the spec with a partial set of values provided in the JSON object. | Command:
```bash
kubectl run nginx --image=python --overrides='{ "apiVersion": "stable-2.0.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] -- [... |
Edit the authentication-service service using the "code" editor. | Command:
```bash
KUBE_EDITOR="code" kubectl edit svc/authentication-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 va... |
Autoscale the deployment "email" with the number of pods between 4 and 13. Use the default autoscaling policy. | Command:
```bash
kubectl autoscale deployment email --min=4 --max=13
```
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 t... |
Import specific keys from a config map into a deployment's environment variables. | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/app-settings 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 defini... |
Add a taint with key 'hardware' on nodes having label release=beta | Command:
```bash
kubectl taint node -l release=beta hardware=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": "", "usage": "... |
Copy the `~/.config/kube` local file to `:/tmp/bar` in the `front-end-pod-12` pod's `image-resizer` container. | Command:
```bash
kubectl cp ~/.config/kube front-end-pod-12::/tmp/bar -c image-resizer
```
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, u... |
Create a new LoadBalancer service named analytics-lb that forwards traffic from port 5432 to port 5000 | Command:
```bash
kubectl create service loadbalancer analytics-lb --tcp=5432:5000
```
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", "defau... |
Retrieve the logs of container "gateway-deployment-1" from the deployment "e-commerce-pod" | Command:
```bash
kubectl logs deployment/gateway-deployment -c e-commerce-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": ... |
Create a pod named "hazelcast" using the "centos" image and configure the container to expose port 5000 | Command:
```bash
kubectl run hazelcast --image=centos --port=5000
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--f... |
Create a new ClusterIP service named 'order-service-clusterip' that maps port 8088 on the service to port 3306 on the pod | Command:
```bash
kubectl create service clusterip order-service-clusterip --tcp=8088: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", ... |
Import specific keys from a config map into a deployment's environment variables. | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/kube-system-config deployment/database-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... |
Create an ingress called 'public-api-ingress' that directs requests for site.com/example to svc1:8000 with the TLS secret "my-cert" | Command:
```bash
kubectl create ingress public-api-ingress --rule="site.com/example=svc1:8000,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 data between your local port 8080 and port 3000 in the pod selected by the deployment named 'mydeployment'. | Command:
```bash
kubectl port-forward deployment/mydeployment 8080 3000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selecte... |
Get the output from running the 'go run hello.go' command in the warp-drive container of the chat-app-pod pod | Command:
```bash
kubectl exec chat-app-pod -c warp-drive -- go run hello.go
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted... |
Create a secret named encryption-key-secret using a file and a literal value | Command:
```bash
kubectl create secret generic encryption-key-secret --from-file=ssh-privatekey=path/to/id_rsa --from-literal=passphrase=topsecret
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret ba... |
Start a pod named 'nginx' with the 'alpine' image, but modify the spec using values parsed from a partial JSON object. | Command:
```bash
kubectl run nginx --image=alpine --overrides='{ "apiVersion": "legacy-1.0.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] -- [... |
Create a cluster role named "default_role" with permissions to connect to non-resource URLs under the "/oapi/*" path. | Command:
```bash
kubectl create clusterrole "default_role" --verb=connect --non-resource-url=/oapi/*
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output"... |
Create a copy of the backend-pod with a debug container and change the container images. | Command:
```bash
kubectl debug backend-pod -it --copy-to=debug-image-app --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... |
Add a taint with the key 'environment' on nodes that have the label 'service=auth' | Command:
```bash
kubectl taint node -l service=auth environment=monitoring-node-15:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "... |
Create an ingress called 'default-ingress' with the following rules: | Command:
```bash
kubectl create ingress default-ingress --rule="testing.com/bar=svc1:8084,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
Create a service for a replicated alpine using a replica set, serving on port 8181 and connecting to the containers on port 543200 | Command:
```bash
kubectl expose rs alpine --port=8181 --target-port=543200
```
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.... |
Create a cluster role named "foo" with ResourceName specified | Command:
```bash
kubectl create clusterrole foo --verb=delete --resource=services --resource-name=report-generator --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|cli... |
Update the annotation of pod 'frontend' with the value 'pass', overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods frontend 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 a... |
View the metrics for a specific node | Command:
```bash
kubectl top node k8s-node-1
```
What it does:
Display resource (CPU/memory) usage of nodes.
The top-node command allows you to see the resource consumption of nodes.
Syntax:
`kubectl top node [NAME | -l label]`
Helpful flags:
"flag": "--selector", "short": "-l", "default": "", "usage": "Selector (la... |
create a secret named "api-key-secret" by combining a file (ssh-privatekey) with a literal value (passphrase) | Command:
```bash
kubectl create secret generic api-key-secret --from-file=ssh-privatekey=path/to/id_rsa --from-literal=passphrase=topsecret
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on ... |
Add a taint with key 'hardware' on nodes having label app-type=microservice | Command:
```bash
kubectl taint node -l app-type=microservice hardware=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"... |
Create a debug pod named my-debugger by making a copy of the vpn-service-pod and changing all the container images to ruby. | Command:
```bash
kubectl debug vpn-service-pod --copy-to=my-debugger --set-image=*=ruby
```
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 resour... |
List the contents of the /usr directory from the first container in the e-commerce-pod pod, sorting by modification time. | Command:
```bash
kubectl exec e-commerce-pod -i -t -- ls -t /usr
```
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 pod disruption budget named cron-jobs-pdb that will select all pods with the region=us-east label and require at least four of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget cron-jobs-pdb --selector=region=us-east --min-available=4
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N [... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=DEBUG_MODE --from=configmap/namespace-config deployment/web-app-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definition... |
Create a service for the replicated wordpress using replica set, which serves on port 8443 and connects to the containers on port 8000 | Command:
```bash
kubectl expose rs wordpress --port=8443 --target-port=800000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified po... |
Create a config map named "app-config-dev" by taking values from specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-config-dev --from-file=properties=/path/to/data/file1.txt --from-file=key1=/path/to/settings/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a... |
Update the annotation 'compliance-level' of the pod 'vpn' to have the value 'PCI-DSS'. | Command:
```bash
kubectl annotate pods vpn compliance-level=PCI-DSS
```
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... |
Forward traffic from port 8081 on localhost and IP 10.19.21.23 to port 5000 in the pod "api-service-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/api-service-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 cri... |
Copy the local file /tmp/foo_dir to the /etc/kubernetes directory inside the remote pod named front-end-pod-12, specifically in the container named web-app-container. | Command:
```bash
kubectl cp /tmp/foo_dir front-end-pod-12:/etc/kubernetes -c web-app-container
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If om... |
view logs of a pod written in the last hour | Command:
```bash
kubectl logs --since=1h 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":... |
Update the image of all containers in the daemonset 'staging' to 'ruby:3.0.2' | Command:
```bash
kubectl set image daemonset staging *=ruby:3.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:
`kubec... |
Execute the 'python' command within the pod proxy-server-pod and retrieve the output | Command:
```bash
kubectl exec proxy-server-pod -- python
```
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.k... |
Update the label of the pod named 'payment' to have the key 'status' and the value 'unhealthy', replacing any existing value. | Command:
```bash
kubectl label --overwrite pods payment 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": "fa... |
List deployments in JSON output format for the "feature-branch-2.3.0" version of the "experimental-apps" API group | Command:
```bash
kubectl get deployments.feature-branch-2.3.0.experimental-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 i... |
Set the cluster field in the local-context context to moon-cluster | Command:
```bash
kubectl config set contexts.local-context.cluster moon-cluster
```
What it does:
Set an individual value in a kubeconfig file.
PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.
PROPERTY_VALUE is the new value you wa... |
Create an ingress resource called 'private-service-ingress' with a rule that directs requests to 'website.com/module' to 'svc1:9090' | Command:
```bash
kubectl create ingress private-service-ingress --rule="website.com/module=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"... |
Create a new config map named app-config in the default namespace with the following file data: properties=/path/to/profiles/file1.txt and key1=/path/to/parameters/file2.txt | Command:
```bash
kubectl create configmap app-config --from-file=properties=/path/to/profiles/file1.txt --from-file=key1=/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 creating... |
Create a copy of the 'media-stream-pod' pod, adding a 'debug' container and changing the container images to 'debian' for the new 'debug' container, 'mysql:5.7' for the 'database' container, and 'nginx:latest' for the 'web' container. | Command:
```bash
kubectl debug media-stream-pod -it --copy-to=my-custom-dbg --image=debian --set-image=database=mysql:5.7,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 resource ... |
Get the output from running a 'bash' command in the first container of the 'order-processing-deployment' deployment | Command:
```bash
kubectl exec deploy/order-processing-deployment -- bash
```
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 named "frontend-pdb" for pods with the label "app=nginx", ensuring that at least 20% of these pods are available at all times. | Command:
```bash
kubectl create pdb frontend-pdb --selector=app=nginx --min-available=20%
```
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=server|cli... |
Create a role named "foo" with API Group specified | Command:
```bash
kubectl create role foo --verb=delete,update,proxy --resource=jobs.batch
```
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|client|none]`
Helpful flags:
"flag": "--outp... |
Update the label of the pod 'gateway' to have the key 'component' and the value 'worker' | Command:
```bash
kubectl label pods gateway component=worker
```
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... |
Add a taint with the key 'datacenter' on nodes that have the label 'region=eu-west-2'. | Command:
```bash
kubectl taint node -l region=eu-west-2 datacenter=prod-node-5:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
Forward port 8000 on localhost and IP 10.19.21.23 to port 6379 on the pod named "log-aggregator-pod". | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/log-aggregator-pod 8000: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 ... |
Create an ingress called 'public-ingress' that directs requests to foo.com/module to the service svc1 on port 5432 with the TLS certificate secret "my-cert" | Command:
```bash
kubectl create ingress public-ingress --rule="foo.com/module=svc1:5432,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage"... |
Create a new config map named `api-config` with the specified keys from the provided file paths | Command:
```bash
kubectl create configmap api-config --from-file=properties=/path/to/profiles/file1.txt --from-file=key1=/path/to/configs/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a ... |
Forward traffic from port 5432 on all addresses to port 8000 in the api-service-pod pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/api-service-pod 5432: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 w... |
Create a new config map named app-secrets in the current namespace using the specified file paths for the keys | Command:
```bash
kubectl create configmap app-secrets --from-file=conf=/path/to/configs/file1.txt --from-file=data=/path/to/settings/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a confi... |
Create a pod disruption budget named 'monitoring-pdb' that will select all pods with the 'role=worker' label and require a minimum of 9 of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget monitoring-pdb --selector=role=worker --min-available=9
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N [--... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.