prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Add a taint with the key 'environment' and value 'app-node-6:PreferNoSchedule' on all nodes having the label 'myLabel' | Command:
```bash
kubectl taint node -l myLabel environment=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": "Outp... |
Forward port 5432 on your localhost and IP 10.19.21.23 to port 8081 in the pod named "analytics-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/analytics-pod 5432:8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the crite... |
Delete pods and services named "chat-app" and "analytics" | Command:
```bash
kubectl delete pod,service chat-app analytics
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label select... |
Create a job named "security-scan-job" using the Amazon Linux image, and run the command "bash" inside the job container. | Command:
```bash
kubectl create job security-scan-job --image=amazonlinux -- bash
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output form... |
Copy the /var/run/secrets/kubernetes.io/serviceaccount/ file from the local machine to the /tmp/bar directory in the front-end-pod-12 pod, specifically in the metrics-exporter container. | Command:
```bash
kubectl cp /var/run/secrets/kubernetes.io/serviceaccount/ front-end-pod-12::/tmp/bar -c metrics-exporter
```
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... |
Create a deployment named jenkins-x using the ruby image and expose port 8081 | Command:
```bash
kubectl create deployment jenkins-x --image=ruby --port=8081
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: ... |
Create a role named "custom_role" with ResourceName specified | Command:
```bash
kubectl create role custom_role --verb=update --resource=pods --resource-name=file-processing --resource-name=search-elasticsearch
```
What it does:
Create a role with single rule.
Syntax:
`kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dr... |
Set a custom TLS server name for the "sun-cluster" cluster entry. | Command:
```bash
kubectl config set-cluster sun-cluster --tls-server-name=cluster-gamma
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-cluster NAME [--server=server] [--certificate... |
Start a pod named "hazelcast" using the "postgres" image, and set the environment variables "DNS_DOMAIN=cluster" and "POD_NAMESPACE=default" in the container. | Command:
```bash
kubectl run hazelcast --image=postgres --env="DNS_DOMAIN=cluster" --env="POD_NAMESPACE=default"
```
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 new config map named app-config-dev using the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-config-dev --from-file=properties=/path/to/properties/file1.txt --from-file=key1=/path/to/parameters/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When cr... |
Create a deployment named "ingress" using the "golang" image and expose port 8000. | Command:
```bash
kubectl create deployment ingress --image=golang --port=8000
```
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: ... |
import specific keys from a config map into the environment variables of a deployment | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/env-vars deployment/frontend-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one... |
Create an ingress called 'default-ingress' to route requests from "testing.com/example" to "svc1:8443" using the TLS secret "my-cert" | Command:
```bash
kubectl create ingress default-ingress --rule="testing.com/example=svc1:8443,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 with a command and specify the image and command to be executed | Command:
```bash
kubectl create job data-migration-job --image=mcr.microsoft.com/dotnet/core/runtime -- dotnet --list-runtimes
```
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... |
Display only the most recent 12 lines of output for the monitoring-pod pod | Command:
```bash
kubectl logs --tail=12 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", "short": "... |
Create a golang pod named 'hazelcast' with the 'golang' image and expose port 9091 | Command:
```bash
kubectl run hazelcast --image=golang --port=9091
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--f... |
Execute the command "kubectl exec deploy/frontend-deployment -- npm --version" to get the output of the 'npm --version' command from the first container of the frontend-deployment deployment. | Command:
```bash
kubectl exec deploy/frontend-deployment -- npm --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 omitted, ... |
Get the output from running the 'pip --version' command in the first container of the analytics-platform-deployment deployment. | Command:
```bash
kubectl exec deploy/analytics-platform-deployment -- pip --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... |
Set the cluster field in the admin-context context to data-cluster | Command:
```bash
kubectl config set contexts.admin-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... |
Display the logs of the astro-container container from the previously terminated pod named proxy-service-pod | Command:
```bash
kubectl logs -p -c astro-container proxy-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": "--contain... |
Describe the worker-node-1.k8s-cluster.local node. | Command:
```bash
kubectl describe nodes worker-node-1.k8s-cluster.local
```
What it does:
Show details of a specific resource or group of resources.
Print a detailed description of the selected resources, including related resources such as events or controllers. You may select a single object by name, all objects of ... |
Listen on ports 6379 and 6000 locally, forwarding data to/from ports 8088 and 6000 in a pod selected by the 'mydeployment' deployment. | Command:
```bash
kubectl port-forward deployment/mydeployment 6379 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 selecte... |
Copy the local file "/tmp/foo" to the remote pod "front-end-pod-12" in the "prometheus" namespace, and place it at "/tmp/bar". | Command:
```bash
kubectl cp :/tmp/foo prometheus/front-end-pod-12:/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 kubec... |
Output the modified deployment in YAML format for the 'order-processing-deployment', by setting the 'GOOGLE_API_KEY' environment variable to 'your-google-api-key' | Command:
```bash
kubectl set env deployment/order-processing-deployment GOOGLE_API_KEY=your-google-api-key -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 definition... |
Partially update the 'monitoring-node-15' node by specifying the 'replicas' value as 3 using a strategic merge patch in JSON format. | Command:
```bash
kubectl patch node monitoring-node-15 -p '{"spec":{"replicas":3}'
```
What it does:
Update fields of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.
JSON and YAML formats are accepted.
Syntax:
`kubectl patch (-f FILENAME | TYPE NAME) [-p PATCH|--patch-file FILE]`
Helpful... |
Create a debug pod with the same configuration as the security-service-pod, but with the command of cyber-sleuth. | Command:
```bash
kubectl debug security-service-pod -it --copy-to=debug-image-1 --container=cyber-sleuth -- 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 ... |
Create an ingress called 'public-service-ingress' that directs requests to website.com/example to svc1:8010 with a tls secret named "my-cert" | Command:
```bash
kubectl create ingress public-service-ingress --rule="website.com/example=svc1:8010,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default"... |
Create a new secret named gcp-service-account-secret with keys for each file in the path/to/data folder | Command:
```bash
kubectl create secret generic gcp-service-account-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 basen... |
Create a Pod Disruption Budget (PDB) named "payment-gateway-pdb" that selects pods with the label "project=my-project" and requires a minimum of 9 of those pods to be available at all times. | Command:
```bash
kubectl create poddisruptionbudget payment-gateway-pdb --selector=project=my-project --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-ava... |
Add a taint with key 'app' on nodes that have the label 'app-type=microservice', specifically on the 'worker-node-3' node, and set it to 'PreferNoSchedule'. | Command:
```bash
kubectl taint node -l app-type=microservice app=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": "", "usag... |
Display the most recent 31 lines of logs for the 'analytics-pod' pod | Command:
```bash
kubectl logs --tail=31 analytics-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": "-... |
Get the output from running the 'irb' command in the 'nebula-navigator' container of the 'cdn-service-pod' pod. | Command:
```bash
kubectl exec cdn-service-pod -c nebula-navigator -- irb
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, u... |
Create a new ClusterIP service named api-service-clusterip with the TCP port mapping of 9090:8088 | Command:
```bash
kubectl create service clusterip api-service-clusterip --tcp=9090:8088
```
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... |
Create a single ingress called 'app-ingress' that directs requests from 'foo.com/bar' to the 'svc1' service on port 8181 | Command:
```bash
kubectl create ingress app-ingress --rule="foo.com/bar=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": "", "usage": "Out... |
Create a deployment named wordpress with the golang image and 2 replicas | Command:
```bash
kubectl create deployment wordpress --image=golang --replicas=2
```
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... |
List the rc/web, service/proxy-server-rc, and pods/payment-gateway-pod resources. | Command:
```bash
kubectl get rc/web service/proxy-server-rc pods/payment-gateway-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 n... |
Start a pod named "hazelcast" using the specified Elasticsearch image, and expose port 8080 on the container. | Command:
```bash
kubectl run hazelcast --image=docker.elastic.co/elasticsearch/elasticsearch --port=8080
```
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] ... |
Create a new generic secret named oauth-secret using the ssh-privatekey and ssh-publickey files located at path/to/id_rsa and path/to/id_rsa.pub respectively. | Command:
```bash
kubectl create secret generic oauth-secret --from-file=ssh-privatekey=path/to/id_rsa --from-file=ssh-publickey=path/to/id_rsa.pub
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret ba... |
Output the modified 'notification-handler-deployment' deployment in YAML format with the 'ENV' environment variable set to 'prod', without making any changes to the object on the server. | Command:
```bash
kubectl set env deployment/notification-handler-deployment ENV=prod -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 t... |
Update the environment variables of the "monitoring-stack-deployment" deployment by importing the "SECRET_KEY" key from the "ui-config" config map. | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/ui-config deployment/monitoring-stack-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... |
Forward local port 3000 to port 8088 in the pod, for the frontend-pod pod | Command:
```bash
kubectl port-forward pod/frontend-pod 3000 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 autom... |
Get the documentation for the "podIP" field in the "status" section of the "configmaps" resource. | Command:
```bash
kubectl explain resource=configmaps.status.podIP
```
What it does:
List the fields for supported resources.
This command describes the fields associated with each supported API resource. Fields are identified via a simple JSONPath identifier:
<type>.<fieldName>[.<fieldName>]
Add the --recursive flag t... |
Copy the contents of /tmp/foo_dir directory from the 'file-server-pod-14' pod in the 'monitoring' namespace to the /tmp/bar directory on your local machine. | Command:
```bash
kubectl cp monitoring/file-server-pod-14:/tmp/foo_dir /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 ... |
Forward traffic from port 3000 on all addresses to port 5432 in the backend-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/backend-pod 3000: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 ... |
Create an ingress with multiple hosts and the pathType as Prefix. | Command:
```bash
kubectl create ingress ingress1 --class=default \
--rule="site.com/path*=svc:5000" \
--rule="module.com/admin*=svc2:http"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output",... |
Start streaming the logs of the 'lunar-launcher' container in the 'web-app-pod' pod. | Command:
```bash
kubectl logs -f -c lunar-launcher 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", "s... |
Add a taint with key 'hardware' and no value to the node 'app-node-6' | Command:
```bash
kubectl taint nodes app-node-6 hardware: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... |
Forward local port 3000 to port 3000 of the pod "cdn-service-pod" | Command:
```bash
kubectl port-forward pod/cdn-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 selected au... |
Import the values of specific keys from a ConfigMap into the environment variables of a deployment | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/db-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 variable definitio... |
Create a copy of the 'vpn-service-pod' pod and change all container images to 'mcr.microsoft.com/dotnet/core/runtime' | Command:
```bash
kubectl debug vpn-service-pod --copy-to=my-debugger --set-image=*=mcr.microsoft.com/dotnet/core/runtime
```
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 wil... |
Import the MAX_CONNECTIONS key from the app-config config map and set it as an environment variable in the authentication-service-deployment deployment. | Command:
```bash
kubectl set env --keys=MAX_CONNECTIONS --from=configmap/app-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 varia... |
Create a secret named ldap-credentials-secret with specified keys as files | Command:
```bash
kubectl create secret generic ldap-credentials-secret --from-file=ssh-privatekey=path/to/id_rsa --from-file=ssh-publickey=path/to/id_rsa.pub
```
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 ... |
Update the 'gateway' pod with the annotation 'scaling-policy' and the value 'auto-horizontal-scaling' | Command:
```bash
kubectl annotate pods gateway scaling-policy=auto-horizontal-scaling
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and... |
Update the annotation 'app-version' of the pod 'cdn' to '2.5.1', overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods cdn 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 ar... |
Add a taint with key 'workload' on nodes having label customer=acme-corp | Command:
```bash
kubectl taint node -l customer=acme-corp workload=backup-node-14: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": "", "u... |
Set the CPU limits of the "alpine" container in the deployment to 1 and the memory limits to 512Mi. | Command:
```bash
kubectl set resources deployment alpine -c=nginx --limits=cpu=1,memory=512Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to i... |
Remove the "client-secret" configuration value for the OpenID Connect authentication provider for the "prod-user" entry. | Command:
```bash
kubectl config set-credentials prod-user --auth-provider=oidc --auth-provider-arg=client-secret-
```
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:
--client-certificate=certfile --client-k... |
Create an Ingress resource named 'api-v2-ingress' that routes requests from testing.com/input to the service named 'svc1' on port 8443, using the TLS secret named 'my-cert' | Command:
```bash
kubectl create ingress api-v2-ingress --rule="testing.com/input=svc1:8443,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": "", "usa... |
Update the image of all deployments and replica sets' nginx container to 'alpine:3.14' | Command:
```bash
kubectl set image deployments,rc alpine=alpine:3.14 --all
```
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)
Synta... |
Create a deployment named monitoring with the docker.elastic.co/elasticsearch/elasticsearch image and expose port 8000 | Command:
```bash
kubectl create deployment monitoring --image=docker.elastic.co/elasticsearch/elasticsearch --port=8000
```
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", "defau... |
Update the pod 'backend' by setting the annotation 'criticality' to 'high', replacing any existing value. | Command:
```bash
kubectl annotate --overwrite pods backend criticality='high'
```
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... |
Set the service account of the 'backend-microservice-deployment' deployment to 'kube-scheduler'. | Command:
```bash
kubectl set serviceaccount deployment backend-microservice-deployment kube-scheduler
```
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
... |
Mark the node "kube-master-9" as schedulable | Command:
```bash
kubectl uncordon kube-master-9
```
What it does:
Mark node as schedulable.
Syntax:
`kubectl uncordon NODE`
Helpful flags:
"flag": "--selector", "short": "-l", "default": "", "usage": "Selector (label query) to filter on " |
Add a taint with key 'cpu-type' on nodes having label release=beta | Command:
```bash
kubectl taint node -l release=beta cpu-type=backup-node-14: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":... |
Expose a deployment as a service with specific port configurations | Command:
```bash
kubectl expose deployment php --port=8181 --target-port=543200
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified ... |
Set the CPU limits of the go container in the deployment named "go" to "50m" and the memory limits to "128Mi" | Command:
```bash
kubectl set resources deployment go -c=nginx --limits=cpu=50m,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... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=api_key --from=configmap/env-vars deployment/mydeployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more ... |
Open and edit the configuration of a service using the Sublime editor | Command:
```bash
KUBE_EDITOR="sublime" kubectl edit svc/order-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 variable... |
Create a pod disruption budget named payment-gateway-pdb that will select all pods with the component=web label and require a minimum of 9 of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget payment-gateway-pdb --selector=component=web --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-availabl... |
import the DATABASE_URL key from the monitoring-config config map and set it as an environment variable in the load-balancer-deployment deployment | Command:
```bash
kubectl set env --keys=DATABASE_URL --from=configmap/monitoring-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 d... |
Create a copy of the "security-service-pod" by adding a debug container and changing container images | Command:
```bash
kubectl debug security-service-pod -it --copy-to=debug-image-web --image=debian --set-image=api=api:v2,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 resourc... |
Create a pod disruption budget named critical-services-pdb that will select all pods with the role=worker label and require at least one of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget critical-services-pdb --selector=role=worker --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-availabl... |
List deployments in JSON output format of the "v1.0.0" version in the "mobile-apps" API group. | Command:
```bash
kubectl get deployments.v1.0.0.mobile-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 wil... |
show the resource usage metrics for the cdn-service-pod and its containers | Command:
```bash
kubectl top pod cdn-service-pod --containers
```
What it does:
Display resource (CPU/memory) usage of pods.
The 'top pod' command allows you to see the resource consumption of pods.
Due to the metrics pipeline delay, they may be unavailable for a few minutes since pod creation.
Syntax:
`kubectl top p... |
Update the pod named 'vpn' with the label 'role' and the value 'cache' | Command:
```bash
kubectl label pods vpn role=cache
```
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 tru... |
Listen on port 6379 on your local machine and forward the traffic to port 9090 in the 'mypod' pod | Command:
```bash
kubectl port-forward pod/mypod 6379: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 automaticall... |
Create a copy of the backend pod and change all container images to "mongo" | Command:
```bash
kubectl debug backend-pod --copy-to=debug-image-memcached --set-image=*=mongo
```
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... |
Set the resource request and limits for all containers in the 'redis' deployment | Command:
```bash
kubectl set resources deployment redis --limits=cpu=200m,memory=512Mi --requests=cpu=50m,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... |
Forward local traffic from port 5000 to port 5432 in a pod selected by the "api-server-deployment" deployment. | Command:
```bash
kubectl port-forward deployment/api-server-deployment 5000 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 b... |
Import environment variables from a config map with a specific prefix | Command:
```bash
kubectl set env --from=configmap/db-config --prefix=MYSQL_ deployment/mydeployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or mor... |
Create a service for a replicated php using replica set, serving on port 8443 and connecting to the containers on port 8888 | Command:
```bash
kubectl expose rs php --port=8443 --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 specified port. A ... |
Begin streaming the logs of the nano-bot container in the mypod pod | Command:
```bash
kubectl logs -f -c nano-bot mypod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "short": "-c",... |
Create a new config map named log-config using the files file1.txt and file2.txt | Command:
```bash
kubectl create configmap log-config --from-file=settings=/path/to/configs/file1.txt --from-file=key2=/path/to/preferences/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a... |
Forward traffic from port 9090 on all addresses to port 5432 in the analytics-pod pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/analytics-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 wil... |
Create a single ingress called 'public-ingress' that directs requests to website.com/module to a service called 'svc1' running on port 8010, and configure it to use the TLS secret named "my-cert". | Command:
```bash
kubectl create ingress public-ingress --rule="website.com/module=svc1:8010,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "us... |
Check if you have permission to list the job named "data-synchronization-job" in the namespace "testing" | Command:
```bash
kubectl auth can-i list jobs.batch/data-synchronization-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 parti... |
Change the cluster field of the local-context to cluster-alpha | Command:
```bash
kubectl config set contexts.local-context.cluster cluster-alpha
```
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 w... |
Add a taint with the key 'datacenter' on nodes that have the label 'myLabel'. | Command:
```bash
kubectl taint node -l myLabel 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": "Outpu... |
Forward traffic from local port 3000 to port 8888 in the pod named "security-service-pod" | Command:
```bash
kubectl port-forward pod/security-service-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 will be select... |
Create a pod named "hazelcast" using the Redis image and expose port 5432. | Command:
```bash
kubectl run hazelcast --image=redis --port=5432
```
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... |
compare the configuration in the given file with the current state in Kubernetes | Command:
```bash
cat pod.json | kubectl diff -f -
```
What it does:
Diff configurations specified by file name or stdin between the current online configuration, and the configuration as it would be if applied.
The output is always YAML.
KUBECTL_EXTERNAL_DIFF environment variable can be used to select your own diff co... |
Get the output of running the 'mongo' command in the nano-bot container from the email-service-pod. | Command:
```bash
kubectl exec email-service-pod -c nano-bot -- mongo
```
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 t... |
Forward connections to port 3000 on localhost and IP address 10.19.21.23 to port 8000 in the log-aggregator-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/log-aggregator-pod 3000: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 ... |
Forward localhost ports 8000 and 6000 to the selected pod's ports 8080 and 6000 in the 'monitoring-stack-deployment' deployment. | Command:
```bash
kubectl port-forward deployment/monitoring-stack-deployment 8000 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 ... |
Create a copy of the "payment-gateway-pod" by adding a debug container and changing container images. | Command:
```bash
kubectl debug payment-gateway-pod -it --copy-to=debug-image-memcached --image=debian --set-image=logger=logging-app:debug,worker=my-custom-worker:1.2.3
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster o... |
Copy the contents of the local file '/var/run/secrets/kubernetes.io/serviceaccount/' to the directory '/tmp/bar_dir' in the remote pod 'database-pod-2' in the 'velero' namespace. | Command:
```bash
kubectl cp /var/run/secrets/kubernetes.io/serviceaccount/ velero/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": "Contai... |
Retrieve the logs from container monitoring-stack-deployment-1 from the deployment named media-stream-pod. | Command:
```bash
kubectl logs deployment/monitoring-stack-deployment -c media-stream-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... |
Retrieve the snapshot logs from the container "web-app-pod-1" of the deployment "user-management-deployment". | Command:
```bash
kubectl logs deployment/user-management-deployment -c web-app-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... |
Copy the directory "/var/run/secrets/kubernetes.io/serviceaccount/" from the "load-balancer-pod-9" pod in the "rook-ceph" namespace to the "/tmp/bar_dir" directory locally. | Command:
```bash
kubectl exec -n rook-ceph load-balancer-pod-9 -- tar cf - /var/run/secrets/kubernetes.io/serviceaccount/ | tar xf - -C /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"... |
Create a copy of the proxy-service-pod pod and change all containers' images to centos | Command:
```bash
kubectl debug proxy-service-pod --copy-to=dgb-img --set-image=*=centos
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by default if no resour... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.