prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Add an annotation to the 'auth' pod with the key 'env' and the value 'staging' | Command:
```bash
kubectl annotate pods auth env=staging
```
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 valu... |
Get output from the 'nano-bot' container in the 'database-pod' pod | Command:
```bash
kubectl attach database-pod -c nano-bot
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use th... |
Get the output of running the 'composer --version' command in the 'rocket-ranger' container of the 'web-app-pod' pod. | Command:
```bash
kubectl exec web-app-pod -c rocket-ranger -- composer --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 om... |
Create a new ClusterIP service named "database-service-clusterip" with TCP ports 8080 and 8181 | Command:
```bash
kubectl create service clusterip database-service-clusterip --tcp=8080:8181
```
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... |
Import environment variables from a secret into a deployment | Command:
```bash
kubectl set env --from=secret/app-config-secret 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 definitions in one or mor... |
Retrieve the logs from the first container of the 'certificates-renewal-job' job. | Command:
```bash
kubectl logs job/certificates-renewal-job
```
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 cluster role named "custom_role" with the ability to connect and access configmaps resources with the resource names "dashboard-ui" and "staging-app-server" | Command:
```bash
kubectl create clusterrole custom_role --verb=connect --resource=configmaps --resource-name=dashboard-ui --resource-name=staging-app-server
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run... |
Copy the file "/tmp/foo" from the "admin-dashboard-pod-16" pod in the "kube-public" namespace to the local directory "/tmp/bar" | Command:
```bash
kubectl cp kube-public/admin-dashboard-pod-16::/tmp/foo /tmp/bar
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use th... |
Create a copy of the 'e-commerce-pod' pod and add a debug container to it | Command:
```bash
kubectl debug e-commerce-pod -it --copy-to=debug-image-web --image=debian --set-image=cache=redis:alpine,proxy=nginx:1.21
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource ... |
Update the service account of the database-deployment deployment to my-service-account. | Command:
```bash
kubectl set serviceaccount deployment database-deployment my-service-account
```
What it does:
Update the service account of pod template resources.
Possible resources (case insensitive) can be:
replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset
Syntax:... |
Get the version of node running in the first pod of the payment-processor-deployment. | Command:
```bash
kubectl exec deploy/payment-processor-deployment -- node --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... |
Create a copy of the 'monitoring-pod' with a debug container and different container images: set the 'debug-image-app' image to 'debian', and change the 'cache' container image to 'redis:alpine' | Command:
```bash
kubectl debug monitoring-pod -it --copy-to=debug-image-app --image=debian --set-image=cache=redis:alpine,cache=redis:alpine
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resourc... |
Forward local port 3000 to port 5432 in the pod named "api-service-pod" in order to access the service running on that port. | Command:
```bash
kubectl port-forward pod/api-service-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 be selected au... |
Create an ingress named 'default-ingress' with a rule that directs requests to 'website.com/bar' to the 'svc1' service on port 8000, using the TLS secret named "my-cert". | Command:
```bash
kubectl create ingress default-ingress --rule="website.com/bar=svc1:8000,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
Remove label 'env' from pod 'foo' if it exists | Command:
```bash
kubectl label pods foo env-
```
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 true, che... |
Forward traffic from port 8000 on all addresses to port 8000 in the analytics-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/analytics-pod 8000:8000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod wil... |
Check if the current user has authorization to list the "content-import-job" job in the "kube-node-lease" namespace. | Command:
```bash
kubectl auth can-i list jobs.batch/content-import-job -n kube-node-lease
```
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 par... |
set the environment variable 'PORT' to '8080' for the 'scheduler-app-deployment' deployment | Command:
```bash
kubectl set env deployment/scheduler-app-deployment PORT=8080
```
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 templates (with... |
Update the annotation 'criticality' of the pod 'web' with the value 'high', overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods web 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 arb... |
Copy the local directory `~/.config/kube_dir` to the remote pod `image-resizer-pod-20` 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 the... |
Apply a strategic merge patch to the prod-node-5 node, using the specified JSON patch to partially update its 'unschedulable' attribute | Command:
```bash
kubectl patch node prod-node-5 -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]`
Helpf... |
Auto scale a deployment "cdn" with the number of pods between 1 and 8 using the default autoscaling policy | Command:
```bash
kubectl autoscale deployment cdn --min=1 --max=8
```
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 ... |
Launch the editor "micro" to modify the service "analytics-service" | Command:
```bash
KUBE_EDITOR="micro" kubectl edit svc/analytics-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 variab... |
Create a secret named api-secret-key and add keys for each file in the folder "bar" | Command:
```bash
kubectl create secret generic api-secret-key --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 the basenam... |
Attach to the nano-bot container in the email-service-pod and get the output | Command:
```bash
kubectl attach email-service-pod -c nano-bot
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, u... |
Create a debug session for 'database-pod', make a copy of it with the name 'debug-image-1', and change all container images to 'mcr.microsoft.com/dotnet/core/runtime'. | Command:
```bash
kubectl debug database-pod --copy-to=debug-image-1 --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 will... |
Copy the contents of the /var/run/secrets/kubernetes.io/serviceaccount/ directory on the local machine to the /tmp/bar_dir directory inside the task-processor-pod-17 pod in the prometheus namespace. | Command:
```bash
kubectl cp /var/run/secrets/kubernetes.io/serviceaccount/ prometheus/task-processor-pod-17:/tmp/bar_dir
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usag... |
Delete the pods and services named "vpn" and "api" | Command:
```bash
kubectl delete pod,service vpn api
```
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.
Some re... |
Create a new secret called 'my-secret' using the settings.env file at path/to/settings.env. | Command:
```bash
kubectl create secret generic my-secret --from-env-file=path/to/settings.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 o... |
Create a cron job named `report-generation` that runs the command `npm --version` every minute using the `node` image. | Command:
```bash
kubectl create cronjob report-generation --image=node --schedule="*/1 * * * *" -- npm --version
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short":... |
Copy the local directory "/tmp/foo_dir" to the remote pod "metrics-exporter-pod-10" in the "/tmp/bar_dir" directory. | Command:
```bash
kubectl cp /tmp/foo_dir metrics-exporter-pod-10::/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 the k... |
Forward local port 8081 to pod port 9090 to access analytics pod | Command:
```bash
kubectl port-forward pod/analytics-pod 8081:9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected auto... |
Forward traffic from local port 9090 to port 5432 in the e-commerce-pod, and also listen on local port 6000 and forward traffic to port 6000 in the e-commerce-pod | Command:
```bash
kubectl port-forward pod/e-commerce-pod 9090 5432
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected aut... |
import environment variables from the 'payment-gateway-secret' secret and set them in the 'api-server-deployment' deployment | Command:
```bash
kubectl set env --from=secret/payment-gateway-secret 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 one or ... |
Import the SECRET_KEY key from the app-secrets config map into the environment of the notification-handler-deployment deployment. | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/app-secrets deployment/notification-handler-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable de... |
Start a Jenkins pod with overridden spec values specified in JSON | Command:
```bash
kubectl run nginx --image=jenkins --overrides='{ "apiVersion": "alpha-2.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] -- [CO... |
Set the CPU limit of the MongoDB container in the deployment "mongo" to 10 and the memory limit to 1 Gigabyte. | Command:
```bash
kubectl set resources deployment mongo -c=nginx --limits=cpu=10,memory=1Gi
```
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... |
Create a secret named oauth-secret with keys for each file in the specified folder | Command:
```bash
kubectl create secret generic oauth-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 the basename of the... |
List the replication controllers 'web', the service 'log-aggregator-rc' and the pods 'frontend-pod' | Command:
```bash
kubectl get rc/web service/log-aggregator-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 namesp... |
Set the certificate authority data for the "my-k8s-cluster" cluster entry by running the command "kubectl config set-cluster my-k8s-cluster --embed-certs --certificate-authority=~/.kube/moon-cluster/kubernetes.ca.crt" | Command:
```bash
kubectl config set-cluster my-k8s-cluster --embed-certs --certificate-authority=~/.kube/moon-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... |
Start a python pod and expose port 7000 | Command:
```bash
kubectl run hazelcast --image=python --port=7000
```
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... |
Import the specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=DATABASE_URL --from=configmap/api-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 defin... |
Create a service for the replication controller specified in the "hazelcast-controller.yaml" file, which serves on port 7000 and connects to the containers on port 900000 | Command:
```bash
kubectl expose -f hazelcast-controller.yaml --port=7000 --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 ... |
Forward traffic from port 5000 on localhost and IP address 10.19.21.23 to port 8081 in the web-app-pod pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/web-app-pod 5000: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 criteri... |
Create a new config map named app-config-prod with the key1=config1 and key2=config2. | Command:
```bash
kubectl create configmap app-config-prod --from-literal=settings=config1 --from-literal=key2=config2
```
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, th... |
Update the pod 'proxy' with the annotation 'owner' and the value 'alice smith' | Command:
```bash
kubectl annotate pods proxy 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 st... |
Start a pod named hazelcast using the ethereum/client-go container image and expose port 8082 | Command:
```bash
kubectl run hazelcast --image=ethereum/client-go --port=8082
```
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:
... |
Edit the configuration of the "gateway-service" service using the "atom" text editor. | Command:
```bash
KUBE_EDITOR="atom" kubectl edit svc/gateway-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... |
Set the cluster field of the my-context context to testing-cluster in the kubectl config file | Command:
```bash
kubectl config set contexts.client-1-context.cluster testing-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 ... |
Open the 'web-service' service for editing using the 'sublime' editor. | Command:
```bash
KUBE_EDITOR="sublime" kubectl edit svc/web-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,... |
Set the custom TLS server name "star-cluster" for the cluster-alpha entry | Command:
```bash
kubectl config set-cluster cluster-alpha --tls-server-name=star-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... |
Create a cron job named "report-generation" using the image "wordpress" and schedule it to run every minute | Command:
```bash
kubectl create cronjob report-generation --image=wordpress --schedule="*/1 * * * *" -- wp
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o",... |
Create a new ClusterIP service named api-service-clusterip | Command:
```bash
kubectl create service clusterip api-service-clusterip --tcp=8081:5432
```
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 debug pod named dgb-img by copying the log-aggregator-pod and replace all container images with busybox. | Command:
```bash
kubectl debug log-aggregator-pod --copy-to=dgb-img --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 reso... |
Copy the local file ~/.config/kube to the /etc/kubernetes directory in the worker-pod-4 pod, specifically in the monitoring-agent container. | Command:
```bash
kubectl cp ~/.config/kube worker-pod-4:/etc/kubernetes -c monitoring-agent
```
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 omitt... |
Scale the deployment named "api-service-rs" to 1 replica | Command:
```bash
kubectl scale --current-replicas=5 --replicas=1 deployment/api-service-rs
```
What it does:
Set a new size for a deployment, replica set, replication controller, or stateful set.
Scale also allows users to specify one or more preconditions for the scale action.
If --current-replicas or --resource-vers... |
Rename the context 'staging-context' to 'app-2-context' in your kubeconfig file | Command:
```bash
kubectl config rename-context staging-context app-2-context
```
What it does:
Renames a context from the kubeconfig file.
CONTEXT_NAME is the context name that you want to change.
NEW_NAME is the new name you want to set.
Note: If the context being renamed is the 'current-context', this field will als... |
Update the pod named 'analytics' by adding or updating the annotation 'contact-email' with the value 'support@example.com' | Command:
```bash
kubectl annotate --overwrite pods analytics contact-email='support@example.com'
```
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... |
Create an ingress called 'myapp-ingress' that directs requests from website.com/input to svc1:8083 with a TLS secret "my-cert" | Command:
```bash
kubectl create ingress myapp-ingress --rule="website.com/input=svc1:8083,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... |
Copy the directory /var/run/secrets/kubernetes.io/serviceaccount/ from the remote pod 'kube-system/cache-pod-5' to the local directory /tmp/bar_dir. | Command:
```bash
kubectl cp kube-system/cache-pod-5:/var/run/secrets/kubernetes.io/serviceaccount/ /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": "Cont... |
Forward traffic from a random port on your local machine to port 8000 in the pod named 'api-service-pod' | Command:
```bash
kubectl port-forward pod/api-service-pod :8000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automa... |
Retrieve the output from running the 'mongod' command in the nano-bot container of the e-commerce-pod pod. | Command:
```bash
kubectl exec e-commerce-pod -c nano-bot -- mongod
```
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... |
Set the resource request and limits for all containers in the alpine deployment | Command:
```bash
kubectl set resources deployment alpine --limits=cpu=200m,memory=512Mi --requests=cpu=10,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 request... |
Run the 'go run hello.go' command on pod e-commerce-pod and get the output | Command:
```bash
kubectl exec e-commerce-pod -- go run hello.go
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the ku... |
Import specific keys from a config map to set environment variables for a deployment. | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/ui-config deployment/mydeployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or m... |
Get the logs of container payment-processor-deployment-1 from the deployment api-service-pod | Command:
```bash
kubectl logs deployment/payment-processor-deployment -c api-service-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flag... |
Update the backend pod with the annotation "deployment-script" and the value "https://example.com/deploy.sh", overwriting any existing value. | Command:
```bash
kubectl annotate --overwrite pods backend deployment-script='https://example.com/deploy.sh'
```
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... |
Create a copy of the payment-gateway-pod named debug-image-memcached, changing all container images to busybox for debugging purposes. | Command:
```bash
kubectl debug payment-gateway-pod --copy-to=debug-image-memcached --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 def... |
Set the CPU limits to "10" and memory limits to "1Gi" for the golang container in the deployment named "golang". | Command:
```bash
kubectl set resources deployment golang -c=nginx --limits=cpu=10,memory=1Gi
```
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... |
Get the output from running the 'ash' command on the first pod of the database-deployment deployment. | Command:
```bash
kubectl exec deploy/database-deployment -- ash
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the ku... |
Add a taint to a specific node with a key but no value | Command:
```bash
kubectl taint nodes worker-node-3 zone: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: js... |
Create a service for the replication controller specified in "python-controller.yaml", serving on port 3001 and connecting to the containers on port 909200. | Command:
```bash
kubectl expose -f python-controller.yaml --port=3001 --target-port=909200
```
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... |
Create a new config map named log-config by specifying the keys for the files instead of using their basenames on disk | Command:
```bash
kubectl create configmap log-config --from-file=properties=/path/to/profiles/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 creating a... |
Forward local ports 8000 and 6000 to the corresponding ports of a pod selected by the deployment/database-deployment | Command:
```bash
kubectl port-forward deployment/database-deployment 8000 8000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be ... |
Execute the 'php --version' command in the time-machine container of the payment-gateway-pod and display the output. | Command:
```bash
kubectl exec payment-gateway-pod -c time-machine -- 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 ... |
Execute the 'redis-cli' command inside the first pod of the 'notification-service' service. | Command:
```bash
kubectl exec svc/notification-service -- redis-cli
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use th... |
Create a copy of the payment-gateway-pod and replace all container images with the postgres image. | Command:
```bash
kubectl debug payment-gateway-pod --copy-to=dgb-img --set-image=*=postgres
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by default if no re... |
Forward port 8080 on localhost and IP 10.19.21.23 to port 6379 in the pod named "analytics-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/analytics-pod 8080: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 crite... |
Continuously stream the logs of the "code-explorer" container in the "email-service-pod" pod | Command:
```bash
kubectl logs -f -c code-explorer email-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... |
Forward traffic from your local machine's port 8081 to port 6379 in the pod named "frontend-pod" | Command:
```bash
kubectl port-forward pod/frontend-pod 8081: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... |
Copy the local file /tmp/foo_dir to the remote pod monitoring-agent-pod-6 in the ingress-nginx namespace, and save it as /tmp/bar. | Command:
```bash
kubectl cp /tmp/foo_dir ingress-nginx/monitoring-agent-pod-6::/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, ... |
Execute the command 'jenkins-plugin-cli' on the first container of the 'backend-service' service's pod and display the output. | Command:
```bash
kubectl exec svc/backend-service -- jenkins-plugin-cli
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, us... |
Execute the 'go run hello.go' command inside the pod named 'frontend-pod' and retrieve the output from the first container. | Command:
```bash
kubectl exec frontend-pod -- go run hello.go
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kube... |
Listen on port 8000 on localhost and IP address 10.19.21.23, and forward the traffic to port 8080 in the pod 'log-aggregator-pod' | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/log-aggregator-pod 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 ... |
Create a copy of a pod with a debug container and change container images | Command:
```bash
kubectl debug media-stream-pod -it --copy-to=my-debugger --image=debian --set-image=scheduler=my-scheduler:1.0,web=nginx:latest
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by res... |
Embed the certificate authority data for the 'cloud-cluster' cluster entry | Command:
```bash
kubectl config set-cluster cloud-cluster --embed-certs --certificate-authority=~/.kube/staging-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... |
Start a pod named "hazelcast" using the image "ethereum/client-go" and expose port 8000 | Command:
```bash
kubectl run hazelcast --image=ethereum/client-go --port=8000
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
... |
Import the 'api_key' key from the 'global-config' config map to the 'authentication-service-deployment' deployment. | Command:
```bash
kubectl set env --keys=api_key --from=configmap/global-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 variable d... |
Port forward data between local ports 5000 and 6000 and the pod's ports 5432 and 6000 of the 'log-aggregator-pod' pod | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 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 be selected... |
Forward port 8888 on all addresses to port 8888 in the pod named "analytics-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/analytics-pod 8888: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 wil... |
Import specific keys from a config map for a deployment | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/monitoring-config deployment/authentication-service-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment var... |
Listen on port 5432 on all addresses, forwarding to port 9090 in the 'web-app-pod' pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/web-app-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 criteria, a pod will ... |
Create a job named "cleanup" using the "confluentinc/cp-kafka" image, and run the command "kafka-server-start /etc/kafka/server.properties" inside the job. | Command:
```bash
kubectl create job cleanup --image=confluentinc/cp-kafka -- kafka-server-start /etc/kafka/server.properties
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short":... |
List the deployments in the "alpha-2.0" version of the "internal-apps" API group in JSON output format. | Command:
```bash
kubectl get deployments.alpha-2.0.internal-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 yo... |
Set up autoscaling for the "database" deployment with a minimum of 6 pods and a maximum of 9 pods | Command:
```bash
kubectl autoscale deployment database --min=6 --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... |
Add a taint with key 'hardware' on nodes having label myLabel | Command:
```bash
kubectl taint node -l myLabel hardware=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": "Out... |
Delete the context for the client-2-context cluster in the kubectl configuration | Command:
```bash
kubectl config delete-context client-2-context
```
What it does:
Delete the specified context from the kubeconfig.
Syntax:
`kubectl config delete-context NAME` |
Forward local port 8080 to port 8000 in the pod named web-app-pod | Command:
```bash
kubectl port-forward pod/web-app-pod 8080:8000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automa... |
List the deployments in YAML output format in the "stable-2.0.0" version of the "testing-apps" API group. | Command:
```bash
kubectl get deployments.stable-2.0.0.testing-apps -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 ... |
show the most recent 23 lines of logs for the pod named backend-pod | Command:
```bash
kubectl logs --tail=23 backend-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"... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.