prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Embed client certificate data in the "security-user" entry | Command:
```bash
kubectl config set-credentials security-user --client-certificate=~/.kube/admin.crt --embed-certs=true
```
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 --cl... |
Create a pod disruption budget named replica-set-pdb that selects all pods with the project=my-project label and ensures that at least one of them is available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget replica-set-pdb --selector=project=my-project --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-availab... |
Add a taint with key 'special' on nodes having label 'project=project-alpha' | Command:
```bash
kubectl taint node -l project=project-alpha special=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": "", "usa... |
Create an ingress named 'api-v1-ingress' with a rule to route requests for 'testing.com/example' to 'svc1:8080' and use the TLS secret 'my-cert' | Command:
```bash
kubectl create ingress api-v1-ingress --rule="testing.com/example=svc1:8080,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": "", "u... |
Import the LOG_LEVEL key from the app-config config map and set it as an environment variable in the monitoring-stack-deployment deployment. | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/app-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... |
Start the hazelcast pod with a custom command and arguments | Command:
```bash
kubectl run nginx --image=hazelcast/hazelcast --command -- <cmd> <arg1> ... <argN>
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args... |
Forward port 3000 on localhost and IP 10.19.21.23 to port 8000 in the pod named "web-app-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/web-app-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 criteri... |
Forward port 8888 on all addresses to port 8080 in the pod named 'api-service-pod' | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/api-service-pod 8888:8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod w... |
Start the redis pod using a different command and custom arguments. | Command:
```bash
kubectl run nginx --image=redis --command -- <cmd> <arg1> ... <argN>
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful... |
Forward port 8888 on all addresses to port 3000 in the pod "analytics-pod" and listen for incoming connections. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/analytics-pod 8888:3000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod wil... |
Copy the file /tmp/foo from the remote pod worker-pod-4 in the kube-dns namespace to the local directory /tmp/bar | Command:
```bash
kubectl cp kube-dns/worker-pod-4:/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 kubectl.kub... |
Retrieve the output from executing the command '/bin/bash -c "echo 'Hello, Amazon Linux'"' in the lunar-launcher container from the payment-gateway-pod pod | Command:
```bash
kubectl exec payment-gateway-pod -c lunar-launcher -- /bin/bash -c "echo 'Hello, Amazon Linux'"
```
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": "",... |
Create a job named "security-scan-job" using the "mongo" image, and run the command "mongo --version" within the job. | Command:
```bash
kubectl create job security-scan-job --image=mongo -- mongo --version
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output... |
Attach to a pod and open a raw terminal to execute commands interactively | Command:
```bash
kubectl attach web-app-pod -c code-explorer -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 omitt... |
Auto scale the "log-aggregator" replication controller with the target CPU utilization set to 40% | Command:
```bash
kubectl autoscale rc log-aggregator --max=4 --cpu-percent=40
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler th... |
Forward traffic from port 8088 on all addresses to port 8888 in the 'backend-pod' pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/backend-pod 8088: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 ... |
Create an ingress called 'api-v2-ingress' with a rule that directs requests to foo.com/module to svc1:5000 | Command:
```bash
kubectl create ingress api-v2-ingress --rule="foo.com/module=svc1:5000,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage"... |
Forward traffic from local port 8088 to port 5432 in a pod selected by the "mydeployment" deployment. | Command:
```bash
kubectl port-forward deployment/mydeployment 8088 5432
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selecte... |
Create a job named "image-build-job" with the nginx image and execute the command "nginx -t" inside the job | Command:
```bash
kubectl create job image-build-job --image=nginx -- nginx -t
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. ... |
Get output from running the 'jenkins-plugin-cli' command from the 'frontend-pod' pod using the first container. | Command:
```bash
kubectl exec frontend-pod -- 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, use the k... |
Execute the 'yum install -y wget' command inside the 'time-machine' container of the 'e-commerce-pod' pod and get the output. | Command:
```bash
kubectl exec e-commerce-pod -c time-machine -- yum install -y wget
```
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... |
Retrieve the logs of the container 'web-app-deployment-1' from the deployment named 'monitoring-pod' | Command:
```bash
kubectl logs deployment/web-app-deployment -c monitoring-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": ... |
Create a role named "admin_role" with ResourceName specified for watching pods with the resource names "backup-service" and "order-fulfillment" | Command:
```bash
kubectl create role admin_role --verb=watch --resource=pods --resource-name=backup-service --resource-name=order-fulfillment
```
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=... |
Roll back the daemonset 'nginx' to revision 3. | Command:
```bash
kubectl rollout undo daemonset/nginx --to-revision=3
```
What it does:
Roll back to a previous rollout.
Syntax:
`kubectl rollout undo (TYPE NAME | TYPE/NAME) [flags]`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to files identifying the r... |
Forward local port 6379 to port 8081 in the pod "security-service-pod" | Command:
```bash
kubectl port-forward pod/security-service-pod 6379: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 select... |
Embed the certificate authority data for the "edge-cluster" cluster entry | Command:
```bash
kubectl config set-cluster edge-cluster --embed-certs --certificate-authority=~/.kube/data-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 set... |
Copy the file /tmp/foo from the pod named message-broker-pod-15 in the namespace prometheus to the local directory /etc/kubernetes | Command:
```bash
kubectl cp prometheus/message-broker-pod-15:/tmp/foo /etc/kubernetes
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, us... |
Setup autoscaling for the "vpn" deployment with a minimum of 6 pods and a maximum of 12 pods | Command:
```bash
kubectl autoscale deployment vpn --min=6 --max=12
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that uses the... |
Copy the file "/tmp/foo" from the remote pod "web-app-pod-1" in the "metallb-system" namespace to the local directory "/tmp/bar_dir". | Command:
```bash
kubectl cp metallb-system/web-app-pod-1::/tmp/foo /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 ... |
Create a new namespace named kube-system | Command:
```bash
kubectl create namespace kube-system
```
What it does:
Create a namespace with the specified name.
Syntax:
`kubectl create namespace NAME [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json|yaml|name|go-template|go-te... |
Delete the pods and services with the names "chat-app" and "payment" | Command:
```bash
kubectl delete pod,service chat-app payment
```
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... |
Open the gateway-service service for editing in the nano editor | Command:
```bash
KUBE_EDITOR="nano" 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... |
Scale the deployment named 'payment-service-rs' to 3 replicas, if its current size is 5. | Command:
```bash
kubectl scale --current-replicas=5 --replicas=3 deployment/payment-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-... |
Add a taint with key 'app' and value 'k8s-node-1:PreferNoSchedule' to nodes that have the label 'environment=production' | Command:
```bash
kubectl taint node -l environment=production app=k8s-node-1: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"... |
Create an ingress named 'private-ingress' that routes requests to 'site.com/module' to the service 'svc1' running on port '5001', and use the TLS secret 'my-cert' for secure communication. | Command:
```bash
kubectl create ingress private-ingress --rule="site.com/module=svc1:5001,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... |
Attach and interact with the cosmic-container in the database-pod. | Command:
```bash
kubectl attach database-pod -c cosmic-container
```
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... |
Embed the certificate authority data for the "prod-cluster" cluster entry | Command:
```bash
kubectl config set-cluster prod-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 ... |
Import the 'DATABASE_URL' key from the 'namespace-config' ConfigMap and set it as an environment variable in the 'notification-handler-deployment' Deployment. | Command:
```bash
kubectl set env --keys=DATABASE_URL --from=configmap/namespace-config 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 vari... |
Start streaming the logs of the 'warp-drive' container in the 'frontend-pod' pod | Command:
```bash
kubectl logs -f -c warp-drive frontend-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "shor... |
Create a copy of the 'monitoring-pod' pod, changing the command of 'nebula-navigator' container to 'sh' | Command:
```bash
kubectl debug monitoring-pod -it --copy-to=my-custom-dbg --container=nebula-navigator -- sh
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by... |
Check if the current user has permission to list the job named "log-rotation-job" in the "logging" namespace. | Command:
```bash
kubectl auth can-i list jobs.batch/log-rotation-job -n logging
```
What it does:
Check whether an action is allowed.
VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is a partial URL t... |
Create an ingress called 'default-ingress' that directs requests for the URL site.com/bar to the service svc1:8000 with a TLS secret named "my-cert" | Command:
```bash
kubectl create ingress default-ingress --rule="site.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": "", "usage":... |
Update the image of all containers in the daemonset "prod" to "redis:6.2.5" | Command:
```bash
kubectl set image daemonset prod *=redis:6.2.5
```
What it does:
Update existing container image(s) of resources.
Possible resources include (case insensitive):
pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), statefulset (sts), cronjob (cj), replicaset (rs)
Syntax:
`kubectl... |
import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/global-config deployment/log-aggregator-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defini... |
Import specific keys from a config map to an environment variable in a deployment. | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/namespace-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 ... |
Return the snapshot of the previous terminated ruby container logs from the pod proxy-server-pod. | Command:
```bash
kubectl logs -p -c ruby proxy-server-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 an ingress called 'app-gateway-ingress' with the following rules: requests to testing.com/example should be directed to svc1:7000 and use the tls secret "my-cert" | Command:
```bash
kubectl create ingress app-gateway-ingress --rule="testing.com/example=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": "... |
Set the resource limits and requests for all containers in the "centos" deployment. | Command:
```bash
kubectl set resources deployment centos --limits=cpu=200m,memory=512Mi --requests=cpu=500m,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 request... |
Create a new config map named "app-config" using specific keys instead of file basenames on disk. | Command:
```bash
kubectl create configmap app-config --from-file=settings=/path/to/data/file1.txt --from-file=key2=/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 confi... |
Create an ingress with specific rules and TLS settings | Command:
```bash
kubectl create ingress app-proxy-ingress --rule="website.com/module=svc1:6379,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 communications from port 8000 on all addresses to port 5432 in the chat-app-pod pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/chat-app-pod 8000: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... |
Listen on local port 5432 and forward it to port 8081 inside the 'frontend-pod' pod. | Command:
```bash
kubectl port-forward pod/frontend-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 criteria, a pod will be selected autom... |
Scale the deployment named prod-app-rs to 3 replicas if its current size is 1. | Command:
```bash
kubectl scale --current-replicas=1 --replicas=3 deployment/prod-app-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-version... |
Autoscale the replication controller "security" with a maximum of 7 pods and target CPU utilization set to 40% | Command:
```bash
kubectl autoscale rc security --max=7 --cpu-percent=40
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that use... |
Retrieve the output from running the 'geth' command in the 'nebula-navigator' container of the 'auth-service-pod' pod. | Command:
```bash
kubectl exec auth-service-pod -c nebula-navigator -- geth
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted,... |
Get output from running the 'mysqld' command from the gateway-pod pod, using the first container by default | Command:
```bash
kubectl exec gateway-pod -- mysqld
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.kubern... |
Retrieve the details of the ReplicaSet named "web", the Service named "payment-gateway-rc", and the Pod named "auth-service-pod" by using the "kubectl get" command followed by the resource types and names separated by space. | Command:
```bash
kubectl get rc/web service/payment-gateway-rc pods/auth-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 n... |
Execute the 'geth' command in the 'stardust-shuttle' container of the 'security-service-pod' pod and display the output. | Command:
```bash
kubectl exec security-service-pod -c stardust-shuttle -- geth
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omit... |
attach to a specific container within a pod in interactive mode | Command:
```bash
kubectl attach web-app-pod -c quantum-quark -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 omitt... |
Scale the deployment named staging-app-rs to 7 replicas | Command:
```bash
kubectl scale --current-replicas=3 --replicas=7 deployment/staging-app-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... |
Attach to the 'lunar-launcher' container within the 'web-app-pod' pod and get its output | Command:
```bash
kubectl attach web-app-pod -c lunar-launcher
```
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... |
Apply an update to the 'backend-microservice-deployment' deployment by setting the environment variable SMTP_PASSWORD to 'your-password' | Command:
```bash
kubectl set env deployment/backend-microservice-deployment SMTP_PASSWORD=your-password
```
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... |
List resources of type ReplicationController (rc), Service, and Pod by their respective names "web", "chat-app-rc", and "media-stream-pod" | Command:
```bash
kubectl get rc/web service/chat-app-rc pods/media-stream-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 namespac... |
Listen on port 5000 locally and forward the traffic to port 5432 in the pod named 'api-service-pod' | Command:
```bash
kubectl port-forward pod/api-service-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 au... |
Create a new ExternalName service named external-geolocation-service with the external name "sandbox-site.co" | Command:
```bash
kubectl create service externalname external-geolocation-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 ... |
Update the annotation 'app-version' of the pod 'monitoring' to '2.5.1', replacing any existing value | Command:
```bash
kubectl annotate --overwrite pods monitoring 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 inc... |
create a new secret named password-secret from an environment file | Command:
```bash
kubectl create secret generic password-secret --from-env-file=path/to/data.env
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, the key will default to the basename... |
Start the ubuntu pod with a custom command and arguments | Command:
```bash
kubectl run nginx --image=ubuntu --command -- <cmd> <arg1> ... <argN>
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpfu... |
Apply a taint to the node 'kube-master-9' with the key 'environment' and value 'production', and the effect 'NoSchedule' | Command:
```bash
kubectl taint nodes kube-master-9 environment=production:NoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output ... |
Describe the pod specified in the "settings.json" file. | Command:
```bash
kubectl describe -f settings.json
```
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 that type, provide a ... |
Set a custom TLS server name for the cluster "galaxy-cluster" to use for validation. | Command:
```bash
kubectl config set-cluster galaxy-cluster --tls-server-name=sun-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... |
Start a pod named hazelcast using the ruby image, and expose port 8083 in the container. | Command:
```bash
kubectl run hazelcast --image=ruby --port=8083
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--fil... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=CONFIG_FILE_PATH --from=configmap/kube-system-config deployment/gateway-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... |
Listen on port 8080 on localhost and IP 10.19.21.23, and forward the incoming traffic to port 8888 in the 'api-service-pod' pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/api-service-pod 8080: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 cri... |
Create a role binding named "admin" that assigns the "admin" cluster role to the users "app-operator" and "sysadmin", as well as the group "security-auditors" | Command:
```bash
kubectl create rolebinding admin --clusterrole=admin --user=app-operator --user=sysadmin --group=security-auditors
```
What it does:
Create a role binding for a particular role or cluster role.
Syntax:
`kubectl create rolebinding NAME --clusterrole=NAME|--role=NAME [--user=username] [--group=groupnam... |
Edit the last-applied-configuration annotations of a deployment named "golang" in YAML format | Command:
```bash
kubectl apply edit-last-applied deployment/golang
```
What it does:
Edit the latest last-applied-configuration annotations of resources from the default editor.
The edit-last-applied command allows you to directly edit any API resource you can retrieve via the command-line tools. It will open the edit... |
Edit the cache-service svc resource using the gedit editor as an alternative option. | Command:
```bash
KUBE_EDITOR="gedit" kubectl edit svc/cache-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,... |
Forward traffic from port 8080 on all addresses to port 8888 in the pod named "chat-app-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/chat-app-pod 8080: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... |
Taint node 'k8s-node-1' with key 'disktype', value 'ssd', and effect 'NoSchedule' | Command:
```bash
kubectl taint nodes k8s-node-1 disktype=ssd:NoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One o... |
Set the CPU and memory limits to 200m and 512Mi respectively, and CPU and memory requests to 3 and 2Gi respectively, for all containers in the 'kafka' deployment. | Command:
```bash
kubectl set resources deployment kafka --limits=cpu=200m,memory=512Mi --requests=cpu=3,memory=2Gi
```
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, ... |
Create a copy of the vpn-service-pod with a debug container and updated container images | Command:
```bash
kubectl debug vpn-service-pod -it --copy-to=debug-image-api --image=debian --set-image=logger=logging-app:debug,api=api:v2
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource... |
Create a job called image-build-job with the ubuntu image, and execute the command "docker run ubuntu echo 'Hello'" | Command:
```bash
kubectl create job image-build-job --image=ubuntu -- docker run ubuntu echo "Hello
```
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": "", "us... |
Forward local data from port 9090 to port 8000 in the 'cdn-service-pod' 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... |
Rename a context in your kubeconfig file | Command:
```bash
kubectl config rename-context dev-context client-1-context
```
What it does:
Renames a context from the kubeconfig file.
CONTEXT_NAME is the context name that you want to change.
NEW_NAME is the new name you want to set.
Note: If the context being renamed is the 'current-context', this field will also... |
Forward local port to a pod port | Command:
```bash
kubectl port-forward pod/backend-pod 8000:9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automa... |
Update the annotation 'git-repo' of pod 'foo' with the value 'https://github.com/example/my-app', overwriting any existing value. | Command:
```bash
kubectl annotate --overwrite pods foo git-repo='https://github.com/example/my-app'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger t... |
start a busybox pod with the ruby image and keep it in the foreground without restarting if it exits | Command:
```bash
kubectl run -i -t busybox --image=ruby --restart=Never
```
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"... |
Copy the local file /tmp/foo to the remote pod api-server-pod-3 in the container named database-container, and place it in the /tmp/bar directory | Command:
```bash
kubectl cp /tmp/foo api-server-pod-3:/tmp/bar -c database-container
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use... |
Set the cpu limit of the go container in the nginx deployment to "10" and the memory limit to "4Gi" | Command:
```bash
kubectl set resources deployment go -c=nginx --limits=cpu=10,memory=4Gi
```
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 sp... |
Create a role named "foo" with API Group specified. Grant the role permissions to update, get, and patch network policies. | Command:
```bash
kubectl create role foo --verb=update,get,patch --resource=networkpolicies.networking.k8s.io
```
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|client|none]`
Helpful fl... |
Start port forwarding on port 5432 locally, forwarding data to and from port 8888 in a pod selected by the web-app-deployment deployment. | Command:
```bash
kubectl port-forward deployment/web-app-deployment 5432 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 s... |
Retrieve the logs of the previously terminated nano-bot container from the log-aggregator-pod. | Command:
```bash
kubectl logs -p -c nano-bot log-aggregator-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", "... |
Expose a replication controller with specific specifications from a YAML file. | Command:
```bash
kubectl expose -f ruby-controller.yaml --port=6379 --target-port=300100
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the s... |
Set the certificate authority data for the 'on-prem-cluster' cluster entry using the command `kubectl config set-cluster on-prem-cluster --embed-certs --certificate-authority=~/.kube/testing-cluster/kubernetes.ca.crt` | Command:
```bash
kubectl config set-cluster on-prem-cluster --embed-certs --certificate-authority=~/.kube/testing-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 conf... |
Create a new config map named kube-system-config using data from a folder | Command:
```bash
kubectl create configmap kube-system-config --from-file=path/to/data
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a config map based on a file, the key will default to the basena... |
Execute the 'bash' command in the stardust-shuttle container of the backend-pod and get the output. | Command:
```bash
kubectl exec backend-pod -c stardust-shuttle -- bash
```
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 ... |
Add a taint with key 'datacenter' on nodes having label app=web-app | Command:
```bash
kubectl taint node -l app=web-app datacenter=db-node-7:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Ou... |
Get the output from running the 'pip --version' command in the 'stardust-shuttle' container of the 'chat-app-pod' pod. | Command:
```bash
kubectl exec chat-app-pod -c stardust-shuttle -- 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 omi... |
List deployments in the "dev-2.2.0" version of the "api-v2" API group in YAML format. | Command:
```bash
kubectl get deployments.dev-2.2.0.api-v2 -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 ... |
Start streaming the logs of the "astro-container" container in the "mypod" pod | Command:
```bash
kubectl logs -f -c astro-container 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"... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.