prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Create a pod using a JSON file passed through stdin | Command:
```bash
cat params.json | kubectl create -f -
```
What it does:
Create a resource from a file or from stdin.
JSON and YAML formats are accepted.
Syntax:
`kubectl create -f FILENAME`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to files to use to ... |
Copy the file /tmp/foo from the ingress-controller-pod-8 pod in the metallb-system namespace to the /tmp/bar_dir directory locally. | Command:
```bash
kubectl cp metallb-system/ingress-controller-pod-8:/tmp/foo /tmp/bar_dir
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted... |
Update the last-applied-configuration of a resource using the contents of the 'config.yaml' file. | Command:
```bash
kubectl apply set-last-applied -f config.yaml
```
What it does:
Set the latest last-applied-configuration annotations by setting it to match the contents of a file. This results in the last-applied-configuration being updated as though 'kubectl apply -f ' was run, without updating any other parts of t... |
Import the "max_connections" key from the "ui-config" config map into the "mydeployment" deployment. | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/ui-config deployment/mydeployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one... |
Create a new config map named "app-name-config" with the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-name-config --from-file=properties=/path/to/configurations/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... |
Create an ingress with TLS enabled, using the default ingress certificate and different path types | Command:
```bash
kubectl create ingress ingtls --class=default \
--rule="foo.com/=svc:https,tls" \
--rule="testing.com/path/subpath*=othersvc:5432"
```
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": "-... |
Copy a file from a remote pod to a local directory | Command:
```bash
kubectl cp velero/security-scanner-pod-18::/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 k... |
Create an ingress that directs requests to a specific URL path to a service with a specified TLS secret | Command:
```bash
kubectl create ingress rontend-ingress --rule="site.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": "", "usag... |
Add a taint with the key 'datacenter' and value 'monitoring-node-15:PreferNoSchedule' on nodes that have the label 'stack=tech-stack'. | Command:
```bash
kubectl taint node -l stack=tech-stack datacenter=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 'rontend-ingress' with a rule that directs requests from website.com/input to svc1:8000, and use the tls secret "my-cert". | Command:
```bash
kubectl create ingress rontend-ingress --rule="website.com/input=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": "", "us... |
Copy the file '/tmp/foo' from the 'openfaas/auth-service-pod-11' pod to the local location '/tmp/bar'. | Command:
```bash
kubectl cp openfaas/auth-service-pod-11:/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 kube... |
Embed the certificate authority data for the 'dev-cluster' cluster entry using the command 'kubectl config set-cluster dev-cluster --embed-certs --certificate-authority=~/.kube/app-cluster/kubernetes.ca.crt' | Command:
```bash
kubectl config set-cluster dev-cluster --embed-certs --certificate-authority=~/.kube/app-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-c... |
import log_level key from config map monitoring-config into proxy-service-deployment deployment | Command:
```bash
kubectl set env --keys=log_level --from=configmap/monitoring-config 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 defi... |
Forward local ports 6379 and 6000 to the corresponding ports on the pod | Command:
```bash
kubectl port-forward pod/proxy-server-pod 6379 6379
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected a... |
Copy the directory "/tmp/foo_dir" from the pod "backend-pod-13" to the local directory "/tmp/bar_dir" | Command:
```bash
kubectl cp ingress-nginx/backend-pod-13:/tmp/foo_dir /tmp/bar_dir
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use t... |
Create an ingress called 'frontend-ingress' that directs requests from testing.com/example to service svc1 on port 3306, using the TLS secret "my-cert". | Command:
```bash
kubectl create ingress rontend-ingress --rule="testing.com/example=svc1:3306,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "... |
Execute the 'docker run -d ubuntu sleep 3600' command inside the 'mycontainer' container in the 'proxy-service-pod' pod, and retrieve the output. | Command:
```bash
kubectl exec proxy-service-pod -c mycontainer -- docker run -d ubuntu sleep 3600
```
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": "Cont... |
Create a php pod named 'nginx' using the 'php' image, but override the specification with a partial set of values parsed from the provided JSON. | Command:
```bash
kubectl run nginx --image=php --overrides='{ "apiVersion": "v1.1.1", "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] -- [COMMAND] ... |
Set the annotation 'monitoring-tool' to 'Prometheus' for the pod named 'gateway' | Command:
```bash
kubectl annotate pods gateway monitoring-tool=Prometheus
```
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 arb... |
Create a pod disruption budget named monitoring-pdb that will select all pods with the region=us-east label and require a minimum of 9 of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget monitoring-pdb --selector=region=us-east --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 ... |
Run the 'ash' command inside the 'database-pod' pod and get the output | Command:
```bash
kubectl exec database-pod -- ash
```
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.kubernet... |
Copy the file '/tmp/foo' from the remote pod 'load-balancer-pod-9' in the 'monitoring' namespace to the local directory '/tmp/bar' | Command:
```bash
kubectl cp monitoring/load-balancer-pod-9:/tmp/foo :/tmp/bar
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the ku... |
Delete both the pods and services with the names "web" and "backend" | Command:
```bash
kubectl delete pod,service web backend
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label selector.
Som... |
Set the cpu limits of the alpine container in the deployment named 'alpine' to 10 and the memory limits to 4Gi. | Command:
```bash
kubectl set resources deployment alpine -c=nginx --limits=cpu=10,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 it... |
Create a new config map named env-vars with specified keys instead of file basenames on disk. | Command:
```bash
kubectl create configmap env-vars --from-file=settings=/path/to/configurations/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 creat... |
Retrieve the output from running the 'mysql' command within the pod named 'monitoring-pod', specifically in the 'lunar-launcher' container. | Command:
```bash
kubectl exec monitoring-pod -c lunar-launcher -- mysql
```
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, us... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/app-secrets 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 definitio... |
Set a custom TLS server name for validation of the dev-cluster cluster entry. | Command:
```bash
kubectl config set-cluster dev-cluster --tls-server-name=app-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... |
Replace a pod using the JSON configuration provided in the 'setup.json' file. | Command:
```bash
cat setup.json | kubectl replace -f -
```
What it does:
Replace a resource by file name or stdin.
JSON and YAML formats are accepted. If replacing an existing resource, the complete resource spec must be provided. This can be obtained by
$ kubectl get TYPE NAME -o yaml
Syntax:
`kubectl replace -f FIL... |
Set the CPU limit of the go container in the nginx deployment to "500m" and the memory limit to "512Mi". | Command:
```bash
kubectl set resources deployment go -c=nginx --limits=cpu=500m,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 it... |
Create a pod named 'hazelcast' using the 'ubuntu' image, and have the container within the pod expose port 8081. | Command:
```bash
kubectl run hazelcast --image=ubuntu --port=8081
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--f... |
Forward local port 5000 to port 6379 in a pod selected by the log-aggregator-deployment deployment. | Command:
```bash
kubectl port-forward deployment/log-aggregator-deployment 5000 6379
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod wi... |
Set the custom TLS server name to "on-prem-cluster" for the cluster entry named "cluster-alpha" in the kubeconfig file. | Command:
```bash
kubectl config set-cluster cluster-alpha --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] [--certifi... |
Set a custom TLS server name for the web-cluster cluster entry | Command:
```bash
kubectl config set-cluster web-cluster --tls-server-name=galaxy-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] [--certificat... |
View detailed information about pods with a label "stack" set to "tech-stack". | Command:
```bash
kubectl describe po -l stack=tech-stack
```
What it does:
Show details of a specific resource or group of resources.
Print a detailed description of the selected resources, including related resources such as events or controllers. You may select a single object by name, all objects of that type, prov... |
Copy the local file ~/.config/kube to the remote pod argocd/task-processor-pod-17 in the namespace, and place it in the /etc/kubernetes directory of the pod. | Command:
```bash
kubectl cp ~/.config/kube argocd/task-processor-pod-17:/etc/kubernetes
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, ... |
create a pod disruption budget named "critical-services-pdb" that selects pods with the label "tier=frontend" and requires a minimum of four of them to be available at any given time. | Command:
```bash
kubectl create poddisruptionbudget critical-services-pdb --selector=tier=frontend --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-availa... |
Import specific keys from a config map into the environment variables of a deployment | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/app-settings deployment/scheduler-app-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definiti... |
Create a deployment named 'monitoring' using the 'amazonlinux' image and exposing port 9092. | Command:
```bash
kubectl create deployment monitoring --image=amazonlinux --port=9092
```
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. ... |
Display the most recent 31 lines of logs for the pod named "media-stream-pod" | Command:
```bash
kubectl logs --tail=31 media-stream-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":... |
Create a new ClusterIP service named ldap-service-clusterip, listening on port 8443 and forwarding traffic to port 8010 | Command:
```bash
kubectl create service clusterip ldap-service-clusterip --tcp=8443:8010
```
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", "... |
Copy the "~/.config/kube" file to the "/tmp/bar_dir" directory in the remote pod named "argocd/load-balancer-pod-9" in the specified namespace. | Command:
```bash
kubectl cp ~/.config/kube argocd/load-balancer-pod-9:/tmp/bar_dir
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use t... |
Create a service for a replication controller, serving on port 8081 and connecting to containers on port 801000 | Command:
```bash
kubectl expose -f ruby-controller.yaml --port=8081 --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 s... |
Listen on port 8081 on localhost and selected IP (10.19.21.23), forwarding to port 9090 in the pod "security-service-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/security-service-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 th... |
Retrieve the previous terminated logs of the "warp-drive" container from the "security-service-pod" pod. | Command:
```bash
kubectl logs -p -c warp-drive security-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 deployment named worker using the python image and expose port 9091 | Command:
```bash
kubectl create deployment worker --image=python --port=9091
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: j... |
create a job called 'batch-processing' using the 'wordpress' image and run the command 'mysql --version' | Command:
```bash
kubectl create job batch-processing --image=wordpress -- mysql --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": "Out... |
Remove the taint with key 'disktype' from the node 'prod-node-5' | Command:
```bash
kubectl taint nodes prod-node-5 disktype-
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json|yaml|... |
Execute the 'geth attach' command inside the media-stream-pod pod, using the first container by default, and display the output. | Command:
```bash
kubectl exec media-stream-pod -- 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 omitted, use the kube... |
Set a custom TLS server name for the "data-cluster" cluster entry. | Command:
```bash
kubectl config set-cluster data-cluster --tls-server-name=cluster-gamma
```
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] [--certificat... |
Create a new config map named app-config-dev in the current namespace, using specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-config-dev --from-file=settings=/path/to/profiles/file1.txt --from-file=key2=/path/to/data/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a c... |
Update the pod identified by the type and name specified in the "options.json" file by adding the annotation "custom-label" with the value "my-custom-value" | Command:
```bash
kubectl annotate -f options.json custom-label=my-custom-value
```
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 includ... |
Create a service for the replication controller specified in "python-controller.yaml" file | Command:
```bash
kubectl expose -f python-controller.yaml --port=8080 --target-port=808200
```
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... |
Update the 'monitoring' pod by setting the annotation 'backup-strategy' to 'daily backups'. | Command:
```bash
kubectl annotate pods monitoring backup-strategy='daily backups'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and inc... |
Attach to the nebula-navigator container in the gateway-pod pod and get the output. | Command:
```bash
kubectl attach gateway-pod -c nebula-navigator
```
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,... |
Create a new NodePort service named 'ingress-controller-nodeport' that exposes port 8084 on all nodes and forwards traffic to port 5000. | Command:
```bash
kubectl create service nodeport ingress-controller-nodeport --tcp=8084:5000
```
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", "de... |
Create a job named 'audit-job' using the 'alpine' image, and run the 'sleep 3600' command in the job. | Command:
```bash
kubectl create job audit-job --image=alpine -- 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": "", "usage": "Output format. One... |
Create a cluster role named "default_role" with the ability to patch services and specific resource names | Command:
```bash
kubectl create clusterrole default_role --verb=patch --resource=services --resource-name=blog-backend --resource-name=billing-service
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=serve... |
Set the resource request and limits for the mysql deployment | Command:
```bash
kubectl set resources deployment mysql --limits=cpu=200m,memory=512Mi --requests=cpu=10,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 requested... |
Autoscale the deployment "frontend" with the number of pods between 7 and 15 | Command:
```bash
kubectl autoscale deployment frontend --min=7 --max=15
```
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 use... |
Rename the context 'on-prem-context' to 'app-2-context' in your kubeconfig file | Command:
```bash
kubectl config rename-context on-prem-context app-2-context
```
What it does:
Renames a context from the kubeconfig file.
CONTEXT_NAME is the context name that you want to change.
NEW_NAME is the new name you want to set.
Note: If the context being renamed is the 'current-context', this field will als... |
Create a deployment named "web" running the "php" image with 5 replicas. | Command:
```bash
kubectl create deployment web --image=php --replicas=5
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json|y... |
Update the 'proxy' pod by adding an annotation 'scaling-policy' with the value 'auto-horizontal-scaling' | Command:
```bash
kubectl annotate pods proxy scaling-policy=auto-horizontal-scaling
```
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 i... |
Delete the pods and services named "auth" and "gateway" | Command:
```bash
kubectl delete pod,service auth gateway
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label selector.
So... |
Create a cron job named "weekly-summary" with a CentOS image and a schedule of running every minute | Command:
```bash
kubectl create cronjob weekly-summary --image=centos --schedule="*/1 * * * *" -- bash
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "de... |
Retrieve the output from running the 'postgres' command in the 'lunar-launcher' container within the 'cdn-service-pod' pod. | Command:
```bash
kubectl exec cdn-service-pod -c lunar-launcher -- postgres
```
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 copy of the web-app-pod and start a debug session | Command:
```bash
kubectl debug web-app-pod -it --copy-to=debug-image-app --container=code-explorer -- 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 used by def... |
Delete the pods and services with the names "foo" and "log-aggregator" | Command:
```bash
kubectl delete pod,service foo log-aggregator
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label select... |
Edit the deployment named 'mydeployment' in YAML format, save any modifications made to the deployment's configuration in its annotation. | Command:
```bash
kubectl edit deployment/mydeployment -o yaml --save-config
```
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... |
Create a debug copy of the analytics-pod by adding a debug container and changing container images | Command:
```bash
kubectl debug analytics-pod -it --copy-to=debug-image-1 --image=debian --set-image=logger=logging-app:debug,mailer=mailer:latest
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by re... |
import the specific key "my-example-key" from the global-config config map and set it as an environment variable for the mydeployment deployment | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/global-config deployment/mydeployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in ... |
Forward local port 8888 to port 8080 in the cdn-service-pod pod | Command:
```bash
kubectl port-forward pod/cdn-service-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 au... |
Create a job for data migration with a specific command | Command:
```bash
kubectl create job data-migration-job --image=confluentinc/cp-kafka -- kafka-server-start /etc/kafka/server.properties
```
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... |
Return the previous terminated logs of the "nebula-navigator" container from the "payment-gateway-pod" pod | Command:
```bash
kubectl logs -p -c nebula-navigator payment-gateway-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": "--cont... |
Create a cluster role named "bar" with the following permissions: | Command:
```bash
kubectl create clusterrole bar --verb=get --resource=configmaps --resource-name=file-storage --resource-name=web-frontend
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|client|non... |
Get the output from running the 'node' command in the 'stardust-shuttle' container of the 'frontend-pod' pod. | Command:
```bash
kubectl exec frontend-pod -c stardust-shuttle -- 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... |
set the CPU and memory resource limits to 200m and 512Mi respectively, and set the CPU and memory resource requests to 500m and 64Mi respectively, for all containers in the go deployment. | Command:
```bash
kubectl set resources deployment go --limits=cpu=200m,memory=512Mi --requests=cpu=500m,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 requested,... |
Import the secret_key from the config map db-config and set it as an environment variable in the payment-processor-deployment deployment. | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/db-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 definit... |
Create an ingress named 'public-api-ingress' that routes requests from 'site.com/example' to 'svc1:8084' using the tls secret 'my-cert' | Command:
```bash
kubectl create ingress public-api-ingress --rule="site.com/example=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": "", "... |
Create a new ClusterIP service named 'order-service-clusterip' that maps port 9000 on the cluster to port 8083 on the pods | Command:
```bash
kubectl create service clusterip order-service-clusterip --tcp=9000:8083
```
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", ... |
Copy a file from a remote pod to your local machine | Command:
```bash
kubectl cp istio-system/image-resizer-pod-20:/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... |
Display the most recent 20 lines of logs from the log-aggregator-pod. | Command:
```bash
kubectl logs --tail=20 log-aggregator-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... |
Rename a context in your kubeconfig file | Command:
```bash
kubectl config rename-context on-prem-context new-context
```
What it does:
Renames a context from the kubeconfig file.
CONTEXT_NAME is the context name that you want to change.
NEW_NAME is the new name you want to set.
Note: If the context being renamed is the 'current-context', this field will also ... |
Add a taint with the key 'datacenter' and the value 'app-node-6:PreferNoSchedule' on the nodes that have the label 'app-type=microservice' | Command:
```bash
kubectl taint node -l app-type=microservice datacenter=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": "", "... |
Create a service for the replicated 'php' controller, which serves on port 3000 and connects to the containers on port 9090. | Command:
```bash
kubectl expose rc php --port=3000 --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 port. A ... |
Create a new LoadBalancer service named 'backend-lb' that forwards traffic from port 8081 on the external IP to port 8081 on the backend, using the command 'kubectl create service loadbalancer backend-lb --tcp=8081:8081' | Command:
```bash
kubectl create service loadbalancer backend-lb --tcp=8081: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", "default... |
Create an ingress called 'private-api-ingress' that directs requests to foo.com/module and uses the service named svc1 with port 8081 | Command:
```bash
kubectl create ingress private-api-ingress --rule="foo.com/module=svc1:8081,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... |
Import specific keys from a config map to an environment variable in a deployment | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/log-config deployment/backend-microservice-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable def... |
Add a taint with key 'special' on nodes having label role=database | Command:
```bash
kubectl taint node -l role=database special=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": "Ou... |
Create a pod disruption budget named 'worker-pdb' that will select all pods with the 'version=v2' label and require a minimum of four of them to be available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget worker-pdb --selector=version=v2 --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 [--dry-r... |
Verify if the user has permission to list the job named "queue-processing-job" in the "staging" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/queue-processing-job -n staging
```
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 U... |
Forward port 9090 on all addresses to port 8081 in the pod named security-service-pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/security-service-pod 9090: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 ... |
Set the service account of the deployment "monitoring-stack-deployment" to "jenkins" | Command:
```bash
kubectl set serviceaccount deployment monitoring-stack-deployment jenkins
```
What it does:
Update the service account of pod template resources.
Possible resources (case insensitive) can be:
replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset
Syntax:
`k... |
Forward the local port 5432 to port 8081 in the analytics-pod pod | Command:
```bash
kubectl port-forward pod/analytics-pod 5432:8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected auto... |
Retrieve the logs from the container 'vpn-service-pod-1' of the 'order-processing-deployment' deployment. | Command:
```bash
kubectl logs deployment/order-processing-deployment -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... |
Create a Pod Disruption Budget named 'load-balancer-pdb' that selects all pods with the 'region=us-east' label and requires a minimum of four of them to be available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget load-balancer-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... |
Create a new config map named app-config-prod with the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-config-prod --from-file=settings=/path/to/configurations/file1.txt --from-file=key2=/path/to/data/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creat... |
Forward traffic from port 8000 on all addresses to port 8888 in the pod named "chat-app-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/chat-app-pod 8000:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will... |
Listen on port 8000 locally and forward it to the target port of the "https" service port in a pod selected by the "order-service" service | Command:
```bash
kubectl port-forward service/order-service 8000: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 selected... |
Assign the label 'role=backend' to the pod named 'web' | Command:
```bash
kubectl label pods web role=backend
```
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 t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.