prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
View the rollout history of a deployment named "prod" | Command:
```bash
kubectl rollout history deployment/prod
```
What it does:
View previous rollout revisions and configurations.
Syntax:
`kubectl rollout history (TYPE NAME | TYPE/NAME) [flags]`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to files identify... |
Add a taint with key 'special' on nodes having label team=devops | Command:
```bash
kubectl taint node -l team=devops special=app-node-6: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... |
Run the 'redis-cli' command on the first container of the frontend-pod pod and display the output. | Command:
```bash
kubectl exec frontend-pod -- redis-cli
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.ku... |
Copy the local file /tmp/foo_dir to the remote pod named message-broker-pod-15 in the ingress-nginx namespace and place it in the /tmp/bar directory. | Command:
```bash
kubectl cp /tmp/foo_dir ingress-nginx/message-broker-pod-15:/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, us... |
Get the output from running the 'python --version' command in the quantum-quark container from the media-stream-pod pod. | Command:
```bash
kubectl exec media-stream-pod -c quantum-quark -- python --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... |
Forward local port 3000 to port 5432 in the chat-app-pod pod | Command:
```bash
kubectl port-forward pod/chat-app-pod 3000 5432
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected autom... |
Attach to the code-explorer container of the cdn-service-pod and get its output. | Command:
```bash
kubectl attach cdn-service-pod -c code-explorer
```
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... |
Get the output of the 'dotnet --list-runtimes' command from the first pod of the service 'monitoring-service'. | Command:
```bash
kubectl exec svc/monitoring-service -- dotnet --list-runtimes
```
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... |
Create a service for a replicated Python application that serves on port 80 and connects to the containers on port 8000. | Command:
```bash
kubectl expose rc python --port=8089 --target-port=800000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port.... |
Listen on port 8088 on all addresses and forward the traffic to port 8088 in the 'frontend-pod' pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/frontend-pod 8088: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... |
Create a service for a Python deployment that serves on port 80 and connects to the containers on port 8000 | Command:
```bash
kubectl expose deployment python --port=9092 --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 specifi... |
Add a taint with key 'zone' on nodes that have the label 'instance=app-instance-1' | Command:
```bash
kubectl taint node -l instance=app-instance-1 zone=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": "", "usag... |
Add a taint with the key 'cpu-type' and value 'prod-node-5:PreferNoSchedule' on nodes having the label 'namespace=mynamespace'. | Command:
```bash
kubectl taint node -l namespace=mynamespace cpu-type=prod-node-5: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": "", "u... |
Create a cluster role named "foo" that allows users to perform "patch", "watch", and "exec" operations on configmaps. | Command:
```bash
kubectl create clusterrole foo --verb=patch,watch,exec --resource=configmaps
```
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", "shor... |
Create a new pod called "hazelcast" using the nginx image and expose port 27017 within the container. | Command:
```bash
kubectl run hazelcast --image=nginx --port=27017
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--f... |
Create a service for the replicated alpine deployment, exposing port 8888 and connecting to the containers on port 330600. | Command:
```bash
kubectl expose rc alpine --port=8888 --target-port=330600
```
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.... |
Copy the ~/.config/kube file to the /etc/kubernetes directory in the file-server-pod-14 pod in the kube-public namespace. | Command:
```bash
kubectl cp ~/.config/kube kube-public/file-server-pod-14:/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... |
Taint nodes with label 'environment=production' by adding the taint key-value pair 'dedicated=worker-node-3:PreferNoSchedule' | Command:
```bash
kubectl taint node -l environment=production dedicated=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": ""... |
Get output from the cosmic-container in the media-stream-pod | Command:
```bash
kubectl attach media-stream-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 omi... |
Apply a taint to the node 'storage-node-13' with the key 'dedicated', value 'special-user' and effect 'NoSchedule' | Command:
```bash
kubectl taint nodes storage-node-13 dedicated=special-user: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": "Outpu... |
Embed the certificate authority data for the 'web-cluster' cluster entry using the command: kubectl config set-cluster web-cluster --embed-certs --certificate-authority=~/.kube/testing-cluster/kubernetes.ca.crt | Command:
```bash
kubectl config set-cluster web-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 config s... |
Set the service account for the deployment "backend-microservice-deployment" to "jenkins" | Command:
```bash
kubectl set serviceaccount deployment backend-microservice-deployment jenkins
```
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... |
Set the service account for the 'authentication-service-deployment' deployment to 'argocd' | Command:
```bash
kubectl set serviceaccount deployment authentication-service-deployment argocd
```
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
Synta... |
Run a proxy to the Kubernetes API server on port 9091, serving static content from ./local/www/ | Command:
```bash
kubectl proxy --port=9091 --www=./local/www/
```
What it does:
Creates a proxy server or application-level gateway between localhost and the Kubernetes API server. It also allows serving static content over specified HTTP path. All incoming data enters through one port and gets forwarded to the remote... |
Create a deployment named ingress running the ruby image and expose port 8000 | Command:
```bash
kubectl create deployment ingress --image=ruby --port=8000
```
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: js... |
Create a debugger pod named "my-debugger" by copying the "analytics-pod" with all container images changed to "nginx" | Command:
```bash
kubectl debug analytics-pod --copy-to=my-debugger --set-image=*=nginx
```
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 resourc... |
Copy the local file /tmp/foo to the remote pod load-balancer-pod-9, specifically to the /tmp/bar directory inside the pod's worker-container. | Command:
```bash
kubectl cp /tmp/foo load-balancer-pod-9::/tmp/bar -c worker-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, u... |
Add a taint to a node named 'kube-master-9' with the key 'cpu-type' and no value | Command:
```bash
kubectl taint nodes kube-master-9 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... |
import the 'external_api_url' key from the 'app-config' ConfigMap and set it as an environment variable in the 'frontend-deployment' deployment | Command:
```bash
kubectl set env --keys=external_api_url --from=configmap/app-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 definitio... |
Create a new config map named global-config from the key=value pairs in the specified file | Command:
```bash
kubectl create configmap global-config --from-file=path/to/configs
```
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 basename... |
Create a pod disruption budget named worker-pdb that will select all pods with the project=my-project label and require at least one of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget worker-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-available=N ... |
Copy the file '/var/run/secrets/kubernetes.io/serviceaccount/' from your local machine to the '/tmp/bar' directory in the container named 'metrics-exporter' of the pod named 'web-app-pod-1' | Command:
```bash
kubectl cp /var/run/secrets/kubernetes.io/serviceaccount/ web-app-pod-1::/tmp/bar -c metrics-exporter
```
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"... |
Forward traffic from port 5000 on all addresses to port 5432 in the mypod pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/mypod 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 sel... |
Forward traffic from port 9090 on localhost and IP 10.19.21.23 to port 8081 in the 'e-commerce-pod' pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/e-commerce-pod 9090: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 crit... |
Import the 'redis_host' key from the 'app-config-dev' config map to the 'authentication-service-deployment' deployment. | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/app-config-dev 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 variab... |
Execute the 'mysql' command in the first container of the 'web-service' service | Command:
```bash
kubectl exec svc/web-service -- 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, use the kubectl.kub... |
Add a taint with key 'app' on nodes having label team=devops | Command:
```bash
kubectl taint node -l team=devops app=storage-node-13: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... |
Forward local port 8088 to port 8888 in the selected pod. | Command:
```bash
kubectl port-forward deployment/mydeployment 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 be selecte... |
Forward local port 5432 to port 3000 in the frontend-pod | Command:
```bash
kubectl port-forward pod/frontend-pod 5432 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 autom... |
Taint the nodes labeled with role=database with the key 'dedicated' and value 'app-node-6:PreferNoSchedule' | Command:
```bash
kubectl taint node -l role=database dedicated=app-node-6: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": "... |
Partially update a node with a new value using a strategic merge patch in JSON format. | Command:
```bash
kubectl patch node testing-node-11 -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]`
Helpf... |
Create a new ExternalName service named `external-file-storage-service` with the external name `blog-test.blog` | Command:
```bash
kubectl create service externalname external-file-storage-service --external-name blog-test.blog
```
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 ... |
Create a deployment named "registry" that runs the nginx image and exposes port 3001. | Command:
```bash
kubectl create deployment registry --image=nginx --port=3001
```
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: ... |
Forward data between the local port 6379 and the pod's port 8088 in the 'api-server-deployment' deployment. | Command:
```bash
kubectl port-forward deployment/api-server-deployment 6379 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 b... |
View the previous terminated logs of the container named "stardust-shuttle" in the pod named "backend-pod" | Command:
```bash
kubectl logs -p -c stardust-shuttle 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", ... |
forward local port 8888 to port 3000 in the selected pods of the api-server deployment | Command:
```bash
kubectl port-forward deployment/api-server-deployment 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 will b... |
Add a taint with key 'workload' on nodes having label region=eu-west-2 | Command:
```bash
kubectl taint node -l region=eu-west-2 workload=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":... |
Forward local port 8888 to pod port 9090 in the backend-pod pod. | Command:
```bash
kubectl port-forward pod/backend-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 automa... |
Return the snapshot logs from the container "cdn-service-pod-1" of the deployment "backend-microservice-deployment". | Command:
```bash
kubectl logs deployment/backend-microservice-deployment -c cdn-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 f... |
Create a new ClusterIP service named 'frontend-service-clusterip' that listens on port 27017 and forwards traffic to port 9091. | Command:
```bash
kubectl create service clusterip frontend-service-clusterip --tcp=27017:9091
```
What it does:
Create a ClusterIP service with the specified name.
Syntax:
`kubectl create service clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-... |
forward local port 8081 to port 8080 in the pod 'backend-pod' | Command:
```bash
kubectl port-forward pod/backend-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 automa... |
Embed the certificate authority data for the 'staging-cluster' cluster entry using the provided certificate authority file path. | Command:
```bash
kubectl config set-cluster staging-cluster --embed-certs --certificate-authority=~/.kube/my-k8s-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 confi... |
Scale the deployment named 'webapp-replicaset' to 7 replicas if its current size is 1 | Command:
```bash
kubectl scale --current-replicas=1 --replicas=7 deployment/webapp-replicaset
```
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-v... |
Create an ingress named 'annotated' with the class 'default' and the rule 'site.com/example=svc:port' | Command:
```bash
kubectl create ingress annotated --class=default --rule="site.com/example=svc:port" \
--annotation ingress.annotation1=website \
--annotation ingress.annotation2=bla
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=s... |
Retrieve snapshot logs from the container `log-aggregator-pod-1` of the `payment-processor-deployment` deployment. | Command:
```bash
kubectl logs deployment/payment-processor-deployment -c log-aggregator-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 f... |
Create a config map named env-vars using the values from a file | Command:
```bash
kubectl create configmap env-vars --from-file=path/to/configurations
```
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... |
Embed the certificate authority data for the "data-cluster" cluster entry in the kubeconfig file. | Command:
```bash
kubectl config set-cluster data-cluster --embed-certs --certificate-authority=~/.kube/e2e/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-cluster ... |
Add a taint with key 'app' on nodes having label instance='app-instance-1'. | Command:
```bash
kubectl taint node -l instance=app-instance-1 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... |
Copy the file /var/run/secrets/kubernetes.io/serviceaccount/ from your local machine to the /tmp/bar_dir directory in a remote pod called worker-pod-4, located in the kube-public namespace. | Command:
```bash
kubectl cp /var/run/secrets/kubernetes.io/serviceaccount/ kube-public/worker-pod-4:/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": "Con... |
Create a cron job called 'metrics-collection' with the image 'redis' and the schedule set to run every minute | Command:
```bash
kubectl create cronjob metrics-collection --image=redis --schedule="*/1 * * * *" -- redis-server
```
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"... |
Remove the label 'role' from the pod named 'monitoring' if it exists | Command:
```bash
kubectl label pods monitoring role-
```
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 t... |
Update the annotation 'security-scan-status' of the pod 'email' to 'pass' | Command:
```bash
kubectl annotate pods email 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 and include arbitr... |
Set the cpu limits of the ubuntu container in the nginx deployment to "3" and memory limits to "512Mi" | Command:
```bash
kubectl set resources deployment ubuntu -c=nginx --limits=cpu=3,memory=512Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to i... |
Forward traffic from port 8000 on your local machine to port 5432 in the pod named "chat-app-pod" | Command:
```bash
kubectl port-forward 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 be selected autom... |
Update the 'backend' pod with the annotation 'app-version' and set the value to '2.5.1' | Command:
```bash
kubectl annotate pods backend 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 include arbitrary st... |
Update the label of the pod named 'analytics' to have the label 'release' with the value 'v1.0' | Command:
```bash
kubectl label pods analytics release=v1.0
```
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":... |
Taint nodes labeled with 'project=project-alpha' with the key 'datacenter' and value 'kube-master-9:PreferNoSchedule' | Command:
```bash
kubectl taint node -l project=project-alpha datacenter=kube-master-9: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 logs of the previous terminated 'quantum-quark' container from the 'gateway-pod' pod | Command:
```bash
kubectl logs -p -c quantum-quark 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", "sh... |
Retrieve the logs from the pod named "auth-service-pod" with only one container | Command:
```bash
kubectl logs 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": "--container", "short": "-c", "de... |
Add/update the annotation 'SLA' with the value '99.9% uptime' for the pod 'frontend' | Command:
```bash
kubectl annotate pods frontend SLA='99.9% uptime'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include arbitrary ... |
Create a copy of the "gateway-pod" with a debug container and change the container images. | Command:
```bash
kubectl debug gateway-pod -it --copy-to=debug-image-memcached --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 resourc... |
List the replication controller named 'web', the service named 'vpn-service-rc', and the pod named 'database-pod' | Command:
```bash
kubectl get rc/web service/vpn-service-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 namespace... |
Execute the command 'apk add curl' inside the first pod of the 'gateway-deployment' deployment, using the first container by default. | Command:
```bash
kubectl exec deploy/gateway-deployment -- apk add curl
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, us... |
List the replication controller 'web', service 'database-rc', and pod 'payment-gateway-pod' | Command:
```bash
kubectl get rc/web service/database-rc pods/payment-gateway-pod
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is names... |
Create a secret from an env file | Command:
```bash
kubectl create secret generic monitoring-credentials-secret --from-env-file=path/to/parameters.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 def... |
Display the last 3 lines of logs for the 'analytics-pod' pod. | Command:
```bash
kubectl logs --tail=3 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": "-c... |
Create a secret named docker-registry-secret using the keys from the files located in the folder path/to/profiles | Command:
```bash
kubectl create secret generic docker-registry-secret --from-file=path/to/profiles
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, the key will default to the basen... |
Forward local port 5432 to the target port of the "https" service in the scheduler-service pod. | Command:
```bash
kubectl port-forward service/scheduler-service 5432: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 sele... |
Create a copy of the "monitoring-pod" pod, adding a debug container and changing the container images for the "scheduler" and "mailer" containers. | Command:
```bash
kubectl debug monitoring-pod -it --copy-to=my-debugger --image=debian --set-image=scheduler=my-scheduler:1.0,mailer=mailer:latest
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by r... |
Execute 'jenkins-plugin-cli' command in 'auth-service-pod' and get the output | Command:
```bash
kubectl exec auth-service-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 t... |
Embed the client certificate data from the file "~/.kube/admin.crt" into the "cluster-admin" entry in the Kubernetes configuration. | Command:
```bash
kubectl config set-credentials cluster-admin --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... |
Import the max_connections key from the config map 'env-vars' to the 'load-balancer-deployment' deployment. | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/env-vars deployment/load-balancer-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 definit... |
Output the modified 'order-processing-deployment' deployment in YAML format, with the new environment variable 'CACHE_SIZE' set to '64MB' | Command:
```bash
kubectl set env deployment/order-processing-deployment CACHE_SIZE=64MB -o yaml
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more po... |
Copy the directory "/var/run/secrets/kubernetes.io/serviceaccount/" from the remote pod "front-end-pod-12" in the "istio-system" namespace to the local directory "/etc/kubernetes". | Command:
```bash
kubectl cp istio-system/front-end-pod-12:/var/run/secrets/kubernetes.io/serviceaccount/ /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": "", "usag... |
Create a single ingress called 'api-gateway-ingress' that directs requests to website.com/module to a service named svc1 on port 3306, using the TLS secret "my-cert". | Command:
```bash
kubectl create ingress api-gateway-ingress --rule="website.com/module=svc1:3306,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": ""... |
Return the logs from the 'email-service-pod' pod | Command:
```bash
kubectl logs email-service-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "short": "-c", "d... |
Import the keys "config_file_path" from the config map "app-settings" and set them as environment variables for the "order-processing-deployment" deployment. | Command:
```bash
kubectl set env --keys=config_file_path --from=configmap/app-settings 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... |
Create a pod named 'hazelcast' using the 'nginx' image and have the container expose port 8082 | Command:
```bash
kubectl run hazelcast --image=nginx --port=8082
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--fi... |
Expose a replication controller using the configuration file "centos-controller.yaml", serving on port 9000 and connecting to containers on port 808000. | Command:
```bash
kubectl expose -f centos-controller.yaml --port=9000 --target-port=808000
```
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... |
Get the output from running the command 'node --version' in the 'code-explorer' container of the 'backend-pod' pod. | Command:
```bash
kubectl exec backend-pod -c code-explorer -- node --version
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitte... |
Get the documentation of a resource and its fields | Command:
```bash
kubectl explain resource=configmaps
```
What it does:
List the fields for supported resources.
This command describes the fields associated with each supported API resource. Fields are identified via a simple JSONPath identifier:
<type>.<fieldName>[.<fieldName>]
Add the --recursive flag to display all... |
Update the image of all containers in the 'development' daemonset to 'redis:6.2.5' | Command:
```bash
kubectl set image daemonset development *=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:
`... |
Get the modified YAML of the 'log-aggregator-deployment' deployment with the SMTP_HOST environment variable set to 'smtp.example.com', without making changes to the object on the server. | Command:
```bash
kubectl set env deployment/log-aggregator-deployment SMTP_HOST=smtp.example.com -o yaml
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one o... |
Switch to raw terminal mode and attach to a pod called media-stream-pod, specifically the container nebula-navigator | Command:
```bash
kubectl attach media-stream-pod -c nebula-navigator -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. ... |
Create a pod named nginx using the ruby image, while applying some specific configuration through overrides in JSON format | Command:
```bash
kubectl run nginx --image=ruby --overrides='{ "apiVersion": "stable-2.0.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [CO... |
Import the 'redis_host' key from the 'namespace-config' config map into the 'user-management-deployment' deployment. | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/namespace-config 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 de... |
List the replication controller named "api-service-rc" in ps output format | Command:
```bash
kubectl get replicationcontroller api-service-rc
```
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 ... |
Return the snapshot logs from the container named authentication-service-deployment-1 in the deployment named gateway-pod | Command:
```bash
kubectl logs deployment/authentication-service-deployment -c gateway-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 fla... |
Create an ingress resource called 'myapp-ingress' that directs requests from site.com/example to svc1:8181 with a TLS secret named "my-cert" | Command:
```bash
kubectl create ingress myapp-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": "", "usage... |
list specific resources by their type and names | Command:
```bash
kubectl get rc/web service/database-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 namesp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.