prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Listen on a random port locally, forwarding to port 5000 in the 'frontend-pod' pod | Command:
```bash
kubectl port-forward pod/frontend-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 automatic... |
Forward traffic from local port 8088 to port 8080 in the pod named "frontend-pod" | Command:
```bash
kubectl port-forward pod/frontend-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 autom... |
Update the annotation 'last-deployment' of pod 'gateway' with the value '2023-03-15', replacing any existing value | Command:
```bash
kubectl annotate --overwrite pods gateway last-deployment='2023-03-15'
```
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 a... |
Set the cluster field in the context config to a specific cluster | Command:
```bash
kubectl config set contexts.client-2-context.cluster galaxy-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... |
Forward traffic from local port 8000 to port 8000 in the pod named "mypod" | Command:
```bash
kubectl port-forward pod/mypod 8000:8000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automaticall... |
Stream the logs in real-time from all containers in pods that have the label "owner" set to "john-doe" | Command:
```bash
kubectl logs -f -l owner=john-doe --all-containers=true
```
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... |
Forward data between local ports 3000 and 8088 to the 'chat-app-pod' pod ports 3000 and 8088 | Command:
```bash
kubectl port-forward pod/chat-app-pod 3000 8088
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected autom... |
Autoscale the replication controller "api" with the number of pods between 1 and 7, targeting a CPU utilization of 20%. | Command:
```bash
kubectl autoscale rc api --max=7 --cpu-percent=20
```
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 a service for the replication controller specified in "node-controller.yaml" file, which serves on port 8081 and connects to the containers on port 808200 | Command:
```bash
kubectl expose -f node-controller.yaml --port=8081 --target-port=808200
```
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... |
Taint the nodes with the label 'release=beta' by adding a taint with key 'disktype' and value 'node-1' and set it to PreferNoSchedule. | Command:
```bash
kubectl taint node -l release=beta disktype=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": "Output... |
Delete the pods and services with the names "backend" and "proxy" | Command:
```bash
kubectl delete pod,service backend proxy
```
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.
S... |
Update the 'gateway' pod with the annotation 'criticality' set to 'high', overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods gateway 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... |
Completely drain the gpu-node-12 node, even if there are pods not managed by a replication controller, replica set, job, daemon set, or stateful set on it | Command:
```bash
kubectl drain gpu-node-12 --force
```
What it does:
Drain node in preparation for maintenance.
The given node will be marked unschedulable to prevent new pods from arriving. 'drain' evicts the pods if the API server supports https://kubernetes.io/docs/concepts/workloads/pods/disruptions/ . Otherwise, ... |
Forward traffic from local port 8081 to port 8080 in the pod named api-service-pod. | Command:
```bash
kubectl port-forward pod/api-service-pod 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, a pod will be selected au... |
Create a copy of the 'database-pod' pod, changing all container images to 'confluentinc/cp-kafka', and name the new pod 'dgb-img'. | Command:
```bash
kubectl debug database-pod --copy-to=dgb-img --set-image=*=confluentinc/cp-kafka
```
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... |
List deployments in YAML format from the "testing-apps" API group, using the "v2.0.0" version of the API. | Command:
```bash
kubectl get deployments.v2.0.0.testing-apps -o yaml
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you wi... |
Import the environment variables from the 'ssh-key-secret' secret and set them for the 'analytics-platform-deployment' deployment. | Command:
```bash
kubectl set env --from=secret/ssh-key-secret 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 variable definitions in one or ... |
Forward traffic from port 8000 on localhost and IP 10.19.21.23 to port 8888 in the pod named 'api-service-pod' | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/api-service-pod 8000: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... |
Add a taint with the key 'hardware' and value 'worker-node-3:PreferNoSchedule' on all nodes that have the label 'app=web-app'. | Command:
```bash
kubectl taint node -l app=web-app hardware=worker-node-3:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "... |
List the deployments in the "api-v2" API group, in the "legacy-1.0.0" version, with the output format in JSON. | Command:
```bash
kubectl get deployments.legacy-1.0.0.api-v2 -o json
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you wi... |
Import the API_KEY key from the ui-config config map into the authentication-service-deployment deployment. | Command:
```bash
kubectl set env --keys=API_KEY --from=configmap/ui-config deployment/authentication-service-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defin... |
Start a hazelcast pod with the nginx image | Command:
```bash
kubectl run nginx --image=hazelcast/hazelcast
```
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": "--file... |
Create a cron job named daily-report that runs the command `go version` every minute using the image `golang`. | Command:
```bash
kubectl create cronjob daily-report --image=golang --schedule="*/1 * * * *" -- go version
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o",... |
Forward port 8088 locally to the targetPort of the "https" service port in a selected pod, named "backend-service" | Command:
```bash
kubectl port-forward service/backend-service 8088:https
```
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... |
Import the MAX_CONNECTIONS key from the config map called app-config-prod into the environment variables of the database-deployment deployment. | Command:
```bash
kubectl set env --keys=MAX_CONNECTIONS --from=configmap/app-config-prod 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 defin... |
Remove the 'bar' label from the 'backend' pod | Command:
```bash
kubectl label pods backend 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... |
Listen on port 5000 locally and forward data to/from port 9090 in a pod selected by the log-aggregator-deployment deployment | Command:
```bash
kubectl port-forward deployment/log-aggregator-deployment 5000 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 wi... |
Create a deployment named jenkins with the jenkins image and exposing port 8082 | Command:
```bash
kubectl create deployment jenkins --image=jenkins --port=8082
```
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:... |
Execute the 'node' command in the 'rocket-ranger' container of the 'api-service-pod' pod and retrieve the output. | Command:
```bash
kubectl exec api-service-pod -c rocket-ranger -- 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... |
Check if you have permission to list the job named "notification-sender-job" in the namespace "staging" | Command:
```bash
kubectl auth can-i list jobs.batch/notification-sender-job -n staging
```
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 partia... |
Attach to the running pod named chat-app-pod and get the output from the first container in the pod or the container specified by the 'kubectl.kubernetes.io/default-container' annotation. | Command:
```bash
kubectl attach chat-app-pod
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.ku... |
Attach to a specific container in a pod and establish a raw terminal connection | Command:
```bash
kubectl attach backend-pod -c stardust-shuttle -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... |
Create a copy of the 'payment-gateway-pod' with a debug container and different container images | Command:
```bash
kubectl debug payment-gateway-pod -it --copy-to=debug-image-app --image=debian --set-image=worker=my-custom-worker:1.2.3,scheduler=my-scheduler:1.0
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objec... |
Copy the file /tmp/foo from the remote pod named task-processor-pod-17 in the kubeapps namespace to the local directory /tmp/bar | Command:
```bash
kubectl cp kubeapps/task-processor-pod-17:/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 ku... |
import the keys "CONFIG_FILE_PATH" from the "ui-config" config map into the "frontend-deployment" deployment | Command:
```bash
kubectl set env --keys=CONFIG_FILE_PATH --from=configmap/ui-config deployment/frontend-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definition... |
Create an ingress called 'api-ingress' that directs requests to a specific path of a website to a service, with TLS encryption enabled | Command:
```bash
kubectl create ingress api-ingress --rule="website.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": "", "usag... |
Import environment variables from a secret for a deployment | Command:
```bash
kubectl set env --from=secret/email-credentials-secret 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 definitions in... |
Create a debug container named dgb-img with the same configuration as the security-service-pod, but with all container images changed to mcr.microsoft.com/dotnet/core/runtime. | Command:
```bash
kubectl debug security-service-pod --copy-to=dgb-img --set-image=*=mcr.microsoft.com/dotnet/core/runtime
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods wi... |
Import the specific key named 'my-example-key' from the 'app-config' config map into the environment variables of the 'cache-cluster-deployment' deployment. | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/app-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 defini... |
Display the most recent 12 lines of logs for the 'analytics-pod' pod. | Command:
```bash
kubectl logs --tail=12 analytics-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "short": "-... |
Import specific keys from a config map to the environment variables of a deployment named "gateway-deployment" | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/ui-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 definitions in o... |
Begin streaming the logs of the nebula-navigator container in the auth-service-pod pod. | Command:
```bash
kubectl logs -f -c nebula-navigator auth-service-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--contain... |
Set a new environment variable for the 'payment-processor-deployment' deployment | Command:
```bash
kubectl set env deployment/payment-processor-deployment MONGO_URI=mongodb://localhost:27017/mydb
```
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... |
Scale the replica set 'payment-service-rs' to have 1 replica. | Command:
```bash
kubectl scale --replicas=1 rs/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-version is specified, it is v... |
Retrieve the snapshot logs from the container 'proxy-service-pod-1' in the 'web-app-deployment' deployment. | Command:
```bash
kubectl logs deployment/web-app-deployment -c proxy-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:
"flag... |
List the deployments in YAML output format, specifically in the "v2.1.0" version of the "prod-apps" API group | Command:
```bash
kubectl get deployments.v2.1.0.prod-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 ... |
Create an ingress named 'private-service-ingress' with a rule that directs requests from 'site.com/example' to 'svc1:9091' and uses the TLS secret 'my-cert'. | Command:
```bash
kubectl create ingress private-service-ingress --rule="site.com/example=svc1:9091,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 traffic from port 5000 on all addresses to port 8081 in the 'analytics-pod' pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/analytics-pod 5000:8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod wil... |
Add a taint to a specific node, 'edge-node-10', with the key 'cpu-type' and no value. | Command:
```bash
kubectl taint nodes edge-node-10 cpu-type:NoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of:... |
Get the output from running the 'mongo' command inside the 'mycontainer' container in the 'api-service-pod' pod. | Command:
```bash
kubectl exec api-service-pod -c mycontainer -- mongo
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use ... |
Add or update the annotation 'scaling-policy' with the value 'auto-horizontal-scaling' for the pod 'proxy-server', replacing any existing value. | Command:
```bash
kubectl annotate --overwrite pods proxy-server scaling-policy='auto-horizontal-scaling'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be lar... |
Delete the pods and services named "payment" and "proxy-server" | Command:
```bash
kubectl delete pod,service payment proxy-server
```
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 sele... |
Create a pod disruption budget with the name statefulset-pdb | Command:
```bash
kubectl create poddisruptionbudget statefulset-pdb --selector=region=us-east --min-available=9
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N... |
List the replication controller 'web', service 'analytics-rc', and pod 'log-aggregator-pod' by their types and names | Command:
```bash
kubectl get rc/web service/analytics-rc pods/log-aggregator-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 names... |
Create a copy of the proxy-service-pod with all container images changed to golang | Command:
```bash
kubectl debug proxy-service-pod --copy-to=dgb-img --set-image=*=golang
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by default if no resour... |
Create a secret named api-key-secret from an environment file | Command:
```bash
kubectl create secret generic api-key-secret --from-env-file=path/to/properties.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 bas... |
Retrieve the snapshot logs from the container 'monitoring-pod-1' of the 'database-deployment' deployment. | Command:
```bash
kubectl logs deployment/database-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":... |
Update the environment variable 'DEBUG' in the 'frontend-deployment' deployment | Command:
```bash
kubectl set env deployment/frontend-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 (within r... |
Create an ingress called 'app-ingress' that directs requests to the website.com/input path to the svc1:7000 service, using the TLS secret "my-cert". | Command:
```bash
kubectl create ingress app-ingress --rule="website.com/input=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"... |
Set the cpu limits of the container "nginx" in the "node" deployment to "3" and the memory limits to "4Gi" | Command:
```bash
kubectl set resources deployment node -c=nginx --limits=cpu=3,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 s... |
Create a cluster role named "admin_role" with the ability to create pods and specific resource names "blog-backend" and "app-worker-1" | Command:
```bash
kubectl create clusterrole admin_role --verb=create --resource=pods --resource-name=blog-backend --resource-name=app-worker-1
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|client... |
Forward port 8088 on localhost and IP 10.19.21.23 to port 3000 on the frontend-pod to enable local access to the pod's service on port 3000. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/frontend-pod 8088: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 criter... |
Forward traffic from port 8000 to port 8888 in the e-commerce-pod pod, allowing incoming connections from all addresses. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/e-commerce-pod 8000: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 wi... |
List all the allowed actions that can be performed in the "production" namespace | Command:
```bash
kubectl auth can-i --list --namespace=production
```
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 that starts wit... |
Get the output from the cyber-sleuth container in the web-app-pod | Command:
```bash
kubectl attach web-app-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, use... |
Update the service account of the deployment gateway-deployment to spinnaker | Command:
```bash
kubectl set serviceaccount deployment gateway-deployment spinnaker
```
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:
`kubectl ... |
Forward local port 9090 to port 8000 in the pod "log-aggregator-pod" and start listening for incoming traffic. | Command:
```bash
kubectl port-forward pod/log-aggregator-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... |
import environment variables from a secret for a specific deployment | Command:
```bash
kubectl set env --from=secret/password-secret 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 variable definitions in one or m... |
Continuously stream the logs of the "mycontainer" container in the "security-service-pod" pod | Command:
```bash
kubectl logs -f -c mycontainer 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": "--containe... |
Set the last-applied-configuration of a resource to match the contents of the 'parameters.yaml' file | Command:
```bash
kubectl apply set-last-applied -f parameters.yaml
```
What it does:
Set the latest last-applied-configuration annotations by setting it to match the contents of a file. This results in the last-applied-configuration being updated as though 'kubectl apply -f ' was run, without updating any other parts ... |
Import the SECRET_KEY key from the app-config-dev config map and set it as an environment variable for the monitoring-stack-deployment deployment. | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/app-config-dev 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 def... |
Embed the client certificate data located at "~/.kube/admin.crt" in the "prod-user" entry. | Command:
```bash
kubectl config set-credentials prod-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 --client... |
Create a deployment named "auth" that runs the "golang" image and exposes port 8089 | Command:
```bash
kubectl create deployment auth --image=golang --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: jso... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/app-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 variable defini... |
Create a job named 'data-migration-job' using the 'wordpress' image, run the 'mysql' command with the specified version | Command:
```bash
kubectl create job data-migration-job --image=wordpress -- mysql --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": "O... |
Create a service for the replicated node, named "node", which will serve on port 8089 and connect to the containers on port 700000. | Command:
```bash
kubectl expose rc node --port=8089 --target-port=700000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port. A... |
Update the criticality of a pod defined in "preferences.json" to high. | Command:
```bash
kubectl annotate -f preferences.json 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 arbitr... |
Update the last-deployment annotation of the pod specified in the "params.json" file to "2023-03-15" | Command:
```bash
kubectl annotate -f params.json last-deployment=2023-03-15
```
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 a... |
Create a copy of the 'gateway-pod' pod and change all container images to 'postgres'. Save the copy as 'debug-image-web'. | Command:
```bash
kubectl debug gateway-pod --copy-to=debug-image-web --set-image=*=postgres
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by default if no re... |
Forward the traffic from port 5000 on localhost and IP 10.19.21.23 to port 8888 in the 'api-service-pod' pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/api-service-pod 5000: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 Pod Disruption Budget named 'database-pdb' that will select all pods with the 'component=web' label and require at least four of them to be available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget database-pdb --selector=component=web --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=N [--... |
Execute the 'mysql' command in the first container of the 'analytics-platform-deployment' deployment. | Command:
```bash
kubectl exec deploy/analytics-platform-deployment -- mysql
```
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... |
Listen on port 8888 locally and forward data to/from port 8000 in a pod selected by the "web-app-deployment" deployment. | Command:
```bash
kubectl port-forward deployment/web-app-deployment 8888 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 s... |
Listen on port 3000 on all addresses, and forward the traffic to port 3000 in the security-service-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/security-service-pod 3000:3000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a ... |
Rename a context in your kubeconfig file | Command:
```bash
kubectl config rename-context dev-context service-account-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 wi... |
Execute the 'redis-server' command in the nebula-navigator container of the backend-pod pod and get the output. | Command:
```bash
kubectl exec backend-pod -c nebula-navigator -- redis-server
```
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... |
Get the phase value of the media-stream-pod pod | Command:
```bash
kubectl get -o template pod/media-stream-pod --template={{.status.phase}}
```
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 typ... |
Forward local port 5432 to port 5000 in the pod "log-aggregator-pod" | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 5432 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... |
Attach to the 'frontend-pod' pod and get output from the 'warp-drive' container | Command:
```bash
kubectl attach frontend-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, use ... |
Begin streaming the logs of the 'ruby' container in the 'payment-gateway-pod' pod | Command:
```bash
kubectl logs -f -c ruby payment-gateway-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", "sho... |
Set the CPU and memory limits for the nginx container in the centos deployment to 500m and 64Mi respectively. | Command:
```bash
kubectl set resources deployment centos -c=nginx --limits=cpu=500m,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 to... |
Import environment variables prefixed with MYSQL_ from the app-config-prod ConfigMap and apply them to the monitoring-stack-deployment deployment. | Command:
```bash
kubectl set env --from=configmap/app-config-prod --prefix=MYSQL_ 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 defi... |
Import the api_key key from the app-config-prod ConfigMap to the environment variables of the gateway-deployment deployment. | Command:
```bash
kubectl set env --keys=api_key --from=configmap/app-config-prod 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 definitions in... |
Create a new secret named app-config-secret and specify the keys to be used | Command:
```bash
kubectl create secret generic app-config-secret --from-file=ssh-privatekey=path/to/id_rsa --from-file=ssh-publickey=path/to/id_rsa.pub
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secr... |
Forward traffic from local port 8088 to port 5000 in the pod, allowing you to access the pod locally. | Command:
```bash
kubectl port-forward pod/proxy-server-pod 8088: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 a... |
Scale the deployment named "frontend-rs" to 3 replicas, matching the current size of 7 replicas. | Command:
```bash
kubectl scale --current-replicas=7 --replicas=3 deployment/frontend-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... |
Copy the ~/.config/kube local file to :/tmp/bar in the remote pod named image-resizer-pod-20 in the monitoring namespace | Command:
```bash
kubectl cp ~/.config/kube monitoring/image-resizer-pod-20::/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... |
Create a copy of the e-commerce pod and change all container images to use the Ubuntu image. | Command:
```bash
kubectl debug e-commerce-pod --copy-to=debug-image-api --set-image=*=ubuntu
```
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 r... |
Display the last 31 lines of logs for the 'frontend-pod' pod | Command:
```bash
kubectl logs --tail=31 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... |
Import the REDIS_HOST key from the api-config config map into the environment variables of the api-server-deployment deployment. | Command:
```bash
kubectl set env --keys=REDIS_HOST --from=configmap/api-config deployment/api-server-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.