prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Create a deployment named "loadbalancer" using the "nginx" image | Command:
```bash
kubectl create deployment loadbalancer --image=nginx
```
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: json|yam... |
Add a taint to the node 'storage-node-13' with the key 'hardware' and no value, so that no new pods will be scheduled on it. | Command:
```bash
kubectl taint nodes storage-node-13 hardware: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 ... |
Forward port 3000 on localhost and IP 10.19.21.23 to port 5000 in the pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/mypod 3000: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 p... |
Start a pod named nginx using the docker.elastic.co/elasticsearch/elasticsearch image, and override the pod's spec with a partial set of values parsed from a JSON. | Command:
```bash
kubectl run nginx --image=docker.elastic.co/elasticsearch/elasticsearch --overrides='{ "apiVersion": "v2.1.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overri... |
Create a single ingress called 'api-v1-ingress' that directs requests to website.com/module to svc1:8082 with a tls secret "my-cert" | Command:
```bash
kubectl create ingress api-v1-ingress --rule="website.com/module=svc1:8082,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": "", "us... |
Forward local ports to a pod | Command:
```bash
kubectl port-forward deployment/log-aggregator-deployment 6379 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 wi... |
Import specific keys from a config map into a deployment's environment variables. | Command:
```bash
kubectl set env --keys=CONFIG_FILE_PATH --from=configmap/env-vars 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 definitions... |
Exec into the database-pod and run the 'node' command | Command:
```bash
kubectl exec database-pod -- node
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.kuberne... |
Create a new ClusterIP service named 'database-service-clusterip' with the TCP port mapping 8080:8083. | Command:
```bash
kubectl create service clusterip database-service-clusterip --tcp=8080:8083
```
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... |
Forward traffic from local port 9090 to port 8080 in the pod named "web-app-pod" | Command:
```bash
kubectl port-forward pod/web-app-pod 9090:8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automa... |
Forward traffic from host port 8081 to pod port 8081, allowing access from all addresses | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/chat-app-pod 8081:8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will... |
Expose the replicated 'wordpress' resource as a service, serving on port 8082 and connecting to the containers on port 300000. | Command:
```bash
kubectl expose rc wordpress --port=8082 --target-port=300000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified po... |
Update the cluster role binding for elasticsearch to include the specified service account. | Command:
```bash
kubectl set subject clusterrolebinding admin --serviceaccount=namespace:elasticsearch
```
What it does:
Update the user, group, or service account in a role binding or cluster role binding.
Syntax:
`kubectl set subject (-f FILENAME | TYPE NAME) [--user=username] [--group=groupname] [--serviceaccount=... |
Create a new secret with the name 'email-credentials-secret' and the specified keys instead of names on disk | Command:
```bash
kubectl create secret generic email-credentials-secret --from-file=ssh-privatekey=path/to/id_rsa --from-file=ssh-publickey=path/to/id_rsa.pub
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating... |
Create a new config map named app-config-prod using the properties file located at path/to/properties | Command:
```bash
kubectl create configmap app-config-prod --from-file=path/to/properties
```
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 bas... |
Create a service for a replicated alpine container that serves on port 9090 and connects to the containers on port 500000. | Command:
```bash
kubectl expose rc alpine --port=9090 --target-port=500000
```
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.... |
Forward local ports 8000 and 6000 to the pod's ports 8000 and 6000 | Command:
```bash
kubectl port-forward pod/analytics-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 auto... |
Create a new secret named oauth-secret from an environment file | Command:
```bash
kubectl create secret generic oauth-secret --from-env-file=path/to/settings.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 basenam... |
Forward traffic from port 3000 on localhost and IP 10.19.21.23 to port 8088 in the analytics-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/analytics-pod 3000:8088
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the crite... |
Print the supported API resources for the batch API group | Command:
```bash
kubectl api-resources --api-group=batch
```
What it does:
Print the supported API resources on the server.
Syntax:
`kubectl api-resources`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: wide|name. " |
Delete pods and services with names "analytics" and "foo" | Command:
```bash
kubectl delete pod,service analytics foo
```
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... |
Create a service for the ruby deployment, which serves on port 8081 and connects to the containers on port 808100 | Command:
```bash
kubectl expose deployment ruby --port=8081 --target-port=808100
```
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... |
Import the DATABASE_URL key from the configmap 'ui-config' and set it as an environment variable in the 'email-server-deployment' deployment. | Command:
```bash
kubectl set env --keys=DATABASE_URL --from=configmap/ui-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 definition... |
Create a pod with the image "postgres" and expose port 8181. | Command:
```bash
kubectl run hazelcast --image=postgres --port=8181
```
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": "-... |
Create a job named "log-collection" using the "ruby" image, and execute the command "gem --version" within the job. | Command:
```bash
kubectl create job log-collection --image=ruby -- gem --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": "Output forma... |
Update the pod named 'gateway' by adding a label with the key 'role' and the value 'cache' | Command:
```bash
kubectl label pods gateway role=cache
```
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... |
View the previous terminated logs for the "warp-drive" container in the "email-service-pod" pod. | Command:
```bash
kubectl logs -p -c warp-drive 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", ... |
Forward traffic from port 8081 on all addresses to port 8080 in the pod "proxy-server-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/proxy-server-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 ... |
Expose a replica set named "php" with a service, serving on port 8084, and connecting to the containers on port 500000. | Command:
```bash
kubectl expose rs php --port=8084 --target-port=500000
```
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 ... |
Remove the taint with key 'app' and effect 'PreferNoSchedule' from the node 'backup-node-14' | Command:
```bash
kubectl taint nodes backup-node-14 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. One... |
Create an ingress called 'app-gateway-ingress' that routes traffic from site.com/example to svc1:8888 with a TLS secret named "my-cert" | Command:
```bash
kubectl create ingress app-gateway-ingress --rule="site.com/example=svc1:8888,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", ... |
Update the environment variable 'ENV' for the deployment 'notification-handler-deployment' | Command:
```bash
kubectl set env deployment/notification-handler-deployment ENV=prod
```
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... |
Create a new NodePort service named web-app-nodeport, mapping port 8010 on the nodes to port 9091 on the service | Command:
```bash
kubectl create service nodeport web-app-nodeport --tcp=9091:8010
```
What it does:
Create a NodePort service with the specified name.
Syntax:
`kubectl create service nodeport NAME [--tcp=port:targetPort] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "",... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=debug_mode --from=configmap/app-name-config deployment/scheduler-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 defin... |
Roll back a DaemonSet to a specific revision | Command:
```bash
kubectl rollout undo daemonset/namespace-3 --to-revision=7
```
What it does:
Roll back to a previous rollout.
Syntax:
`kubectl rollout undo (TYPE NAME | TYPE/NAME) [flags]`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to files identifying... |
Apply a taint with key 'dedicated', value 'special-user', and effect 'NoSchedule' to the 'worker-node-3' node | Command:
```bash
kubectl taint nodes worker-node-3 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": "Output ... |
Scale the deployment named 'frontend-rs' to 1 replica, considering its current size is 3. | Command:
```bash
kubectl scale --current-replicas=3 --replicas=1 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... |
Create an ingress named 'website-ingress' that routes requests from foo.com/module to a service called 'svc1' running on port 8081 | Command:
```bash
kubectl create ingress website-ingress --rule="foo.com/module=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": "", "usage... |
Create a copy of the api-service-pod with a debug container and change the container images to debian and nginx:latest respectively. | Command:
```bash
kubectl debug api-service-pod -it --copy-to=debug-image-memcached --image=debian --set-image=web=nginx:latest,logger=logging-app:debug
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified... |
Check if the current user has permission to list the "log-analysis-job" job in the "cert-manager" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/log-analysis-job -n cert-manager
```
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 ... |
Fetch the logs of the first container in the 'security-scan-job' job. | Command:
```bash
kubectl logs job/security-scan-job
```
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 an ingress named 'rontend-ingress' that directs requests from testing.com/module to the service 'svc1' at port 3306 | Command:
```bash
kubectl create ingress rontend-ingress --rule="testing.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": "", "u... |
Import the 'database_url' key from the 'app-config-prod' config map and set it as an environment variable for the 'database-deployment' deployment. | Command:
```bash
kubectl set env --keys=database_url --from=configmap/app-config-prod deployment/database-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definiti... |
Get the output from running the 'redis-cli' command in the 'time-machine' container inside the 'api-service-pod' pod. | Command:
```bash
kubectl exec api-service-pod -c time-machine -- 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,... |
Modify the resource using an alternative text editor | Command:
```bash
KUBE_EDITOR="emacs" kubectl edit svc/web-service
```
What it does:
Edit a resource from the default editor.
The edit command allows you to directly edit any API resource you can retrieve via the command-line tools. It will open the editor defined by your KUBE_EDITOR, or EDITOR environment variables, o... |
Configure the "analytics" replication controller to automatically scale the number of pods based on CPU utilization | Command:
```bash
kubectl autoscale rc analytics --max=7 --cpu-percent=81
```
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 us... |
Deny a Certificate Signing Request (CSR) with the name 'csr-elastic-9' | Command:
```bash
kubectl certificate deny csr-elastic-9
```
What it does:
Deny a certificate signing request.
kubectl certificate deny allows a cluster admin to deny a certificate signing request (CSR). This action tells a certificate signing controller to not to issue a certificate to the requestor.
Syntax:
`kubectl... |
Execute `docker run -it ubuntu` command in the first container of the first pod of the deployment authentication-service-deployment | Command:
```bash
kubectl exec deploy/authentication-service-deployment -- docker run -it ubuntu
```
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": "Contai... |
Get the output from running the 'pip --version' command in the api-service-pod pod. | Command:
```bash
kubectl exec api-service-pod -- pip --version
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kub... |
Create a service for the 'ubuntu' deployment, which serves on port 8081 and connects to the containers on port 909000. | Command:
```bash
kubectl expose deployment ubuntu --port=8081 --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 specifi... |
Import the environment variables from the "my-secret" secret and set them in the "payment-processor-deployment" deployment. | Command:
```bash
kubectl set env --from=secret/my-secret deployment/payment-processor-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... |
Create an ingress named 'app-ingress' that routes requests from 'website.com/bar' to 'svc1:8888' and uses the TLS secret 'my-cert' | Command:
```bash
kubectl create ingress app-ingress --rule="website.com/bar=svc1:8888,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": ... |
Import the environment variables from the 'docker-registry-secret' secret and set them in the deployment named 'search-engine-deployment' | Command:
```bash
kubectl set env --from=secret/docker-registry-secret deployment/search-engine-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 ... |
Partially update the 'monitoring-node-15' node by applying a strategic merge patch with the following JSON: '{"spec":{"type":"LoadBalancer"}' | Command:
```bash
kubectl patch node monitoring-node-15 -p '{"spec":{"type":"LoadBalancer"}'
```
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]`... |
Update the annotation 'security-scan-status' of the pod 'security' with the value 'pass'. | Command:
```bash
kubectl annotate pods security 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 arb... |
Get the output from running the 'dotnet --list-sdks' command from the time-machine container inside the e-commerce-pod pod | Command:
```bash
kubectl exec e-commerce-pod -c time-machine -- dotnet --list-sdks
```
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 ... |
Restart a daemon set | Command:
```bash
kubectl rollout restart daemonset/services
```
What it does:
Restart a resource.
Resource rollout will be restarted.
Syntax:
`kubectl rollout restart RESOURCE`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to files identifying the resource... |
List all allowed actions in the "kube-node-lease" namespace | Command:
```bash
kubectl auth can-i --list --namespace=kube-node-lease
```
What it does:
Check whether an action is allowed.
VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is a partial URL that start... |
Retrieve the output from running the 'kafka-console-producer --broker-list localhost:9092 --topic test' command inside the nano-bot container of the cdn-service-pod. | Command:
```bash
kubectl exec cdn-service-pod -c nano-bot -- kafka-console-producer --broker-list localhost:9092 --topic test
```
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", "... |
Create a pod disruption budget named notification-service-pdb that will select all pods with the tier=frontend label and require at least one of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget notification-service-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-ava... |
Remove the label named 'bar' from the 'log-aggregator' pod | Command:
```bash
kubectl label pods log-aggregator unhealthy-
```
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", "usag... |
Execute a bash command in the pod "auth-service-pod" using the container "nano-bot" | Command:
```bash
kubectl exec auth-service-pod -c nano-bot -- 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... |
Check if the current authenticated user has permission to list the cron-job job in the production namespace | Command:
```bash
kubectl auth can-i list jobs.batch/cron-job -n production
```
What it does:
Check whether an action is allowed.
VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is a partial URL that s... |
Create a single ingress called 'app-loadbalancer-ingress' that directs requests to foo.com/bar to svc1 on port 5432, and use the TLS secret "my-cert". | Command:
```bash
kubectl create ingress app-loadbalancer-ingress --rule="foo.com/bar=svc1:5432,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", ... |
Set up auto scaling for the replication controller "email" with a target CPU utilization of 40% and a minimum of 1 pod and a maximum of 2 pods. | Command:
```bash
kubectl autoscale rc email --max=2 --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 uses t... |
Create a new config map named monitoring-config using the key=value pairs from the file located at path/to/options | Command:
```bash
kubectl create configmap monitoring-config --from-file=path/to/options
```
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 base... |
Set the resource request and limits for all containers in the 'postgres' deployment. | Command:
```bash
kubectl set resources deployment postgres --limits=cpu=200m,memory=512Mi --requests=cpu=50m,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 requ... |
Attach to the 'log-aggregator-pod' and get the output from the 'stardust-shuttle' container | Command:
```bash
kubectl attach log-aggregator-pod -c stardust-shuttle
```
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 o... |
Add a taint with the key 'app' and value 'monitoring-node-15:PreferNoSchedule' on the nodes having the label 'instance=app-instance-1' | Command:
```bash
kubectl taint node -l instance=app-instance-1 app=monitoring-node-15: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": ""... |
Set resource limits for the specified container in a deployment. Set the CPU limit to "50m" and the memory limit to "2Gi". | Command:
```bash
kubectl set resources deployment elasticsearch -c=nginx --limits=cpu=50m,memory=2Gi
```
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 ... |
Forward data between local port 8888 and the selected pod's port 5432 of the 'web-app-deployment' deployment | Command:
```bash
kubectl port-forward deployment/web-app-deployment 8888 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 s... |
Forward local port 6379 to remote port 8088 in the pod named "api-service-pod" | Command:
```bash
kubectl port-forward pod/api-service-pod 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 be selected au... |
import the API_KEY key from the config map named app-config and set it as an environment variable in the backend-microservice-deployment deployment. | Command:
```bash
kubectl set env --keys=API_KEY --from=configmap/app-config deployment/backend-microservice-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defini... |
Listen on ports 6379 and 6000 locally and forward the data to/from ports 5432 and 6000 in a pod selected by the 'search-engine-deployment' deployment | Command:
```bash
kubectl port-forward deployment/search-engine-deployment 6379 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 wil... |
Forward traffic from port 5432 on all addresses to port 8088 in the pod named "chat-app-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/chat-app-pod 5432: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... |
Set the service account of the deployment named "frontend-deployment" to "argocd" | Command:
```bash
kubectl set serviceaccount deployment frontend-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
Syntax:
`kubectl se... |
Create a service for the centos replication controller specified in the "centos-controller.yaml" file, with the service serving on port 80 and connecting to the containers on port 8000 | Command:
```bash
kubectl expose -f centos-controller.yaml --port=8000 --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... |
Create a new secret named 'api-secret-key' using the files from the 'path/to/profiles' folder. | Command:
```bash
kubectl create secret generic api-secret-key --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 basename of t... |
Add a taint with key 'datacenter' on nodes having label region=eu-west-2 | Command:
```bash
kubectl taint node -l region=eu-west-2 datacenter=gpu-node-12:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
Create a new secret from an env file named "azure-storage-secret" | Command:
```bash
kubectl create secret generic azure-storage-secret --from-env-file=path/to/data.env
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, the key will default to the bas... |
Create a new config map named monitoring-config with key1=config1 and key2=config2 | Command:
```bash
kubectl create configmap monitoring-config --from-literal=conf=config1 --from-literal=data=config2
```
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 ... |
Forward traffic from local port 5000 to port 8088 in the frontend-pod. | Command:
```bash
kubectl port-forward pod/frontend-pod 5000:8088
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected autom... |
Forward local port 5000 to port 5000 in the pod named 'frontend-pod' | Command:
```bash
kubectl port-forward pod/frontend-pod 5000: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... |
Add a taint with key 'environment' on nodes having label namespace=mynamespace | Command:
```bash
kubectl taint node -l namespace=mynamespace environment=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": "... |
Scale the deployment named webapp-replicaset to 5 replicas, assuming the current size is 3. | Command:
```bash
kubectl scale --current-replicas=3 --replicas=5 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... |
Start a pod named "hazelcast" using the "amazonlinux" image and let the container expose port 8084 | Command:
```bash
kubectl run hazelcast --image=amazonlinux --port=8084
```
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":... |
Add a taint with the key 'special' and value 'testing-node-11:PreferNoSchedule' on nodes that have the label 'app-type=microservice' | Command:
```bash
kubectl taint node -l app-type=microservice special=testing-node-11:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "",... |
Create a new ExternalName service named 'external-logging-service' with the external name practice-online.site | Command:
```bash
kubectl create service externalname external-logging-service --external-name practice-online.site
```
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... |
Forward the local ports 9090 to the pod's port 8000 in the chat-app-pod pod. | Command:
```bash
kubectl port-forward pod/chat-app-pod 9090 8000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected autom... |
Update the 'order-processing-deployment' deployment by setting the environment variable 'DB_HOST' to 'localhost' | Command:
```bash
kubectl set env deployment/order-processing-deployment DB_HOST=localhost
```
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 temp... |
Create a pod named "hazelcast" using the MySQL image, and expose port 3001. | Command:
```bash
kubectl run hazelcast --image=mysql --port=3001
```
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... |
Import the 'SECRET_KEY' key from the 'namespace-config' config map and set it as an environment variable in the 'monitoring-stack-deployment' deployment. | Command:
```bash
kubectl set env --keys=SECRET_KEY --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 d... |
Update the 'chat-app' pod by adding the annotation 'alert-email' with the value 'alerts@example.com'. | Command:
```bash
kubectl annotate pods chat-app alert-email=alerts@example.com
```
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... |
Delete the pods and services with the names "web" and "vpn" | Command:
```bash
kubectl delete pod,service web vpn
```
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.
Some re... |
Copy the local file /tmp/foo to the remote pod named api-server-pod-3 in the /tmp/bar_dir directory, specifically in the load-balancer container. | Command:
```bash
kubectl cp :/tmp/foo api-server-pod-3:/tmp/bar_dir -c load-balancer
```
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... |
Set the CPU limit of the 'nginx' container within the 'ubuntu' deployment to 2 and the memory limit to 512Mi | Command:
```bash
kubectl set resources deployment ubuntu -c=nginx --limits=cpu=2,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... |
Port forward the local port 8088 to port 5432 in the pod "proxy-server-pod" and listen on all addresses. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/proxy-server-pod 8088:5432
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod ... |
Rename the context 'dev-context' to 'user-a-context' in your kubeconfig file | Command:
```bash
kubectl config rename-context dev-context user-a-context
```
What it does:
Renames a context from the kubeconfig file.
CONTEXT_NAME is the context name that you want to change.
NEW_NAME is the new name you want to set.
Note: If the context being renamed is the 'current-context', this field will also b... |
Get the output from running the `ruby --version` command in the `rocket-ranger` container of the `payment-gateway-pod` pod | Command:
```bash
kubectl exec payment-gateway-pod -c rocket-ranger -- ruby --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. I... |
Taint nodes with label environment=production and add 'app' taint with effect PreferNoSchedule | Command:
```bash
kubectl taint node -l environment=production app=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": "O... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.