prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Create a role named "foo" with ResourceName specified | Command:
```bash
kubectl create role foo --verb=proxy --resource=pods --resource-name=backup-service --resource-name=auth-proxy
```
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|client|... |
Remove the taint with key 'hardware' and effect 'NoExecute' from node 'dev-node-4' if one exists. | Command:
```bash
kubectl taint nodes dev-node-4 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: j... |
Create a job named "database-seeding-job" using the "node" image, and run the command "npm --version" inside the job. | Command:
```bash
kubectl create job database-seeding-job --image=node -- npm --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... |
Create a new config map named 'app-secrets' from the environment file located at 'path/to/configurations.env' | Command:
```bash
kubectl create configmap app-secrets --from-env-file=path/to/configurations.env
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a config map based on a file, the key will default to... |
Create a secret using files in a directory | Command:
```bash
kubectl create secret generic api-key-secret --from-file=path/to/properties
```
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 basename of... |
Update the environment variable in the deployment to the specified value | Command:
```bash
kubectl set env deployment/authentication-service-deployment PORT=8080
```
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 templa... |
Create a pod running the "mcr.microsoft.com/dotnet/core/runtime" image and expose port 6379. | Command:
```bash
kubectl run hazelcast --image=mcr.microsoft.com/dotnet/core/runtime --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...... |
Create a deployment named "gateway" using the nginx image and expose port 7000 | Command:
```bash
kubectl create deployment gateway --image=nginx --port=7000
```
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: j... |
Forward local port 6379 to port 8080 in the pod 'cdn-service-pod' | Command:
```bash
kubectl port-forward pod/cdn-service-pod 6379: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 be selected au... |
Import specific keys from a config map into an environment variable for a deployment | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/log-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 variable definitio... |
Forward local port to pod port | Command:
```bash
kubectl port-forward pod/frontend-pod 8888:8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected autom... |
Forward port 8088 on localhost to port 8081 in the proxy-server-pod | Command:
```bash
kubectl port-forward pod/proxy-server-pod 8088:8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected a... |
Remove taints with key 'workload' from node 'worker-node-3' | Command:
```bash
kubectl taint nodes worker-node-3 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|yam... |
Create a new service named 'external-identity-provider-service' with type 'externalname' and set the external name to 'document-company.com'. | Command:
```bash
kubectl create service externalname external-identity-provider-service --external-name document-company.com
```
What it does:
Create an ExternalName service with the specified name.
ExternalName service references to an external DNS address instead of only pods, which will allow application authors to... |
Get the documentation for the 'containers' field in the 'spec' section of the 'services' resource | Command:
```bash
kubectl explain resource=services.spec.containers
```
What it does:
List the fields for supported resources.
This command describes the fields associated with each supported API resource. Fields are identified via a simple JSONPath identifier:
<type>.<fieldName>[.<fieldName>]
Add the --recursive flag ... |
Add a taint with key 'zone' on nodes having label region=eu-west-2 | Command:
```bash
kubectl taint node -l region=eu-west-2 zone=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": "", "usage": "Ou... |
Import the SMTP_SERVER key from the app-config-dev config map into the web-app-deployment deployment. | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/app-config-dev 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... |
Forward traffic from port 8088 on all addresses to port 8000 in the pod named 'api-service-pod' | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/api-service-pod 8088: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... |
Set the cpu limits of the nginx container in the amazonlinux deployment to "500m" and the memory limits to "1Gi" | Command:
```bash
kubectl set resources deployment amazonlinux -c=nginx --limits=cpu=500m,memory=1Gi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst u... |
Create an ingress named 'rontend-ingress' that routes requests from site.com/input to svc1:3306 with a TLS secret named "my-cert" | Command:
```bash
kubectl create ingress rontend-ingress --rule="site.com/input=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": "", "usage... |
Create a deployment named "drupal" using the "ubuntu" image and expose port 8888. | Command:
```bash
kubectl create deployment drupal --image=ubuntu --port=8888
```
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: j... |
create a job with a specific command | Command:
```bash
kubectl create job log-collection --image=php --
```
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 of: json... |
Create a new config map named "global-config" using specified key-value pairs from files. | Command:
```bash
kubectl create configmap global-config --from-file=properties=/path/to/properties/file1.txt --from-file=key1=/path/to/properties/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When cre... |
Create a pod disruption budget named ingress-controller-pdb that will select all pods with the project=my-project label and require at least four of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget ingress-controller-pdb --selector=project=my-project --min-available=4
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-... |
Rollback the staging deployment to the previous version | Command:
```bash
kubectl rollout undo deployment/staging
```
What it does:
Manage the rollout of a resource.
Valid resource types include:
Syntax:
`kubectl rollout SUBCOMMAND` |
Configure the cluster field of the testing-context context to cluster-gamma | Command:
```bash
kubectl config set contexts.testing-context.cluster cluster-gamma
```
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... |
Retrieve snapshot logs from the 'email-service-pod-1' container of the 'api-server-deployment' deployment. | Command:
```bash
kubectl logs deployment/api-server-deployment -c email-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:
"f... |
Create an ingress called 'default-ingress' that routes requests from foo.com/example to the service named svc1 on port 8083 with the TLS secret named "my-cert". | Command:
```bash
kubectl create ingress default-ingress --rule="foo.com/example=svc1:8083,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
Retrieve the snapshot logs from the container 'backend-pod-1' of the deployment 'analytics-platform-deployment' | Command:
```bash
kubectl logs deployment/analytics-platform-deployment -c backend-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:
... |
Forward port 8080 on localhost and IP address 10.19.21.23 to port 3000 in the pod "proxy-server-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/proxy-server-pod 8080:3000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the cr... |
Create a job with an image and a command | Command:
```bash
kubectl create job data-migration-job --image=python -- python --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": "Out... |
Listen on port 5000 on localhost and 10.19.21.23 IP, forwarding the traffic to the 'web-app-pod' pods 8088 port. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/web-app-pod 5000: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 criteri... |
Expose a replica set as a service, where the service listens on port 8083 and forwards traffic to the containers on port 330600. | Command:
```bash
kubectl expose rs php --port=8083 --target-port=330600
```
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 ... |
Forward traffic from local port 6379 to the pod's port 8081 | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/chat-app-pod 6379:8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will... |
import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=MAX_CONNECTIONS --from=configmap/kube-system-config deployment/database-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... |
Embed the certificate authority data for the web-cluster cluster entry | Command:
```bash
kubectl config set-cluster web-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 set-... |
import the MAX_CONNECTIONS key from the api-config ConfigMap and set it as an environment variable in the user-management-deployment deployment | Command:
```bash
kubectl set env --keys=MAX_CONNECTIONS --from=configmap/api-config 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 def... |
Create a deployment named "db" using the "amazonlinux" image and expose port 5001 | Command:
```bash
kubectl create deployment db --image=amazonlinux --port=5001
```
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: ... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=EXTERNAL_API_URL --from=configmap/monitoring-config 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 definitio... |
Copy the local directory "/tmp/foo_dir" to the remote pod "logging-agent-pod-7" in the "/tmp/bar_dir" directory. | Command:
```bash
kubectl cp /tmp/foo_dir logging-agent-pod-7:/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 kubect... |
Forward traffic from port 8081 on all addresses to port 9090 in the pod "log-aggregator-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/log-aggregator-pod 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 po... |
Update the cluster configuration for a specific context. | Command:
```bash
kubectl config set contexts.prod-context.cluster testing-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 ... |
Create a pod named "nginx" using the MySQL image. | Command:
```bash
kubectl run nginx --image=mysql
```
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": "--filename", "short"... |
Update the description of the pod specified in "preferences.json" to "Web server for marketing site" | Command:
```bash
kubectl annotate -f preferences.json description='Web server for marketing site'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger tha... |
Execute the 'mysql' command in the 'nano-bot' container of the 'frontend-pod' pod and get the output. | Command:
```bash
kubectl exec frontend-pod -c nano-bot -- mysql
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the ku... |
Forward local port 6379 to port 8888 of the pod | Command:
```bash
kubectl port-forward pod/proxy-server-pod 6379:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected a... |
Expose a service based on the configuration specified in the "php-controller.yaml" file | Command:
```bash
kubectl expose -f php-controller.yaml --port=8081 --target-port=808300
```
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 sp... |
attach to the 'mycontainer' container inside the 'cdn-service-pod' pod in raw terminal mode | Command:
```bash
kubectl attach cdn-service-pod -c mycontainer -i -t
```
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 omi... |
Add a taint with the key 'hardware' on nodes that have the label 'cluster=my-cluster' and the value 'PreferNoSchedule' | Command:
```bash
kubectl taint node -l cluster=my-cluster hardware=node-2:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "... |
Create a deployment named "web" that runs the "php" image and exposes port 8000 | Command:
```bash
kubectl create deployment web --image=php --port=8000
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json|ya... |
Create a new NodePort service named web-app-nodeport | Command:
```bash
kubectl create service nodeport web-app-nodeport --tcp=9000:3001
```
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": "",... |
Remove all the taints with key 'cpu-type' from the node 'kube-master-9' | Command:
```bash
kubectl taint nodes kube-master-9 cpu-type-
```
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|yam... |
Set the resource request and limits for all containers in the 'wordpress' deployment | Command:
```bash
kubectl set resources deployment wordpress --limits=cpu=200m,memory=512Mi --requests=cpu=500m,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 re... |
Get the output from running the command 'nginx -g "daemon off;"' in the nano-bot container of the pod named 'backend-pod' | Command:
```bash
kubectl exec backend-pod -c nano-bot -- nginx -g "daemon off;"
```
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 omi... |
Add a taint on nodes with label stack=tech-stack, with key 'workload' and value 'backup-node-14' and effect 'PreferNoSchedule' | Command:
```bash
kubectl taint node -l stack=tech-stack workload=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": "", "usa... |
Import the 'debug_mode' key from the 'ui-config' config map into the 'user-management-deployment' deployment. | Command:
```bash
kubectl set env --keys=debug_mode --from=configmap/ui-config 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 definitio... |
View the last-applied-configuration annotations in JSON format for the specified file named "parameters.yaml". | Command:
```bash
kubectl apply view-last-applied -f parameters.yaml -o json
```
What it does:
View the latest last-applied-configuration annotations by type/name or file.
The default output will be printed to stdout in YAML format. You can use the -o option to change the output format.
Syntax:
`kubectl apply view-las... |
Update the deployment 'order-processing-deployment' with a new environment variable | Command:
```bash
kubectl set env deployment/order-processing-deployment CACHE_SIZE=64MB
```
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 templa... |
Create a job with a specified image and command | Command:
```bash
kubectl create job certificate-renewal --image=mysql -- mysql
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format.... |
Create a deployment named 'web' using the 'centos' image and expose port 8000. | Command:
```bash
kubectl create deployment web --image=centos --port=8000
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json... |
Create a new secret named ssh-key-secret from an environment file | Command:
```bash
kubectl create secret generic ssh-key-secret --from-env-file=path/to/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 the basena... |
Forward traffic from port 6379 on all addresses to port 6379 in the security-service-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/security-service-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 ... |
Create an ingress called 'api-v2-ingress' that routes requests from 'foo.com/input' to 'svc1:9090' with TLS enabled using the secret 'my-cert' | Command:
```bash
kubectl create ingress api-v2-ingress --rule="foo.com/input=svc1:9090,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":... |
Retrieve the output from running the 'python --version' command in the first container of the first pod of the 'logging-service' service. | Command:
```bash
kubectl exec svc/logging-service -- 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 omitted, use ... |
Execute the command 'yum install -y aws-cli' in the 'cyber-sleuth' container of the 'proxy-server-pod' pod and get the output. | Command:
```bash
kubectl exec proxy-server-pod -c cyber-sleuth -- yum install -y aws-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 nam... |
Create a service for the 'wordpress' deployment, exposing it on port 8181, and connecting to the containers on port 700000 | Command:
```bash
kubectl expose deployment wordpress --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 spec... |
Create a pod disruption budget for batch processing | Command:
```bash
kubectl create poddisruptionbudget batch-processing-pdb --selector=region=us-east --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-availa... |
Taint nodes with the label 'stack=tech-stack' by adding a taint with key 'workload=prod-node-5' and effect 'PreferNoSchedule' | Command:
```bash
kubectl taint node -l stack=tech-stack workload=prod-node-5:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage"... |
update the service account of the deployment 'notification-handler-deployment' to 'kube-scheduler' | Command:
```bash
kubectl set serviceaccount deployment notification-handler-deployment kube-scheduler
```
What it does:
Update the service account of pod template resources.
Possible resources (case insensitive) can be:
replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset
... |
Forward port 6379 on your local machine to port 5000 in the analytics-pod pod. | Command:
```bash
kubectl port-forward pod/analytics-pod 6379:5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected auto... |
Create a new config map named "app-settings" using specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-settings --from-file=settings=/path/to/parameters/file1.txt --from-file=key2=/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 ... |
Remove all the taints with the key 'datacenter' from the node 'app-node-6'. | Command:
```bash
kubectl taint nodes app-node-6 datacenter-
```
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... |
Forward traffic from localhost port 6379 to the targetPort of the "https" service port in a pod selected by the "order-service" service | Command:
```bash
kubectl port-forward service/order-service 6379: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 selected... |
Start a python pod and configure it to expose port 8000 | Command:
```bash
kubectl run hazelcast --image=python --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": "--f... |
Embed the certificate authority data for the cluster-alpha cluster entry | Command:
```bash
kubectl config set-cluster cluster-alpha --embed-certs --certificate-authority=~/.kube/cluster-alpha/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... |
Add a taint with key 'cpu-type' on nodes having label 'namespace=mynamespace' | Command:
```bash
kubectl taint node -l namespace=mynamespace cpu-type=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": "", "us... |
Embed the certificate authority data for the 'star-cluster' cluster entry by running the command "kubectl config set-cluster star-cluster --embed-certs --certificate-authority=~/.kube/sun-cluster/kubernetes.ca.crt" | Command:
```bash
kubectl config set-cluster star-cluster --embed-certs --certificate-authority=~/.kube/sun-cluster/kubernetes.ca.crt
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-... |
Update the 'analytics' pod by adding or overwriting the annotation 'deployment-script' with the value 'https://example.com/deploy.sh' | Command:
```bash
kubectl annotate --overwrite pods analytics deployment-script='https://example.com/deploy.sh'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can ... |
Update the image of all deployments and replication controllers to 'httpd:2.4.48' for the container named 'httpd'. | Command:
```bash
kubectl set image deployments,rc httpd=httpd:2.4.48 --all
```
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)
Synta... |
Forward traffic from local port 9090 to port 8000 in the 'e-commerce-pod' pod | Command:
```bash
kubectl port-forward pod/e-commerce-pod 9090: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 aut... |
Add a taint to nodes with a specific label | Command:
```bash
kubectl taint node -l feature=feature-xyz cpu-type=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": "", "usa... |
Taint nodes with the label 'release=beta' using the taint key 'environment' and the value 'edge-node-10' with the effect 'PreferNoSchedule'. | Command:
```bash
kubectl taint node -l release=beta environment=edge-node-10:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage"... |
Get output from code-explorer in the pod "security-service-pod" | Command:
```bash
kubectl attach security-service-pod -c code-explorer
```
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 om... |
Connect to the stardust-shuttle container in the database-pod and view the output | Command:
```bash
kubectl attach database-pod -c stardust-shuttle
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted... |
Create a new config map called 'ui-config' based on the files in the 'configs' folder | Command:
```bash
kubectl create configmap ui-config --from-file=path/to/configs
```
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 basename of ... |
Update the 'security' pod by adding the annotation 'last-deployment' with the value '2023-03-15'. | Command:
```bash
kubectl annotate pods security last-deployment=2023-03-15
```
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 ar... |
Set the custom TLS server name to "kube-cluster-2" for the "kube-cluster-2" cluster entry in the kubeconfig file | Command:
```bash
kubectl config set-cluster kube-cluster-2 --tls-server-name=kube-cluster-2
```
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] [--certifi... |
Create a job named 'cleanup' using the 'postgres' image and running the 'postgres' command. | Command:
```bash
kubectl create job cleanup --image=postgres -- postgres
```
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 o... |
Forward traffic from local port 8088 to port 5432 in the pod "log-aggregator-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/log-aggregator-pod 8088:5432
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a po... |
Import the 'external_api_url' key from the 'global-config' config map and set it as an environment variable for the 'authentication-service-deployment' deployment. | Command:
```bash
kubectl set env --keys=external_api_url --from=configmap/global-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 v... |
Set the cluster field of the 'staging-context' context to 'app-cluster' | Command:
```bash
kubectl config set contexts.staging-context.cluster app-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 w... |
create a pod using the provided JSON configuration | Command:
```bash
cat setup.json | kubectl create -f -
```
What it does:
Create a resource from a file or from stdin.
JSON and YAML formats are accepted.
Syntax:
`kubectl create -f FILENAME`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to files to use to c... |
Create an ingress called 'api-v1-ingress' that directs requests to the 'testing.com/example' path to the service 'svc1:8083' with a TLS secret named "my-cert" | Command:
```bash
kubectl create ingress api-v1-ingress --rule="testing.com/example=svc1:8083,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "u... |
Execute the command 'composer --version' in the 'code-explorer' container of the 'auth-service-pod' pod | Command:
```bash
kubectl exec auth-service-pod -c code-explorer -- composer --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. ... |
Expose a replicated node as a service, serving on port 6379 and connecting to the containers on port 8000 | Command:
```bash
kubectl expose rc node --port=6379 --target-port=800000
```
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... |
Import the keys "external_api_url" from the config map "api-config" and set them as environment variables for the "load-balancer-deployment" deployment. | Command:
```bash
kubectl set env --keys=external_api_url --from=configmap/api-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 defi... |
Create a deployment named "scheduler" with 2 replicas, using the "amazonlinux" image. | Command:
```bash
kubectl create deployment scheduler --image=amazonlinux --replicas=2
```
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. ... |
Forward local port 5432 to remote port 9090 in the pod "mypod" | Command:
```bash
kubectl port-forward pod/mypod 5432 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 selected automaticall... |
Set the cluster field to kube-cluster-1 for the dev-context context. | Command:
```bash
kubectl config set contexts.dev-context.cluster kube-cluster-1
```
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 wa... |
Set the DEBUG_MODE environment variable for the load-balancer-deployment deployment by importing the DEBUG_MODE key from the global-config ConfigMap. | Command:
```bash
kubectl set env --keys=DEBUG_MODE --from=configmap/global-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 definit... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.