prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Listen on port 9090 on localhost and IP address 10.19.21.23, and forward the traffic to port 8088 in the 'e-commerce-pod' pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/e-commerce-pod 9090: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 crit... |
Execute the 'elasticsearch' command in the first container of the first pod of the 'search-service' service. | Command:
```bash
kubectl exec svc/search-service -- 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 omitted, use the ... |
Start a 'busybox' pod with the image 'docker.elastic.co/elasticsearch/elasticsearch' and keep it in the foreground | Command:
```bash
kubectl run -i -t busybox --image=docker.elastic.co/elasticsearch/elasticsearch --restart=Never
```
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] -- [C... |
Set the service account of the 'log-aggregator-deployment' deployment to 'flux' | Command:
```bash
kubectl set serviceaccount deployment log-aggregator-deployment flux
```
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:
`kubect... |
Taint nodes with label version=v1.0.0 with a taint key 'hardware' and value 'prod-node-5:PreferNoSchedule' | Command:
```bash
kubectl taint node -l version=v1.0.0 hardware=prod-node-5:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": ... |
Auto scale the replication controller "proxy-server" with a target CPU utilization of 90% and a minimum of 1 pod and a maximum of 3 pods. | Command:
```bash
kubectl autoscale rc proxy-server --max=3 --cpu-percent=90
```
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... |
View the resource utilization metrics for all pods in the specified namespace | Command:
```bash
kubectl top pod --namespace=external-geolocation-service
```
What it does:
Display resource (CPU/memory) usage of pods.
The 'top pod' command allows you to see the resource consumption of pods.
Due to the metrics pipeline delay, they may be unavailable for a few minutes since pod creation.
Syntax:
`k... |
Get the output from running the 'elasticsearch' command in the pod named 'database-pod' using the container 'warp-drive'. | Command:
```bash
kubectl exec database-pod -c warp-drive -- 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 omitted, ... |
Create a job named security-scan-job using the wordpress image, and run the command "mysql --version" in the job. | Command:
```bash
kubectl create job security-scan-job --image=wordpress -- mysql --version
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Ou... |
Set the CPU limits of the nginx container in the deployment named 'nginx' to 10 and the memory limits to 512Mi. | Command:
```bash
kubectl set resources deployment nginx -c=nginx --limits=cpu=10,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... |
Add a taint with key 'disktype' on nodes having label component=proxy | Command:
```bash
kubectl taint node -l component=proxy 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": ... |
Get the specific resources by their type and names | Command:
```bash
kubectl get rc/web service/log-aggregator-rc pods/backend-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 namespa... |
Automatically scale the 'backend' deployment with a minimum of 2 pods and a maximum of 13 pods. | Command:
```bash
kubectl autoscale deployment backend --min=2 --max=13
```
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... |
Port-forward the pod/security-service-pod to listen on port 3000 locally and forward the traffic to port 5000 in the pod. | Command:
```bash
kubectl port-forward pod/security-service-pod 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 pod will be select... |
Delete pods and services with the names "web" and "payment" | Command:
```bash
kubectl delete pod,service web 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.
Som... |
Update the pod 'media-stream' with the annotation 'git-repo' and the value 'https'. This will overwrite any existing value. | Command:
```bash
kubectl annotate --overwrite pods media-stream git-repo='https://github.com/example/my-app'
```
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... |
Create a new ExternalName service named external-file-storage-service with the external name example-domain.com | Command:
```bash
kubectl create service externalname external-file-storage-service --external-name example-domain.com
```
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 refere... |
Partially update a node by applying a strategic merge patch in JSON format | Command:
```bash
kubectl patch node storage-node-13 -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]`
H... |
Forward traffic from local port 8000 to port 9090 in the pod selected by the 'database-deployment' deployment | Command:
```bash
kubectl port-forward deployment/database-deployment 8000 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 ... |
Create a new config map named app-config by specifying the keys for the values instead of using the filenames on the disk | Command:
```bash
kubectl create configmap app-config --from-file=properties=/path/to/parameters/file1.txt --from-file=key1=/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 creati... |
Update the annotation 'description' in the pod 'chat-app' to 'Web server for marketing site', overwriting any existing value. | Command:
```bash
kubectl annotate --overwrite pods chat-app 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 larg... |
create a service for the replication controller specified in the "wordpress-controller.yaml" file, serving on port 80 and connecting to the containers on port 8000 | Command:
```bash
kubectl expose -f wordpress-controller.yaml --port=6379 --target-port=300100
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on ... |
Create a debug container in a pod, make a copy of the existing pod, and change container images. | Command:
```bash
kubectl debug proxy-service-pod -it --copy-to=dgb-img --image=debian --set-image=api=api:v2,web=nginx:latest
```
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. Pod... |
Create a service for the replicated ruby pods, serving on port 8082 and connecting to the containers on port 9090 | Command:
```bash
kubectl expose rc ruby --port=8082 --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... |
Create a new ExternalName service named my-ns with the external name "illustration-shop.shop". | Command:
```bash
kubectl create service externalname my-ns --external-name illustration-shop.shop
```
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 services that ex... |
execute the 'geth' command inside the proxy-service-pod pod and print the output | Command:
```bash
kubectl exec proxy-service-pod -- geth
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.ku... |
Update the 'monitoring' pod with the annotation 'release-notes' and the value 'https://example.com/release-notes/v2.5.1' | Command:
```bash
kubectl annotate pods monitoring release-notes='https://example.com/release-notes/v2.5.1'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be l... |
Add a taint to nodes in the 'eu-west-2' region with the key 'special' and the value 'web-node-8' | Command:
```bash
kubectl taint node -l region=eu-west-2 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": ... |
Import the REDIS_HOST key from the config map "app-name-config" into the environment of the "authentication-service-deployment" deployment. | Command:
```bash
kubectl set env --keys=REDIS_HOST --from=configmap/app-name-config deployment/authentication-service-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment varia... |
Set the cluster field in the team-alpha-context to prod-cluster. | Command:
```bash
kubectl config set contexts.team-alpha-context.cluster prod-cluster
```
What it does:
Set an individual value in a kubeconfig file.
PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.
PROPERTY_VALUE is the new value y... |
Create a deployment named gitlab using the jenkins image, and expose port 8000. | Command:
```bash
kubectl create deployment gitlab --image=jenkins --port=8000
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: ... |
Listen on port 8080 locally, forwarding to the targetPort of the service's port named "https" | Command:
```bash
kubectl port-forward service/database-service 8080: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 selec... |
Create a job named 'log-processing-job' using the 'ethereum/client-go' image and execute the command 'geth version' inside the job. | Command:
```bash
kubectl create job log-processing-job --image=ethereum/client-go -- geth 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": "", "usag... |
Add a taint with the key 'workload' on nodes having the label 'owner=john-doe' | Command:
```bash
kubectl taint node -l owner=john-doe workload=kube-master-9:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage"... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=API_KEY --from=configmap/global-config deployment/api-server-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions i... |
Create a job with a command to run nginx and specify a specific command to be executed | Command:
```bash
kubectl create job data-migration-job --image=nginx -- nginx -g "daemon off;"
```
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":... |
Create a copy of the 'proxy-service-pod' pod, changing all container images to 'python' | Command:
```bash
kubectl debug proxy-service-pod --copy-to=my-custom-dbg --set-image=*=python
```
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 ... |
Create a debuggable copy of the e-commerce pod and attach to it using a BusyBox container image | Command:
```bash
kubectl debug e-commerce-pod -it --image=busybox --copy-to=dgb-img
```
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 i... |
Listen on port 3000 on localhost and IP address 10.19.21.23, forwarding the traffic to port 5000 in the web-app-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/web-app-pod 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 criteri... |
Stream the logs of the container "astro-container" in the pod "cdn-service-pod" | Command:
```bash
kubectl logs -f -c astro-container cdn-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 local port 8080 to port 3000 in the frontend-pod to access the pod locally | Command:
```bash
kubectl port-forward pod/frontend-pod 8080 3000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected autom... |
Set the label 'tier' to 'backend' for the pod named 'gateway' | Command:
```bash
kubectl label pods gateway tier=backend
```
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": "... |
Import the API_KEY key from the env-vars config map into the payment-processor-deployment deployment. | Command:
```bash
kubectl set env --keys=API_KEY --from=configmap/env-vars 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... |
Create a new secret named 'azure-storage-secret' using the environment variables defined in 'path/to/profiles.env' file. | Command:
```bash
kubectl create secret generic azure-storage-secret --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... |
Apply a strategic merge patch to the db-node-7 node, specifying the patch as YAML | Command:
```bash
kubectl patch node db-node-7 -p $'spec:\n 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]`
Helpful fla... |
Run the 'mysqld' command in the cdn-service-pod and print the output | Command:
```bash
kubectl exec cdn-service-pod -- mysqld
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.ku... |
Create a service for the replicated python containers, which serves on port 9090 and connects to the containers on port 8082. | Command:
```bash
kubectl expose rc python --port=9090 --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 specified port.... |
Create a cluster role named "default_role" with the AggregationRule specified as "rbac.example.com/aggregate-to-security=true" | Command:
```bash
kubectl create clusterrole default_role --aggregation-rule="rbac.example.com/aggregate-to-security=true"
```
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 flag... |
Add a taint with key 'workload' on nodes having the label team=devops using the command 'kubectl taint node -l team=devops workload=prod-node-5:PreferNoSchedule' | Command:
```bash
kubectl taint node -l team=devops workload=prod-node-5:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Ou... |
stream the logs in real-time for the 'astro-container' container in the 'chat-app-pod' pod | Command:
```bash
kubectl logs -f -c astro-container chat-app-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", ... |
Return the snapshot logs from the container 'backend-microservice-deployment-1' of the deployment named 'proxy-server-pod'. | Command:
```bash
kubectl logs deployment/backend-microservice-deployment -c proxy-server-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 ... |
Set the cpu limits of the 'amazonlinux' deployment's 'nginx' container to "50m" and memory limits to "64Mi" | Command:
```bash
kubectl set resources deployment amazonlinux -c=nginx --limits=cpu=50m,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 u... |
Execute the command "pg_dump --version" in the lunar-launcher container of the auth-service-pod and retrieve the output | Command:
```bash
kubectl exec auth-service-pod -c lunar-launcher -- 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. ... |
Create a job named "scaling-job" using the "amazonlinux" image, and execute the command "yum install -y aws-cli" within the job. | Command:
```bash
kubectl create job scaling-job --image=amazonlinux -- yum install -y aws-cli
```
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": ... |
Create a copy of the 'payment-gateway-pod' pod, adding a debug container with the 'debian' image and changing the container images of 'scheduler' to 'my-scheduler:1.0' and 'worker' to 'my-custom-worker:1.2.3'. | Command:
```bash
kubectl debug payment-gateway-pod -it --copy-to=debug-image-memcached --image=debian --set-image=scheduler=my-scheduler:1.0,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... |
Start streaming the logs of the 'stardust-shuttle' container in the 'email-service-pod' pod | Command:
```bash
kubectl logs -f -c stardust-shuttle 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": "--contai... |
Create a new config map named "namespace-config" and populate it with the contents of the specified files | Command:
```bash
kubectl create configmap namespace-config --from-file=properties=/path/to/options/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 cr... |
Forward traffic from local port 8000 to the target port of the analytics-service's "https" port in the selected pod. | Command:
```bash
kubectl port-forward service/analytics-service 8000:https
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be sele... |
Create a new config map named global-config with the specified keys from the provided files | Command:
```bash
kubectl create configmap global-config --from-file=settings=/path/to/properties/file1.txt --from-file=key2=/path/to/settings/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 creatin... |
Forward traffic from port 9090 on localhost and IP 10.19.21.23 to port 3000 in the pod named 'api-service-pod' | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/api-service-pod 9090: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... |
Open the search-service service for editing using the micro text editor instead of the default editor. | Command:
```bash
KUBE_EDITOR="micro" kubectl edit svc/search-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... |
Create a secret from an environment file | Command:
```bash
kubectl create secret generic email-credentials-secret --from-env-file=path/to/options.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 ... |
Create a cluster role named "default_role" with the ability to perform the "create" action on a specific NonResourceURL | Command:
```bash
kubectl create clusterrole "default_role" --verb=create --non-resource-url=/port-forward
```
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": "--ou... |
Assign a taint to nodes labeled with the region "eu-west-2" | Command:
```bash
kubectl taint node -l region=eu-west-2 hardware=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":... |
Create a service for the replicated alpine pods, serving on port 3306, and connecting to the containers on port 700000. | Command:
```bash
kubectl expose rc alpine --port=3306 --target-port=700000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port.... |
Remove the 'description' annotation from the 'frontend' pod | Command:
```bash
kubectl annotate pods frontend description-
```
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 string... |
Create an ingress named 'service-ingress' that routes requests from foo.com/input to svc1:8081, and use the tls secret "my-cert". | Command:
```bash
kubectl create ingress service-ingress --rule="foo.com/input=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"... |
Enable the OpenID Connect auth provider for the "cloud-user" entry with additional arguments | Command:
```bash
kubectl config set-credentials cloud-user --auth-provider=oidc --auth-provider-arg=client-id=foo --auth-provider-arg=client-secret=bar
```
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:
--... |
Create a new secret named ssh-key-secret from an environment file | Command:
```bash
kubectl create secret generic ssh-key-secret --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... |
Retrieve the documentation for the 'replicas' field in the 'spec' section of the 'pods' resource. | Command:
```bash
kubectl explain resource=pods.spec.replicas
```
What it does:
List the fields for supported resources.
This command describes the fields associated with each supported API resource. Fields are identified via a simple JSONPath identifier:
<type>.<fieldName>[.<fieldName>]
Add the --recursive flag to dis... |
Update the image of all containers in the daemonset named "namespace-1" to "nginx:1.21.3". | Command:
```bash
kubectl set image daemonset namespace-1 *=nginx:1.21.3
```
What it does:
Update existing container image(s) of resources.
Possible resources include (case insensitive):
pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), statefulset (sts), cronjob (cj), replicaset (rs)
Syntax:
... |
Delete the pods and services with the names "monitoring" and "api" | Command:
```bash
kubectl delete pod,service monitoring api
```
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.
... |
Roll back a daemonset to a specific revision | Command:
```bash
kubectl rollout undo daemonset/prod --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 the re... |
Copy the local directory "/tmp/foo_dir" to the remote pod "message-broker-pod-15" in the "/tmp/bar_dir" directory. | Command:
```bash
kubectl cp /tmp/foo_dir message-broker-pod-15:/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 the kube... |
Create a debug version of 'mypod' by adding a 'debian' container with the image 'redis:alpine' for the 'cache' container and 'nginx:latest' for the 'web' container | Command:
```bash
kubectl debug mypod -it --copy-to=debug-image-app --image=debian --set-image=cache=redis:alpine,web=nginx:latest
```
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.... |
Create a job named 'log-processing-job' using the 'mysql' image, with the command 'mysql' | Command:
```bash
kubectl create job log-processing-job --image=mysql -- mysql
```
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. ... |
Create a pod disruption budget with selector and minimum availability requirements | Command:
```bash
kubectl create poddisruptionbudget auth-service-pdb --selector=tier=frontend --min-available=9
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N... |
Create an ingress resource named 'private-service-ingress' with a rule that directs requests to site.com/module to svc1:8000 and uses the 'my-cert' tls secret. | Command:
```bash
kubectl create ingress private-service-ingress --rule="site.com/module=svc1:8000,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 the 'debug_mode' environment variable in the 'api-server-deployment' deployment by importing the specific key from the 'app-config' config map. | Command:
```bash
kubectl set env --keys=debug_mode --from=configmap/app-config deployment/api-server-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions i... |
Create an ingress called 'private-api-ingress' with a rule that directs requests from website.com/input to svc1:8083 | Command:
```bash
kubectl create ingress private-api-ingress --rule="website.com/input=svc1:8083,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "",... |
Forward port 8080 locally to port 5000 in the 'chat-app-pod' pod | Command:
```bash
kubectl port-forward pod/chat-app-pod 8080: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... |
edit the db-service service using the nano editor. | Command:
```bash
KUBE_EDITOR="nano" kubectl edit svc/db-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, or ... |
Set the custom TLS server name for the on-prem-cluster cluster entry | Command:
```bash
kubectl config set-cluster on-prem-cluster --tls-server-name=cluster-beta
```
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 cron job named "data-sync" that runs the command "apache2ctl -D FOREGROUND" every minute, using the "wordpress" image. | Command:
```bash
kubectl create cronjob data-sync --image=wordpress --schedule="*/1 * * * *" -- apache2ctl -D FOREGROUND
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", ... |
Open the web-service service for editing using the atom editor | Command:
```bash
KUBE_EDITOR="atom" 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, or... |
Create a new ExternalName service named 'external-monitoring-service' that maps to the external DNS name 'practice-online.site' | Command:
```bash
kubectl create service externalname external-monitoring-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 refere... |
Port forward from local machine to a pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/log-aggregator-pod 8088:5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the ... |
Forward traffic from port 9090 on localhost and IP address 10.19.21.23 to port 8888 in the backend-pod pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/backend-pod 9090: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 criteri... |
Auto scale the replication controller "frontend" with a target CPU utilization of 81%, ensuring that the number of pods is maintained between 1 and 7. | Command:
```bash
kubectl autoscale rc frontend --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 use... |
Copy the file /tmp/foo from the auth-service-pod-11 pod in the default namespace to the /tmp/bar_dir directory on your local machine. | Command:
```bash
kubectl cp default/auth-service-pod-11:/tmp/foo /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 the ku... |
list the replication controller named web, the service named api-service-rc, and the pod named proxy-server-pod | Command:
```bash
kubectl get rc/web service/api-service-rc pods/proxy-server-pod
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is names... |
Create a new secret named jwt-secret with key1=supersecret and key2=topsecret | Command:
```bash
kubectl create secret generic jwt-secret --from-literal=key1=supersecret --from-literal=key2=topsecret
```
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... |
Add a taint with key 'dedicated=storage-node-13:PreferNoSchedule' on the nodes that have the label 'instance=app-instance-1' | Command:
```bash
kubectl taint node -l instance=app-instance-1 dedicated=storage-node-13:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default":... |
Update the label of the pod with the name 'vpn'. Set the label name as 'env' and the value as 'production'. | Command:
```bash
kubectl label pods vpn env=production
```
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... |
Create a service for the replicated nginx using replica set, which serves on port 5432 and connects to the containers on port 909100 | Command:
```bash
kubectl expose rs nginx --port=5432 --target-port=909100
```
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 traffic from port 8000 on all addresses to port 8081 in the frontend-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/frontend-pod 8000: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... |
Create a copy of the vpn-service-pod with all container images changed to ethereum/client-go | Command:
```bash
kubectl debug vpn-service-pod --copy-to=debug-image-web --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 de... |
Set the service account of the frontend-deployment deployment to the default service account | Command:
```bash
kubectl set serviceaccount deployment frontend-deployment default
```
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 s... |
Import environment variables from a config map with a prefix MYSQL_ into the deployment/user-management-deployment | Command:
```bash
kubectl set env --from=configmap/kube-system-config --prefix=MYSQL_ deployment/user-management-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable de... |
Create a service named "centos-https" that exposes container port 8443 as port 443 | Command:
```bash
kubectl expose service centos --port=443 --target-port=8888 --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 service o... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.