prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Configure the replication controller "proxy-server" to automatically scale the number of pods based on CPU utilization | Command:
```bash
kubectl autoscale rc proxy-server --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 that... |
Open the 'docker-registry' service for editing using the 'code' editor | Command:
```bash
KUBE_EDITOR="code" kubectl edit svc/docker-registry
```
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... |
Get output from running the 'wp' command in time-machine container of the pod named backend-pod. | Command:
```bash
kubectl exec backend-pod -c time-machine -- wp
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the ku... |
Execute the 'apache2ctl -D FOREGROUND' command in the rocket-ranger container of the pod named proxy-service-pod and retrieve the output. | Command:
```bash
kubectl exec proxy-service-pod -c rocket-ranger -- 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... |
Add a taint with key 'special' on nodes having label project=project-alpha | Command:
```bash
kubectl taint node -l project=project-alpha special=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": "",... |
provide a detailed description of the cloud-node-4.cloud-provider.io node | Command:
```bash
kubectl describe nodes cloud-node-4.cloud-provider.io
```
What it does:
Show details of a specific resource or group of resources.
Print a detailed description of the selected resources, including related resources such as events or controllers. You may select a single object by name, all objects of t... |
Create a new ExternalName service named 'external-database-service' with the external name 'education-edu.edu' | Command:
```bash
kubectl create service externalname external-database-service --external-name education-edu.edu
```
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 s... |
View the details of a specific revision of a daemonset | Command:
```bash
kubectl rollout history daemonset/namespace-2 --revision=1
```
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... |
Forward local port 8081 to port 9090 in the pod selected by the database-deployment deployment, in order to provide access to the database | Command:
```bash
kubectl port-forward deployment/database-deployment 8081 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 ... |
Apply a taint to a specific node with a key-value pair and effect | Command:
```bash
kubectl taint nodes node-1 environment=production: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.... |
Forward traffic from port 8888 on all addresses to port 8888 in the proxy-server-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/proxy-server-pod 8888: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 ... |
Forward traffic from port 8888 on your local machine and IP address 10.19.21.23 to port 3000 in the pod named "security-service-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/security-service-pod 8888: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 th... |
Create a role binding named 'default_role' that assigns the 'default_role' cluster role to the 'admin', 'devops-user', and 'operations-team'. | Command:
```bash
kubectl create rolebinding default_role --clusterrole=default_role --user=admin --user=devops-user --group=operations-team
```
What it does:
Create a role binding for a particular role or cluster role.
Syntax:
`kubectl create rolebinding NAME --clusterrole=NAME|--role=NAME [--user=username] [--group=... |
Get the snapshot logs of all containers in pods with the label "project=project-alpha". | Command:
```bash
kubectl logs -l project=project-alpha --all-containers=true
```
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": "--... |
Forward traffic from localhost and IP 10.19.21.23 on port 8888 to port 8000 in the chat-app-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/chat-app-pod 8888: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 criter... |
Create a new ingress resource called 'app2-ingress' with a rule that directs requests from 'site.com/input' to service 'svc1' on port 8080 | Command:
```bash
kubectl create ingress app2-ingress --rule="site.com/input=svc1:8080,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": ... |
Remove the pods and services named "foo" and "monitoring" | Command:
```bash
kubectl delete pod,service foo monitoring
```
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.
... |
Add a taint with key 'datacenter' on nodes having label region=eu-west-2 | Command:
```bash
kubectl taint node -l region=eu-west-2 datacenter=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... |
List the replication controller named 'web', the service named 'monitoring-rc', and the pod named 'analytics-pod' | Command:
```bash
kubectl get rc/web service/monitoring-rc pods/analytics-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 namespace... |
Create a job named image-build-job using the redis image. The command to be executed inside the job is redis-cli. | Command:
```bash
kubectl create job image-build-job --image=redis -- redis-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": "Output format.... |
Switch to raw terminal mode and interact with the 'bash' shell inside the 'astro-container' from the 'mypod' pod | Command:
```bash
kubectl exec mypod -c astro-container -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 omitted, u... |
delete pods and services with the names "monitoring" and "auth" | Command:
```bash
kubectl delete pod,service monitoring auth
```
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.... |
Import specific keys from a config map into an environment variable of a deployment | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/monitoring-config deployment/log-aggregator-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable def... |
Check if you have permission to list the job named "log-analysis-job" in the "monitoring" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/log-analysis-job -n monitoring
```
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 UR... |
Set the CPU limits for the jenkins container in the deployment to "3" and the memory limits to "512Mi" | Command:
```bash
kubectl set resources deployment jenkins -c=nginx --limits=cpu=3,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 ... |
Create an ingress called 'api-v1-ingress' that directs requests to 'foo.com/bar' to 'svc1:7000' with a TLS secret named 'my-cert' | Command:
```bash
kubectl create ingress api-v1-ingress --rule="foo.com/bar=svc1:7000,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "... |
Create a pod disruption budget named logging-pdb that will select all pods with the label role=worker and require a minimum of four of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget logging-pdb --selector=role=worker --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 [--dry... |
Display the most recent 3 lines of logs for the 'chat-app-pod' pod | Command:
```bash
kubectl logs --tail=3 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", "short": "-c"... |
Roll back to a specific revision of a daemonset. | Command:
```bash
kubectl rollout undo daemonset/namespace-1 --to-revision=1
```
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... |
Update the 'vpn' pod by adding the annotation 'alert-email' with the value 'alerts@example.com' | Command:
```bash
kubectl annotate pods vpn alert-email=alerts@example.com
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include arb... |
Execute the 'jenkins-plugin-cli' command inside the payment-gateway-pod and obtain the output from the first container | Command:
```bash
kubectl exec payment-gateway-pod -- jenkins-plugin-cli
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, us... |
Embed certificate authority data for the staging-cluster cluster entry | Command:
```bash
kubectl config set-cluster staging-cluster --embed-certs --certificate-authority=~/.kube/prod-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 ... |
Begin streaming the logs of the specified container in the given pod. | Command:
```bash
kubectl logs -f -c mycontainer analytics-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", "sh... |
View the details of the third revision of the 'development' daemonset. | Command:
```bash
kubectl rollout history daemonset/development --revision=3
```
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 a cluster role named "reader" with the verb "create" and resources "pods" with the resource names "database-master" and "staging-app-server" | Command:
```bash
kubectl create clusterrole reader --verb=create --resource=pods --resource-name=database-master --resource-name=staging-app-server
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|c... |
Create an autoscaling policy for the deployment "security" with a minimum of 3 pods and a maximum of 12 pods | Command:
```bash
kubectl autoscale deployment security --min=3 --max=12
```
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... |
Retrieve logs from all containers within the email-service-pod | Command:
```bash
kubectl logs email-service-pod --all-containers=true
```
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": "--contain... |
Set the service account for the deployment "scheduler-app-deployment" to "vault" | Command:
```bash
kubectl set serviceaccount deployment scheduler-app-deployment vault
```
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... |
Create a debug copy of the gateway-pod with updated container images. | Command:
```bash
kubectl debug gateway-pod -it --copy-to=debug-image-1 --image=debian --set-image=proxy=nginx:1.21,app=app:debug
```
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. ... |
List deployments in the specified API group and version, and format the output as JSON. | Command:
```bash
kubectl get deployments.v1.1.1.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... |
Remove exec auth plugin environment variables for the "dev-user" entry | Command:
```bash
kubectl config set-credentials dev-user --exec-env=var-to-remove-
```
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:
... |
Forward traffic from port 5000 on all addresses to port 5000 in the pod named log-aggregator-pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/log-aggregator-pod 5000:5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a po... |
List resources by type and names | Command:
```bash
kubectl get rc/web service/log-aggregator-rc pods/proxy-service-pod
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is n... |
Forward port 6379 from the pod "proxy-server-pod" to the same port on all addresses | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/proxy-server-pod 6379: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 criteria, a pod ... |
Import specific keys from a config map and set them as environment variables for a deployment | Command:
```bash
kubectl set env --keys=EXTERNAL_API_URL --from=configmap/monitoring-config deployment/scheduler-app-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variab... |
Create a new ClusterIP service named notification-service-clusterip | Command:
```bash
kubectl create service clusterip notification-service-clusterip --tcp=8080:9090
```
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":... |
Copy a file named "foo" from the "/tmp" directory of a pod named "payment-gateway-pod-19" to the "/tmp" directory locally. | Command:
```bash
kubectl cp ingress-nginx/payment-gateway-pod-19::/tmp/foo /tmp/bar
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use ... |
Create a cluster role named "reader" with the ability to list, use, and connect to services and services/proxy subresources. | Command:
```bash
kubectl create clusterrole reader --verb=list,use,connect --resource=services,services/proxy
```
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": "... |
Execute the command 'apache2ctl -D FOREGROUND' in the container 'lunar-launcher' of the pod 'chat-app-pod' and display the output. | Command:
```bash
kubectl exec chat-app-pod -c lunar-launcher -- 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 nam... |
Import specific keys from a config map into an environment variable for a deployment | Command:
```bash
kubectl set env --keys=REDIS_HOST --from=configmap/env-vars 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 definition... |
Forward port 5432 on all addresses to port 8000 in the pod named "backend-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/backend-pod 5432:8000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will ... |
Remove all taints with key 'workload' from node 'prod-node-5' | Command:
```bash
kubectl taint nodes prod-node-5 workload-
```
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: json|yaml|... |
Display the last 43 lines of logs from the analytics-pod | Command:
```bash
kubectl logs --tail=43 analytics-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", "short": "-... |
Copy the `~/.config/kube` file from the remote pod `cert-manager/ingress-controller-pod-8` to the local directory `/tmp/bar_dir`. | Command:
```bash
kubectl cp cert-manager/ingress-controller-pod-8:~/.config/kube /tmp/bar_dir
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omi... |
Apply the taint "cpu-type:NoSchedule" to the node "app-node-6". | Command:
```bash
kubectl taint nodes app-node-6 cpu-type: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... |
Forward traffic from local port 6379 to port 8088 of the backend-pod | Command:
```bash
kubectl port-forward pod/backend-pod 6379 8088
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automa... |
Set a custom TLS server name to use for validation for the data-cluster cluster entry. | Command:
```bash
kubectl config set-cluster data-cluster --tls-server-name=star-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... |
Copy the file "foo" from the "/tmp" directory of the pod "monitoring-agent-pod-6" in the "kube-server" cluster to the "/etc/kubernetes" directory locally. | Command:
```bash
kubectl cp kube-server/monitoring-agent-pod-6:/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, ... |
Create a role named "bar" which allows creating pods and specifying resource names as "file-storage" and "image-processor". | Command:
```bash
kubectl create role bar --verb=create --resource=pods --resource-name=file-storage --resource-name=image-processor
```
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|cli... |
Create and run a pod with the nginx image using custom command and arguments | Command:
```bash
kubectl run nginx --image=php --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] [--command] -- [COMMAND] [args...]`
Helpful f... |
Import environment variables from a secret to a deployment | Command:
```bash
kubectl set env --from=secret/aws-credentials-secret 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 definitions in on... |
create a new ExternalName service with the name "external-logging-service" that points to "sandbox-site.co" | Command:
```bash
kubectl create service externalname external-logging-service --external-name sandbox-site.co
```
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 serv... |
Create a service for the replicated ruby pod, which serves on port 80 and connects to the containers on port 8000. | Command:
```bash
kubectl expose rc ruby --port=8181 --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. A... |
Retrieve the list of deployments in the "sandbox-apps" API group, specifically in the "stable-2.0.0" version, and display the output in YAML format. | Command:
```bash
kubectl get deployments.stable-2.0.0.sandbox-apps -o yaml
```
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 ... |
Configure new exec auth plugin arguments for the "admin" entry | Command:
```bash
kubectl config set-credentials admin --exec-arg=arg1 --exec-arg=arg2
```
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 flag... |
Create a copy of 'mypod' with a debug container and changed container images | Command:
```bash
kubectl debug mypod -it --copy-to=debug-image-app --image=debian --set-image=logger=logging-app:debug,app=app:debug
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and na... |
Add a taint to node-2 with the key 'app' and no value | Command:
```bash
kubectl taint nodes node-2 app: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: json|yaml|... |
Set the custom TLS server name "data-cluster" for the "cloud-cluster" cluster | Command:
```bash
kubectl config set-cluster cloud-cluster --tls-server-name=data-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... |
set the environment variables for a deployment by importing specific keys from a config map | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/db-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 variable definitions... |
Add a taint with key 'workload' on nodes having label instance=app-instance-1 and the value 'monitoring-node-15' as 'PreferNoSchedule' | Command:
```bash
kubectl taint node -l instance=app-instance-1 workload=monitoring-node-15:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default... |
Forward local port 3000 to port 5432 in the pod named proxy-server-pod | Command:
```bash
kubectl port-forward pod/proxy-server-pod 3000: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 a... |
Scale the deployment named `web` to 5 replicas, matching the current size of 7 replicas. | Command:
```bash
kubectl scale --current-replicas=7 --replicas=5 deployment/web
```
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 spec... |
Execute the 'elasticsearch' command inside the first container of the first pod in the 'proxy-service-deployment' deployment. | Command:
```bash
kubectl exec deploy/proxy-service-deployment -- 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 omit... |
Create a new ClusterIP service named notification-service-clusterip that maps incoming traffic on port 8081 to port 8081 of the corresponding pods. | Command:
```bash
kubectl create service clusterip notification-service-clusterip --tcp=8081:8081
```
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":... |
Forward traffic from local port 8088 to port 6379 in the pod named "proxy-server-pod" | Command:
```bash
kubectl port-forward pod/proxy-server-pod 8088: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 criteria, a pod will be selected a... |
Update the environment variables of the "monitoring-stack-deployment" deployment by importing the "CONFIG_FILE_PATH" key from the "namespace-config" config map. | Command:
```bash
kubectl set env --keys=CONFIG_FILE_PATH --from=configmap/namespace-config deployment/monitoring-stack-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment vari... |
Create a copy of the 'email-service-pod' and name it 'debug-image-app' with all container images changed to 'jenkins' | Command:
```bash
kubectl debug email-service-pod --copy-to=debug-image-app --set-image=*=jenkins
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by default if ... |
Run the 'node --version' command on the first pod of the 'user-service' service, using the first container | Command:
```bash
kubectl exec svc/user-service -- node --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... |
Update the number of replicas for a specific node using a strategic merge patch in YAML format | Command:
```bash
kubectl patch node k8s-node-1 -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... |
Add the taint with key 'disktype' on nodes that have the label 'tier=frontend' | Command:
```bash
kubectl taint node -l tier=frontend disktype=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": "O... |
Add the taint 'datacenter' on nodes with the label 'customer=acme-corp' | Command:
```bash
kubectl taint node -l customer=acme-corp datacenter=k8s-node-1:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usa... |
Get the output from running the 'python --version' command in the astro-container of the monitoring-pod. | Command:
```bash
kubectl exec monitoring-pod -c astro-container -- python --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... |
Create a new secret named 'encryption-key-secret' with keys for each file in the 'path/to/preferences' folder. | Command:
```bash
kubectl create secret generic encryption-key-secret --from-file=path/to/preferences
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, the key will default to the bas... |
Auto scale the replication controller "proxy-server" with a minimum of 1 and maximum of 2 pods, based on a target CPU utilization of 20% | Command:
```bash
kubectl autoscale rc proxy-server --max=2 --cpu-percent=20
```
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... |
Delete the pods and services with the names "database" and "security" | Command:
```bash
kubectl delete pod,service database security
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label selecto... |
Update the annotation 'owner' of a pod named 'backend' with the value 'alice smith' | Command:
```bash
kubectl annotate pods backend owner='alice smith'
```
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 ... |
Create a job named 'backup' using the 'postgres' image and run the 'pg_dump --version' command | Command:
```bash
kubectl create job backup --image=postgres -- pg_dump --version
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output forma... |
Output modified deployment in YAML without altering the object on the server | Command:
```bash
kubectl set env deployment/api-server-deployment DB_HOST=localhost -o yaml
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more pod te... |
Copy "~/.config/kube" from a remote pod named "logging/database-pod-2" to the local directory "/tmp/bar_dir" | Command:
```bash
kubectl cp logging/database-pod-2:~/.config/kube /tmp/bar_dir
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the k... |
Set the custom TLS server name to "cloud-cluster" for the e2e cluster entry. | Command:
```bash
kubectl config set-cluster e2e --tls-server-name=cloud-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-authori... |
Create a service for the 'hazelcast' replica set that serves on port 8083 and connects to the containers on port 500000. | Command:
```bash
kubectl expose rs hazelcast --port=8083 --target-port=500000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified po... |
Delete the pods and services named "vpn" and "chat-app" | Command:
```bash
kubectl delete pod,service vpn chat-app
```
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.
So... |
Create a new ClusterIP service named 'log-service-clusterip' that forwards traffic from port 8010 to port 8088. | Command:
```bash
kubectl create service clusterip log-service-clusterip --tcp=8010:8088
```
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", "d... |
Run the 'ash' command in the nano-bot container of pod mypod and get the output. | Command:
```bash
kubectl exec mypod -c nano-bot -- ash
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.kub... |
Launch an interactive debug session for cdn-service-pod and create a copy of it named debug-image-1 | Command:
```bash
kubectl debug cdn-service-pod -it --copy-to=debug-image-1 --container=rocket-ranger -- 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 d... |
Scale the deployment named 'payment-service-rs' to have 1 replica, assuming its current size is 3. | Command:
```bash
kubectl scale --current-replicas=3 --replicas=1 deployment/payment-service-rs
```
What it does:
Set a new size for a deployment, replica set, replication controller, or stateful set.
Scale also allows users to specify one or more preconditions for the scale action.
If --current-replicas or --resource-... |
List deployments in JSON output format for the "legacy-1.0.0" version of the "testing-apps" API group | Command:
```bash
kubectl get deployments.legacy-1.0.0.testing-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 ... |
Import specific keys from a config map into a deployment. | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/db-config deployment/gateway-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in on... |
Set resource request and limits for all containers in a deployment named "postgres" | Command:
```bash
kubectl set resources deployment postgres --limits=cpu=200m,memory=512Mi --requests=cpu=500m,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 req... |
Add a label to the 'proxy-server' pod with the key 'release' and the value 'v1.0' | Command:
```bash
kubectl label pods proxy-server release=v1.0
```
What it does:
Update the labels on a resource.
Syntax:
`kubectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]`
Helpful flags:
"flag": "--all-namespaces", "short": "-A", "default": "false", "usag... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.