prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Add a taint to the 'storage-node-13' node with the key 'disktype', value 'ssd', and effect 'NoSchedule' | Command:
```bash
kubectl taint nodes storage-node-13 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. ... |
Forward traffic from port 8081 on all addresses to port 5432 in the pod named "api-service-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/api-service-pod 8081:5432
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod w... |
Create a pod disruption budget named payment-gateway-pdb that will select all pods with the release=1.0.0 label and require at least four of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget payment-gateway-pdb --selector=release=1.0.0 --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-availabl... |
Display only the most recent 3 lines of output in the 'api-service-pod' pod | Command:
```bash
kubectl logs --tail=3 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", "short": "... |
Set the CPU and memory limits for the containers in a deployment named "node" with the label "nginx" to 5 CPU units and 128MiB, respectively. | Command:
```bash
kubectl set resources deployment node -c=nginx --limits=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 requested, but may burst up to its... |
Execute the 'php --version' command in the 'nano-bot' container of the 'proxy-service-pod' pod. | Command:
```bash
kubectl exec proxy-service-pod -c nano-bot -- php --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 omitte... |
Execute the command 'go run hello.go' in the warp-drive container of the monitoring-pod and display the output. | Command:
```bash
kubectl exec monitoring-pod -c warp-drive -- go run hello.go
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitt... |
Create a new NodePort service named e-commerce-nodeport that maps port 8088 on the cluster to port 3000 on the service. | Command:
```bash
kubectl create service nodeport e-commerce-nodeport --tcp=8088:3000
```
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", "default": ... |
Set the 'app-version' annotation to '2.5.1' for the pod named 'api'. | Command:
```bash
kubectl annotate pods api 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 string... |
Create a new pod named "hazelcast" using the "node" image and expose port 8089. | Command:
```bash
kubectl run hazelcast --image=node --port=8089
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--fil... |
Create a new config map named monitoring-config with specified keys instead of file basenames on disk. | Command:
```bash
kubectl create configmap monitoring-config --from-file=conf=/path/to/configurations/file1.txt --from-file=data=/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 c... |
Create an ingress called 'app2-ingress' with a rule that directs requests to 'site.com/module' to 'svc1:8081' using the TLS secret 'my-cert' | Command:
```bash
kubectl create ingress app2-ingress --rule="site.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": "", "usage":... |
Set the cluster field in the prod-context context to moon-cluster | Command:
```bash
kubectl config set contexts.prod-context.cluster moon-cluster
```
What it does:
Set an individual value in a kubeconfig file.
PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.
PROPERTY_VALUE is the new value you wan... |
Create a secret with keys for each file in a specified folder | Command:
```bash
kubectl create secret generic monitoring-credentials-secret --from-file=path/to/data
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, the key will default to the ba... |
Connect to a specific container in a pod and interact with its terminal. | Command:
```bash
kubectl attach log-aggregator-pod -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... |
Create a job called "database-seeding-job" using the "golang" image and with the command "go version" | Command:
```bash
kubectl create job database-seeding-job --image=golang -- go version
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output ... |
Retrieve the previous terminated logs of the "cyber-sleuth" container from the pod named "auth-service-pod". | Command:
```bash
kubectl logs -p -c cyber-sleuth auth-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",... |
Copy the ~/.config/kube file from the local machine to /tmp/bar_dir in the web-app-container of the api-server-pod-3 pod. | Command:
```bash
kubectl cp ~/.config/kube api-server-pod-3:/tmp/bar_dir -c web-app-container
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omi... |
View the most recent 3 lines of logs for the pod named "security-service-pod" | Command:
```bash
kubectl logs --tail=3 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", "shor... |
List the resources of the specified types and names | Command:
```bash
kubectl get rc/web service/payment-gateway-rc pods/frontend-pod
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is names... |
import the environment variables from the 'docker-registry-secret' secret and apply them to the 'backend-microservice-deployment' deployment | Command:
```bash
kubectl set env --from=secret/docker-registry-secret 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 definitions ... |
Copy the local file `/tmp/foo` to the remote pod `kube-proxy/cache-pod-5` in the `/tmp/bar` directory. | Command:
```bash
kubectl cp :/tmp/foo kube-proxy/cache-pod-5:/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 kubectl.ku... |
Begin streaming the logs of the 'nebula-navigator' container in the 'monitoring-pod' pod. | Command:
```bash
kubectl logs -f -c nebula-navigator monitoring-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container... |
Create a new config map named db-config using the files /path/to/parameters/file1.txt and /path/to/settings/file2.txt | Command:
```bash
kubectl create configmap db-config --from-file=conf=/path/to/parameters/file1.txt --from-file=data=/path/to/settings/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a conf... |
Create a deployment named 'web' with 4 replicas that runs the 'ethereum/client-go' image | Command:
```bash
kubectl create deployment web --image=ethereum/client-go --replicas=4
```
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.... |
set the cluster field of a context to a specific cluster | Command:
```bash
kubectl config set contexts.local-context.cluster kube-cluster-1
```
What it does:
Set an individual value in a kubeconfig file.
PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.
PROPERTY_VALUE is the new value you ... |
Expose a replica set as a service, serving on port 8089 and connecting to the containers on port 8000. | Command:
```bash
kubectl expose rs node --port=8089 --target-port=8000
```
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 d... |
View the logs from container "user-management-deployment-1" in the deployment named "backend-pod" | Command:
```bash
kubectl logs deployment/user-management-deployment -c backend-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:
"fl... |
Create a deployment named 'proxy' with the 'mcr.microsoft.com/dotnet/core/runtime' image and 5 replicas | Command:
```bash
kubectl create deployment proxy --image=mcr.microsoft.com/dotnet/core/runtime --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": "", "us... |
set resource limits for a deployment's container | Command:
```bash
kubectl set resources deployment redis -c=nginx --limits=cpu=2,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... |
Forward local traffic on port 3000 to port 6379 in the 'chat-app-pod' pod | Command:
```bash
kubectl port-forward pod/chat-app-pod 3000 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 autom... |
Create an ingress called 'api-gateway-ingress' that directs requests to site.com/module to a service named svc1:8181 with a TLS secret named "my-cert". | Command:
```bash
kubectl create ingress api-gateway-ingress --rule="site.com/module=svc1:8181,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": "", "... |
Delete the pods and services with the names "proxy" and "chat-app" | Command:
```bash
kubectl delete pod,service proxy chat-app
```
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.
... |
Create a new deployment named drupal using the nginx image, and expose port 8443 | Command:
```bash
kubectl create deployment drupal --image=nginx --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": "", "usage": "Output format. One of: js... |
Import the environment variables from a secret into a deployment | Command:
```bash
kubectl set env --from=secret/ssh-key-secret deployment/search-engine-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more ... |
Create a new secret named gcp-service-account-secret by including keys from each file in the folder bar. | Command:
```bash
kubectl create secret generic gcp-service-account-secret --from-file=path/to/configurations
```
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... |
Create a new ExternalName service named external-messaging-service that points to a specified external name or domain | Command:
```bash
kubectl create service externalname external-messaging-service --external-name dummy-website.io
```
What it does:
Create an ExternalName service with the specified name.
ExternalName service references to an external DNS address instead of only pods, which will allow application authors to reference s... |
Auto scale the replication controller "vpn" with the number of pods between 1 and 2 based on the CPU utilization target of 81%. | Command:
```bash
kubectl autoscale rc vpn --max=2 --cpu-percent=81
```
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... |
Return the snapshot logs from the container scheduler-app-deployment-1 of the deployment named vpn-service-pod | Command:
```bash
kubectl logs deployment/scheduler-app-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 deployment named sonarqube with the jenkins image and expose port 9092 | Command:
```bash
kubectl create deployment sonarqube --image=jenkins --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. One o... |
Forward local port 6379 to pod port 5000 for the "mypod" pod | Command:
```bash
kubectl port-forward pod/mypod 6379 5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automaticall... |
Create a cluster role named "reader" with the ability to patch pods and with specific resource names. | Command:
```bash
kubectl create clusterrole reader --verb=patch --resource=pods --resource-name=file-uploader --resource-name=app-worker-2
```
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... |
Remove the 'description' annotation from the pod 'chat-app' if it exists | Command:
```bash
kubectl annotate pods chat-app description-
```
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 string... |
Execute the command `pg_dump --version` in the container named "warp-drive" within the pod named "log-aggregator-pod" and retrieve the output. | Command:
```bash
kubectl exec log-aggregator-pod -c warp-drive -- pg_dump --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... |
Taint a node with a specific label | Command:
```bash
kubectl taint node -l cluster=my-cluster app=db-node-7:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Ou... |
Create a job named "cleanup" with the image "node" and the command "node --version" | Command:
```bash
kubectl create job cleanup --image=node -- node --version
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One... |
Create an ingress called 'website-ingress' that directs requests from foo.com/module to a service named svc1 on port 5432 | Command:
```bash
kubectl create ingress website-ingress --rule="foo.com/module=svc1:5432,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage... |
Start a MongoDB pod using a specific command and custom arguments | Command:
```bash
kubectl run nginx --image=mongo --command -- <cmd> <arg1> ... <argN>
```
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... |
Create a new secret named 'git-credentials-secret' using the files located at 'path/to/preferences'. | Command:
```bash
kubectl create secret generic git-credentials-secret --from-file=path/to/preferences
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, the key will default to the ba... |
Create a new secret named api-secret-key from the environment variables in the data.env file | Command:
```bash
kubectl create secret generic api-secret-key --from-env-file=path/to/data.env
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, the key will default to the basename ... |
Create a copy of the "chat-app-pod" pod and change the command to "sh" for the "code-explorer" container, then enter the debug session in the copied pod | Command:
```bash
kubectl debug chat-app-pod -it --copy-to=debug-image-1 --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 defa... |
Delete the pods and services with the same names "email" and "email" | Command:
```bash
kubectl delete pod,service email email
```
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... |
List all the allowed actions in the "default" namespace. | Command:
```bash
kubectl auth can-i --list --namespace=default
```
What it does:
Check whether an action is allowed.
VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is a partial URL that starts with "... |
Copy the kubeconfig file from a remote pod to a local directory. | Command:
```bash
kubectl cp velero/api-server-pod-3:~/.config/kube /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... |
Create a config map named log-config from an environment file. | Command:
```bash
kubectl create configmap log-config --from-env-file=path/to/settings.env
```
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 ba... |
Set the service account for a deployment to a specific value | Command:
```bash
kubectl set serviceaccount deployment mydeployment 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:
`kubectl se... |
Create a new deployment named 'grafana' using the 'golang' image, and expose port 7000 | Command:
```bash
kubectl create deployment grafana --image=golang --port=7000
```
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: ... |
Set a custom TLS server name for the kube-cluster-1 cluster entry. | Command:
```bash
kubectl config set-cluster kube-cluster-1 --tls-server-name=web-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... |
Copy the ~/.config/kube directory from a remote pod to /etc/kubernetes on the local machine. | Command:
```bash
kubectl cp kube-flannel/admin-dashboard-pod-16:~/.config/kube /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 om... |
Return snapshot logs from container "email-service-pod-1" of a deployment named "user-management-deployment" | Command:
```bash
kubectl logs deployment/user-management-deployment -c email-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 flag... |
Create a new ExternalName service named external-email-service with the external name example-domain.com | Command:
```bash
kubectl create service externalname external-email-service --external-name example-domain.com
```
What it does:
Create an ExternalName service with the specified name.
ExternalName service references to an external DNS address instead of only pods, which will allow application authors to reference ser... |
Expose a service for a replicated wordpress app, serving on port 5000 and connecting to the containers on port 637900. | Command:
```bash
kubectl expose rc wordpress --port=5000 --target-port=637900
```
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... |
Set the resource request and limits for all containers in the hazelcast deployment | Command:
```bash
kubectl set resources deployment hazelcast --limits=cpu=200m,memory=512Mi --requests=cpu=50m,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 req... |
Embed the certificate authority data for the "prod-cluster" cluster entry. | Command:
```bash
kubectl config set-cluster prod-cluster --embed-certs --certificate-authority=~/.kube/cluster-alpha/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... |
Create a priority class named "background-priority" with a value of 1, a description of "Low priority, minimal impact", and a preemption policy set to "Never". | Command:
```bash
kubectl create priorityclass background-priority --value=1 --description="Low priority, minimal impact" --preemption-policy="Never"
```
What it does:
Create a priority class with the specified name, value, globalDefault and description.
Syntax:
`kubectl create priorityclass NAME --value=VALUE --globa... |
Create a debug container in the security-service-pod, using the 'debian' image and copying it to 'dgb-img' | Command:
```bash
kubectl debug security-service-pod -it --copy-to=dgb-img --image=debian --set-image=mailer=mailer:latest,scheduler=my-scheduler:1.0
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by... |
Execute the 'geth' command in the 'nano-bot' container of the 'chat-app-pod' pod and get the output. | Command:
```bash
kubectl exec chat-app-pod -c nano-bot -- 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 the kub... |
Create a service based on the specifications in the "node-controller.yaml" file, which will serve on port 5432 and connect to the containers on port 8888. | Command:
```bash
kubectl expose -f node-controller.yaml --port=5432 --target-port=888800
```
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... |
Forward port 6379 of a pod to all addresses on the local machine | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/mypod 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 sel... |
Copy the file /tmp/foo from the remote pod rook-ceph/image-resizer-pod-20 to the /etc/kubernetes directory on the local machine. | Command:
```bash
kubectl cp rook-ceph/image-resizer-pod-20:/tmp/foo /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, use ... |
Create a service for the replication controller specified in "wordpress-controller.yaml" | Command:
```bash
kubectl expose -f wordpress-controller.yaml --port=9090 --target-port=900000
```
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 ... |
execute 'docker run ubuntu echo "Hello, World"' command in the first container of the api-service pod and get the output | Command:
```bash
kubectl exec svc/api-service -- docker run ubuntu echo "Hello, World"
```
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.... |
Use a specific editor to edit the configuration of a service | Command:
```bash
KUBE_EDITOR="nvim" kubectl edit svc/payment-service
```
What it does:
Edit a resource from the default editor.
The edit command allows you to directly edit any API resource you can retrieve via the command-line tools. It will open the editor defined by your KUBE_EDITOR, or EDITOR environment variables... |
Create a cron job named "system-health-check" that runs the command "elasticsearch-plugin --list" every minute using the specified image. | Command:
```bash
kubectl create cronjob system-health-check --image=docker.elastic.co/elasticsearch/elasticsearch --schedule="*/1 * * * *" -- elasticsearch-plugin --list
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND... |
Return the snapshot logs from the container named backend-pod-1 of the api-server-deployment deployment. | Command:
```bash
kubectl logs deployment/api-server-deployment -c backend-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": ... |
Create a service for a replication controller specified in "wordpress-controller.yaml" file, which serves on port 80 and connects to the containers on port 8000. | Command:
```bash
kubectl expose -f wordpress-controller.yaml --port=80 --target-port=800000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on th... |
List deployments in YAML output format, using the "alpha-2.0" version of the "extensions" API group. | Command:
```bash
kubectl get deployments.alpha-2.0.extensions -o yaml
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you w... |
Set the service account of the cache-cluster-deployment deployment to "dashboard" | Command:
```bash
kubectl set serviceaccount deployment cache-cluster-deployment dashboard
```
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:
`ku... |
Update the annotation 'owner' of the pod 'web' with the value 'alice smith' | Command:
```bash
kubectl annotate pods web owner='alice smith'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include arbitrary stri... |
Autoscale the deployment "email" with a minimum of 6 pods and a maximum of 12 pods | Command:
```bash
kubectl autoscale deployment email --min=6 --max=12
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that uses t... |
Set the cluster field in the dev-context context to web-cluster | Command:
```bash
kubectl config set contexts.dev-context.cluster web-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 want ... |
Delete the pods and services with the names "security" and "proxy" | Command:
```bash
kubectl delete pod,service security proxy
```
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.
... |
Retrieve the snapshot logs from the payment-gateway-pod, which has only one container. | Command:
```bash
kubectl logs 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": "--container", "short": "-c", ... |
Import the 'redis_host' key from the 'env-vars' config map and set it as an environment variable for the 'proxy-service-deployment' deployment. | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/env-vars 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 definitions ... |
Create a copy of analytics-pod with changed container images to php | Command:
```bash
kubectl debug analytics-pod --copy-to=debug-image-app --set-image=*=php
```
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 resou... |
Create a new config map named "app-config" from the environment variables defined in the "profiles.env" file | Command:
```bash
kubectl create configmap app-config --from-env-file=path/to/profiles.env
```
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 ba... |
Listen on port 5432 locally, forwarding data to/from port 5000 in the security-service-pod. | Command:
```bash
kubectl port-forward pod/security-service-pod 5432 5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be select... |
Import the 'external_api_url' key from the 'monitoring-config' ConfigMap into the 'user-management-deployment' Deployment. | Command:
```bash
kubectl set env --keys=external_api_url --from=configmap/monitoring-config 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 vari... |
List deployments in JSON output format for the "v3.0.0" version of the "external-apps" API group. | Command:
```bash
kubectl get deployments.v3.0.0.external-apps -o json
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you w... |
import the 'LOG_LEVEL' key from the 'global-config' config map and set it as an environment variable in the 'scheduler-app-deployment' deployment | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/global-config 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 new ExternalName service named external-dns-service with the external name demo-service.dev. | Command:
```bash
kubectl create service externalname external-dns-service --external-name demo-service.dev
```
What it does:
Create an ExternalName service with the specified name.
ExternalName service references to an external DNS address instead of only pods, which will allow application authors to reference service... |
Create a new config map named app-name-config and populate it with specified keys and file paths on disk | Command:
```bash
kubectl create configmap app-name-config --from-file=properties=/path/to/preferences/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 cr... |
Update the annotation of pod 'payment'with the value 'https, overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods payment git-repo='https://github.com/example/my-app'
```
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 larg... |
Update the 'web-node-8' node by setting the 'unschedulable' field to true. | Command:
```bash
kubectl patch node web-node-8 -p '{"spec":{"unschedulable":true}}'
```
What it does:
Update fields of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.
JSON and YAML formats are accepted.
Syntax:
`kubectl patch (-f FILENAME | TYPE NAME) [-p PATCH|--patch-file FILE]`
Helpfu... |
Create a service for the replicated 'ubuntu' resource, which serves on port 3001 and connects to the containers on port 909100 | Command:
```bash
kubectl expose rc ubuntu --port=3001 --target-port=909100
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port.... |
Create a service for the 'nginx' deployment, serving on port 5001 and connecting to the containers on port 801000. | Command:
```bash
kubectl expose deployment nginx --port=5001 --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 specifie... |
Create a new config map named 'log-config' using the key=value pairs found in the file located at 'path/to/preferences'. | Command:
```bash
kubectl create configmap log-config --from-file=path/to/preferences
```
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 basenam... |
Create a job named "log-processing-job" with the image "mongo". The job will run the command "mongo --version". | Command:
```bash
kubectl create job log-processing-job --image=mongo -- mongo --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": "Outpu... |
Create a new NodePort service named 'e-commerce-nodeport' that maps port 9092 on the node to port 5000 on the service. | Command:
```bash
kubectl create service nodeport e-commerce-nodeport --tcp=9092: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", "default": ... |
Update the pod 'database' with the annotation 'team' and the value 'frontend-team', overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods database 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 incl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.