prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Create a new config map named 'namespace-config' from the key=value pairs found in the 'path/to/data' file | Command:
```bash
kubectl create configmap namespace-config --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... |
Update the image of all containers in the daemonset named "test" to "ubuntu:20.04". | Command:
```bash
kubectl set image daemonset test *=ubuntu:20.04
```
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:
`kubect... |
Set the CPU and memory limits for a container in a deployment named "go" to 100m and 128Mi respectively | Command:
```bash
kubectl set resources deployment go -c=nginx --limits=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 requested, but may burst up to it... |
Create a role binding for multiple users and a group using a specific cluster role | Command:
```bash
kubectl create rolebinding view --clusterrole=view --user=user1 --user=user2 --group=group1
```
What it does:
Create a role binding for a particular role or cluster role.
Syntax:
`kubectl create rolebinding NAME --clusterrole=NAME|--role=NAME [--user=username] [--group=groupname] [--serviceaccount=na... |
Expose a replica set as a service, serving on port 3001 and connecting to containers on port 844300 | Command:
```bash
kubectl expose rs centos --port=3001 --target-port=844300
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port.... |
Copy the file located at /var/run/secrets/kubernetes.io/serviceaccount/ from the local machine to the /tmp/bar directory in the remote pod named load-balancer-pod-9 in the velero namespace. | Command:
```bash
kubectl cp /var/run/secrets/kubernetes.io/serviceaccount/ velero/load-balancer-pod-9::/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": "Cont... |
Forward local traffic on port 8888 to port 9090 in a pod selected by the deployment named "search-engine-deployment". | Command:
```bash
kubectl port-forward deployment/search-engine-deployment 8888 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 wil... |
Import the environment variables from the 'docker-registry-secret' secret into the 'user-management-deployment' deployment | Command:
```bash
kubectl set env --from=secret/docker-registry-secret deployment/user-management-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 on... |
Create an ingress resource called 'app1-ingress' that directs requests from foo.com/example to svc1:5432 | Command:
```bash
kubectl create ingress app1-ingress --rule="foo.com/example=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 service account of the search-engine-deployment deployment to elasticsearch | Command:
```bash
kubectl set serviceaccount deployment search-engine-deployment elasticsearch
```
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:... |
Rename the context 'cloud-context' to 'new-context' in your kubeconfig file | Command:
```bash
kubectl config rename-context cloud-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 be... |
Forward traffic from local port 5000 to port 8080 in the chat-app-pod pod. | Command:
```bash
kubectl port-forward pod/chat-app-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 criteria, a pod will be selected autom... |
Create a job named "database-seeding-job" using the image "mcr.microsoft.com/dotnet/core/runtime" with the command "dotnet". | Command:
```bash
kubectl create job database-seeding-job --image=mcr.microsoft.com/dotnet/core/runtime -- dotnet
```
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", "defa... |
Copy the ~/.config/kube local file to :/tmp/bar in the "file-server" container of the "web-app-pod-1" pod | Command:
```bash
kubectl cp ~/.config/kube web-app-pod-1::/tmp/bar -c file-server
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use th... |
Embed the certificate authority data for the cluster-gamma cluster entry by running the command: | Command:
```bash
kubectl config set-cluster cluster-gamma --embed-certs --certificate-authority=~/.kube/prod-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 se... |
Set the service account of the load-balancer-deployment deployment to gitlab-runner. | Command:
```bash
kubectl set serviceaccount deployment load-balancer-deployment gitlab-runner
```
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:... |
Switch to raw terminal mode and attach to the time-machine container in the mypod pod | Command:
```bash
kubectl attach mypod -c time-machine -i -t
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use... |
Copy the local file /tmp/foo to the remote pod logging-agent-pod-7 in the container security-scanner, placing it in the /tmp/bar_dir directory | Command:
```bash
kubectl cp :/tmp/foo logging-agent-pod-7:/tmp/bar_dir -c security-scanner
```
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 omitte... |
Update the label of the pod 'media-stream' to 'unhealthy', overwriting any existing value for the label 'status' | Command:
```bash
kubectl label --overwrite pods media-stream 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"... |
Retrieve the logs from the container "security-service-pod-1" of the "authentication-service-deployment" deployment. | Command:
```bash
kubectl logs deployment/authentication-service-deployment -c security-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]`
He... |
Start a redis pod with the specified image, but customize the pod's specification using a JSON file. | Command:
```bash
kubectl run nginx --image=redis --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] -- [C... |
Create a deployment named 'registry' using the 'docker.elastic.co/elasticsearch/elasticsearch' image and expose port 8443 | Command:
```bash
kubectl create deployment registry --image=docker.elastic.co/elasticsearch/elasticsearch --port=8443
```
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 specific keys from a config map | Command:
```bash
kubectl set env --keys=api_key --from=configmap/app-config deployment/api-server-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in o... |
Create a service for the replication controller specified in the "wordpress-controller.yaml" file | Command:
```bash
kubectl expose -f wordpress-controller.yaml --port=80 --target-port=300000
```
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 th... |
Create a new config map named app-config-dev by using specific keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-config-dev --from-file=properties=/path/to/configurations/file1.txt --from-file=key1=/path/to/properties/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
Whe... |
Create a config map named db-config by specifying keys instead of file basenames on disk | Command:
```bash
kubectl create configmap db-config --from-file=conf=/path/to/profiles/file1.txt --from-file=data=/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 config map... |
Attach to a pod named chat-app-pod, in the container named astro-container, and start an interactive terminal session. | Command:
```bash
kubectl attach chat-app-pod -c astro-container -i -t
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If om... |
execute the 'apk add curl' command within the backend-pod pod. | Command:
```bash
kubectl exec backend-pod -- apk add curl
```
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.... |
Copy the directory /var/run/secrets/kubernetes.io/serviceaccount/ from the admin-dashboard-pod-16 pod in the namespace ingress-nginx and paste it to the /tmp/bar directory on your local machine. | Command:
```bash
kubectl cp ingress-nginx/admin-dashboard-pod-16:/var/run/secrets/kubernetes.io/serviceaccount/ :/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": "", "usa... |
Wait for the pod named "backend-pod" to be in the "Ready" condition. | Command:
```bash
kubectl wait --for=condition=Ready pod/backend-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 wa... |
Add the label 'unhealthy=true' to the pod named 'backend'. | Command:
```bash
kubectl label pods backend unhealthy=true
```
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":... |
Forward port 8088 on all addresses to port 5432 in the pod named "e-commerce-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/e-commerce-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 wi... |
Change the service account of the deployment `notification-handler-deployment` to `default`. | Command:
```bash
kubectl set serviceaccount deployment notification-handler-deployment default
```
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... |
Autoscale the replication controller "cdn" with a target CPU utilization of 40% and a maximum of 4 pods. | Command:
```bash
kubectl autoscale rc cdn --max=4 --cpu-percent=40
```
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 the... |
Import specific keys from a config map to the environment variables of a deployment | Command:
```bash
kubectl set env --keys=external_api_url --from=configmap/app-name-config deployment/load-balancer-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable... |
Forward local port 8000 to port 5000 in the pod with name "log-aggregator-pod" | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 8000 5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected... |
Forward traffic from port 8000 on all addresses to port 9090 in the 'api-service-pod' pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/api-service-pod 8000: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 w... |
Import specific keys from a config map into a deployment's environment variables | Command:
```bash
kubectl set env --keys=MAX_CONNECTIONS --from=configmap/app-name-config deployment/log-aggregator-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable... |
Update the annotation 'release-notes' with the value 'https://example.com/release-notes/v2.5.1' for the pod named 'web', overwriting any existing value. | Command:
```bash
kubectl annotate --overwrite pods web release-notes='https://example.com/release-notes/v2.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... |
Create a copy of the cdn-service-pod and add a debug container to it | Command:
```bash
kubectl debug cdn-service-pod -it --copy-to=debug-image-web --image=debian --set-image=logger=logging-app:debug,app=app:debug
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resou... |
Copy the local directory ~/.config/kube_dir to the remote pod image-resizer-pod-20 in the default namespace, and place it in the /tmp/bar_dir directory. | Command:
```bash
kubectl cp ~/.config/kube_dir image-resizer-pod-20::/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... |
Run the 'geth' command in the rocket-ranger container of the frontend-pod pod and display the output | Command:
```bash
kubectl exec frontend-pod -c rocket-ranger -- geth
```
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 th... |
Create an ingress called 'service-ingress' and configure it to direct requests for 'website.com/example' to the service 'svc1:9000' | Command:
```bash
kubectl create ingress service-ingress --rule="website.com/example=svc1:9000,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "... |
Update the status of a pod to "unhealthy" using the configuration specified in the "options.yaml" file. | Command:
```bash
kubectl label -f options.yaml 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": "false", "us... |
Get the logs from the 'proxy-server-pod-1' container in the 'mydeployment' deployment | Command:
```bash
kubectl logs deployment/mydeployment -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:
"flag": "--c... |
Create a deployment named gitlab with the ubuntu image and expose port 9091. | Command:
```bash
kubectl create deployment gitlab --image=ubuntu --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 copy of the 'media-stream-pod' pod and change all container images to 'confluentinc/cp-kafka' | Command:
```bash
kubectl debug media-stream-pod --copy-to=debug-image-app --set-image=*=confluentinc/cp-kafka
```
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 b... |
Create a new LoadBalancer service named 'vpn-service-lb' that maps port 8888 externally to port 5432 internally. | Command:
```bash
kubectl create service loadbalancer vpn-service-lb --tcp=8888:5432
```
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", "def... |
Create a new secret named payment-gateway-secret using a combination of a file and a literal | Command:
```bash
kubectl create secret generic payment-gateway-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 b... |
Forward traffic from port 8088 on all addresses to port 9090 in the 'cdn-service-pod' pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/cdn-service-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 w... |
Forward local port 8888 to port 3000 in the pod named "mypod" | Command:
```bash
kubectl port-forward pod/mypod 8888 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 selected automaticall... |
Forward port 5432 on localhost and IP address 10.19.21.23 to port 9090 in the backend pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/backend-pod 5432:9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteri... |
Set the label 'tier' with the value 'backend' for the pod named 'frontend' | Command:
```bash
kubectl label pods frontend tier=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": ... |
Execute the 'node' command in the 'proxy-service-pod' pod and display the output. | Command:
```bash
kubectl exec proxy-service-pod -- node
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.ku... |
Create a job named 'deployment-rollout-job' with the image 'mongo' and the command 'mongod' | Command:
```bash
kubectl create job deployment-rollout-job --image=mongo -- mongod
```
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 for... |
Create an ingress named 'default-ingress' that routes requests from testing.com/example to svc1:3001, and uses a TLS secret called "my-cert". | Command:
```bash
kubectl create ingress default-ingress --rule="testing.com/example=svc1:3001,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 service for nginx deployment, serving on port 80, connecting to containers on port 8000 | Command:
```bash
kubectl expose deployment nginx --port=8081 --target-port=909100
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specifie... |
Copy the local file "/tmp/foo_dir" to the remote pod "rook-ceph/message-broker-pod-15" in the namespace and place it in the directory "/etc/kubernetes". | Command:
```bash
kubectl cp /tmp/foo_dir rook-ceph/message-broker-pod-15:/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 new config map named namespace-config with the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap namespace-config --from-file=settings=/path/to/configurations/file1.txt --from-file=key2=/path/to/properties/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
Whe... |
Listen on port 8888 on all addresses and forward the traffic to port 8080 in the pod named 'cdn-service-pod' | Command:
```bash
kubectl port-forward --address 0.0.0.0 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 w... |
attach and interact with the nano-bot container in the frontend-pod | Command:
```bash
kubectl attach frontend-pod -c nano-bot -i -t
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, ... |
Create a new config map named app-settings, using the files located at path/to/settings folder. | Command:
```bash
kubectl create configmap app-settings --from-file=path/to/settings
```
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... |
Create a new config map named 'app-config-dev' using the 'settings' key from the file '/path/to/configs/file1.txt' and the 'key2' key from the file '/path/to/properties/file2.txt' instead of using the file basenames on disk. | Command:
```bash
kubectl create configmap app-config-dev --from-file=settings=/path/to/configs/file1.txt --from-file=key2=/path/to/properties/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creatin... |
Check if you can list the job "queue-processing-job" in the "testing" namespace. | Command:
```bash
kubectl auth can-i list jobs.batch/queue-processing-job -n testing
```
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... |
Add a new taint to the node 'prod-node-5' with the key 'environment', value 'production', and effect 'NoSchedule' | Command:
```bash
kubectl taint nodes prod-node-5 environment=production: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 fo... |
Retrieve the logs from the 'web-app-pod' pod with a single container. | Command:
```bash
kubectl logs web-app-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", "default... |
Copy the file ~/.config/kube from your local system to the /tmp/bar directory in the remote pod named auth-service-pod-11 located in the istio-system namespace. | Command:
```bash
kubectl cp ~/.config/kube istio-system/auth-service-pod-11:/tmp/bar
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use... |
Set specific keys from a config map as environment variables for a deployment named "analytics-platform-deployment" | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/log-config deployment/analytics-platform-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defin... |
Create a copy of the payment-gateway-pod with a debug container and updated container images | Command:
```bash
kubectl debug payment-gateway-pod -it --copy-to=debug-image-memcached --image=debian --set-image=app=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... |
Update node 'prod-node-5' by adding a taint with key 'hardware', value 'gpu', and effect 'NoExecute' | Command:
```bash
kubectl taint nodes prod-node-5 hardware=gpu:NoExecute
```
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 o... |
Expose a replica set as a service, serving on port 6379 and targeting the containers on port 300100. | Command:
```bash
kubectl expose rs hazelcast --port=6379 --target-port=300100
```
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... |
Embed the certificate authority data for the 'galaxy-cluster' cluster entry by running the command: | Command:
```bash
kubectl config set-cluster galaxy-cluster --embed-certs --certificate-authority=~/.kube/prod-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 s... |
Create an ingress that directs requests to a specific service with TLS encryption | Command:
```bash
kubectl create ingress app1-ingress --rule="testing.com/module=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": "", "usag... |
Forward local port 8088 to pod port 8081 for the chat-app-pod | Command:
```bash
kubectl port-forward pod/chat-app-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 selected autom... |
Create a new ClusterIP service named backend-service-clusterip that maps port 5001 on the service to port 27017 on the backend application. | Command:
```bash
kubectl create service clusterip backend-service-clusterip --tcp=5001:27017
```
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... |
Create a deployment named 'cache' with the 'wordpress' image, and expose port 3000 | Command:
```bash
kubectl create deployment cache --image=wordpress --port=3000
```
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:... |
Create an ingress with a rule that directs requests to a specific service and port, using a TLS secret for secure communication. | Command:
```bash
kubectl create ingress default-ingress --rule="site.com/bar=svc1:7000,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage":... |
Apply a taint with key 'app' on nodes that have the label 'stack=tech-stack' | Command:
```bash
kubectl taint node -l stack=tech-stack app=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": "O... |
Attach to the first pod of the 'redis' replica set | Command:
```bash
kubectl attach rs/redis
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.kubern... |
Create a copy of a monitoring pod, changing all container images to Alpine. | Command:
```bash
kubectl debug monitoring-pod --copy-to=debug-image-web --set-image=*=alpine
```
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 r... |
Set the service account of the 'email-server-deployment' deployment to 'spinnaker' | Command:
```bash
kubectl set serviceaccount deployment email-server-deployment spinnaker
```
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:
`kub... |
Import the 'my-example-key' key from the 'app-secrets' config map into the environment variables of the 'scheduler-app-deployment' deployment. | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/app-secrets 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 defin... |
Return the snapshot logs from the container named "log-aggregator-pod-1" of the deployment named "load-balancer-deployment" | Command:
```bash
kubectl logs deployment/load-balancer-deployment -c log-aggregator-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags... |
Create an ingress called 'private-api-ingress' with a rule that directs requests for testing.com/module to svc1 on port 9092 | Command:
```bash
kubectl create ingress private-api-ingress --rule="testing.com/module=svc1:9092,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": ""... |
Create a job called `scaling-job` using the `mysql` image and run the `mysql` command inside the job container. | Command:
```bash
kubectl create job scaling-job --image=mysql -- mysql
```
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 of:... |
Listen on a random port on your local machine, and forward traffic to port 5000 in the analytics-pod pod. | Command:
```bash
kubectl port-forward pod/analytics-pod :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 automati... |
Copy a local file to a specific directory in a remote pod's specific container | Command:
```bash
kubectl cp /tmp/foo_dir backend-pod-13:/etc/kubernetes -c api-server-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 o... |
Remove the taint with key 'hardware' and effect 'NoExecute' from node 'db-node-7' | Command:
```bash
kubectl taint nodes db-node-7 hardware:NoExecute-
```
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: js... |
Add the label 'release=v2.0' to the pod named 'cdn' | Command:
```bash
kubectl label pods cdn release=v2.0
```
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... |
Forward local port 5432 to port 5000 in the e-commerce-pod | Command:
```bash
kubectl port-forward pod/e-commerce-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 aut... |
Set the custom TLS server name to "prod-cluster" for the "data-cluster" cluster entry | Command:
```bash
kubectl config set-cluster data-cluster --tls-server-name=prod-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... |
Create a copy of the gateway-pod called debug-image-web, with all container images changed to busybox. | Command:
```bash
kubectl debug gateway-pod --copy-to=debug-image-web --set-image=*=busybox
```
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 res... |
Listen on ports 8081 and 6000 on your local machine, forwarding data to/from ports 8081 and 6000 in the pod selected by the deployment named 'analytics-platform-deployment'. | Command:
```bash
kubectl port-forward deployment/analytics-platform-deployment 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 po... |
Create a role binding named default_role for developer3, k8s-admin, and qa-engineers using the default_role cluster role | Command:
```bash
kubectl create rolebinding default_role --clusterrole=default_role --user=developer3 --user=k8s-admin --group=qa-engineers
```
What it does:
Create a role binding for a particular role or cluster role.
Syntax:
`kubectl create rolebinding NAME --clusterrole=NAME|--role=NAME [--user=username] [--group=... |
Embed the certificate authority data for the star-cluster cluster entry. | Command:
```bash
kubectl config set-cluster star-cluster --embed-certs --certificate-authority=~/.kube/galaxy-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 s... |
Add a taint with the key 'cpu-type' on the nodes that have the label release=beta | Command:
```bash
kubectl taint node -l release=beta cpu-type=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 secret named monitoring-credentials-secret with keys for each file in the path/to/profiles folder. | Command:
```bash
kubectl create secret generic monitoring-credentials-secret --from-file=path/to/profiles
```
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 th... |
Enable autoscaling for the 'cdn' deployment with a minimum of 7 pods and a maximum of 9 pods | Command:
```bash
kubectl autoscale deployment cdn --min=7 --max=9
```
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 the ... |
Set the custom TLS server name to "cloud-cluster" for the "cloud-cluster" cluster entry | Command:
```bash
kubectl config set-cluster cloud-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] [--certifica... |
Import the 'LOG_LEVEL' key from the 'app-name-config' config map and set it as an environment variable in the 'email-server-deployment' deployment. | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/app-name-config deployment/email-server-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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.