prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Create a new config map named 'global-config' using the specified keys instead of the file basenames on disk | Command:
```bash
kubectl create configmap global-config --from-file=conf=/path/to/settings/file1.txt --from-file=data=/path/to/profiles/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... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/app-settings 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 definiti... |
Create a single ingress called app1-ingress that directs requests to testing.com/input to svc1:9090 with a tls secret "my-cert" | Command:
```bash
kubectl create ingress app1-ingress --rule="testing.com/input=svc1:9090,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage... |
Forward local port 9090 to port 8081 in the pod named "chat-app-pod" | Command:
```bash
kubectl port-forward pod/chat-app-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 pod will be selected autom... |
Add a taint with key 'environment' and value 'edge-node-10:PreferNoSchedule' on nodes having the label 'team=devops' | Command:
```bash
kubectl taint node -l team=devops 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": "", "usage":... |
Forward traffic from local port 5000 to port 8888 in the chat-app-pod | Command:
```bash
kubectl port-forward pod/chat-app-pod 5000:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected autom... |
Copy the '/var/run/secrets/kubernetes.io/serviceaccount/' file from the local machine to the '/etc/kubernetes' directory in the 'kube-dns/cache-pod-5' pod in the specified namespace. | Command:
```bash
kubectl cp /var/run/secrets/kubernetes.io/serviceaccount/ kube-dns/cache-pod-5:/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": "Cont... |
Create a job with the specified image and command | Command:
```bash
kubectl create job audit-job --image=docker.elastic.co/elasticsearch/elasticsearch -- elasticsearch
```
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", "... |
Create a deployment named ingress that runs the Redis image and exposes port 8089 | Command:
```bash
kubectl create deployment ingress --image=redis --port=8089
```
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... |
Add a taint to nodes with a specific label | Command:
```bash
kubectl taint node -l service=auth datacenter=dev-node-4:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "... |
Retrieve the snapshot logs from the container named api-service-pod-1 in the search-engine-deployment deployment. | Command:
```bash
kubectl logs deployment/search-engine-deployment -c api-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:
"... |
Update the 'node-1' node by adding a taint with key 'disktype', value 'ssd', and effect 'NoSchedule' | Command:
```bash
kubectl taint nodes node-1 disktype=ssd: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: j... |
Port forward from local port 3000 to pod port 3000 | Command:
```bash
kubectl port-forward pod/security-service-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 be select... |
Copy the ~/.config/kube directory from the 'file-server-pod-14' pod in the 'default' namespace to the local directory /tmp/bar_dir. | Command:
```bash
kubectl cp default/file-server-pod-14:~/.config/kube /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... |
Update the pod 'analytics' with the annotation 'backup-strategy' and the value 'daily-backups', overwriting any existing value. | Command:
```bash
kubectl annotate --overwrite pods analytics 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 lab... |
Create a pod disruption budget named cron-jobs-pdb that will select all pods with the release=1.0.0 label and require at least one of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget cron-jobs-pdb --selector=release=1.0.0 --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 [-... |
Add a taint with the key 'cpu-type' and the value 'testing-node-11:PreferNoSchedule' on all nodes with the label 'release=beta' | Command:
```bash
kubectl taint node -l release=beta cpu-type=testing-node-11:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage"... |
Listen on all addresses on port 8000 and forward the traffic to port 8000 in the pod named 'api-service-pod'. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/api-service-pod 8000: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 ui-config using the specified keys instead of the file basenames on disk. | Command:
```bash
kubectl create configmap ui-config --from-file=conf=/path/to/settings/file1.txt --from-file=data=/path/to/options/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 config ... |
Create an ingress resource named 'web-ingress' with a rule that directs requests from 'testing.com/input' to the service named 'svc1' on port 5000 | Command:
```bash
kubectl create ingress web-ingress --rule="testing.com/input=svc1:5000,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"... |
Run the command 'mysql --version' in the 'cosmic-container' from the 'frontend-pod' and retrieve the output. | Command:
```bash
kubectl exec frontend-pod -c cosmic-container -- mysql --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 deployment named worker using the postgres image | Command:
```bash
kubectl create deployment worker --image=postgres
```
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|yaml|n... |
Create a copy of the 'mypod' pod, naming it 'debug-image-1', and launch a shell in the 'nano-bot' container | Command:
```bash
kubectl debug mypod -it --copy-to=debug-image-1 --container=nano-bot -- 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 default if no re... |
Update the annotation of a pod with the specified application version | Command:
```bash
kubectl annotate -f params.json app-version=2.5.1
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include arbitrary ... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=DEBUG_MODE --from=configmap/monitoring-config deployment/authentication-service-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment var... |
Import specific keys from a config map into an environment variable of a deployment. | Command:
```bash
kubectl set env --keys=DATABASE_URL --from=configmap/api-config 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 defin... |
Enable a new exec auth plugin for the "admin" entry by setting the --exec-command parameter to "/path/to/the/executable" and the --exec-api-version parameter to "client.authentication.k8s.io/v1beta1" | Command:
```bash
kubectl config set-credentials admin --exec-command=/path/to/the/executable --exec-api-version=client.authentication.k8s.io/v1beta1
```
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:
--cli... |
Forward local port 8888 to port 8080 in the 'web-app-pod' pod. | Command:
```bash
kubectl port-forward pod/web-app-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 automa... |
List deployments in JSON output format, specifying the version and API group | Command:
```bash
kubectl get deployments.v1.1.1.api-v1 -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 onl... |
Wait for the specified pod to be deleted after issuing the delete command, with a timeout of 60 seconds. | Command:
```bash
kubectl delete pod/auth-service-pod
kubectl wait --for=delete pod/busybox1 --timeout=60s
```
What it does:
Experimental: Wait for a specific condition on one or many resources.
The command takes multiple resources and waits until the specified condition is seen in the Status field of every given resou... |
Set the resource request and limits for all containers in the Jenkins deployment | Command:
```bash
kubectl set resources deployment jenkins --limits=cpu=200m,memory=512Mi --requests=cpu=5,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 request... |
Execute the 'nginx' command inside the 'stardust-shuttle' container in the 'vpn-service-pod' pod | Command:
```bash
kubectl exec vpn-service-pod -c stardust-shuttle -- nginx
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted,... |
Forward traffic from port 8081 on all addresses to port 8088 inside the analytics-pod pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/analytics-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 criteria, a pod wil... |
Begin streaming the logs of the "mycontainer" container in the "api-service-pod" pod | Command:
```bash
kubectl logs -f -c mycontainer api-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", "... |
Update the deployment 'email-server-deployment' with a new environment variable named QUEUE_NAME and set its value to 'task-queue' | Command:
```bash
kubectl set env deployment/email-server-deployment QUEUE_NAME=task-queue
```
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 temp... |
Create a pod disruption budget named 'notification-service-pdb' that will select all pods with the 'owner=team-1' label and require a minimum of four of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget notification-service-pdb --selector=owner=team-1 --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-avai... |
Output the modified 'web-app-deployment' deployment in YAML format with the CACHE_SIZE environment variable set to '64MB', without altering the object on the server. | Command:
```bash
kubectl set env deployment/web-app-deployment CACHE_SIZE=64MB -o yaml
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more pod templat... |
Attach to the pod "vpn-service-pod" and connect to the container "nano-bot" to get the output. | Command:
```bash
kubectl attach vpn-service-pod -c nano-bot
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use... |
Forward port 3000 on all addresses to port 8888 in the e-commerce-pod pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/e-commerce-pod 3000: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 wi... |
start a pod with the redis image and expose port 3306 | Command:
```bash
kubectl run hazelcast --image=redis --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": "--fi... |
Create a new config map named 'db-config' using the specified keys and files | Command:
```bash
kubectl create configmap db-config --from-file=settings=/path/to/parameters/file1.txt --from-file=key2=/path/to/configurations/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... |
Set the CPU limit for the python container in the deployment named "python" to "2" and the memory limit to "256Mi". | Command:
```bash
kubectl set resources deployment python -c=nginx --limits=cpu=2,memory=256Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to i... |
Partially update the gpu-node-12 node by applying a strategic merge patch from the YAML file provided | Command:
```bash
kubectl patch node gpu-node-12 -p $'spec:\n rules:\n- http:\n paths:\n - path: /\n backend:\n service:\n name: new-service'
```
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.
Sy... |
Forward port 5000 on localhost and IP 10.19.21.23 to port 8088 in the e-commerce-pod pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/e-commerce-pod 5000: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 crit... |
Execute the 'go run hello.go' command inside the proxy-server-pod pod, using the first container by default | Command:
```bash
kubectl exec proxy-server-pod -- 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, use the ... |
Import the `config_file_path` key from the `kube-system-config` config map into the `gateway-deployment` deployment. | Command:
```bash
kubectl set env --keys=config_file_path --from=configmap/kube-system-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 de... |
Check the rollout status of the daemonset in the namespace-2 namespace. | Command:
```bash
kubectl rollout status daemonset/namespace-2
```
What it does:
Manage the rollout of a resource.
Valid resource types include:
Syntax:
`kubectl rollout SUBCOMMAND` |
Copy the local file ~/.config/kube to the directory /tmp/bar_dir inside the remote pod named 'database-pod-2' in the namespace 'monitoring'. | Command:
```bash
kubectl cp ~/.config/kube monitoring/database-pod-2:/tmp/bar_dir
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use th... |
Create a priority class named 'development-priority' with a value of 15, a description of "Priority for development and staging", and a preemption policy of "Never" | Command:
```bash
kubectl create priorityclass development-priority --value=15 --description="Priority for development and staging" --preemption-policy="Never"
```
What it does:
Create a priority class with the specified name, value, globalDefault and description.
Syntax:
`kubectl create priorityclass NAME --value=VAL... |
Wait until the pod named "monitoring-pod" is in the "Ready" state | Command:
```bash
kubectl wait --for=condition=Ready pod/monitoring-pod
```
What it does:
Experimental: Wait for a specific condition on one or many resources.
The command takes multiple resources and waits until the specified condition is seen in the Status field of every given resource.
Alternatively, the command can... |
Listen on port 8088 on your local machine and forward the traffic to port 5432 in the 'security-service-pod' pod | Command:
```bash
kubectl port-forward pod/security-service-pod 8088: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 select... |
Forward port 9090 on all addresses to port 5432 in the pod named chat-app-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/chat-app-pod 9090: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... |
Forward local traffic on port 8080 to port 9090 in the cdn-service-pod, listening locally on port 8080 and forwarding data to/from ports 9090 in the pod. | Command:
```bash
kubectl port-forward pod/cdn-service-pod 8080 9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected au... |
Copy the local file /tmp/foo to the /tmp/bar_dir directory inside the task-processor-pod-17 pod in the kube-flannel namespace. | Command:
```bash
kubectl cp :/tmp/foo kube-flannel/task-processor-pod-17:/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, us... |
Add a taint with key 'hardware' on nodes having label stack=tech-stack | Command:
```bash
kubectl taint node -l stack=tech-stack 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": "Ou... |
Check if you have permission to list the "log-analysis-job" job in the "kube-public" namespace. | Command:
```bash
kubectl auth can-i list jobs.batch/log-analysis-job -n kube-public
```
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 local port 8088 to port 9090 in the chat-app-pod pod | Command:
```bash
kubectl port-forward pod/chat-app-pod 8088:9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected autom... |
Update the 'frontend' pod with the annotation 'team' and set its value to 'frontend team' | Command:
```bash
kubectl annotate pods frontend team='frontend team'
```
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 arbitrar... |
Listen on port 9090 on all addresses and forward the traffic to port 8888 in the 'security-service-pod' pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/security-service-pod 9090:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a ... |
Set the user field of the 'prod-context' context entry to 'cluster-admin' without modifying any other values. | Command:
```bash
kubectl config set-context prod-context --user=cluster-admin
```
What it does:
Set a context 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-context [NAME | --current] [--cluster=cluster_nickname]... |
Create a pod disruption budget named cron-jobs-pdb that will select all pods with the owner=team-1 label and require a minimum of 9 of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget cron-jobs-pdb --selector=owner=team-1 --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 [--... |
Edit the last-applied-configuration annotations for the deployment named 'cp-kafka' in the 'confluentinc' namespace | Command:
```bash
kubectl apply edit-last-applied deployment/confluentinc/cp-kafka
```
What it does:
Edit the latest last-applied-configuration annotations of resources from the default editor.
The edit-last-applied command allows you to directly edit any API resource you can retrieve via the command-line tools. It wil... |
Create a new ClusterIP service named git-service-clusterip that listens on port 5432 and forwards traffic to port 9090 | Command:
```bash
kubectl create service clusterip git-service-clusterip --tcp=5432:9090
```
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", "d... |
Set the custom TLS server name for the web-cluster cluster entry to "testing-cluster". | Command:
```bash
kubectl config set-cluster web-cluster --tls-server-name=testing-cluster
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-cluster NAME [--server=server] [--certifica... |
Set the service account of the deployment "notification-handler-deployment" to "prometheus" | Command:
```bash
kubectl set serviceaccount deployment notification-handler-deployment prometheus
```
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
Syn... |
Create a new config map named env-vars from the key=value pairs in the specified file | Command:
```bash
kubectl create configmap env-vars --from-file=path/to/data
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a config map based on a file, the key will default to the basename of the ... |
Set the cluster field in the my-context context to data-cluster in the cloud-context configuration | Command:
```bash
kubectl config set contexts.cloud-context.cluster data-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... |
Forward local port 5000 to port 8088 in the pod "log-aggregator-pod" | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 5000 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... |
Start a Wordpress pod and expose port 8000 | Command:
```bash
kubectl run hazelcast --image=wordpress --port=8000
```
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": "... |
Create a pod named 'hazelcast' with the mongo image and expose port 9000 | Command:
```bash
kubectl run hazelcast --image=mongo --port=9000
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--fi... |
Roll back to the previous deployment in the "prod" namespace, but only simulate the action without making any actual changes. | Command:
```bash
kubectl rollout undo --dry-run=server deployment/prod
```
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 ... |
Run a proxy to the Kubernetes API server on port 8089, serving static content from the ./local/www/ directory. | Command:
```bash
kubectl proxy --port=8089 --www=./local/www/
```
What it does:
Creates a proxy server or application-level gateway between localhost and the Kubernetes API server. It also allows serving static content over specified HTTP path. All incoming data enters through one port and gets forwarded to the remote... |
Retrieve the snapshot logs from the container 'cdn-service-pod-1' of the 'email-server-deployment' deployment | Command:
```bash
kubectl logs deployment/email-server-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 flags:
"f... |
Retrieve the output from executing the 'jenkins-plugin-cli' command in the 'nano-bot' container of the 'chat-app-pod' pod. | Command:
```bash
kubectl exec chat-app-pod -c nano-bot -- jenkins-plugin-cli
```
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... |
Delete the pods and services named "frontend" and "security" | Command:
```bash
kubectl delete pod,service frontend 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... |
Add a taint with the key 'hardware' and the value 'monitoring-node-15:PreferNoSchedule' on nodes that have the label 'service=auth' | Command:
```bash
kubectl taint node -l service=auth hardware=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": "", "usa... |
Forward traffic from port 5000 on localhost and IP address 10.19.21.23 to port 8080 in the analytics-pod pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/analytics-pod 5000: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 crite... |
Delete the pods and services named "payment" and "log-aggregator" | Command:
```bash
kubectl delete pod,service payment 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 se... |
Retrieve snapshot logs from the container 'monitoring-stack-deployment-1' within the 'database-pod' deployment. | Command:
```bash
kubectl logs deployment/monitoring-stack-deployment -c database-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:
"... |
Scale the deployment "web" to 3 replicas to match the current size of the deployment named "web" to 5. | Command:
```bash
kubectl scale --current-replicas=5 --replicas=3 deployment/web
```
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-version is spec... |
Get the output from running the 'psql' command on the first pod of the 'notification-service' service, using the first container by default. | Command:
```bash
kubectl exec svc/notification-service -- psql
```
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 kub... |
Copy a file from your local machine to a remote pod in a specific namespace | Command:
```bash
kubectl cp /var/run/secrets/kubernetes.io/serviceaccount/ kube-system/security-scanner-pod-18:/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... |
Add a taint with key 'workload' on nodes that have the label tier=frontend | Command:
```bash
kubectl taint node -l tier=frontend workload=worker-node-3: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 an ingress resource called 'default-ingress' that directs requests to the website.com/module path to the 'svc1' service on port 5001 | Command:
```bash
kubectl create ingress default-ingress --rule="website.com/module=svc1:5001,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... |
Forward traffic from port 8888 on all addresses to port 5000 in the pod named "e-commerce-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/e-commerce-pod 8888: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 wi... |
Get the output from running the 'sleep 3600' command in the pod named payment-gateway-pod | Command:
```bash
kubectl exec payment-gateway-pod -- 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": "Container name. If omitted, use the ku... |
Forward the local port 8081 to port 8081 in the pod/log-aggregator-pod | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 8081 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... |
Create a service for alpine deployment serving on port 80 and connecting to containers on port 8000 | Command:
```bash
kubectl expose deployment alpine --port=7000 --target-port=500000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specifi... |
Set the service account of the 'mydeployment' deployment to 'my-service-account' | Command:
```bash
kubectl set serviceaccount deployment mydeployment my-service-account
```
What it does:
Update the service account of pod template resources.
Possible resources (case insensitive) can be:
replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset
Syntax:
`kubec... |
Create a copy of the 'vpn-service-pod' pod with a debug container and change the container images for the 'database' and 'proxy' containers | Command:
```bash
kubectl debug vpn-service-pod -it --copy-to=debug-image-1 --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 a... |
Create a job called deployment-rollout-job and run the command "yum install -y wget" in a CentOS container image. | Command:
```bash
kubectl create job deployment-rollout-job --image=centos -- yum install -y wget
```
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... |
Retrieve snapshot logs from all containers in pods with the label "release=beta" | Command:
```bash
kubectl logs -l release=beta --all-containers=true
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container... |
Add an annotation "monitoring-tool=Prometheus" to the pod identified by the type and name specified in the "settings.json" file. | Command:
```bash
kubectl annotate -f settings.json 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... |
Forward traffic from port 8088 on localhost and IP 10.19.21.23 to port 5000 in the pod named proxy-server-pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/proxy-server-pod 8088: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 cr... |
Create a cluster role named "custom_role" with ResourceName specified | Command:
```bash
kubectl create clusterrole custom_role --verb=proxy --resource=services --resource-name=prod-api-gateway --resource-name=file-storage
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=serve... |
List resources by their type and names | Command:
```bash
kubectl get rc/web service/security-service-rc pods/log-aggregator-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 i... |
Apply resources from a directory using Kustomize | Command:
```bash
kubectl apply -k conf/
```
What it does:
Apply a configuration to a resource by file name or stdin. The resource name must be specified. This resource will be created if it doesn't exist yet. To use 'apply', always create the resource initially with either 'apply' or 'create --save-config'.
JSON and Y... |
Create a pod disruption budget that selects all pods with the label component=web and requires a minimum of four pods to be available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget batch-processing-pdb --selector=component=web --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-availab... |
Attach to the 'nebula-navigator' container in the 'cdn-service-pod' pod to get the output | Command:
```bash
kubectl attach cdn-service-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 omit... |
Retrieve the snapshot logs from the container "analytics-pod-1" within the deployment "backend-microservice-deployment". | Command:
```bash
kubectl logs deployment/backend-microservice-deployment -c analytics-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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.