prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Set the custom TLS server name to "sun-cluster" for the "app-cluster" cluster entry in the kubectl configuration. | Command:
```bash
kubectl config set-cluster app-cluster --tls-server-name=sun-cluster
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-cluster NAME [--server=server] [--certificate-a... |
Scale the deployment named mysql to 7 replicas if its current size is 1 | Command:
```bash
kubectl scale --current-replicas=1 --replicas=7 deployment/mysql
```
What it does:
Set a new size for a deployment, replica set, replication controller, or stateful set.
Scale also allows users to specify one or more preconditions for the scale action.
If --current-replicas or --resource-version is sp... |
Update the image of all containers in the daemonset named 'nginx' to 'nginx:1.21.3'. | Command:
```bash
kubectl set image daemonset nginx *=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:
`kubec... |
update environment variable in deployment | Command:
```bash
kubectl set env deployment/database-deployment QUEUE_NAME=task-queue
```
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 template... |
Create a debug copy of the 'gateway-pod' and change all container images to 'centos'. | Command:
```bash
kubectl debug gateway-pod --copy-to=debug-image-app --set-image=*=centos
```
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 reso... |
Apply a taint with the key 'hardware' on nodes that have the label 'myLabel' | Command:
```bash
kubectl taint node -l myLabel hardware=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": "Output ... |
Set the cluster field in a specific context to a given value | Command:
```bash
kubectl config set contexts.on-prem-context.cluster star-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 you ... |
Open the payment-service service for editing using the sublime editor. | Command:
```bash
KUBE_EDITOR="sublime" kubectl edit svc/payment-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 variab... |
Expose a replicated controller as a service on a given port and target port | Command:
```bash
kubectl expose rc ubuntu --port=9090 --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 port.... |
Copy the local file ~/.config/kube to the /tmp/bar_dir directory in the remote pod kube-node-lease/load-balancer-pod-9 in the default namespace | Command:
```bash
kubectl cp ~/.config/kube kube-node-lease/load-balancer-pod-9:/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 omitt... |
Expose the nginx deployment as a service, serving on port 80, connecting to the containers on port 8000. | Command:
```bash
kubectl expose deployment nginx --port=80 --target-port=844300
```
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 ... |
Auto scale the replication controller "foo" with a target CPU utilization of 81% and a minimum of 1 pod and a maximum of 4 pods. | Command:
```bash
kubectl autoscale rc foo --max=4 --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 uses the... |
Create a new config map named env-vars with specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap env-vars --from-file=settings=/path/to/profiles/file1.txt --from-file=key2=/path/to/properties/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a c... |
Add a taint with the key 'special' and the value 'app-node-6:PreferNoSchedule' on nodes that have the label 'release=beta' | Command:
```bash
kubectl taint node -l release=beta special=app-node-6:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Out... |
Create a new NodePort service named payment-gateway-nodeport that maps port 9092 on the cluster to port 8010 on the service | Command:
```bash
kubectl create service nodeport payment-gateway-nodeport --tcp=9092: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", "defau... |
Add a taint on nodes with a specific label | Command:
```bash
kubectl taint node -l cluster=my-cluster environment=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": "", ... |
Get the list of topics from the Kafka service running in the warp-drive container inside the vpn-service-pod pod. | Command:
```bash
kubectl exec vpn-service-pod -c warp-drive -- 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. If ... |
Port forward data between local ports 8080 and 6000 to ports 5000 and 6000 in the pod selected by the "email-server-deployment" deployment | Command:
```bash
kubectl port-forward deployment/email-server-deployment 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... |
Get the output from running the 'apache2ctl -D FOREGROUND' command from the media-stream-pod pod using the first container by default. | Command:
```bash
kubectl exec media-stream-pod -- apache2ctl -D FOREGROUND
```
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,... |
Import specific keys from a config map into a deployment's environment variables | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/app-secrets deployment/web-app-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in ... |
Show the resource usage metrics for the pods that have the label "namespace=mynamespace" | Command:
```bash
kubectl top pod -l namespace=mynamespace
```
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:
`kubectl top pod [... |
Create a job from a cron job named "system-health-check" | Command:
```bash
kubectl create job test-job --from=cronjob/system-health-check
```
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... |
Taint nodes with the label 'team=devops' with a 'datacenter' key and 'node-1:PreferNoSchedule' value. | Command:
```bash
kubectl taint node -l team=devops datacenter=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": "Outpu... |
Delete pods and services named "monitoring" and "proxy" | Command:
```bash
kubectl delete pod,service monitoring proxy
```
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... |
Create a new config map named monitoring-config using the properties.env file located at path/to/properties.env | Command:
```bash
kubectl create configmap monitoring-config --from-env-file=path/to/properties.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 ... |
Get output from running the 'bash' command in the 'lunar-launcher' container of the 'auth-service-pod' pod. | Command:
```bash
kubectl exec auth-service-pod -c lunar-launcher -- 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, u... |
Forward port 5432 on your local machine 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 5432:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteri... |
Create a new ClusterIP service named 'security-service-clusterip' with a TCP port mapping of 8888:5001. | Command:
```bash
kubectl create service clusterip security-service-clusterip --tcp=8888:5001
```
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... |
Create a copy of the "monitoring-pod" pod, but with a different command for the "warp-drive" container, and name the new pod "my-debugger". | Command:
```bash
kubectl debug monitoring-pod -it --copy-to=my-debugger --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... |
Create a role named "bar" with the verb "delete" and resources "pods" with specific resource names "blog-backend" and "identity-provider" | Command:
```bash
kubectl create role bar --verb=delete --resource=pods --resource-name=blog-backend --resource-name=identity-provider
```
What it does:
Create a role with single rule.
Syntax:
`kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run=server|c... |
Check if you have permission to list the job named "security-scan-job" in the "testing" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/security-scan-job -n testing
```
What it does:
Check whether an action is allowed.
VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is a partial URL ... |
Create a job named security-scan-job with the image ruby and the command irb. | Command:
```bash
kubectl create job security-scan-job --image=ruby -- irb
```
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. One ... |
Get the output from running the command 'java -jar /usr/share/jenkins/jenkins.war' in the container 'mycontainer' of the 'frontend-pod' pod. | Command:
```bash
kubectl exec frontend-pod -c mycontainer -- java -jar /usr/share/jenkins/jenkins.war
```
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": "... |
Switch to raw terminal mode and launch a bash shell in the code-explorer container of the cdn-service-pod, sending inputs to 'bash' and receiving outputs from 'bash'. | Command:
```bash
kubectl exec cdn-service-pod -c code-explorer -i -t -- bash -il
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If om... |
Import specific keys from a config map to a deployment's environment variables. | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/db-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 variable d... |
Create a debug copy of chat-app-pod, including a debug container and changing container images | Command:
```bash
kubectl debug chat-app-pod -it --copy-to=debug-image-1 --image=debian --set-image=api=api:v2,api=api:v2
```
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 wil... |
Set the custom TLS server name to use for validation for the cluster-gamma cluster entry. | Command:
```bash
kubectl config set-cluster cluster-gamma --tls-server-name=cluster-gamma
```
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 a taint with key 'hardware' on nodes having label project=project-alpha | Command:
```bash
kubectl taint node -l project=project-alpha hardware=app-node-6: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": "", "us... |
Create an ingress with a specific rule and TLS secret for routing requests to a service. | Command:
```bash
kubectl create ingress api-v1-ingress --rule="site.com/bar=svc1:5000,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": ... |
Run the 'mysqld' command in the 'cyber-sleuth' container of the 'analytics-pod' pod and get the output. | Command:
```bash
kubectl exec analytics-pod -c cyber-sleuth -- 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 ... |
Add a taint with the key 'special' on nodes that have the label 'myLabel' and set the value as 'gpu-node-12' with the effect 'PreferNoSchedule' | Command:
```bash
kubectl taint node -l myLabel special=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": "Output ... |
Create a pod disruption budget named database-pdb that will select all pods with the project=my-project label and require a minimum of one of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget database-pdb --selector=project=my-project --min-available=1
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=... |
Create a deployment named 'db' using the 'redis' image, with the command 'redis-server' | Command:
```bash
kubectl create deployment db --image=redis -- redis-server
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: js... |
Import specific keys from a config map into the environment variables of a deployment. | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/api-config deployment/gateway-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions ... |
Create an ingress named 'www-ingress' with a rule that directs requests for 'site.com/module' to 'svc1:6379', and use the TLS secret 'my-cert'. | Command:
```bash
kubectl create ingress www-ingress --rule="site.com/module=svc1:6379,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": ... |
List deployments in JSON output format for the "v1.1.0" version of the "external-apps" API group. | Command:
```bash
kubectl get deployments.v1.1.0.external-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 w... |
Forward data between port 3000 on your local machine and port 5000 in the pod "mypod". | Command:
```bash
kubectl port-forward 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 pod will be selected automaticall... |
Execute the 'docker run -it ubuntu' command inside the first pod of the 'gateway-deployment', and display the output. | Command:
```bash
kubectl exec deploy/gateway-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": "Container name. If om... |
Forward local port 5432 to port 5000 in the pod named "chat-app-pod" | Command:
```bash
kubectl port-forward pod/chat-app-pod 5432 5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected autom... |
Create a new NodePort service named 'auth-service-nodeport' with a TCP port mapping of 3001 to 8000. | Command:
```bash
kubectl create service nodeport auth-service-nodeport --tcp=3001:8000
```
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"... |
Copy the local directory /tmp/foo_dir to the remote pod named load-balancer-pod-9 in the default namespace, and place it in the directory /tmp/bar_dir_dir. | Command:
```bash
kubectl cp :/tmp/foo_dir load-balancer-pod-9:/tmp/bar_dir_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 k... |
Create an ingress named "api-gateway-ingress" that maps the request for "site.com/input" to the service "svc1:6379" | Command:
```bash
kubectl create ingress api-gateway-ingress --rule="site.com/input=svc1:6379,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "u... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/db-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 variable d... |
Create a single ingress called 'external-ingress' that directs requests to website.com/example to svc1:8084 with a tls secret "my-cert" | Command:
```bash
kubectl create ingress external-ingress --rule="website.com/example=svc1:8084,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": "", ... |
Auto scale the deployment "chat-app" with a minimum of 3 pods and a maximum of 9 pods | Command:
```bash
kubectl autoscale deployment chat-app --min=3 --max=9
```
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... |
Create a new pod named "hazelcast" using the "ruby" image, and expose port 8000 within the container. | Command:
```bash
kubectl run hazelcast --image=ruby --port=8000
```
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": "--fil... |
Set the environment variable 'DEBUG' to 'true' for the 'database-deployment' deployment. | Command:
```bash
kubectl set env deployment/database-deployment DEBUG=true
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more pod templates (within r... |
Get the output from running the 'sleep 3600' command in the security-service-pod pod, using the first container by default. | Command:
```bash
kubectl exec security-service-pod -- 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, use the k... |
Create a new config map named app-settings from an environment file | Command:
```bash
kubectl create configmap app-settings --from-env-file=path/to/options.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 to the b... |
Embed the certificate authority data for the 'edge-cluster' cluster entry by using the command 'kubectl config set-cluster edge-cluster --embed-certs --certificate-authority=~/.kube/cloud-cluster/kubernetes.ca.crt' | Command:
```bash
kubectl config set-cluster edge-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 se... |
Partially update a node by applying a strategic merge patch from provided YAML content. | Command:
```bash
kubectl patch node dev-node-4 -p $'spec:\n replicas: 3'
```
What it does:
Update fields of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.
JSON and YAML formats are accepted.
Syntax:
`kubectl patch (-f FILENAME | TYPE NAME) [-p PATCH|--patch-file FILE]`
Helpful flags:
"f... |
Import the 'EXTERNAL_API_URL' key from the 'kube-system-config' config map and set it as an environment variable in the 'load-balancer-deployment' deployment. | Command:
```bash
kubectl set env --keys=EXTERNAL_API_URL --from=configmap/kube-system-config deployment/load-balancer-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... |
Open and edit the logging-service service using the nano editor. | Command:
```bash
KUBE_EDITOR="nano" kubectl edit svc/logging-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 pod disruption budget named ingress-controller-pdb that will select all pods with the project=my-project label and require a minimum of one of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget ingress-controller-pdb --selector=project=my-project --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-... |
Create a single ingress called 'app-gateway-ingress' that directs requests to testing.com/bar to svc1:27017 with a tls secret "my-cert" | Command:
```bash
kubectl create ingress app-gateway-ingress --rule="testing.com/bar=svc1:27017,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": "", ... |
View the details of daemonset revision 7 in the namespace-2 namespace | Command:
```bash
kubectl rollout history daemonset/namespace-2 --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... |
Update the container images for the 'httpd' deployment | Command:
```bash
kubectl set image deployment/httpd busybox=busybox httpd=httpd:2.4.48
```
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... |
Create a new config map named db-config with the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap db-config --from-file=properties=/path/to/properties/file1.txt --from-file=key1=/path/to/options/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a... |
Set up autoscaling for the replication controller "log-aggregator" with a target CPU utilization of 50% | Command:
```bash
kubectl autoscale rc log-aggregator --max=4 --cpu-percent=50
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler th... |
Add a taint with key 'special' on nodes having label zone=us-east-1 | Command:
```bash
kubectl taint node -l zone=us-east-1 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": "O... |
Rename a context in your kubeconfig file. | Command:
```bash
kubectl config rename-context on-prem-context team-alpha-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 wil... |
Forward port locally to pod | Command:
```bash
kubectl port-forward pod/analytics-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 auto... |
Set a custom TLS server name for the edge-cluster cluster entry | Command:
```bash
kubectl config set-cluster edge-cluster --tls-server-name=prod-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... |
Create a new ClusterIP service named auth-service-clusterip, mapping local port 7000 to container port 3000. | Command:
```bash
kubectl create service clusterip auth-service-clusterip --tcp=7000:3000
```
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", "... |
Attach to the astro-container in security-service-pod and get the output | Command:
```bash
kubectl attach security-service-pod -c astro-container
```
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 ... |
Create a deployment named my-dep running the mongo image with port 5432 exposed | Command:
```bash
kubectl create deployment my-dep --image=mongo --port=5432
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: js... |
Set the CPU and memory limits for the hazelcast container in the deployment named "hazelcast" to 200 milliCPU and 4 gigabytes respectively. | Command:
```bash
kubectl set resources deployment hazelcast -c=nginx --limits=cpu=200m,memory=4Gi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up ... |
create a job named 'backup' with the image 'ruby' and the command 'ruby --version' | Command:
```bash
kubectl create job backup --image=ruby -- ruby --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 format. One ... |
Create a job named "indexing" using the Elasticsearch image, with the command "elasticsearch" | Command:
```bash
kubectl create job indexing --image=docker.elastic.co/elasticsearch/elasticsearch -- elasticsearch
```
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", "d... |
Import the 'smtp_server' key from the 'monitoring-config' config map and set it as an environment variable for the 'search-engine-deployment' deployment | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/monitoring-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 de... |
Create a pod disruption budget named "web-app-pdb" that selects all pods with the "app=nginx" label and ensures that at least 70% of the selected pods are available at any given time. | Command:
```bash
kubectl create pdb web-app-pdb --selector=app=nginx --min-available=70%
```
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 [--dry-run=server|clie... |
Create a new ClusterIP service named ldap-service-clusterip, with a port mapping from local port 27017 to target port 3001. | Command:
```bash
kubectl create service clusterip ldap-service-clusterip --tcp=27017:3001
```
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 to the 'edge-node-10' node with the key 'dedicated' and no value | Command:
```bash
kubectl taint nodes edge-node-10 dedicated: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... |
Apply a taint with the key 'special' and no value to the node 'dev-node-4'. | Command:
```bash
kubectl taint nodes dev-node-4 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: js... |
Set specific keys from a config map as environment variables for a deployment | Command:
```bash
kubectl set env --keys=api_key --from=configmap/monitoring-config deployment/cache-cluster-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defini... |
Set resource requests and limits for containers in go deployment. | Command:
```bash
kubectl set resources deployment go --limits=cpu=200m,memory=512Mi --requests=cpu=100m,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... |
Add the annotation 'release-notes' with the value 'https://example.com/release-notes/v2.5.1' to the 'log-aggregator' pod. | Command:
```bash
kubectl annotate pods log-aggregator 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 ... |
Create a cluster role named "default_role" with the ability to execute commands and access the /watch/* URL | Command:
```bash
kubectl create clusterrole "default_role" --verb=exec --non-resource-url=/watch/*
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", ... |
Listen on port 5000 on all addresses, and forward it to port 8080 in the frontend-pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/frontend-pod 5000: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... |
Create a new config map named 'app-secrets' with the specified keys by using the files '/path/to/profiles/file1.txt' and '/path/to/options/file2.txt' | Command:
```bash
kubectl create configmap app-secrets --from-file=conf=/path/to/profiles/file1.txt --from-file=data=/path/to/options/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a confi... |
Get the list of Kafka topics by executing the command 'kafka-topics --list' in the 'warp-drive' container of the 'api-service-pod' pod. | Command:
```bash
kubectl exec api-service-pod -c warp-drive -- 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. If ... |
Forward traffic from port 8080 on all addresses to port 8888 in the frontend-pod pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/frontend-pod 8080:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will... |
Execute the 'mongod' command in the 'code-explorer' container of the 'vpn-service-pod' and get the output. | Command:
```bash
kubectl exec vpn-service-pod -c code-explorer -- mongod
```
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, u... |
Set the custom TLS server name for the cluster-alpha cluster entry | Command:
```bash
kubectl config set-cluster cluster-alpha --tls-server-name=moon-cluster
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-cluster NAME [--server=server] [--certificat... |
Import specific keys from a config map into a deployment's environment variables. | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/ui-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 definiti... |
Remove the developer user from the kubectl configuration. | Command:
```bash
kubectl config delete-user developer
```
What it does:
Delete the specified user from the kubeconfig.
Syntax:
`kubectl config delete-user NAME` |
Update the node 'k8s-node-1' by adding a taint with key 'app', value 'backend', and effect 'PreferNoSchedule' | Command:
```bash
kubectl taint nodes k8s-node-1 app=backend:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. ... |
copy the file /tmp/foo from the remote pod argocd/image-resizer-pod-20 to the local directory /etc/kubernetes. | Command:
```bash
kubectl cp argocd/image-resizer-pod-20:/tmp/foo /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... |
Import specified keys from a config map into the environment variables of a deployment | Command:
```bash
kubectl set env --keys=external_api_url --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... |
Create a copy of the "analytics-pod" pod, adding a debug container and changing container images | Command:
```bash
kubectl debug analytics-pod -it --copy-to=debug-image-memcached --image=debian --set-image=cache=redis:alpine,api=api:v2
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.