prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Partially update the node specified in the "node-specific.yaml" file using a strategic merge patch | Command:
```bash
kubectl patch -f node-specific.yaml -p '{"spec":{"rules":[{"http":{"paths":[{"path":"/","backend":{"service": {"name": "new-service"}}}]}}'
```
What it does:
Update fields of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.
JSON and YAML formats are accepted.
Syntax:
`kube... |
Create a cron job named 'log-rotation' using the 'mongo' image. The cron job should run the command 'mongod' every minute. | Command:
```bash
kubectl create cronjob log-rotation --image=mongo --schedule="*/1 * * * *" -- mongod
```
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", "def... |
Create a pod named 'hazelcast' using the 'ruby' image and expose port 27017. | Command:
```bash
kubectl run hazelcast --image=ruby --port=27017
```
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... |
Attach to the warp-drive container in the vpn-service-pod and get its output. | Command:
```bash
kubectl attach vpn-service-pod -c warp-drive
```
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 copy of the 'monitoring-pod' with all container images changed to 'wordpress' and name it 'debug-image-web'. | Command:
```bash
kubectl debug monitoring-pod --copy-to=debug-image-web --set-image=*=wordpress
```
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 n... |
List deployments in YAML output format for the "custom-version" version of the "mobile-apps" API group | Command:
```bash
kubectl get deployments.custom-version.mobile-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... |
Edit the config of a service using the nvim editor | Command:
```bash
KUBE_EDITOR="nvim" kubectl edit svc/db-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, or ... |
Forward local port 8000 to port 8080 in the 'chat-app-pod' pod | Command:
```bash
kubectl port-forward pod/chat-app-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 criteria, a pod will be selected autom... |
Forward port 3000 on all addresses to port 8081 in the pod "mypod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/mypod 3000:8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be sel... |
Create a role named "foo" with specific resource names | Command:
```bash
kubectl create role foo --verb=create --resource=pods --resource-name=file-storage --resource-name=document-storage
```
What it does:
Create a role with single rule.
Syntax:
`kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run=server|cl... |
Create an ingress named 'app-ingress' that directs requests to 'site.com/bar' and forwards them to the service 'svc1:7000' | Command:
```bash
kubectl create ingress app-ingress --rule="site.com/bar=svc1:7000,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Ou... |
Create a new secret named tls-certificate-secret with keys for each file in the specified path. | Command:
```bash
kubectl create secret generic tls-certificate-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 the... |
Create a deployment named "wordpress" using the "mongo" image and expose port 8089 | Command:
```bash
kubectl create deployment wordpress --image=mongo --port=8089
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of:... |
Check if you have permission to list the "data-migration-job" job in the "namespace-1" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/data-migration-job -n namespace-1
```
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... |
Get the output from running the 'composer --version' command in the 'rocket-ranger' container of the 'cdn-service-pod' pod. | Command:
```bash
kubectl exec cdn-service-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. I... |
Copy the file ~/.config/kube from a remote pod called logging-agent-pod-7 to the local directory /tmp/bar. | Command:
```bash
kubectl cp logging/logging-agent-pod-7:~/.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... |
Get the output of the 'elasticsearch-plugin --list' command from the monitoring-pod. | Command:
```bash
kubectl exec monitoring-pod -- elasticsearch-plugin --list
```
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... |
Update the environment variable JWT_SECRET to "your-jwt-secret" in the deployment called "search-engine-deployment" | Command:
```bash
kubectl set env deployment/search-engine-deployment JWT_SECRET=your-jwt-secret
```
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 po... |
Forward traffic from port 8088 on your local machine to port 8080 on the 'e-commerce-pod' pod | Command:
```bash
kubectl port-forward pod/e-commerce-pod 8088:8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected aut... |
Copy the /tmp/foo_dir local file to /tmp/bar in the "payment-gateway" container of the "worker-pod-4" pod. | Command:
```bash
kubectl cp /tmp/foo_dir worker-pod-4:/tmp/bar -c payment-gateway
```
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... |
Copy the /var/run/secrets/kubernetes.io/serviceaccount/ file from your local machine to the /tmp/bar directory inside the payment-gateway-pod-19 pod in the ingress-nginx namespace. | Command:
```bash
kubectl cp /var/run/secrets/kubernetes.io/serviceaccount/ ingress-nginx/payment-gateway-pod-19:/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": "", "usag... |
Return the logs from the container `security-service-pod-1` of the deployment `notification-handler-deployment` | Command:
```bash
kubectl logs deployment/notification-handler-deployment -c security-service-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Help... |
Execute the 'apk add curl' command inside the first container of the cache-cluster-deployment deployment and retrieve the output. | Command:
```bash
kubectl exec deploy/cache-cluster-deployment -- apk add curl
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitt... |
Import the keys 'EXTERNAL_API_URL' from the 'env-vars' config map and set them as environment variables for the 'notification-handler-deployment' deployment. | Command:
```bash
kubectl set env --keys=EXTERNAL_API_URL --from=configmap/env-vars 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... |
Create a new ExternalName service named external-notification-service with the external name set to "sandbox-site.co" | Command:
```bash
kubectl create service externalname external-notification-service --external-name sandbox-site.co
```
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... |
Expose the replication controller specified in nginx-controller.yaml on port 7000, and connect it to the containers on port 637900. | Command:
```bash
kubectl expose -f nginx-controller.yaml --port=7000 --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 ... |
Autoscale the replication controller "chat-app" with a minimum of 1 pod, maximum of 3 pods, and a target CPU utilization of 81% | Command:
```bash
kubectl autoscale rc chat-app --max=3 --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 use... |
Copy the local file /tmp/foo to the remote pod monitoring/file-server-pod-14 in the namespace, at the location /tmp/bar. | Command:
```bash
kubectl cp /tmp/foo monitoring/file-server-pod-14::/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 kub... |
Forward local port 8088 to port 9090 in the pod named "log-aggregator-pod" | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 8088:9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected... |
Copy a directory from a remote pod to a local directory | Command:
```bash
kubectl cp velero/front-end-pod-12:/tmp/foo_dir /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 the... |
Set the service account of the 'gateway-deployment' deployment to 'kube-scheduler' | Command:
```bash
kubectl set serviceaccount deployment gateway-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
Syntax:
`kub... |
Switch to raw terminal mode and attach to the 'time-machine' container within the 'backend-pod' pod | Command:
```bash
kubectl attach backend-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 omitte... |
Add a taint with the key 'special' on the nodes that have the label tier=frontend | Command:
```bash
kubectl taint node -l tier=frontend special=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": "Out... |
Update the label of pod 'web' with the value 'development' | Command:
```bash
kubectl label pods web env=development
```
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": "I... |
Forward local traffic on port 8088 to port 8081 in the specified pod | Command:
```bash
kubectl port-forward pod/mypod 8088 8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automaticall... |
Set up an autoscaling policy for the deployment named "payment" | Command:
```bash
kubectl autoscale deployment payment --min=2 --max=15
```
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... |
Import the DATABASE_URL key from the config map named namespace-config and set it as an environment variable in the deployment named mydeployment. | Command:
```bash
kubectl set env --keys=DATABASE_URL --from=configmap/namespace-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... |
Create a debug image of a pod by copying it and changing the container images to amazonlinux | Command:
```bash
kubectl debug web-app-pod --copy-to=debug-image-api --set-image=*=amazonlinux
```
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... |
Create an ingress called 'web-ingress' that directs requests to testing.com/bar to a service named svc1 on port 3000, using the TLS secret "my-cert". | Command:
```bash
kubectl create ingress web-ingress --rule="testing.com/bar=svc1:3000,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": ... |
Create a new ClusterIP service named inventory-service-clusterip that maps port 8089 on the service to port 8088 on the backend pods. | Command:
```bash
kubectl create service clusterip inventory-service-clusterip --tcp=8089: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": "-... |
Forward traffic from localhost and IP 10.19.21.23 on port 8000 to port 8080 in the backend-pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/backend-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 criteri... |
Create a copy of the "monitoring-pod" with all container images changed to "busybox" | Command:
```bash
kubectl debug monitoring-pod --copy-to=my-debugger --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... |
Import the 'secret_key' key from the 'kube-system-config' ConfigMap into the 'monitoring-stack-deployment' Deployment. | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/kube-system-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... |
Create a copy of the auth-service-pod with a debug container, change the container images to `debian` for the debug container and to `api:v2` for the `api` container, and change the `proxy` container's image to `nginx:1.21`. | Command:
```bash
kubectl debug auth-service-pod -it --copy-to=debug-image-api --image=debian --set-image=api=api:v2,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 and na... |
Create a debug copy of the analytics-pod in an interactive session, with a debian image for the debug container | Command:
```bash
kubectl debug analytics-pod -it --copy-to=debug-image-app --image=debian --set-image=scheduler=my-scheduler:1.0,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 identi... |
Retrieve the logs from the container named 'media-stream-pod-1' within the deployment 'authentication-service-deployment' | Command:
```bash
kubectl logs deployment/authentication-service-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]`
Helpfu... |
Create a nginx pod using the nginx image, but modify the spec with a partial set of values parsed from JSON | Command:
```bash
kubectl run nginx --image=nginx --overrides='{ "apiVersion": "v2.1.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] -- [COMMAND... |
Create a deployment with a specific image and command to run. | Command:
```bash
kubectl create deployment prometheus --image=confluentinc/cp-kafka -- kafka-topics --list
```
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": "", "usa... |
Partially update the dev-node-4 node by using a strategic merge patch, with the JSON patch specifying to update the "someField" to "newValue" | Command:
```bash
kubectl patch node dev-node-4 -p '{"spec":{"someField":"newValue"}'
```
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... |
Create an ingress rule with the name 'myapp-ingress' that redirects requests from 'foo.com/input' to service 'svc1:8082' and uses the tls secret 'my-cert' | Command:
```bash
kubectl create ingress myapp-ingress --rule="foo.com/input=svc1:8082,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": ... |
Update the 'proxy' pod by adding the annotation 'SLA' with the value '99.9% uptime' | Command:
```bash
kubectl annotate pods proxy SLA='99.9% uptime'
```
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 str... |
Remove all the taints with the key 'special' from the node 'db-node-7' | Command:
```bash
kubectl taint nodes db-node-7 special-
```
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: json|yaml|nam... |
Switch to raw terminal mode for the pod 'web-app-pod' with container name 'cosmic-container' | Command:
```bash
kubectl attach web-app-pod -c cosmic-container -i -t
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If om... |
List the replication controller with the name 'web', the service with the name 'analytics-rc', and the pod with the name 'payment-gateway-pod' | Command:
```bash
kubectl get rc/web service/analytics-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 name... |
Retrieve the previous terminated logs of the 'nano-bot' container from the 'web-app-pod' pod. | Command:
```bash
kubectl logs -p -c nano-bot web-app-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "short":... |
Create a new ClusterIP service named 'analytics-service-clusterip' that maps port 5001 on the cluster to port 8084 on the pods. | Command:
```bash
kubectl create service clusterip analytics-service-clusterip --tcp=5001:8084
```
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": "-... |
Rollback the `namespace-1` deployment to the previous version | Command:
```bash
kubectl rollout undo deployment/namespace-1
```
What it does:
Manage the rollout of a resource.
Valid resource types include:
Syntax:
`kubectl rollout SUBCOMMAND` |
Create a pod disruption budget named load-balancer-pdb that selects pods with the region=us-east label and requires at least one of them to be available at all times. | Command:
```bash
kubectl create poddisruptionbudget load-balancer-pdb --selector=region=us-east --min-available=1
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available... |
Remove the taint on node 'edge-node-10' with key 'app' and effect 'PreferNoSchedule' if it exists | Command:
```bash
kubectl taint nodes edge-node-10 app: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": "Output format. One o... |
Import specific keys from a config map to a deployment by specifying the keys and the source config map. | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/app-name-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 defi... |
Create a new config map named 'log-config' with the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap log-config --from-file=properties=/path/to/data/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 con... |
Create a new config map named app-name-config and populate it with specific keys and values from files on disk. | Command:
```bash
kubectl create configmap app-name-config --from-file=properties=/path/to/properties/file1.txt --from-file=key1=/path/to/configurations/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
Wh... |
Port forward traffic from localhost:8081 to pod/web-app-pod:8081, allowing access from all addresses. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/web-app-pod 8081:8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will ... |
Create a new config map named app-secrets with the specified keys "conf" and "data" mapped to the respective files "/path/to/options/file1.txt" and "/path/to/preferences/file2.txt" | Command:
```bash
kubectl create configmap app-secrets --from-file=conf=/path/to/options/file1.txt --from-file=data=/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 co... |
Create a new secret named password-secret from the environment file located at path/to/configs.env. | Command:
```bash
kubectl create secret generic password-secret --from-env-file=path/to/configs.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 basen... |
Set the CPU limits of the Jenkins container in the deployment to "100m" and the memory limit to "64Mi". | Command:
```bash
kubectl set resources deployment jenkins -c=nginx --limits=cpu=100m,memory=64Mi
```
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 t... |
Import the 'debug_mode' key from the 'app-secrets' ConfigMap into the 'cache-cluster-deployment' Deployment. | Command:
```bash
kubectl set env --keys=debug_mode --from=configmap/app-secrets deployment/cache-cluster-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... |
Listen on port 6379 on localhost and the IP 10.19.21.23, and forward traffic to port 8080 in the pod named 'chat-app-pod' | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/chat-app-pod 6379: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 criter... |
View the details of a specific revision for a daemonset | Command:
```bash
kubectl rollout history daemonset/prod --revision=1
```
What it does:
View previous rollout revisions and configurations.
Syntax:
`kubectl rollout history (TYPE NAME | TYPE/NAME) [flags]`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to fi... |
Forward traffic from all addresses on port 8888 to port 5000 in the mypod pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/mypod 8888:5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be sel... |
Import the 'secret_key' key from the 'app-name-config' ConfigMap to the 'cache-cluster-deployment' deployment. | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/app-name-config deployment/cache-cluster-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... |
Update the resource requests and limits for all the containers in the alpine deployment | Command:
```bash
kubectl set resources deployment alpine --limits=cpu=200m,memory=512Mi --requests=cpu=10,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 request... |
Copy the file named "foo" located at "/tmp/foo" in the remote pod "argocd/metrics-exporter-pod-10" to "/tmp/bar" on your local machine. | Command:
```bash
kubectl cp argocd/metrics-exporter-pod-10:/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 the kub... |
Import specific keys from a config map to a deployment's environment variables | Command:
```bash
kubectl set env --keys=CONFIG_FILE_PATH --from=configmap/namespace-config deployment/order-processing-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment vari... |
Update the pod identified in the "preferences.json" file by adding the custom-label=my-custom-value annotation. | Command:
```bash
kubectl annotate -f preferences.json custom-label=my-custom-value
```
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 in... |
List multiple resources of different types by their names | Command:
```bash
kubectl get rc/web service/auth-service-rc pods/security-service-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 ... |
Retrieve the list of deployments in YAML output format from the "beta-1.0" version of the "testing-apps" API group. | Command:
```bash
kubectl get deployments.beta-1.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 you ... |
Create a new secret named 'encryption-key-secret' from the 'profiles.env' file in the 'path/to' directory | Command:
```bash
kubectl create secret generic encryption-key-secret --from-env-file=path/to/profiles.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 th... |
Add a taint with the key 'hardware=backup-node-14' and the effect 'PreferNoSchedule' on nodes labeled with 'app-type=microservice' | Command:
```bash
kubectl taint node -l app-type=microservice 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": "",... |
Forward local port 9090 to port 8000 in the pod "cdn-service-pod" | Command:
```bash
kubectl port-forward pod/cdn-service-pod 9090: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 au... |
Create a new config map named app-settings using the specified keys instead of the file basenames on disk | Command:
```bash
kubectl create configmap app-settings --from-file=settings=/path/to/preferences/file1.txt --from-file=key2=/path/to/profiles/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creatin... |
Import the specific keys "my-example-key" from the config map "namespace-config" and apply them to the environment variables of the "analytics-platform-deployment" deployment | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/namespace-config deployment/analytics-platform-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment vari... |
Add a taint with the key 'environment' on nodes having the label project=project-alpha, the specific node is 'monitoring-node-15' with the taint value 'PreferNoSchedule' | Command:
```bash
kubectl taint node -l project=project-alpha environment=monitoring-node-15:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "defaul... |
Create an ingress called 'default-ingress' that maps requests from testing.com/example to svc1:8089 and uses the TLS secret "my-cert" for secure communication. | Command:
```bash
kubectl create ingress default-ingress --rule="testing.com/example=svc1:8089,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": "", "... |
Forward local port 5000 to port 8080 in the selected pod of the deployment | Command:
```bash
kubectl port-forward deployment/mydeployment 5000 8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selecte... |
Copy the local directory "/tmp/foo_dir" to the remote pod "front-end-pod-12" at "/tmp/bar_dir" in the default namespace. | Command:
```bash
kubectl cp /tmp/foo_dir front-end-pod-12:/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 kubectl.k... |
Set the cluster field in the team-alpha-context context to moon-cluster | Command:
```bash
kubectl config set contexts.team-alpha-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 y... |
Copy the local file '/tmp/foo' to the '/etc/kubernetes' directory inside the remote pod 'load-balancer-pod-9' in the 'rook-ceph' namespace. | Command:
```bash
kubectl cp /tmp/foo rook-ceph/load-balancer-pod-9:/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 t... |
View the last 31 lines of logs for the monitoring-pod | Command:
```bash
kubectl logs --tail=31 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": "... |
List all deployments in the "stable-2.0.0" version of the "mobile-apps" API group in YAML output format | Command:
```bash
kubectl get deployments.stable-2.0.0.mobile-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 y... |
Forward traffic from a randomly assigned local port to port 5000 in the e-commerce-pod | Command:
```bash
kubectl port-forward pod/e-commerce-pod :5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automat... |
Expose a replicated hazelcast as a service, serving on port 5001 and connecting to containers on port 900000 | Command:
```bash
kubectl expose rc hazelcast --port=5001 --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 the specified po... |
List deployments in YAML output format for the "rc-1.1.0" version of the "apps" API group | Command:
```bash
kubectl get deployments.rc-1.1.0.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 you will onl... |
forward port 5000 on all addresses to port 8000 in the pod named "analytics-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/analytics-pod 5000: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... |
Create a service for a replicated CentOS using ReplicaSet, which serves on port 80 and connects to the containers on port 8000. | Command:
```bash
kubectl expose rs centos --port=6379 --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 the specified port.... |
Output the modified deployment configuration in YAML format without making any changes on the server | Command:
```bash
kubectl set env deployment/monitoring-stack-deployment REDIS_HOST=redis-server -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... |
Create a copy of the security-service-pod with the container images changed to hazelcast/hazelcast for debugging purposes | Command:
```bash
kubectl debug security-service-pod --copy-to=debug-image-memcached --set-image=*=hazelcast/hazelcast
```
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 b... |
Update the db-node-7 node by applying a strategic merge patch specified in JSON format | Command:
```bash
kubectl patch node db-node-7 -p '{"spec":{"containers":[{"name":"container-name", "resources":{"limits":{"cpu":"200m"}}}]}'
```
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 FI... |
Create a new config map named app-name-config with the specified keys and file paths | Command:
```bash
kubectl create configmap app-name-config --from-file=settings=/path/to/properties/file1.txt --from-file=key2=/path/to/configs/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 creati... |
Update the pod 'chat-app' by setting the annotation 'criticality' to the value 'high'. | Command:
```bash
kubectl annotate pods chat-app 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 arbitrary st... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.