prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Forward port 8080 on your local machine to port 8000 in the pod named "security-service-pod" | Command:
```bash
kubectl port-forward pod/security-service-pod 8080: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 select... |
Get the output from running the 'dotnet' command in the 'astro-container' from the 'frontend-pod' | Command:
```bash
kubectl exec frontend-pod -c astro-container -- dotnet
```
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... |
Scale the deployment named db-migration-replicaset to 1 replica if its current size is 1 | Command:
```bash
kubectl scale --current-replicas=1 --replicas=1 deployment/db-migration-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 --reso... |
Create a service for an alpine deployment that serves on port 80 and connects to the containers on port 8000. | Command:
```bash
kubectl expose deployment alpine --port=8088 --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 specifi... |
Configure auto scaling for the replication controller "proxy-server" | Command:
```bash
kubectl autoscale rc proxy-server --max=3 --cpu-percent=40
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that... |
Create a new config map named "app-config-dev" with specified keys and their corresponding file paths | Command:
```bash
kubectl create configmap app-config-dev --from-file=settings=/path/to/preferences/file1.txt --from-file=key2=/path/to/configurations/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When... |
Create a new secret with key-value pairs from files in a folder. | Command:
```bash
kubectl create secret generic email-credentials-secret --from-file=path/to/options
```
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 base... |
Create a service based on the specifications in the "php-controller.yaml" file, serving on port 5001 and connecting to the containers on port 500100. | Command:
```bash
kubectl expose -f php-controller.yaml --port=5001 --target-port=500100
```
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 sp... |
Add a taint with the key 'special' on the nodes having the label 'role=database'. | Command:
```bash
kubectl taint node -l role=database special=db-node-7:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Out... |
Create a pod disruption budget named "notification-service-pdb" that will select all pods with the "version=v2" label and require a minimum of four of them to be available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget notification-service-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-availa... |
Create a config map named api-config using specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap api-config --from-file=conf=/path/to/profiles/file1.txt --from-file=data=/path/to/options/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a config... |
Start a pod using the golang image, but customize the pod specification by providing a JSON file with partial values | Command:
```bash
kubectl run nginx --image=golang --overrides='{ "apiVersion": "alpha-2.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] -- [COM... |
Create an ingress called 'web-ingress' that routes requests from site.com/example to svc1:8080 with a tls secret named "my-cert" | Command:
```bash
kubectl create ingress web-ingress --rule="site.com/example=svc1:8080,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage":... |
Create a new ClusterIP service named inventory-service-clusterip that maps port 6379 to port 5432 | Command:
```bash
kubectl create service clusterip inventory-service-clusterip --tcp=6379:5432
```
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": "-... |
Create a new config map named db-config from the key=value pairs in the file located at path/to/data | Command:
```bash
kubectl create configmap db-config --from-file=path/to/data
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a config map based on a file, the key will default to the basename of the... |
Forward traffic from local port 5432 to pod port 9090 | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/mypod 5432: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 sel... |
Create an autoscaling policy for the 'chat-app' deployment with a minimum of 2 pods and a maximum of 14 pods. | Command:
```bash
kubectl autoscale deployment chat-app --min=2 --max=14
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that use... |
Copy the /var/run/secrets/kubernetes.io/serviceaccount/ local file to the /tmp/bar_dir directory in a remote pod within the istio-system namespace. | Command:
```bash
kubectl cp /var/run/secrets/kubernetes.io/serviceaccount/ istio-system/logging-agent-pod-7:/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": "", "usag... |
Create a service for the replicated node using replica set "node" which serves on port 3306 and connects to the containers on port 9090. | Command:
```bash
kubectl expose rs node --port=3306 --target-port=909000
```
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... |
List the deployments in the "alpha-2.0" version of the "third-party-apps" API group in YAML output format. | Command:
```bash
kubectl get deployments.alpha-2.0.third-party-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... |
Update the annotation 'description' of the pod 'database' with the value 'Web server for marketing site' | Command:
```bash
kubectl annotate pods database description='Web server for marketing site'
```
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 labe... |
Edit the environment variables of the 'payment-processor-deployment' by setting the SMTP_HOST value to 'smtp.example.com' | Command:
```bash
kubectl set env deployment/payment-processor-deployment SMTP_HOST=smtp.example.com
```
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 mor... |
Update the SLA annotation of the pod specified in the "parameters.json" file | Command:
```bash
kubectl annotate -f parameters.json 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 arbit... |
Start a pod named "hazelcast" using the WordPress container image and expose port 8888. | Command:
```bash
kubectl run hazelcast --image=wordpress --port=8888
```
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": "... |
Execute the 'mysql' command in the rocket-ranger container within the frontend-pod pod and fetch the output from the command | Command:
```bash
kubectl exec frontend-pod -c rocket-ranger -- 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 t... |
Create a copy of the payment-gateway-pod and change all container images to ubuntu by running the command `kubectl debug payment-gateway-pod --copy-to=debug-image-web --set-image=*=ubuntu` | Command:
```bash
kubectl debug payment-gateway-pod --copy-to=debug-image-web --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... |
Copy the local file "/tmp/foo" to the remote pod "ingress-nginx/payment-gateway-pod-19" in the "ingress-nginx" namespace, and place it in the "/etc/kubernetes" directory. | Command:
```bash
kubectl cp /tmp/foo ingress-nginx/payment-gateway-pod-19:/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... |
Scale the deployment named frontend-rs to have 7 replicas to match the current size of the frontend-rs deployment. | Command:
```bash
kubectl scale --current-replicas=7 --replicas=7 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... |
Expose a pod as a service with a specific port and name | Command:
```bash
kubectl expose pod database-pod --port=6379 --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 por... |
List the replication controller with the name "web", the service with the name "api-service-rc", and the pod with the name "vpn-service-pod" | Command:
```bash
kubectl get rc/web service/api-service-rc pods/vpn-service-pod
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namesp... |
Taint node 'app-node-6' with a new taint or update the existing one with a key 'app', value 'backend' and effect 'PreferNoSchedule' | Command:
```bash
kubectl taint nodes app-node-6 app=backend:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. ... |
Set the annotation 'custom-label' to 'my-custom-value' for the 'monitoring' pod | Command:
```bash
kubectl annotate pods monitoring custom-label=my-custom-value
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and includ... |
Create a new config map named log-config in the current namespace, and include the properties key with the content of the /path/to/configs/file1.txt file, and the key1 key with the content of the /path/to/data/file2.txt file. | Command:
```bash
kubectl create configmap log-config --from-file=properties=/path/to/configs/file1.txt --from-file=key1=/path/to/data/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a conf... |
List the replication controllers with the name 'web', the service with the name 'e-commerce-rc', and the pod with the name 'security-service-pod' | Command:
```bash
kubectl get rc/web service/e-commerce-rc pods/security-service-pod
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is na... |
Partially update a node using a strategic merge patch. | Command:
```bash
kubectl patch node kube-master-9 -p $'spec:\n replicas: 3'
```
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]`
Helpful flags:... |
Expose the replication controller specified in the YAML file "wordpress-controller.yaml" as a service on port 6379, connecting to the containers on port 637900. | Command:
```bash
kubectl expose -f wordpress-controller.yaml --port=6379 --target-port=637900
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on ... |
Forward local port 8888 to port 3000 in the pod named 'web-app-pod' | Command:
```bash
kubectl port-forward pod/web-app-pod 8888:3000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automa... |
Set the CPU limit of the "mysql" container in the "deployment" to "3" and the memory limit to "256Mi". | Command:
```bash
kubectl set resources deployment mysql -c=nginx --limits=cpu=3,memory=256Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to it... |
Create a service for the alpine deployment, serving on port 9000 and connecting to the containers on port 8083 | Command:
```bash
kubectl expose deployment alpine --port=9000 --target-port=808300
```
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... |
Create a new config map named 'app-secrets' with the properties and keys specified in the provided files | Command:
```bash
kubectl create configmap app-secrets --from-file=properties=/path/to/preferences/file1.txt --from-file=key1=/path/to/parameters/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 crea... |
Forward port 5432 in the pod backend-pod to port 8081 on all addresses. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/backend-pod 8081: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 ... |
Set custom TLS server name for a cluster entry | Command:
```bash
kubectl config set-cluster prod-cluster --tls-server-name=kube-cluster-1
```
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... |
Create a new version of the vpn-service-pod with additional debug container and modified container images | Command:
```bash
kubectl debug vpn-service-pod -it --copy-to=dgb-img --image=debian --set-image=web=nginx:latest,worker=my-custom-worker:1.2.3
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resou... |
Attach to a pod named mypod, in the container warp-drive and enter raw terminal mode. | Command:
```bash
kubectl attach mypod -c warp-drive -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 omitted, use t... |
Create a new LoadBalancer service named auth-service-lb that maps the external port 3306 to the internal port 8888 | Command:
```bash
kubectl create service loadbalancer auth-service-lb --tcp=3306:8888
```
What it does:
Create a LoadBalancer service with the specified name.
Syntax:
`kubectl create service loadbalancer NAME [--tcp=port:targetPort] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "de... |
Create a debug session for the payment-gateway-pod pod, copying it to a new pod named debug-image-web with all container images set to amazonlinux. | Command:
```bash
kubectl debug payment-gateway-pod --copy-to=debug-image-web --set-image=*=amazonlinux
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by defau... |
create a job named 'certificate-renewal' using the 'mcr.microsoft.com/dotnet/core/runtime' image | Command:
```bash
kubectl create job certificate-renewal --image=mcr.microsoft.com/dotnet/core/runtime -- dotnet --list-sdks
```
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": ... |
Retrieve snapshot logs from container cache-cluster-deployment-1 of the deployment named gateway-pod | Command:
```bash
kubectl logs deployment/cache-cluster-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 flags:
"flag... |
List deployments in a specific version and API group in JSON format. | Command:
```bash
kubectl get deployments.v2.0.0.custom-apps -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 wil... |
Import the environment from the 'api-secret-key' secret and apply it to the 'email-server-deployment' deployment. | Command:
```bash
kubectl set env --from=secret/api-secret-key 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 p... |
List deployments in YAML output format for a specific API group and version. | Command:
```bash
kubectl get deployments.v1.1.0.api-v1 -o yaml
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you will onl... |
Scale the replica set 'db-migration-replicaset' to 1 by running the command `kubectl scale --replicas=1 rs/db-migration-replicaset` | Command:
```bash
kubectl scale --replicas=1 rs/db-migration-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-version is specified, it... |
Copy file from a remote pod to a local directory | Command:
```bash
kubectl cp prometheus/auth-service-pod-11:~/.config/kube /tmp/bar
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use t... |
Create a load balancer service named "database-lb" that maps requests from port 9091 on the load balancer to port 8088 on the pods | Command:
```bash
kubectl create service loadbalancer database-lb --tcp=9091:8088
```
What it does:
Create a LoadBalancer service with the specified name.
Syntax:
`kubectl create service loadbalancer NAME [--tcp=port:targetPort] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "defaul... |
Create a service to expose a container port as port 443 | Command:
```bash
kubectl expose service wordpress --port=443 --target-port=8082 --name=nginx-https
```
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 servic... |
Listen on port 5432 locally, forwarding data to/from port 8000 in the 'proxy-server-pod' pod. | Command:
```bash
kubectl port-forward pod/proxy-server-pod 5432 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 a... |
Scale the deployment named staging-app-rs to 5 replicas, considering its current size is 1. | Command:
```bash
kubectl scale --current-replicas=1 --replicas=5 deployment/staging-app-rs
```
What it does:
Set a new size for a deployment, replica set, replication controller, or stateful set.
Scale also allows users to specify one or more preconditions for the scale action.
If --current-replicas or --resource-vers... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/app-name-config deployment/log-aggregator-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defi... |
Update the pod named 'proxy' and set the annotation 'team' with the value 'frontend team'. | Command:
```bash
kubectl annotate pods proxy 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 arbitrary s... |
Get the output from running the 'psql' command in the 'rocket-ranger' container of the 'security-service-pod' pod. | Command:
```bash
kubectl exec security-service-pod -c rocket-ranger -- psql
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted... |
Update the label of the pod named 'analytics' to set 'component' as 'worker' | Command:
```bash
kubectl label pods analytics component=worker
```
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", "usa... |
Forward traffic from port 8081 on all addresses to port 8000 in the 'analytics-pod' pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/analytics-pod 8081:8000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod wil... |
Compare the current state of resources with the desired state defined in the settings.json file. | Command:
```bash
kubectl diff -f settings.json
```
What it does:
Diff configurations specified by file name or stdin between the current online configuration, and the configuration as it would be if applied.
The output is always YAML.
KUBECTL_EXTERNAL_DIFF environment variable can be used to select your own diff comma... |
Delete the service account user named "service-account" | Command:
```bash
kubectl config delete-user service-account
```
What it does:
Delete the specified user from the kubeconfig.
Syntax:
`kubectl config delete-user NAME` |
List the environment variables defined for the deployment named 'scheduler-app-deployment' | Command:
```bash
kubectl set env deployment/scheduler-app-deployment --list
```
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 ... |
Update the pod 'proxy-server' with the annotation 'description=my frontend running nginx' only if the resource is unchanged from version 1 | Command:
```bash
kubectl annotate pods proxy-server description='my frontend running nginx' --resource-version=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 ca... |
Update the pod 'media-stream' in the current namespace with the annotation 'team' and the value 'frontend-team', overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods media-stream 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 ... |
Update the cluster field in the 'my-context' context to 'kube-cluster-2' | Command:
```bash
kubectl config set contexts.cluster-2-context.cluster kube-cluster-2
```
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 ... |
Create a pod disruption budget named notification-service-pdb that will select all pods with the version=v2 label and require at least four of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget notification-service-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-availa... |
Create a pod disruption budget with the name "replica-set-pdb" that selects all pods with the label "tier=frontend" and ensures that at least one of them is available at any given time. | Command:
```bash
kubectl create poddisruptionbudget replica-set-pdb --selector=tier=frontend --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 ... |
Create a new config map named db-config using the specified keys instead of the basenames of the files on disk | Command:
```bash
kubectl create configmap db-config --from-file=properties=/path/to/configs/file1.txt --from-file=key1=/path/to/preferences/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating ... |
Execute the command 'dotnet --list-runtimes' inside the first container of the first pod of the 'loadbalancer-service' service. | Command:
```bash
kubectl exec svc/loadbalancer-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 om... |
Create a cluster role binding named 'custom_role' and assign the 'custom_role' cluster role to 'developer3', 'k8s-admin', and the 'qa-engineers' group. | Command:
```bash
kubectl create clusterrolebinding custom_role --clusterrole=custom_role --user=developer3 --user=k8s-admin --group=qa-engineers
```
What it does:
Create a cluster role binding for a particular cluster role.
Syntax:
`kubectl create clusterrolebinding NAME --clusterrole=NAME [--user=username] [--group=... |
Change the service account of the deployment "notification-handler-deployment" to "gitlab-runner" | Command:
```bash
kubectl set serviceaccount deployment notification-handler-deployment gitlab-runner
```
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
... |
Forward local port 5432 to port 8888 in the proxy-server-pod, in order to communicate with the pod | Command:
```bash
kubectl port-forward pod/proxy-server-pod 5432 8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected a... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=database_url --from=configmap/namespace-config deployment/monitoring-stack-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable... |
Create a copy of the 'proxy-service-pod' and name it 'my-debugger', with all container images changed to 'ethereum/client-go' | Command:
```bash
kubectl debug proxy-service-pod --copy-to=my-debugger --set-image=*=ethereum/client-go
```
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 defa... |
Remove all taints with the key 'workload' from the 'kube-master-9' node | Command:
```bash
kubectl taint nodes kube-master-9 workload-
```
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|yam... |
Retrieve a list of deployments in YAML output format from the "beta-1.0" version of the "alpha-apps" API group. | Command:
```bash
kubectl get deployments.beta-1.0.alpha-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... |
Create a deployment named "mattermost" with the image "mcr.microsoft.com/dotnet/core/runtime" and expose port 9091. | Command:
```bash
kubectl create deployment mattermost --image=mcr.microsoft.com/dotnet/core/runtime --port=9091
```
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": "",... |
Import specific keys from a config map to an environment variable in a deployment | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/log-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 definitions... |
Embed client certificate data for the "john.doe" user entry | Command:
```bash
kubectl config set-credentials john.doe --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-... |
Enable a new exec auth plugin for the "cluster-admin" entry by setting the exec command to "/path/to/the/executable" and the exec API version to "client.authentication.k8s.io/v1beta1". | Command:
```bash
kubectl config set-credentials cluster-admin --exec-command=/path/to/the/executable --exec-api-version=client.authentication.k8s.io/v1beta1
```
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:... |
import the 'DATABASE_URL' key from the 'app-config' config map and set it as an environment variable for the 'user-management-deployment' deployment | Command:
```bash
kubectl set env --keys=DATABASE_URL --from=configmap/app-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 defini... |
Forward traffic from localhost on port 3000 to port 8080 in the security-service-pod, listening on all addresses | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/security-service-pod 3000: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 ... |
Add the annotation 'compliance-level' with the value 'PCI-DSS' to the pod 'backend' | Command:
```bash
kubectl annotate pods backend compliance-level=PCI-DSS
```
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 arbit... |
Get output from running the 'elasticsearch' command in the first pod of the 'analytics-platform-deployment' deployment. | Command:
```bash
kubectl exec deploy/analytics-platform-deployment -- elasticsearch
```
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 the port 5000 on localhost and IP 10.19.21.23 to port 3000 in the 'analytics-pod' pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/analytics-pod 5000: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 crite... |
Create a pod using the data in the docker-registry.yaml file | Command:
```bash
kubectl create -f ./docker-registry.yaml
```
What it does:
Create a resource from a file or from stdin.
JSON and YAML formats are accepted.
Syntax:
`kubectl create -f FILENAME`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to files to use ... |
Set the CPU limit of the "mongo" container in the "deployment" resource to 3 and the memory limit to 128Mi. | Command:
```bash
kubectl set resources deployment mongo -c=nginx --limits=cpu=3,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, but may burst up to it... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=api_key --from=configmap/monitoring-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 definitio... |
Scale the 'dev-environment-rs' deployment to 1 replica, if its current size is 5. | Command:
```bash
kubectl scale --current-replicas=5 --replicas=1 deployment/dev-environment-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-... |
Start streaming the logs of the 'stardust-shuttle' container in the 'gateway-pod' pod | Command:
```bash
kubectl logs -f -c stardust-shuttle 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", ... |
Remove a label named 'bar' from the 'analytics' pod | Command:
```bash
kubectl label pods analytics component-
```
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": "... |
Auto scale the deployment "web" with a minimum of 2 pods and a maximum of 14 pods | Command:
```bash
kubectl autoscale deployment web --min=2 --max=14
```
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... |
Forward port 5000 on localhost and IP 10.19.21.23 to port 9090 in the pod named "cdn-service-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/cdn-service-pod 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 cri... |
Create a NGINX pod with overridden spec using values from a JSON object. | Command:
```bash
kubectl run nginx --image=wordpress --overrides='{ "apiVersion": "v1.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] -- [COM... |
Create a deployment named 'cache' that runs the 'python' image and exposes port '8082' | Command:
```bash
kubectl create deployment cache --image=python --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: js... |
Copy the local file '/tmp/foo' to the remote pod 'logging-agent-pod-7' in the 'ingress-nginx' namespace, and place it in the '/tmp/bar_dir' directory. | Command:
```bash
kubectl cp /tmp/foo ingress-nginx/logging-agent-pod-7:/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 ... |
Create a deployment named drupal with 2 replicas running the postgres image | Command:
```bash
kubectl create deployment drupal --image=postgres --replicas=2
```
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.