prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Create a cluster role named "bar" that allows the user to perform "list", "create", and "connect" operations on services. | Command:
```bash
kubectl create clusterrole bar --verb=list,create,connect --resource=services
```
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", "sho... |
Set the custom TLS server name for the kube-cluster-2 cluster entry. | Command:
```bash
kubectl config set-cluster kube-cluster-2 --tls-server-name=sun-cluster
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-cluster NAME [--server=server] [--certificat... |
Add a taint with key 'disktype' on nodes having label version=v1.0.0 and node-2 as the name, with a taint effect of 'PreferNoSchedule' | Command:
```bash
kubectl taint node -l version=v1.0.0 disktype=node-2: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... |
Create a job that runs a specific command using a specified image | Command:
```bash
kubectl create job database-seeding-job --image=php -- composer --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": "Ou... |
Copy files from a remote pod to a local directory | Command:
```bash
kubectl cp logging/worker-pod-4:/var/run/secrets/kubernetes.io/serviceaccount/ :/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 ... |
Create a new LoadBalancer service named api-service-lb with a mapping from port 7000 to port 8181 | Command:
```bash
kubectl create service loadbalancer api-service-lb --tcp=7000:8181
```
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", "def... |
Create a new pod named 'hazelcast' using the python image and expose port 3000 | Command:
```bash
kubectl run hazelcast --image=python --port=3000
```
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... |
Execute the command 'dotnet --list-runtimes' inside the first pod of the 'user-management-deployment' deployment | Command:
```bash
kubectl exec deploy/user-management-deployment -- 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 na... |
Import the `max_connections` keys from the `kube-system-config` ConfigMap into the `cache-cluster-deployment` deployment. | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/kube-system-config deployment/cache-cluster-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variab... |
Delete the pods and services with the names "frontend" and "database" | Command:
```bash
kubectl delete pod,service frontend database
```
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 selecto... |
List deployments in JSON output format for the "v2.0.0" version of the "custom-deployments" API group. | Command:
```bash
kubectl get deployments.v2.0.0.custom-deployments -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 ... |
Create a single ingress called 'private-ingress' that directs requests to testing.com/module to svc1:8443 with a tls secret "my-cert" | Command:
```bash
kubectl create ingress private-ingress --rule="testing.com/module=svc1:8443,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "u... |
Update the pod 'log-aggregator' by adding or updating the annotation 'expiration-date' with the value '2024-12-31' | Command:
```bash
kubectl annotate --overwrite pods log-aggregator expiration-date='2024-12-31'
```
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 l... |
Create a ClusterIP service named auth-service-clusterip that forwards traffic from port 8084 to port 8010 | Command:
```bash
kubectl create service clusterip auth-service-clusterip --tcp=8084:8010
```
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": "-o", "... |
Listen on port 9090 locally, forwarding to the targetPort of the 'https' port named service called 'monitoring-service' | Command:
```bash
kubectl port-forward service/monitoring-service 9090: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 sel... |
Remove the taint with key 'app' and effect 'PreferNoSchedule' from the node 'monitoring-node-15' | Command:
```bash
kubectl taint nodes monitoring-node-15 app: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.... |
Create an ingress named 'private-api-ingress' that routes requests for 'testing.com/module' to 'svc1:6379' with a TLS secret named 'my-cert' | Command:
```bash
kubectl create ingress private-api-ingress --rule="testing.com/module=svc1:6379,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": ""... |
Check if you have permission to list the "virus-scan-job" job in the "testing" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/virus-scan-job -n testing
```
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 tha... |
Forward local port 3000 to port 8888 in a pod selected by the "analytics-platform-deployment" deployment. | Command:
```bash
kubectl port-forward deployment/analytics-platform-deployment 3000 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 po... |
Create a pod named "hazelcast" using the image "mcr.microsoft.com/dotnet/core/runtime" and configure the pod to expose port 8081. | Command:
```bash
kubectl run hazelcast --image=mcr.microsoft.com/dotnet/core/runtime --port=8081
```
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...... |
copy the ~/.config/kube file from a remote pod named "backend-pod-13" in the "istio-system" namespace to the /tmp/bar_dir directory locally | Command:
```bash
kubectl cp istio-system/backend-pod-13:~/.config/kube /tmp/bar_dir
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use ... |
Import the 'my-example-key' keys from the 'kube-system-config' config map into the 'web-app-deployment' deployment | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/kube-system-config deployment/web-app-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... |
Create a pod using the data provided in the setup.json file. | Command:
```bash
kubectl create -f ./setup.json
```
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 to create ... |
Forward local port 8000 to port 8000 in the pod named "log-aggregator-pod" | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 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... |
Set the resource request and limits for all containers in the 'python' deployment to a CPU limit of 200m and memory limit of 512Mi, and a CPU request of 1 and memory request of 64Mi. | Command:
```bash
kubectl set resources deployment python --limits=cpu=200m,memory=512Mi --requests=cpu=1,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... |
Create a cluster role named "default_role" with access permissions to update services with the resource names "machine-learning" and "prod-api-gateway" | Command:
```bash
kubectl create clusterrole default_role --verb=update --resource=services --resource-name=machine-learning --resource-name=prod-api-gateway
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run... |
Delete the pods and services with the names "gateway" and "web" | Command:
```bash
kubectl delete pod,service gateway web
```
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.
Som... |
Create a copy of the 'database-pod' pod by debugging it and copying it to a new image called 'dgb-img', with the code-explorer container using the command 'sh' | Command:
```bash
kubectl debug database-pod -it --copy-to=dgb-img --container=code-explorer -- sh
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by default if... |
Delete the pods and services with the names "api" and "gateway". | Command:
```bash
kubectl delete pod,service api gateway
```
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.
Som... |
Create a job with the name "log-collection" and the image "python" that runs the command "python" | Command:
```bash
kubectl create job log-collection --image=python -- python
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. On... |
Create a new config map named monitoring-config using specified files to populate keys | Command:
```bash
kubectl create configmap monitoring-config --from-file=conf=/path/to/parameters/file1.txt --from-file=data=/path/to/properties/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 creat... |
Set the service account of the deployment "analytics-platform-deployment" to "kube-proxy" | Command:
```bash
kubectl set serviceaccount deployment analytics-platform-deployment kube-proxy
```
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... |
Configure auto-scaling for the replication controller "log-aggregator" with a target CPU utilization of 40% and a range of 1 to 3 pods. | Command:
```bash
kubectl autoscale rc log-aggregator --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 th... |
Add the annotation 'custom-label' with the value 'my-custom-value' to the 'email' pod. | Command:
```bash
kubectl annotate pods email 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 include arb... |
Add a taint with key 'special' on nodes having label component=proxy | Command:
```bash
kubectl taint node -l component=proxy special=web-node-8: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": "... |
View the history of rollouts for a deployment | Command:
```bash
kubectl rollout history deployment/my-deployment
```
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... |
Listen on port 8088 on all addresses and forward it to port 8888 in the pod named 'frontend-pod'. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/frontend-pod 8088:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will... |
Execute the command 'pg_dump --version' in the 'code-explorer' container of the 'payment-gateway-pod' pod. | Command:
```bash
kubectl exec payment-gateway-pod -c code-explorer -- pg_dump --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... |
Display a single pod in JSON format | Command:
```bash
kubectl get -o json pod 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 namespaced you will only see ... |
Create a job to run a command using a specific image. | Command:
```bash
kubectl create job report-generation-job --image=wordpress -- wp
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output form... |
Set a custom TLS server name for the prod-cluster cluster entry | Command:
```bash
kubectl config set-cluster prod-cluster --tls-server-name=staging-cluster
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-cluster NAME [--server=server] [--certific... |
Create a mysql pod named 'nginx' with an image of mysql, but override the specification of the pod with a partial set of values parsed from the provided JSON. | Command:
```bash
kubectl run nginx --image=mysql --overrides='{ "apiVersion": "v2.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] -- [COMMAND... |
Create a deployment named "logging" using the Redis image and expose port 8443. | Command:
```bash
kubectl create deployment logging --image=redis --port=8443
```
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: j... |
Execute the 'node' command inside the 'time-machine' container of the 'monitoring-pod' pod and retrieve the output. | Command:
```bash
kubectl exec monitoring-pod -c time-machine -- 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 t... |
Get the details of a specific pod in JSON format. | Command:
```bash
kubectl get -o json pod database-pod
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you will only see res... |
Switch to raw terminal mode and attach to the 'nebula-navigator' container in the 'vpn-service-pod' pod, allowing interaction with the 'bash' shell. | Command:
```bash
kubectl attach vpn-service-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. I... |
Set the resource request and limits for all containers in a deployment named 'ruby' | Command:
```bash
kubectl set resources deployment ruby --limits=cpu=200m,memory=512Mi --requests=cpu=50m,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,... |
Delete the pods and services with the names "email" and "payment" | Command:
```bash
kubectl delete pod,service email payment
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label selector.
S... |
Import the DEBUG_MODE key from the app-settings config map into the environment variables of the gateway-deployment deployment. | Command:
```bash
kubectl set env --keys=DEBUG_MODE --from=configmap/app-settings 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... |
Execute the 'nginx' command inside the 'analytics-pod' pod and get the output. | Command:
```bash
kubectl exec analytics-pod -- nginx
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.kuber... |
Forward local port 8888 to port 8088 on a pod selected by the deployment | Command:
```bash
kubectl port-forward deployment/email-server-deployment 8888 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 new config map named 'monitoring-config' using the key=value pairs found in the 'path/to/parameters' file | Command:
```bash
kubectl create configmap monitoring-config --from-file=path/to/parameters
```
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 b... |
Output the modified deployment named "mydeployment" in YAML format, while setting the environment variable SMTP_USERNAME to "your-username" | Command:
```bash
kubectl set env deployment/mydeployment SMTP_USERNAME=your-username -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 pod t... |
Create a deployment named "jenkins-x" using the "confluentinc/cp-kafka" image and expose port 3306. | Command:
```bash
kubectl create deployment jenkins-x --image=confluentinc/cp-kafka --port=3306
```
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... |
Create a new config map named 'app-name-config' with the specified keys by using files from specified paths | Command:
```bash
kubectl create configmap app-name-config --from-file=settings=/path/to/configurations/file1.txt --from-file=key2=/path/to/properties/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... |
Retrieve the output from running the 'wp' command inside the 'cosmic-container' container within the 'analytics-pod' pod. | Command:
```bash
kubectl exec analytics-pod -c cosmic-container -- wp
```
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 ... |
Create a copy of the security-service-pod and open a debugging terminal in the new pod | Command:
```bash
kubectl debug security-service-pod -it --copy-to=dgb-img --container=time-machine -- sh
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by def... |
Create a new pod called 'my-custom-dbg' with a debug container and attach to it | Command:
```bash
kubectl debug mypod -it --image=busybox --copy-to=my-custom-dbg
```
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 resource is s... |
Create a job named "data-migration-job" using the image "confluentinc/cp-kafka" and run the command "kafka-topics --list" inside the job container. | Command:
```bash
kubectl create job data-migration-job --image=confluentinc/cp-kafka -- kafka-topics --list
```
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":... |
Start a python pod with port 6379 exposed | Command:
```bash
kubectl run hazelcast --image=python --port=6379
```
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... |
import specific keys from a config map and set them as environment variables for a deployment | Command:
```bash
kubectl set env --keys=api_key --from=configmap/global-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... |
Embed the client certificate data in the "robot-user" entry by running the command "kubectl config set-credentials robot-user --client-certificate=~/.kube/admin.crt --embed-certs=true" | Command:
```bash
kubectl config set-credentials robot-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 --clien... |
Scale the resource specified in the pod.json file to have 1 replica. | Command:
```bash
kubectl scale --replicas=1 -f pod.json
```
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 validated b... |
Update the pod 'media-stream' by adding the annotation 'security-scan-status' with the value 'pass', and overwrite any existing value. | Command:
```bash
kubectl annotate --overwrite pods media-stream 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 labe... |
Create an ingress called 'public-api-ingress' with a rule that directs requests for site.com/example to svc1:8081 | Command:
```bash
kubectl create ingress public-api-ingress --rule="site.com/example=svc1:8081,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "... |
Create an ingress named 'ingress1' with multiple hosts and the pathType as Prefix | Command:
```bash
kubectl create ingress ingress1 --class=default \
--rule="site.com/path*=svc:5001" \
--rule="example.com/admin*=svc2:http"
```
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"... |
Create a deployment named `grafana` using the `mcr.microsoft.com/dotnet/core/runtime` image and expose port `9090` | Command:
```bash
kubectl create deployment grafana --image=mcr.microsoft.com/dotnet/core/runtime --port=9090
```
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": "", "u... |
Add the taint with key 'disktype' on nodes having label app=web-app | Command:
```bash
kubectl taint node -l app=web-app disktype=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": "", "usage": "Out... |
List the replication controller 'web', service 'payment-gateway-rc', and pod 'e-commerce-pod' | Command:
```bash
kubectl get rc/web service/payment-gateway-rc pods/e-commerce-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 nam... |
import the 'debug_mode' key from the 'app-settings' config map into the 'monitoring-stack-deployment' deployment. | Command:
```bash
kubectl set env --keys=debug_mode --from=configmap/app-settings 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 defin... |
Add a taint with the key 'app' and value 'k8s-node1:PreferNoSchedule' on all nodes labeled with 'app=web-app' | Command:
```bash
kubectl taint node -l app=web-app 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": "Output f... |
Retrieve a list of deployments from the "backup-apps" API group with version "v3.0.0" in JSON format. | Command:
```bash
kubectl get deployments.v3.0.0.backup-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... |
Update the environment variables of the "mydeployment" deployment by importing the "SECRET_KEY" key from the "namespace-config" configmap. | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/namespace-config deployment/mydeployment
```
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... |
Forward traffic from local port 8888 to port 5000 in the pod named chat-app-pod. | Command:
```bash
kubectl port-forward pod/chat-app-pod 8888: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 autom... |
Create a single ingress called 'api-v2-ingress' that directs requests to foo.com/example to the 'svc1' service on port 9091, using the TLS secret named "my-cert". | Command:
```bash
kubectl create ingress api-v2-ingress --rule="foo.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": "", "usage... |
Retrieve the resource details for the following resources: rc/web, service/security-service-rc, and pods/web-app-pod. | Command:
```bash
kubectl get rc/web service/security-service-rc pods/web-app-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... |
Add a taint with the key 'hardware' and value 'backup-node-14:PreferNoSchedule' on the nodes that have the label 'region=eu-west-2' | Command:
```bash
kubectl taint node -l region=eu-west-2 hardware=backup-node-14:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usa... |
Create a new secret named api-secret-key from an environment file. | Command:
```bash
kubectl create secret generic api-secret-key --from-env-file=path/to/profiles.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 basen... |
Create a copy of the 'cdn-service-pod' and change all container images to 'jenkins' | Command:
```bash
kubectl debug cdn-service-pod --copy-to=my-custom-dbg --set-image=*=jenkins
```
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... |
create a job named log-processing-job using the amazonlinux image and execute the bash command inside it | Command:
```bash
kubectl create job log-processing-job --image=amazonlinux -- bash
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output for... |
Print the result of updating the nginx container image to "wordpress:5.8.1" from the local file "path/to/file.yaml" | Command:
```bash
kubectl set image -f path/to/file.yaml wordpress=wordpress:5.8.1 --local -o yaml
```
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),... |
Embed the certificate authority data for the galaxy-cluster cluster entry by running the command "kubectl config set-cluster galaxy-cluster --embed-certs --certificate-authority=~/.kube/kube-cluster-1/kubernetes.ca.crt" | Command:
```bash
kubectl config set-cluster galaxy-cluster --embed-certs --certificate-authority=~/.kube/kube-cluster-1/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... |
Retrieve the snapshot logs from the log-aggregator-pod container in the log-aggregator-deployment-1 deployment. | Command:
```bash
kubectl logs deployment/log-aggregator-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 flag... |
Create a role named "foo" with the specified resource names "load-balancer" and "error-logger" | Command:
```bash
kubectl create role foo --verb=create --resource=pods --resource-name=load-balancer --resource-name=error-logger
```
What it does:
Create a role with single rule.
Syntax:
`kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run=server|clien... |
Import specific keys from a config map into a deployment. | Command:
```bash
kubectl set env --keys=config_file_path --from=configmap/app-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 defin... |
Add a debug container and change container images of a pod. | Command:
```bash
kubectl debug auth-service-pod -it --copy-to=debug-image-web --image=debian --set-image=worker=my-custom-worker:1.2.3,database=mysql:5.7
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identifi... |
Forward traffic from port 8080 on localhost and IP address 10.19.21.23 to port 5432 in the e-commerce-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/e-commerce-pod 8080: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 crit... |
Copy the local file '/tmp/foo' to the remote pod 'file-server-pod-14' in the '/tmp/bar_dir' directory, specifically in the 'cache-container' container. | Command:
```bash
kubectl cp :/tmp/foo file-server-pod-14:/tmp/bar_dir -c cache-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,... |
Update the resource limits for the 'mongo' deployment container in the 'nginx' pod | Command:
```bash
kubectl set resources deployment mongo -c=nginx --limits=cpu=100m,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 the specific keys from the app-config-prod ConfigMap to the log-aggregator-deployment Deployment by setting the environment variable "config_file_path". | Command:
```bash
kubectl set env --keys=config_file_path --from=configmap/app-config-prod 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 variabl... |
Forward traffic from port 3000 on all addresses to port 8000 in the pod named api-service-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/api-service-pod 3000:8000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod w... |
Partially update the web-node-8 node by patching the container-name container's resource limits to set the CPU limit to 200m. | Command:
```bash
kubectl patch node web-node-8 -p $'spec:\n containers:\n- name: container-name\n resources:\n limits:\n cpu: 200m'
```
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 FI... |
Set the custom TLS server name to use for validation for the "star-cluster" cluster entry | Command:
```bash
kubectl config set-cluster star-cluster --tls-server-name=on-prem-cluster
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-cluster NAME [--server=server] [--certific... |
Create a deployment named gitlab with 3 replicas, using the docker.elastic.co/elasticsearch/elasticsearch image. | Command:
```bash
kubectl create deployment gitlab --image=docker.elastic.co/elasticsearch/elasticsearch --replicas=3
```
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"... |
Execute the 'bash' command in the media-stream-pod and get the output | Command:
```bash
kubectl exec media-stream-pod -- bash
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.kub... |
Update the label of the 'chat-app' pod to 'env=development' | Command:
```bash
kubectl label pods chat-app env=development
```
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... |
Create a service for the 'ruby' deployment, which serves on port 8010 and connects to the containers on port 8000. | Command:
```bash
kubectl expose deployment ruby --port=8010 --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... |
Get the output from running the 'redis-server' command in the first container of the search-service pod. | Command:
```bash
kubectl exec svc/search-service -- 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 omitted, use the k... |
Copy a directory from a remote pod to a local directory | Command:
```bash
kubectl cp istio-system/file-server-pod-14:/tmp/foo_dir /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, us... |
Forward local port 3000 to the pod port 3000 of the specified pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/api-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 cri... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.