prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Set the service account of the deployment "analytics-platform-deployment" to "kube-scheduler" | Command:
```bash
kubectl set serviceaccount deployment analytics-platform-deployment kube-scheduler
```
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
S... |
Import the specific keys 'config_file_path' from the api-config config map into the search-engine-deployment deployment. | Command:
```bash
kubectl set env --keys=config_file_path --from=configmap/api-config 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 defi... |
create a cron job named "report-generation" that runs the command "apk add curl" every minute using the Alpine image. | Command:
```bash
kubectl create cronjob report-generation --image=alpine --schedule="*/1 * * * *" -- apk add curl
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short"... |
Add a taint to nodes in the 'eu-west-2' region with the key 'environment' and value 'worker-node-3' with the effect 'PreferNoSchedule' | Command:
```bash
kubectl taint node -l region=eu-west-2 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": "", "u... |
Execute the 'php --version' command inside the email-service-pod and display the output. | Command:
```bash
kubectl exec email-service-pod -- php --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 k... |
Create a copy of the "database-pod" pod, changing the command of the "warp-drive" container, and start an interactive shell session in the copied pod. | Command:
```bash
kubectl debug database-pod -it --copy-to=debug-image-1 --container=warp-drive -- 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... |
Set the CPU limits of the elasticsearch container in a deployment to 3 and the memory limits to 128Mi. | Command:
```bash
kubectl set resources deployment elasticsearch -c=nginx --limits=cpu=3,memory=128Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst ... |
Show details of a specific context in your kubeconfig file | Command:
```bash
kubectl config get-contexts prod-context
```
What it does:
Display one or many contexts from the kubeconfig file.
Syntax:
`kubectl config get-contexts [(-o|--output=)name)]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: name " |
Create a new config map named monitoring-config from specified files | Command:
```bash
kubectl create configmap monitoring-config --from-file=properties=/path/to/profiles/file1.txt --from-file=key1=/path/to/parameters/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When c... |
Create a new ClusterIP service named monitoring-service-clusterip listening on port 27017, and forwarding the traffic to port 27017 | Command:
```bash
kubectl create service clusterip monitoring-service-clusterip --tcp=27017:27017
```
What it does:
Create a ClusterIP service with the specified name.
Syntax:
`kubectl create service clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short":... |
Create a new config map named 'app-settings' by importing environment variables from the file located at 'path/to/configurations.env' | Command:
```bash
kubectl create configmap app-settings --from-env-file=path/to/configurations.env
```
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 t... |
Delete pods and services with the names "foo" and "cdn" | Command:
```bash
kubectl delete pod,service foo cdn
```
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... |
Delete the pods and services named "log-aggregator" and "email" | Command:
```bash
kubectl delete pod,service log-aggregator email
```
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 sele... |
Create a new ExternalName service named external-notification-service and set the external name to dummy-website.io | Command:
```bash
kubectl create service externalname external-notification-service --external-name dummy-website.io
```
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 referenc... |
import the keys "EXTERNAL_API_URL" from the "app-config-prod" config map to the "order-processing-deployment" deployment | Command:
```bash
kubectl set env --keys=EXTERNAL_API_URL --from=configmap/app-config-prod deployment/order-processing-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment varia... |
Create a job called "log-collection" using the image "confluentinc/cp-kafka" and run the command "kafka-console-producer --broker-list localhost:9092 --topic test" | Command:
```bash
kubectl create job log-collection --image=confluentinc/cp-kafka -- kafka-console-producer --broker-list localhost:9092 --topic test
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"fla... |
Forward local port 8081 to port 5000 in the analytics-pod pod. | Command:
```bash
kubectl port-forward pod/analytics-pod 8081: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 auto... |
Create a service for the specified replication controller config file, with the service serving on port 9091 and connecting to the container on port 801000. | Command:
```bash
kubectl expose -f nginx-controller.yaml --port=9091 --target-port=801000
```
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 ... |
Enable the Google Compute Platform auth provider for the "prod-user" entry | Command:
```bash
kubectl config set-credentials prod-user --auth-provider=gcp
```
What it does:
Set a user entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values.
Client-certificate flags:
--client-certificate=certfile --client-key=keyfile
Bearer token flags:
--t... |
Set the user field of the dev-context context entry to "cluster-admin" | Command:
```bash
kubectl config set-context dev-context --user=cluster-admin
```
What it does:
Set a context 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-context [NAME | --current] [--cluster=cluster_nickname] ... |
Set the CPU limits of the Elasticsearch container in the deployment to "1" and the memory limits to "128Mi" | Command:
```bash
kubectl set resources deployment elasticsearch -c=nginx --limits=cpu=1,memory=128Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst ... |
Remove the taint with key 'datacenter' and effect 'NoExecute' from the node 'storage-node-13' if it exists. | Command:
```bash
kubectl taint nodes storage-node-13 datacenter:NoExecute-
```
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. On... |
Start the elasticsearch pod using a different command and custom arguments | Command:
```bash
kubectl run nginx --image=docker.elastic.co/elasticsearch/elasticsearch --command -- <cmd> <arg1> ... <argN>
```
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] [--c... |
Forward traffic from port 5000 on localhost and IP address 10.19.21.23 to port 8888 inside the pod named log-aggregator-pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/log-aggregator-pod 5000: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 ... |
List deployments in the JSON output format, using the "v1.0.0" version of the "sandbox-apps" API group | Command:
```bash
kubectl get deployments.v1.0.0.sandbox-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 wi... |
Set a taint with the key 'datacenter' and value 'gpu-node-12:PreferNoSchedule' on all nodes with the label 'myLabel' | Command:
```bash
kubectl taint node -l myLabel 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": "", "usage": "Outp... |
Set the cluster field in the my-context context to cluster-beta | Command:
```bash
kubectl config set contexts.user-b-context.cluster cluster-beta
```
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 you w... |
Add a taint to a specific node with a given key and no value | Command:
```bash
kubectl taint nodes web-node-8 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 of: j... |
Update the pod 'database' by setting the annotation 'expiration-date' to '2024-12-31', replacing any existing value. | Command:
```bash
kubectl annotate --overwrite pods database 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 labels ... |
Update the label of pod 'foo' to set the value 'myapp' for the label 'app' | Command:
```bash
kubectl label pods foo app=myapp
```
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 true... |
Update the pod named 'email' with the annotation 'description' and set its value as 'Web server for marketing site' | Command:
```bash
kubectl annotate pods email description='Web server for marketing site'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels ... |
Forward local port 6379 to port 8081 on a pod selected by the deployment named "api-server-deployment" | Command:
```bash
kubectl port-forward deployment/api-server-deployment 6379 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 b... |
Embed the certificate authority data for the 'app-cluster' cluster entry | Command:
```bash
kubectl config set-cluster app-cluster --embed-certs --certificate-authority=~/.kube/cluster-gamma/kubernetes.ca.crt
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set... |
Forward all traffic from port 5432 on all addresses to port 5432 in the cdn-service-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/cdn-service-pod 5432: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 w... |
Set the annotation 'expiration-date' to '2024-12-31' for the pod 'foo' | Command:
```bash
kubectl annotate pods foo 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 labels and include arbit... |
Forward traffic from port 8081 on all addresses to port 8081 in the pod named "frontend-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/frontend-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... |
Copy the file /tmp/foo from your local machine to the /tmp/bar directory in the cache-container of the worker-pod-4 pod. | Command:
```bash
kubectl cp /tmp/foo worker-pod-4:/tmp/bar -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, use the ku... |
Create a pod disruption budget named web-app-pdb that selects pods with the project=my-project label and requires a minimum of 9 of them to be available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget web-app-pdb --selector=project=my-project --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... |
Set the annotation 'custom-label' to 'my-custom-value' for the pod 'auth', overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods auth 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 an... |
Forward local ports 8088 and 6000 to ports 8088 and 6000 in a selected pod of the deployment named "monitoring-stack-deployment" | Command:
```bash
kubectl port-forward deployment/monitoring-stack-deployment 8088 8088
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod ... |
Create a pod named "hazelcast" using the "golang" image, and configure the pod to expose port 3000. | Command:
```bash
kubectl run hazelcast --image=golang --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... |
Import the specific keys `CONFIG_FILE_PATH` from the `app-config` config map and set it as an environment variable in the `backend-microservice-deployment` deployment. | Command:
```bash
kubectl set env --keys=CONFIG_FILE_PATH --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 variab... |
Update the node identified by the type and name specified in "containerd-config.toml" using a strategic merge patch | Command:
```bash
kubectl patch -f containerd-config.toml -p '{"spec":{"containers":[{"name":"container-name", "resources":{"limits":{"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 p... |
Create a cron job that runs the command "redis-cli" every minute using the Redis image | Command:
```bash
kubectl create cronjob cron-task --image=redis --schedule="*/1 * * * *" -- redis-cli
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "def... |
Start streaming the logs of the "mycontainer" container in the "chat-app-pod" pod. | Command:
```bash
kubectl logs -f -c mycontainer 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", "sho... |
Forward traffic from port 3000 on localhost and IP 10.19.21.23 to port 8000 in the pod named "mypod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/mypod 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 p... |
Update the node 'monitoring-node-15' with a taint using the key 'dedicated' and value 'special-user' with the effect 'NoSchedule' | Command:
```bash
kubectl taint nodes monitoring-node-15 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": "Ou... |
Restart a specific daemon set named "development" | Command:
```bash
kubectl rollout restart daemonset/development
```
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 resou... |
Create a pod disruption budget named api-service-pdb that will select all pods with the component=web label and require a minimum of four of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget api-service-pdb --selector=component=web --min-available=4
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N ... |
Forward local port 9090 to port 8888 in the 'chat-app-pod' pod | Command:
```bash
kubectl port-forward pod/chat-app-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 criteria, a pod will be selected autom... |
Forward local traffic on port 8088 to a pod selected by the deployment, which will then forward the traffic to port 5432 in the pod. | Command:
```bash
kubectl port-forward deployment/notification-handler-deployment 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 ... |
Update the 'gateway' pod with the annotation 'contact-email' set to 'support@example.com', replacing any existing value. | Command:
```bash
kubectl annotate --overwrite pods gateway contact-email='support@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 l... |
Update the pod 'cdn' by setting the annotation 'deployment-script' with the value 'https://example.com/deploy.sh', overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods cdn deployment-script='https://example.com/deploy.sh'
```
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 lar... |
Return the previous terminated logs from the time-machine container in the media-stream-pod pod. | Command:
```bash
kubectl logs -p -c time-machine media-stream-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",... |
Start a ruby pod with customized specs by providing a JSON file containing the partial set of values to override the default specifications. | Command:
```bash
kubectl run nginx --image=ruby --overrides='{ "apiVersion": "dev-2.2.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMA... |
Execute the 'node' command in the container named 'mycontainer' within the pod named 'security-service-pod' and retrieve the output. | Command:
```bash
kubectl exec security-service-pod -c mycontainer -- 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, ... |
Attach to the time-machine container in the gateway-pod and get output from it. | Command:
```bash
kubectl attach gateway-pod -c time-machine
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use... |
Copy the local file '/tmp/foo' to the remote pod 'database-pod-2' in the 'kube-system' namespace, and place it in the '/etc/kubernetes' directory. | Command:
```bash
kubectl cp /tmp/foo kube-system/database-pod-2:/etc/kubernetes
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the ... |
Embed the certificate authority data for the 'sun-cluster' cluster entry using the command 'kubectl config set-cluster sun-cluster --embed-certs --certificate-authority=~/.kube/my-k8s-cluster/kubernetes.ca.crt' | Command:
```bash
kubectl config set-cluster sun-cluster --embed-certs --certificate-authority=~/.kube/my-k8s-cluster/kubernetes.ca.crt
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config se... |
Remove a taint from a specific node. | Command:
```bash
kubectl taint nodes gpu-node-12 special:NoSchedule-
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: ... |
Start a pod named nginx with the mongo image, but provide custom specifications using a JSON file | Command:
```bash
kubectl run nginx --image=mongo --overrides='{ "apiVersion": "hotfix-1.1.2", "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] -- [C... |
create a service for the replicated alpine using replica set, which serves on port 3306 and connects to the containers on port 8000 | Command:
```bash
kubectl expose rs alpine --port=3306 --target-port=8000
```
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... |
Update the 'security' pod with the annotation 'contact-email' and the value 'support@example.com'. | Command:
```bash
kubectl annotate pods security contact-email=support@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 inc... |
Forward local ports 8080 to port 3000 on the pod "api-service-pod" | Command:
```bash
kubectl port-forward pod/api-service-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 au... |
Configure a custom TLS server name for validation for the edge-cluster cluster entry | Command:
```bash
kubectl config set-cluster edge-cluster --tls-server-name=web-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] [--certificate-... |
Set a custom TLS server name for the data-cluster cluster entry. | Command:
```bash
kubectl config set-cluster data-cluster --tls-server-name=my-k8s-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] [--certifica... |
Add the label 'role=cache' to the 'backend' pod | Command:
```bash
kubectl label pods backend 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... |
Listen on port 3000 on all addresses, and forward the traffic to port 8000 inside the pod named cdn-service-pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/cdn-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... |
Embed certificate authority data for the "app-cluster" cluster entry. | Command:
```bash
kubectl config set-cluster app-cluster --embed-certs --certificate-authority=~/.kube/cloud-cluster/kubernetes.ca.crt
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set... |
List the pod information in custom columns, showing the container name and image. | Command:
```bash
kubectl get pod log-aggregator-pod -o custom-columns=CONTAINER:.spec.containers[0].name,IMAGE:.spec.containers[0].image
```
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 th... |
Forward traffic from port 8081 on localhost and IP 10.19.21.23 to port 6379 in the frontend-pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/frontend-pod 8081:6379
```
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 criter... |
Forward the local port 6379 to the pod 'api-service-pod' port 8888 | Command:
```bash
kubectl port-forward pod/api-service-pod 6379:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected au... |
Set a custom TLS server name for the staging-cluster cluster entry. | Command:
```bash
kubectl config set-cluster staging-cluster --tls-server-name=edge-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... |
Stream the logs of the "nebula-navigator" container in the "e-commerce-pod" pod | Command:
```bash
kubectl logs -f -c nebula-navigator e-commerce-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... |
Update the pod specified in the "params.json" file with the annotation "release-notes" set to "https://example.com/release-notes/v2.5.1" | Command:
```bash
kubectl annotate -f params.json 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 la... |
Create a pod named "hazelcast" using the Amazon Linux image and expose port 8888 | Command:
```bash
kubectl run hazelcast --image=amazonlinux --port=8888
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
"flag":... |
Create a new ClusterIP service named 'catalog-service-clusterip' with port mapping from port 3001 to port 9092. | Command:
```bash
kubectl create service clusterip catalog-service-clusterip --tcp=3001:9092
```
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"... |
Execute the 'kafka-server-start /etc/kafka/server.properties' command inside the auth-service-pod and retrieve the output. | Command:
```bash
kubectl exec auth-service-pod -- kafka-server-start /etc/kafka/server.properties
```
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": "Cont... |
Remove the environment variable 'ENV' from the container 'nano-bot' in all deployment configurations. | Command:
```bash
kubectl set env deployments --all --containers="nano-bot" ENV-
```
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 (wit... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/app-secrets 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 definitio... |
Partially update the backup-node-14 node by applying the specified strategic merge patch in YAML format | Command:
```bash
kubectl patch node backup-node-14 -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 (-... |
Create a pod disruption budget named replica-set-pdb that selects all pods with the project=my-project label and requires at least four of them to be available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget replica-set-pdb --selector=project=my-project --min-available=4
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-availab... |
Create a new ClusterIP service named order-service-clusterip with TCP port mapping from 7000 on the service to 5000 on the target | Command:
```bash
kubectl create service clusterip order-service-clusterip --tcp=7000:5000
```
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", ... |
View the details of revision 7 for the daemonset in the namespace-1 | Command:
```bash
kubectl rollout history daemonset/namespace-1 --revision=7
```
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 UR... |
Create an ingress resource named 'rontend-ingress' that routes requests from website.com/input to the service named 'svc1' running on port 8181 | Command:
```bash
kubectl create ingress rontend-ingress --rule="website.com/input=svc1:8181,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "us... |
Update the image of all containers in the 'prod' daemonset to 'mysql:5.7.35' | Command:
```bash
kubectl set image daemonset prod *=mysql:5.7.35
```
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:
`kubect... |
Run the 'mysql' command in the 'warp-drive' container of the 'analytics-pod' pod | Command:
```bash
kubectl exec analytics-pod -c warp-drive -- mysql
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the... |
Run the 'sleep 3600' command in the 'nano-bot' container from the 'vpn-service-pod' pod and get the output. | Command:
```bash
kubectl exec vpn-service-pod -c nano-bot -- sleep 3600
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, us... |
Update the image of all containers in the daemonset 'namespace-1' to 'java:11.0.12' | Command:
```bash
kubectl set image daemonset namespace-1 *=java:11.0.12
```
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:
... |
Create a new config map named app-config with the specified keys and corresponding file paths | Command:
```bash
kubectl create configmap app-config --from-file=properties=/path/to/data/file1.txt --from-file=key1=/path/to/preferences/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a ... |
Start a pod named 'hazelcast' with the 'mongo' image and expose port 3000 | Command:
```bash
kubectl run hazelcast --image=mongo --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": "--fi... |
Forward port 8888 locally to port 5432 in the pod "chat-app-pod" | Command:
```bash
kubectl port-forward pod/chat-app-pod 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 selected autom... |
Specify the resource request and limit for all containers in the Kafka deployment. | Command:
```bash
kubectl set resources deployment kafka --limits=cpu=200m,memory=512Mi --requests=cpu=200m,memory=256Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource reques... |
Retrieve the output from the command 'kafka-topics --list' running inside the 'nano-bot' container of the 'payment-gateway-pod' pod. | Command:
```bash
kubectl exec payment-gateway-pod -c nano-bot -- kafka-topics --list
```
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... |
Create a copy of the 'api-service-pod' pod and change all container images to 'docker.elastic.co/elasticsearch/elasticsearch' | Command:
```bash
kubectl debug api-service-pod --copy-to=my-debugger --set-image=*=docker.elastic.co/elasticsearch/elasticsearch
```
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 pod disruption budget named frontend-pdb that selects all pods with the owner=team-1 label and requires at least four of them to be available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget frontend-pdb --selector=owner=team-1 --min-available=4
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N [--d... |
Create a new ClusterIP service named backend-service-clusterip | Command:
```bash
kubectl create service clusterip backend-service-clusterip --tcp=8080:8888
```
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"... |
Add a taint with key 'workload' on nodes having label namespace=mynamespace | Command:
```bash
kubectl taint node -l namespace=mynamespace workload=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"... |
Create a new priority class called "marketing-priority" with a priority value of 300 and a description of "Priority for marketing-related tasks" | Command:
```bash
kubectl create priorityclass marketing-priority --value=300 --description="Priority for marketing-related tasks"
```
What it does:
Create a priority class with the specified name, value, globalDefault and description.
Syntax:
`kubectl create priorityclass NAME --value=VALUE --global-default=BOOL [--d... |
Forward local port 8000 to the pod's port 8000 belonging to the deployment named search-engine-deployment. | Command:
```bash
kubectl port-forward deployment/search-engine-deployment 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 wil... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.