prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Generate the modified deployment in YAML format without making any changes on the server | Command:
```bash
kubectl set env deployment/mydeployment QUEUE_NAME=task-queue -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 templat... |
Copy a file from a remote pod to a local directory | Command:
```bash
kubectl cp kube-dns/web-app-pod-1:/tmp/foo /tmp/bar_dir
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl... |
Forward port 8088 on all addresses to port 6379 in the pod called "chat-app-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/chat-app-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... |
Delete the 'kube-cluster-1' cluster configuration. | Command:
```bash
kubectl config delete-cluster kube-cluster-1
```
What it does:
Delete the specified cluster from the kubeconfig.
Syntax:
`kubectl config delete-cluster NAME` |
Forward port 5432 from your local machine to the pod with the name "chat-app-pod" on port 5432 | Command:
```bash
kubectl port-forward pod/chat-app-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 will be selected autom... |
Remove the 'release-' label from the 'payment' pod | Command:
```bash
kubectl label pods payment release-
```
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 t... |
Create a copy of the proxy-server-pod and change all container images to confluentinc/cp-kafka | Command:
```bash
kubectl debug proxy-server-pod --copy-to=debug-image-memcached --set-image=*=confluentinc/cp-kafka
```
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 ... |
Import the max_connections key from the config map named app-name-config into the environment variables of the authentication-service-deployment deployment. | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/app-name-config deployment/authentication-service-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment ... |
Create an ingress called 'external-ingress' that directs requests to website.com/example to a service named svc1 on port 6379, and use the TLS secret "my-cert". | Command:
```bash
kubectl create ingress external-ingress --rule="website.com/example=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": "", ... |
Import the specific keys 'my-example-key' from the 'configmap/app-secrets' into the deployment named 'mydeployment' | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/app-secrets deployment/mydeployment
```
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 priority class named "urgent-priority" with a value of 100000 and a description of "Immediate, urgent resource allocation" | Command:
```bash
kubectl create priorityclass urgent-priority --value=100000 --description="Immediate, urgent resource allocation"
```
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 [--... |
Create a pod disruption budget named 'database-pdb' that will select all pods with the 'version=v2' label and require a minimum of 9 of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget database-pdb --selector=version=v2 --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 [--dry... |
forward the local port 8000 to the targetPort of the "https" service port in the payment-service pod | Command:
```bash
kubectl port-forward service/payment-service 8000:https
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be select... |
Embed certificate authority data for the galaxy-cluster cluster entry | Command:
```bash
kubectl config set-cluster galaxy-cluster --embed-certs --certificate-authority=~/.kube/cluster-beta/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 s... |
Execute the 'go' command inside the 'astro-container' from the 'database-pod' pod. | Command:
```bash
kubectl exec database-pod -c astro-container -- go
```
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 th... |
Scale the resource specified in the "settings.json" file to a total of 5 replicas | Command:
```bash
kubectl scale --replicas=5 -f settings.json
```
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 specified, it is valida... |
Forward traffic from port 9090 on the localhost and IP address 10.19.21.23 to port 5432 in the 'e-commerce-pod' pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/e-commerce-pod 9090: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 crit... |
Delete the specified user from the kubeconfig file. | Command:
```bash
kubectl config delete-user robot-user
```
What it does:
Delete the specified user from the kubeconfig.
Syntax:
`kubectl config delete-user NAME` |
Remove the taint with key 'hardware' and effect 'NoExecute' from node 'edge-node-10' if it exists | Command:
```bash
kubectl taint nodes edge-node-10 hardware: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. One of:... |
Get specific resources by their type and names | Command:
```bash
kubectl get rc/web service/api-service-rc pods/chat-app-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 new config map named global-config with specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap global-config --from-file=settings=/path/to/settings/file1.txt --from-file=key2=/path/to/configurations/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 cre... |
set service account for deployment log-aggregator-deployment to kube-proxy | Command:
```bash
kubectl set serviceaccount deployment log-aggregator-deployment kube-proxy
```
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:
`... |
Check if you have permission to list the "notification-sender-job" job in the "namespace-1" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/notification-sender-job -n namespace-1
```
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 pa... |
Create a new ExternalName service named 'external-logging-service' that maps to the external name 'education-edu.edu' | Command:
```bash
kubectl create service externalname external-logging-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 se... |
Create a job named "audit-job" using the redis image and execute the "redis-server" command | Command:
```bash
kubectl create job audit-job --image=redis -- redis-server
```
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. On... |
Taint nodes based on label | Command:
```bash
kubectl taint node -l stack=tech-stack datacenter=backup-node-14: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... |
Forward traffic from port 8000 on localhost and IP 10.19.21.23 to port 8888 in the pod named "log-aggregator-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/log-aggregator-pod 8000: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 ... |
Output the modified deployment in YAML format without altering the object on the server. | Command:
```bash
kubectl set env deployment/analytics-platform-deployment DB_USER=username -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... |
Create a job with a specific command | Command:
```bash
kubectl create job deployment-rollout-job --image=ethereum/client-go -- geth attach
```
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": "", "u... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=config_file_path --from=configmap/app-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 vari... |
Copy a local file to a remote pod in a specified namespace | Command:
```bash
kubectl cp /tmp/foo velero/security-scanner-pod-18:/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 ... |
Start a centos pod and expose port 5001 | Command:
```bash
kubectl run hazelcast --image=centos --port=5001
```
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... |
List the deployments in the "legacy-1.0.0" version of the "beta-apps" API group in YAML output format. | Command:
```bash
kubectl get deployments.legacy-1.0.0.beta-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 you... |
Create a new generic secret named 'git-credentials-secret' using the environment variables from the 'path/to/configs.env' file. | Command:
```bash
kubectl create secret generic git-credentials-secret --from-env-file=path/to/configs.env
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, the key will default to th... |
Autoscale the deployment "log-aggregator" with the number of pods between 4 and 12 | Command:
```bash
kubectl autoscale deployment log-aggregator --min=4 --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 th... |
Set the custom TLS server name for the "prod-cluster" cluster entry. | Command:
```bash
kubectl config set-cluster prod-cluster --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] [--certificat... |
Update the label of pod 'monitoring' with the key 'env' and the value 'development' | Command:
```bash
kubectl label pods monitoring env=development
```
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", "usa... |
Forward local ports to a pod's ports | Command:
```bash
kubectl port-forward deployment/api-server-deployment 3000 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 b... |
Create a new ClusterIP service named analytics-service-clusterip that maps port 8089 on the service to port 8082 on the pods. | Command:
```bash
kubectl create service clusterip analytics-service-clusterip --tcp=8089:8082
```
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": "-... |
Run the 'node' command in quantum-quark from the proxy-service-pod pod and get the output | Command:
```bash
kubectl exec proxy-service-pod -c quantum-quark -- 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, u... |
Create a pod disruption budget named ingress-controller-pdb that will select all pods with the env=production label and require a minimum of four of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget ingress-controller-pdb --selector=env=production --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-avai... |
Forward local port 9090 to port 6379 in the pod "api-service-pod" | Command:
```bash
kubectl port-forward pod/api-service-pod 9090 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 au... |
List deployments in YAML output format, in the "v2.0.0" version of the "legacy-apps" API group | Command:
```bash
kubectl get deployments.v2.0.0.legacy-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 you wil... |
Delete the pods and services with the names "proxy-server" and "email" | Command:
```bash
kubectl delete pod,service proxy-server 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 select... |
Create a copy of the cdn-service-pod adding a debug container and changing the container images | Command:
```bash
kubectl debug cdn-service-pod -it --copy-to=debug-image-api --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. Pod... |
Set the service account of the load-balancer-deployment to metrics-server | Command:
```bash
kubectl set serviceaccount deployment load-balancer-deployment metrics-server
```
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... |
Create a cron job called "email-notifications" that runs the command "postgres" every minute. | Command:
```bash
kubectl create cronjob email-notifications --image=postgres --schedule="*/1 * * * *" -- postgres
```
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"... |
Copy the directory '/tmp/foo_dir' from the remote pod 'payment-gateway-pod-19' in namespace 'kube-node-lease' to the local directory '/tmp/bar_dir'. | Command:
```bash
kubectl cp kube-node-lease/payment-gateway-pod-19:/tmp/foo_dir /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 omit... |
Create a service for the pod "vpn-service-pod", with the name "frontend", serving on port 444. | Command:
```bash
kubectl expose pod vpn-service-pod --port=8084 --name=frontend
```
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 ... |
Delete the user named "web-app" | Command:
```bash
kubectl config delete-user web-app
```
What it does:
Delete the specified user from the kubeconfig.
Syntax:
`kubectl config delete-user NAME` |
Create an autoscaler for the replication controller "chat-app" with a target CPU utilization of 90%, and a minimum of 1 pod and a maximum of 6 pods. | Command:
```bash
kubectl autoscale rc chat-app --max=6 --cpu-percent=90
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that use... |
Create a cluster role named "foo" with the following permissions: | Command:
```bash
kubectl create clusterrole foo --verb=proxy --resource=configmaps --resource-name=message-queue --resource-name=billing-service
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|clie... |
Start a pod named "hazelcast" using the "node" image and expose port 9000 | Command:
```bash
kubectl run hazelcast --image=node --port=9000
```
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... |
Forward traffic from local port 6379 to port 8000 in the pod named "log-aggregator-pod" | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 6379:8000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected... |
Taint nodes with label 'release=beta' with a taint key 'hardware' and value 'web-node-8' and effect 'PreferNoSchedule' | Command:
```bash
kubectl taint node -l release=beta hardware=web-node-8:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Ou... |
Import the environment variables from a secret and apply it to a deployment. | Command:
```bash
kubectl set env --from=secret/ldap-credentials-secret deployment/search-engine-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one... |
Forward port 8081 to pod port 8000 | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/cdn-service-pod 8081: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... |
Create a pod disruption budget named cache-cluster-pdb that will select all pods with the env=production label and require at least one of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget cache-cluster-pdb --selector=env=production --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... |
Start a pod named 'hazelcast' using the 'ethereum/client-go' image, and expose port 6379 | Command:
```bash
kubectl run hazelcast --image=ethereum/client-go --port=6379
```
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:
... |
Create a deployment called "app" using the Python image and passing the command "pip --version" to the container. | Command:
```bash
kubectl create deployment app --image=python -- pip --version
```
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:... |
Create a cluster role named "bar" with NonResourceURL specified for the "proxy" verb. | Command:
```bash
kubectl create clusterrole "bar" --verb=proxy --non-resource-url=/debug/flags/v
```
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", "s... |
Create an ingress called 'public-api-ingress' that directs requests to website.com/module to svc1:5001 with a TLS secret named "my-cert" | Command:
```bash
kubectl create ingress public-api-ingress --rule="website.com/module=svc1:5001,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": "",... |
Check to see if you have permission to list the job named "security-scan-job" in the "namespace-1" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/security-scan-job -n namespace-1
```
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 ... |
List the deployments in the "v1.1.0" version of the "api-v2" API group, and display the output in YAML format. | Command:
```bash
kubectl get deployments.v1.1.0.api-v2 -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 you will onl... |
Start a golang pod named "nginx" with the image "golang", but overload the spec with a partial set of values parsed from JSON. | Command:
```bash
kubectl run nginx --image=golang --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] -- [COM... |
Update the 'proxy-service-deployment' deployment by adding a new environment variable 'API_KEY' with the value 'your-api-key' | Command:
```bash
kubectl set env deployment/proxy-service-deployment API_KEY=your-api-key
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more pod temp... |
Forward traffic from port 3000 on all addresses to port 8081 in the security-service-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/security-service-pod 3000: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 ... |
Execute the 'dotnet' command in the 'mypod' pod. | Command:
```bash
kubectl exec mypod -- dotnet
```
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.kubernetes.i... |
Execute the command 'yum install -y wget' in the container 'mycontainer' of the pod 'email-service-pod' and get the output. | Command:
```bash
kubectl exec email-service-pod -c mycontainer -- yum install -y wget
```
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. ... |
Open the 'monitoring-service' service for editing using the 'notepad' editor. | Command:
```bash
KUBE_EDITOR="notepad" kubectl edit svc/monitoring-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 var... |
Create an ingress with TLS enabled using the default ingress certificate and different path types | Command:
```bash
kubectl create ingress ingtls --class=default \
--rule="site.com/=svc:https,tls" \
--rule="foo.com/path/subpath*=othersvc:7000"
```
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": "--ou... |
Create a job named 'data-migration-job' using the 'mongo' image and execute the 'mongod' command | Command:
```bash
kubectl create job data-migration-job --image=mongo -- mongod
```
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.... |
View the CPU and memory usage metrics for a pod and its containers | Command:
```bash
kubectl top pod mypod --containers
```
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 [NAME |... |
Create a new ExternalName service named 'external-ldap-service' with the external name 'tutorial-ai.ai' | Command:
```bash
kubectl create service externalname external-ldap-service --external-name tutorial-ai.ai
```
What it does:
Create an ExternalName service with the specified name.
ExternalName service references to an external DNS address instead of only pods, which will allow application authors to reference services... |
Forward local port 3000 to port 8000 in the pod "web-app-pod" | Command:
```bash
kubectl port-forward pod/web-app-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 will be selected automa... |
Forward traffic from port 8088 on localhost and IP 10.19.21.23 to port 6379 in the pod named "proxy-server-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 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 cr... |
Execute the 'mongo' command inside the 'database-pod' pod | Command:
```bash
kubectl exec database-pod -- mongo
```
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.kubern... |
Delete the pods and services named "security" and "monitoring" | Command:
```bash
kubectl delete pod,service security 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 selec... |
Set the service account of the deployment frontend-deployment to metrics-server | Command:
```bash
kubectl set serviceaccount deployment frontend-deployment metrics-server
```
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:
`ku... |
Retrieve the 'log-aggregator-pod' pod information in YAML format | Command:
```bash
kubectl get -o yaml pod log-aggregator-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 namespaced you will only s... |
Delete the pods and services named "auth" and "web" | Command:
```bash
kubectl delete pod,service auth web
```
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 r... |
Import the LOG_LEVEL key from the db-config ConfigMap and set it as an environment variable in the web-app-deployment deployment. | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/db-config 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 one... |
Add a taint with key 'datacenter' on nodes having label app=web-app | Command:
```bash
kubectl taint node -l app=web-app 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": "O... |
Create a cluster role named "foo" with specific resource names | Command:
```bash
kubectl create clusterrole foo --verb=watch --resource=services --resource-name=cache-redis --resource-name=queue-consumer
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|client|no... |
Display only the 43 most recent lines of logs from the frontend-pod pod. | Command:
```bash
kubectl logs --tail=43 frontend-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... |
Delete pods and services named "payment" and "backend" | Command:
```bash
kubectl delete pod,service payment backend
```
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 the 'redis_host' key from the 'kube-system-config' ConfigMap and set it as an environment variable for the 'monitoring-stack-deployment' deployment. | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/kube-system-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... |
Add the annotation 'alert-email=alerts@example.com' to the 'database' pod | Command:
```bash
kubectl annotate pods database alert-email=alerts@example.com
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and includ... |
Retrieve logs from the container scheduler-app-deployment-1 of the api-service-pod deployment | Command:
```bash
kubectl logs deployment/scheduler-app-deployment -c api-service-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"... |
Add a taint with the key 'dedicated' on nodes having the label 'myLabel' with the value 'prod-node-5:PreferNoSchedule' | Command:
```bash
kubectl taint node -l myLabel dedicated=prod-node-5:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Outpu... |
Listen on port 8081 locally and forward it to port 5432 in the backend-pod pod. | Command:
```bash
kubectl port-forward pod/backend-pod 8081: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 automa... |
Import the 'api_key' key from the 'app-name-config' config map into the 'notification-handler-deployment' deployment. | Command:
```bash
kubectl set env --keys=api_key --from=configmap/app-name-config deployment/notification-handler-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable d... |
Update the annotation 'security-scan-status' of the pod 'security' with the value 'pass', replacing any existing value | Command:
```bash
kubectl annotate --overwrite pods security security-scan-status='pass'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels a... |
Create an ingress called 'internal-ingress' that directs requests to website.com/input to a service called 'svc1' running on port 8081 | Command:
```bash
kubectl create ingress internal-ingress --rule="website.com/input=svc1:8081,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "u... |
Create a single ingress called 'private-ingress' that directs requests to site.com/module to svc1:3306 with a tls secret "my-cert" | Command:
```bash
kubectl create ingress private-ingress --rule="site.com/module=svc1:3306,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
Create a job named "batch-processing" with the image "amazonlinux" and run the command "yum install -y aws-cli" | Command:
```bash
kubectl create job batch-processing --image=amazonlinux -- yum install -y aws-cli
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usa... |
Copy the local directory /tmp/foo_dir to the remote pod metrics-exporter-pod-10 in the openfaas namespace, and place it in the /tmp/bar directory | Command:
```bash
kubectl cp /tmp/foo_dir openfaas/metrics-exporter-pod-10:/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 t... |
Create a service for the replicated WordPress using the replica set 'wordpress' | Command:
```bash
kubectl expose rs wordpress --port=80 --target-port=808200
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port... |
Create a single ingress called 'public-ingress' with a rule that directs requests from foo.com/bar to the service 'svc1' on port 7000, and use the TLS secret 'my-cert'. | Command:
```bash
kubectl create ingress public-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 cluster role named "foo" that allows the user to perform "list", "create", and "connect" operations on services. | Command:
```bash
kubectl create clusterrole foo --verb=list,create,connect --resource=services
```
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", "sho... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.