prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
List the replication controller named "web", the service named "api-service-rc", and the pod named "monitoring-pod". | Command:
```bash
kubectl get rc/web service/api-service-rc pods/monitoring-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 namespa... |
Create a service for the replication controller specified in "node-controller.yaml" file, which listens on port 8010 and forwards requests to the containers on port 801000. | Command:
```bash
kubectl expose -f node-controller.yaml --port=8010 --target-port=801000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the s... |
remove the label named 'bar' from the pod 'proxy' | Command:
```bash
kubectl label pods proxy tier-
```
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, ... |
Embed the certificate authority data for the "app-cluster" cluster entry. | Command:
```bash
kubectl config set-cluster app-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 /var/run/secrets/kubernetes.io/serviceaccount/ from your local machine to the directory /tmp/bar_dir in the pod named file-server-pod-14 in the istio-system namespace | Command:
```bash
kubectl cp /var/run/secrets/kubernetes.io/serviceaccount/ istio-system/file-server-pod-14:/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... |
Create an ingress resource called 'web-ingress' that directs requests for the path '/bar' on the domain 'testing.com' to the service 'svc1' on port 8888 | Command:
```bash
kubectl create ingress web-ingress --rule="testing.com/bar=svc1:8888,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": ... |
Auto scale the replication controller "api" with a target CPU utilization of 50%, and a maximum of 4 pods. | Command:
```bash
kubectl autoscale rc api --max=4 --cpu-percent=50
```
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... |
Create an ingress named 'app-loadbalancer-ingress' that directs requests to site.com/example to the service named 'svc1' on port 8181, and use the TLS secret named 'my-cert' for secure communication. | Command:
```bash
kubectl create ingress app-loadbalancer-ingress --rule="site.com/example=svc1:8181,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default":... |
Import the 'max_connections' key from the 'kube-system-config' ConfigMap to the 'notification-handler-deployment' deployment. | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/kube-system-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... |
Copy the file "/tmp/foo" from the remote pod "kube-system/api-server-pod-3" to the local directory "/tmp/bar" | Command:
```bash
kubectl cp kube-system/api-server-pod-3::/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... |
Create a deployment named "drupal" using the "docker.elastic.co/elasticsearch/elasticsearch" image and expose port 8181. | Command:
```bash
kubectl create deployment drupal --image=docker.elastic.co/elasticsearch/elasticsearch --port=8181
```
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":... |
Partially update the kube-proxy configuration identified in the "kube-proxy-config.yaml" file using strategic merge patch | Command:
```bash
kubectl patch -f kube-proxy-config.yaml -p '{"data":{"key":"new-value"}'
```
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]`
... |
Create an ingress called 'app1-ingress' that maps requests for testing.com/input to svc1:8010 using a TLS secret "my-cert" | Command:
```bash
kubectl create ingress app1-ingress --rule="testing.com/input=svc1:8010,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage... |
Forward port 8081 on localhost and IP 10.19.21.23 to port 8888 in the pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/api-service-pod 8081: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... |
Forward traffic from a random local port to port 5432 in the 'chat-app-pod' pod | Command:
```bash
kubectl port-forward pod/chat-app-pod :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 automatic... |
Import environment variables from the config map "app-name-config" with a prefix "MYSQL_" into the "database-deployment" deployment. | Command:
```bash
kubectl set env --from=configmap/app-name-config --prefix=MYSQL_ deployment/database-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 ... |
forward local port 3000 to pod port 8088 | Command:
```bash
kubectl port-forward pod/analytics-pod 3000 8088
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected auto... |
Retrieve the snapshot logs from the container 'email-server-deployment-1' in the deployment named 'email-service-pod' | Command:
```bash
kubectl logs deployment/email-server-deployment -c email-service-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
... |
Create a service for the ubuntu deployment that serves on port 80 and connects to the containers on port 8000 | Command:
```bash
kubectl expose deployment ubuntu --port=8000 --target-port=8000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified... |
Copy the local file /tmp/foo_dir to the remote pod load-balancer-pod-9 in the velero namespace, and place it in the /etc/kubernetes directory. | Command:
```bash
kubectl cp /tmp/foo_dir velero/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 ... |
Forward port 8000 on localhost and IP 10.19.21.23 to port 6379 in the pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/api-service-pod 8000: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 cri... |
Copy the local file /tmp/foo to the /etc/kubernetes directory in the payment-gateway-pod-19 pod's database-container container. | Command:
```bash
kubectl cp /tmp/foo payment-gateway-pod-19:/etc/kubernetes -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... |
Forward traffic from port 8000 on all addresses to port 8081 in the log-aggregator-pod pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/log-aggregator-pod 8000: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 po... |
Scale the "web" deployment to have a total of 7 replicas, taking into account its current size which is 3. | Command:
```bash
kubectl scale --current-replicas=3 --replicas=7 deployment/web
```
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 is spec... |
Access the raw terminal of a pod named "backend-pod" and the container named "cyber-sleuth", allowing you to send input to the container and receive the output in real-time. | Command:
```bash
kubectl attach backend-pod -c cyber-sleuth -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... |
Forward local traffic on port 8888 to the pod 'e-commerce-pod' on port 9090 | Command:
```bash
kubectl port-forward pod/e-commerce-pod 8888: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 aut... |
Update the annotation of the pod named 'monitoring' with the key 'team' and the value 'frontend team'. | Command:
```bash
kubectl annotate pods monitoring team='frontend team'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include arbitr... |
Create a pod disruption budget named critical-services-pdb that will select all pods with the version=v2 label and require a minimum of four of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget critical-services-pdb --selector=version=v2 --min-available=4
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available... |
Create a pod disruption budget for pods with a specific label and ensure at least one of them is always available. | Command:
```bash
kubectl create poddisruptionbudget api-service-pdb --selector=release=1.0.0 --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=N ... |
Forward local port 9090 to port 8080 in the pod named "analytics-pod" | Command:
```bash
kubectl port-forward pod/analytics-pod 9090 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 auto... |
Import the 'smtp_server' key from the 'monitoring-config' config map into the 'email-server-deployment' deployment. | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/monitoring-config 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 def... |
Display only the most recent 5 lines of output in the backend-pod pod. | Command:
```bash
kubectl logs --tail=5 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",... |
Run the 'geth' command inside the 'nano-bot' container of the 'proxy-service-pod' pod and display the output. | Command:
```bash
kubectl exec proxy-service-pod -c nano-bot -- geth
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use th... |
Rename a context in the kubeconfig file | Command:
```bash
kubectl config rename-context cluster-1-context client-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 wil... |
Create a role named "bar" with ResourceName specified | Command:
```bash
kubectl create role bar --verb=create --resource=pods --resource-name=auth-proxy --resource-name=api-server
```
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|non... |
Autoscale the deployment named "gateway" with a minimum of 4 pods and a maximum of 15 pods. | Command:
```bash
kubectl autoscale deployment gateway --min=4 --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... |
Set the client-key value for the "saas-admin" entry without modifying other values | Command:
```bash
kubectl config set-credentials saas-admin --client-key=~/.kube/admin.key
```
What it does:
Set a user entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values.
Client-certificate flags:
--client-certificate=certfile --client-key=keyfile
Bearer token ... |
Execute the 'node' command in the 'nano-bot' container of the 'vpn-service-pod' pod and retrieve the output | Command:
```bash
kubectl exec vpn-service-pod -c nano-bot -- node
```
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 ... |
Scale the deployment named "prod-app-rs" to 5 replicas if its current size is 1. | Command:
```bash
kubectl scale --current-replicas=1 --replicas=5 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... |
Create a cluster role named "foo" with the verb "list" and the non-resource URL "/healthz" specified | Command:
```bash
kubectl create clusterrole "foo" --verb=list --non-resource-url=/healthz
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": ... |
Autoscale the "media-stream" deployment with a minimum of 6 pods and a maximum of 15 pods. | Command:
```bash
kubectl autoscale deployment media-stream --min=6 --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... |
Import the 'max_connections' key from the 'monitoring-config' config map into the 'backend-microservice-deployment' deployment | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/monitoring-config deployment/backend-microservice-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment ... |
Get the output of running the 'pip --version' command in the 'rocket-ranger' container from the 'cdn-service-pod' pod. | Command:
```bash
kubectl exec cdn-service-pod -c rocket-ranger -- 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... |
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=properties=/path/to/configs/file1.txt --from-file=key1=/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 creatin... |
Create a service for the replicated hazelcast using replica set that serves on port 8084 and connects to the containers on port 8000. | Command:
```bash
kubectl expose rs hazelcast --port=8084 --target-port=8000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port... |
Set the CPU and memory limits and requests for all containers in the 'kafka' deployment to 200m CPU, 512Mi memory limits, and 5 CPU, 128Mi memory requests. | Command:
```bash
kubectl set resources deployment kafka --limits=cpu=200m,memory=512Mi --requests=cpu=5,memory=128Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested... |
Forward local port 9090 to port 3000 on the pod named "mypod" | Command:
```bash
kubectl port-forward pod/mypod 9090:3000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automaticall... |
Run the command 'pip --version' inside the lunar-launcher container of the gateway-pod pod. | Command:
```bash
kubectl exec gateway-pod -c lunar-launcher -- 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 omitte... |
Set custom TLS server name 'testing-cluster' to use for validation for the 'app-cluster' cluster entry. | Command:
```bash
kubectl config set-cluster app-cluster --tls-server-name=testing-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] [--certifica... |
Listen on port 9090 on localhost and IP 10.19.21.23, forwarding traffic to port 8000 in the pod named 'cdn-service-pod' | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 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 cri... |
Retrieve the previous terminated logs of the "astro-container" container from the "security-service-pod" pod | Command:
```bash
kubectl logs -p -c astro-container security-service-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--cont... |
Add a taint on nodes with a specific label | Command:
```bash
kubectl taint node -l myLabel environment=gpu-node-12: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... |
Run the 'nginx' command in the 'lunar-launcher' container inside the 'gateway-pod' pod and get the output | Command:
```bash
kubectl exec gateway-pod -c lunar-launcher -- nginx
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use t... |
Attach to the "cyber-sleuth" container of the "media-stream-pod" pod to get its output. | Command:
```bash
kubectl attach media-stream-pod -c cyber-sleuth
```
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... |
Remove all the taints with 'special' as the key from the node 'storage-node-13' | Command:
```bash
kubectl taint nodes storage-node-13 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|ya... |
Update the 'payment-processor-deployment' deployment by adding a new environment variable called DEBUG with a value of true. | Command:
```bash
kubectl set env deployment/payment-processor-deployment DEBUG=true
```
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 ... |
Partially update a node using a strategic merge patch, specifying the patch as YAML | Command:
```bash
kubectl patch node web-node-8 -p $'spec:\n rules:\n- http:\n paths:\n - path: /\n backend:\n service:\n 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.
Syn... |
Update the annotation 'security-scan-status' with the value 'pass' for the pod 'monitoring', replacing any existing value. | Command:
```bash
kubectl annotate --overwrite pods monitoring security-scan-status='pass'
```
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... |
Create a copy of the auth-service-pod adding a debug container and changing container images | Command:
```bash
kubectl debug auth-service-pod -it --copy-to=debug-image-app --image=debian --set-image=mailer=mailer:latest,app=app:debug
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource... |
Begin streaming the logs of the ruby container in the media-stream-pod pod | Command:
```bash
kubectl logs -f -c ruby media-stream-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"... |
Forward traffic from port 5000 on localhost and IP 10.19.21.23 to port 6379 inside the api-service-pod pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/api-service-pod 5000: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 cri... |
Add an annotation to the pod 'proxy-server' with the key 'team' and the value 'frontend team' | Command:
```bash
kubectl annotate pods proxy-server team='frontend team'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include arbi... |
Update the image of all containers in the daemonset 'namespace-1' to 'httpd:2.4.48'. | Command:
```bash
kubectl set image daemonset namespace-1 *=httpd:2.4.48
```
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:
... |
View the most recent 3 lines of logs for the pod named "frontend-pod" | Command:
```bash
kubectl logs --tail=3 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", "short": "-c"... |
Create a cluster role named "foo" with the following permissions: use, get, and patch on the resources: services and services/proxy. | Command:
```bash
kubectl create clusterrole foo --verb=use,get,patch --resource=services,services/proxy
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--outp... |
Create a new deployment named auth using the mcr.microsoft.com/dotnet/core/runtime image, and expose port 3000. | Command:
```bash
kubectl create deployment auth --image=mcr.microsoft.com/dotnet/core/runtime --port=3000
```
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": "", "usag... |
Create a priority class named external-priority with a value of 5 for prioritizing external-facing services. | Command:
```bash
kubectl create priorityclass external-priority --value=5 --description="Priority for external-facing services"
```
What it does:
Create a priority class with the specified name, value, globalDefault and description.
Syntax:
`kubectl create priorityclass NAME --value=VALUE --global-default=BOOL [--dry... |
Retrieve information about the replication controller named 'web', the service named 'monitoring-rc', and the pod named 'database-pod' | Command:
```bash
kubectl get rc/web service/monitoring-rc pods/database-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 namespaced... |
Expose a pod as a service on a specific port with a given name | Command:
```bash
kubectl expose pod proxy-server-pod --port=8083 --name=frontend
```
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... |
Add a taint on nodes with label zone=us-east-1 | Command:
```bash
kubectl taint node -l zone=us-east-1 disktype=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 a copy of the "log-aggregator-pod" by running a debug session, and change the container to "code-explorer". | Command:
```bash
kubectl debug log-aggregator-pod -it --copy-to=my-debugger --container=code-explorer -- sh
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by ... |
Output the modified YAML configuration of the deployment "monitoring-stack-deployment" with the updated SMTP_PASSWORD environment variable, without making any changes to the server. | Command:
```bash
kubectl set env deployment/monitoring-stack-deployment SMTP_PASSWORD=your-password -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 on... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/kube-system-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 v... |
Forward local ports 8088 and 6000 to ports 5432 and 6000 in the pod named analytics-pod | Command:
```bash
kubectl port-forward pod/analytics-pod 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 selected auto... |
Forward the local port 5000 to port 6379 inside the 'cdn-service-pod' pod. | Command:
```bash
kubectl port-forward pod/cdn-service-pod 5000: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 au... |
Copy the ~/.config/kube file from the metrics-exporter-pod-10 pod in the kubeapps namespace to the /tmp/bar_dir directory on your local machine. | Command:
```bash
kubectl cp kubeapps/metrics-exporter-pod-10:~/.config/kube /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,... |
Create an ingress called 'website-ingress' with the rule to direct requests from testing.com/example to svc1:5432 and use the tls secret "my-cert" | Command:
```bash
kubectl create ingress website-ingress --rule="testing.com/example=svc1:5432,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "... |
Create a job named "database-seeding-job" using the "amazonlinux" image with the command "bash" | Command:
```bash
kubectl create job database-seeding-job --image=amazonlinux -- bash
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output f... |
Display the last 23 lines of logs for the pod named media-stream-pod | Command:
```bash
kubectl logs --tail=23 media-stream-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 named 'public-api-ingress' that routes requests for 'testing.com/bar' to the service 'svc1:8089' with the TLS secret 'my-cert'. | Command:
```bash
kubectl create ingress public-api-ingress --rule="testing.com/bar=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": "", "u... |
Create a debug copy of the gateway-pod, replacing all container images with "mysql" | Command:
```bash
kubectl debug gateway-pod --copy-to=debug-image-memcached --set-image=*=mysql
```
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 a deployment called prometheus using the postgres image and expose port 3000. | Command:
```bash
kubectl create deployment prometheus --image=postgres --port=3000
```
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... |
forward local traffic from port 8081 to the port 8080 in a pod selected by the 'authentication-service-deployment' deployment. | Command:
```bash
kubectl port-forward deployment/authentication-service-deployment 8081 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, ... |
Retrieve the output from running the 'bash' command inside the proxy-server-pod. Use the first container by default. | Command:
```bash
kubectl exec proxy-server-pod -- 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 the kubectl.kub... |
Taint nodes with label 'myLabel' as dedicated nodes and prefer not to schedule new pods on them. | Command:
```bash
kubectl taint node -l myLabel dedicated=edge-node-10:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Outp... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/kube-system-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 def... |
Expose the wordpress replication controller as a service, serving on port 6379 and connecting to the containers on port 909100. | Command:
```bash
kubectl expose rc wordpress --port=6379 --target-port=909100
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified po... |
Copy the local directory "/tmp/foo_dir_dir" to the remote pod "security-scanner-pod-18" in the "/tmp/bar_dir" directory. | Command:
```bash
kubectl cp /tmp/foo_dir_dir security-scanner-pod-18::/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 t... |
Import environment variables from a secret to a deployment | Command:
```bash
kubectl set env --from=secret/database-secret deployment/user-management-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or mo... |
Add a taint with key 'app' on nodes having label customer=acme-corp | Command:
```bash
kubectl taint node -l customer=acme-corp app=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": "Outpu... |
Return snapshot logs from the container `database-pod-1` of a deployment named `proxy-service-deployment`. | Command:
```bash
kubectl logs deployment/proxy-service-deployment -c database-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:
"fla... |
Add a taint on nodes with a specific label | Command:
```bash
kubectl taint node -l cluster=my-cluster datacenter=testing-node-11: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": "",... |
Retrieve the previous terminated logs for the 'cosmic-container' container within the 'analytics-pod' pod | Command:
```bash
kubectl logs -p -c cosmic-container analytics-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container"... |
Update the pod identified in "preferences.json" by adding a new annotation with the key "team" and the value "frontend team" | Command:
```bash
kubectl annotate -f preferences.json team='frontend team'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include ar... |
Start a centos pod named nginx, but customize the pod's specifications with a partial set of values parsed from JSON | Command:
```bash
kubectl run nginx --image=centos --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] -- [COMMAN... |
Copy the `~/.config/kube` file from your local machine to the `/tmp/bar` path in the `logging-agent` container of the `auth-service-pod-11` pod. | Command:
```bash
kubectl cp ~/.config/kube auth-service-pod-11:/tmp/bar -c logging-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 omitted,... |
Embed the certificate authority data for the 'moon-cluster' cluster entry by running the command: "kubectl config set-cluster moon-cluster --embed-certs --certificate-authority=~/.kube/galaxy-cluster/kubernetes.ca.crt". | Command:
```bash
kubectl config set-cluster moon-cluster --embed-certs --certificate-authority=~/.kube/galaxy-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... |
Import environment variables from a secret into a deployment | Command:
```bash
kubectl set env --from=secret/database-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 more ... |
Update the labels of the pod named 'gateway' by adding the label 'role' with the value 'backend' | Command:
```bash
kubectl label pods gateway role=backend
```
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": "... |
View detailed information of pods with label feature=feature-xyz | Command:
```bash
kubectl describe po -l feature=feature-xyz
```
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, p... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.