prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Forward local port 3000 to port 8081 in the pod "e-commerce-pod" | Command:
```bash
kubectl port-forward pod/e-commerce-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 pod will be selected aut... |
Create a cron job named "report-generation" that runs the command "irb" every minute, using the Ruby image. | Command:
```bash
kubectl create cronjob report-generation --image=ruby --schedule="*/1 * * * *" -- irb
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "de... |
Update the criticality annotation of a pod defined in "settings.json" to high | Command:
```bash
kubectl annotate -f settings.json criticality=high
```
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... |
Apply the configuration in the manifest.yaml file to resources with the label environment=production, and delete all other resources that are not in the file and match the label app=nginx | Command:
```bash
kubectl apply --prune -f manifest.yaml -l environment=production
```
What it does:
Apply a configuration to a resource by file name or stdin. The resource name must be specified. This resource will be created if it doesn't exist yet. To use 'apply', always create the resource initially with either 'ap... |
Delete resources from a directory using the kustomization file | Command:
```bash
kubectl delete -k dir/
```
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 resources, suc... |
update the cpu and memory limits for the 'ruby' deployment's 'nginx' container to "200m" and "4Gi" respectively | Command:
```bash
kubectl set resources deployment ruby -c=nginx --limits=cpu=200m,memory=4Gi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to it... |
Embed certificate authority data for the cluster-beta cluster entry | Command:
```bash
kubectl config set-cluster cluster-beta --embed-certs --certificate-authority=~/.kube/dev-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-... |
Create a job using a specific image | Command:
```bash
kubectl create job image-build-job --image=busybox
```
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: js... |
Expose the php deployment as a service, serving on port 5001 and connecting to the containers on port 808200 | Command:
```bash
kubectl expose deployment php --port=5001 --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 ... |
Create a copy of the api-service-pod with a debug container and change the container images | Command:
```bash
kubectl debug api-service-pod -it --copy-to=my-custom-dbg --image=debian --set-image=web=nginx:latest,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... |
Switch to raw terminal mode in the e-commerce-pod with the rocket-ranger container | Command:
```bash
kubectl attach e-commerce-pod -c rocket-ranger -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 om... |
Create an ingress resource named 'service-ingress' that directs requests from site.com/input to svc1:5000 with a TLS secret named "my-cert" | Command:
```bash
kubectl create ingress service-ingress --rule="site.com/input=svc1:5000,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage... |
Create a single ingress called 'public-api-ingress' that directs requests to testing.com/input to the service 'svc1' with port '8080', and use the TLS secret named 'my-cert'. | Command:
```bash
kubectl create ingress public-api-ingress --rule="testing.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": "", ... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=EXTERNAL_API_URL --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... |
Forward traffic from port 8888 on your local machine to port 3000 in the pod named "e-commerce-pod" | Command:
```bash
kubectl port-forward pod/e-commerce-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 the criteria, a pod will be selected aut... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=API_KEY --from=configmap/app-name-config deployment/cache-cluster-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definiti... |
Create a new ExternalName service named external-payment-gateway-service, with the external name set to "bar.com" | Command:
```bash
kubectl create service externalname external-payment-gateway-service --external-name bar.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 reference serv... |
Set the custom TLS server name 'web-cluster' to be used for validation for the 'sun-cluster' cluster entry | Command:
```bash
kubectl config set-cluster sun-cluster --tls-server-name=web-cluster
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-cluster NAME [--server=server] [--certificate-a... |
Get the output from running the 'mongo --version' command in lunar-launcher from the monitoring-pod | Command:
```bash
kubectl exec monitoring-pod -c lunar-launcher -- mongo --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 o... |
Forward local port 8000 to port 8081 in the pod "cdn-service-pod" | Command:
```bash
kubectl port-forward pod/cdn-service-pod 8000: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 au... |
Listen on port 8888 locally, forwarding data to/from port 8888 in the 'api-server-deployment' pods. | Command:
```bash
kubectl port-forward deployment/api-server-deployment 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 will b... |
Listen on port 8888 on all addresses, and forward the traffic to port 5432 in the web-app-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/web-app-pod 8888:5432
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will ... |
Create a cluster role named "reader" with specific permissions for accessing services and services/proxy SubResource. | Command:
```bash
kubectl create clusterrole reader --verb=exec,list,delete --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": "... |
Forward port 6379 on localhost and IP 10.19.21.23 to port 8888 in the pod "api-service-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/api-service-pod 6379:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the cri... |
Forward port 9090 on localhost and IP 10.19.21.23 to port 8888 in the cdn-service-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/cdn-service-pod 9090:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the cri... |
Update the annotation 'app-version' of the 'web' pod to '2.5.1', overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods web app-version='2.5.1'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include ar... |
Create an ingress resource with the name 'app-loadbalancer-ingress' that routes requests for 'foo.com/example' to the service 'svc1' on port 5001, and uses the TLS secret 'my-cert'. | Command:
```bash
kubectl create ingress app-loadbalancer-ingress --rule="foo.com/example=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": ... |
Create a job named 'database-seeding-job' with the centos image and run the 'bash' command. | Command:
```bash
kubectl create job database-seeding-job --image=centos -- bash
```
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... |
Add a taint with key 'workload' on nodes having label team=devops | Command:
```bash
kubectl taint node -l team=devops workload=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": "Out... |
Create a new config map named 'env-vars' with the following keys: | Command:
```bash
kubectl create configmap env-vars --from-file=properties=/path/to/properties/file1.txt --from-file=key1=/path/to/configs/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a ... |
Taint the node 'dev-node-4' with a 'environment' key and no value | Command:
```bash
kubectl taint nodes dev-node-4 environment: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... |
Update the image version of a single-container pod to v4 | Command:
```bash
kubectl get pod mypod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f -
```
What it does:
Replace a resource by file name or stdin.
JSON and YAML formats are accepted. If replacing an existing resource, the complete resource spec must be provided. This can be obtained by
$ kubectl... |
Add a taint with key 'cpu-type' on nodes having label version=v1.0.0 | Command:
```bash
kubectl taint node -l version=v1.0.0 cpu-type=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": "Outp... |
Create a new secret named oauth-secret with keys for each file in the folder "bar" located at path/to/preferences | Command:
```bash
kubectl create secret generic oauth-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 basename of ... |
Create a debug copy of e-commerce-pod with all container images replaced by 'jenkins' | Command:
```bash
kubectl debug e-commerce-pod --copy-to=debug-image-memcached --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 ... |
Switch to raw terminal mode and attach to the 'warp-drive' container inside the 'chat-app-pod'. | Command:
```bash
kubectl attach chat-app-pod -c warp-drive -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 omitted... |
Create a service for a replicated Ubuntu using a replica set, which serves on port 8089 and connects to the containers on port 8181 | Command:
```bash
kubectl expose rs ubuntu --port=8089 --target-port=818100
```
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.... |
Set the 'team' annotation to 'frontend team' for the 'payment' pod. | Command:
```bash
kubectl annotate pods payment team='frontend team'
```
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 role named "custom_role" and grant it the ability to patch pods with specific resource names | Command:
```bash
kubectl create role custom_role --verb=patch --resource=pods --resource-name=nginx-proxy --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|cl... |
Copy the local file '/tmp/foo_dir' to the remote pod 'logging-agent-pod-7' in the 'cert-manager' namespace as '/tmp/bar' | Command:
```bash
kubectl cp /tmp/foo_dir cert-manager/logging-agent-pod-7::/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 ... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/ui-config deployment/email-server-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definit... |
Scale the deployment named mysql to 3 replicas if the current size is 7. | Command:
```bash
kubectl scale --current-replicas=7 --replicas=3 deployment/mysql
```
What it does:
Set a new size for a deployment, replica set, replication controller, or stateful set.
Scale also allows users to specify one or more preconditions for the scale action.
If --current-replicas or --resource-version is sp... |
Copy the contents of the `~/.config/kube` directory from a remote pod to the `/tmp/bar` directory locally. | Command:
```bash
kubectl exec -n argocd database-pod-2 -- tar cf - ~/.config/kube | tar xf - -C :/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 ... |
Copy the local file /tmp/foo to the remote pod 'ingress-controller-pod-8' in the 'kube-system' namespace, and save it as /tmp/bar. | Command:
```bash
kubectl cp /tmp/foo kube-system/ingress-controller-pod-8::/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 ... |
Forward local port 6379 to port 9090 in the mypod pod | Command:
```bash
kubectl port-forward pod/mypod 6379 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... |
Forward traffic from port 6379 on all addresses to port 8080 in the specified pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/security-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 ... |
Copy the kube config file from a remote pod to a local directory. | Command:
```bash
kubectl cp kube-system/monitoring-agent-pod-6:~/.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 omitte... |
Create a new config map named 'monitoring-config' using the specified keys instead of the file basenames on disk | Command:
```bash
kubectl create configmap monitoring-config --from-file=properties=/path/to/properties/file1.txt --from-file=key1=/path/to/settings/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When c... |
Create a service for a replicated WordPress using a replica set | Command:
```bash
kubectl expose rs wordpress --port=80 --target-port=808800
```
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... |
Forward local port 3000 to port 8080 in the 'security-service-pod' pod. | Command:
```bash
kubectl port-forward pod/security-service-pod 3000: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 select... |
Start port-forwarding to listen on port 6379 on all addresses and forward traffic to port 9090 in the pod named "proxy-server-pod". | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/proxy-server-pod 6379: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 ... |
List deployments in JSON output format, in the "legacy-1.0.0" version of the "extensions" API group | Command:
```bash
kubectl get deployments.legacy-1.0.0.extensions -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 yo... |
Create a copy of the cdn-service-pod and add a debug container | Command:
```bash
kubectl debug cdn-service-pod -it --copy-to=debug-image-1 --image=debian --set-image=api=api:v2,web=nginx:latest
```
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.... |
Add a taint with key 'environment' on nodes having label environment=production | Command:
```bash
kubectl taint node -l environment=production environment=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": "",... |
Add a taint with key 'environment' and no value to the 'kube-master-9' node. | Command:
```bash
kubectl taint nodes kube-master-9 environment: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... |
Expose a deployment as a service with specific port mapping | Command:
```bash
kubectl expose deployment alpine --port=6379 --target-port=808000
```
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 specifi... |
Create a new ClusterIP service named notification-service-clusterip, mapping port 9000 on the cluster to port 3001 on the service. | Command:
```bash
kubectl create service clusterip notification-service-clusterip --tcp=9000:3001
```
What it does:
Create a ClusterIP service with the specified name.
Syntax:
`kubectl create service clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short":... |
Forward local port to the web-app-pod on port 5432. | Command:
```bash
kubectl port-forward pod/web-app-pod :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 automatica... |
Create a cluster role named "reader" with the permissions to list pods and access specific resource names such as "api-server" and "image-processor" | Command:
```bash
kubectl create clusterrole reader --verb=list --resource=pods --resource-name=api-server --resource-name=image-processor
```
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... |
Start a pod with ethereum/client-go image and expose port 27017 | Command:
```bash
kubectl run hazelcast --image=ethereum/client-go --port=27017
```
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:... |
Forward local port 8888 to port 9090 in the pod named "proxy-server-pod" | Command:
```bash
kubectl port-forward pod/proxy-server-pod 8888: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 a... |
Add a taint with the key 'workload' and the value 'app-node-6:PreferNoSchedule' on nodes that have the label 'namespace=mynamespace' | Command:
```bash
kubectl taint node -l namespace=mynamespace workload=app-node-6:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "us... |
retrieve the replication controller named "web", the service named "analytics-rc", and the pod named "gateway-pod" | Command:
```bash
kubectl get rc/web service/analytics-rc pods/gateway-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 y... |
Create a service for the ubuntu deployment, which serves on port 80 and connects to the containers on port 8000 | Command:
```bash
kubectl expose deployment ubuntu --port=80 --target-port=909100
```
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... |
Remove the user "prod-user" from the kubectl configuration. | Command:
```bash
kubectl config delete-user prod-user
```
What it does:
Delete the specified user from the kubeconfig.
Syntax:
`kubectl config delete-user NAME` |
Create a pod disruption budget named "statefulset-pdb" that will select all pods with the "owner=team-1" label and require a minimum of 9 of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget statefulset-pdb --selector=owner=team-1 --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 [... |
Create an ingress called 'app1-ingress' with a rule that directs requests for 'testing.com/example' to 'svc1:9092' and uses the TLS secret "my-cert" for secure communication. | Command:
```bash
kubectl create ingress app1-ingress --rule="testing.com/example=svc1:9092,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": "", "usa... |
Forward port 6379 from the cdn-service-pod to port 8888 locally | Command:
```bash
kubectl port-forward pod/cdn-service-pod 6379:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected au... |
Create a new secret named azure-storage-secret using the environment variables specified in the config file located at path/to/configs.env | Command:
```bash
kubectl create secret generic azure-storage-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 ... |
Set the service account of the "search-engine-deployment" deployment to "vault" | Command:
```bash
kubectl set serviceaccount deployment search-engine-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... |
Retrieve the output from the 'rocket-ranger' container in the 'gateway-pod' pod. | Command:
```bash
kubectl attach gateway-pod -c rocket-ranger
```
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, us... |
Add a taint with key 'hardware' on nodes having label stack=tech-stack. | Command:
```bash
kubectl taint node -l stack=tech-stack hardware=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"... |
Set the service account of the log-aggregator-deployment deployment to "tiller" | Command:
```bash
kubectl set serviceaccount deployment log-aggregator-deployment tiller
```
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:
`kube... |
import the SMTP_SERVER key from the configmap named namespace-config and set it as an environment variable for the frontend-deployment deployment. | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/namespace-config deployment/frontend-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definiti... |
Listen on port 8888 on your local machine and forward the traffic to port 5000 in the 'analytics-pod' pod. | Command:
```bash
kubectl port-forward pod/analytics-pod 8888: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... |
Set the service account for the deployment "backend-microservice-deployment" to "elasticsearch" | Command:
```bash
kubectl set serviceaccount deployment backend-microservice-deployment elasticsearch
```
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
... |
Create a debug container named dgb-img based on the e-commerce-pod, with all container images changed to ruby | Command:
```bash
kubectl debug e-commerce-pod --copy-to=dgb-img --set-image=*=ruby
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by default if no resource is... |
Forward traffic from port 6379 on all addresses to port 3000 in the pod named "e-commerce-pod". | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/e-commerce-pod 6379: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 wi... |
Taint nodes with the label "service=auth" with the taint key "dedicated" and value "backup-node-14:PreferNoSchedule" | Command:
```bash
kubectl taint node -l service=auth dedicated=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": "", "usage"... |
Update the backend microservice deployment by importing the value for the config_file_path key from the db-config config map. | Command:
```bash
kubectl set env --keys=config_file_path --from=configmap/db-config deployment/backend-microservice-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variabl... |
Print the list of supported namespaced resources | Command:
```bash
kubectl api-resources --namespaced=true
```
What it does:
Print the supported API resources on the server.
Syntax:
`kubectl api-resources`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: wide|name. " |
Execute the command 'nginx -t' in the 'stardust-shuttle' container within the 'vpn-service-pod' and display the output. | Command:
```bash
kubectl exec vpn-service-pod -c stardust-shuttle -- nginx -t
```
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 omitt... |
Import specific keys from a config map into a deployment's environment variables | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/env-vars deployment/email-server-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions ... |
Embed the certificate authority data for the 'galaxy-cluster' cluster entry using the command: | Command:
```bash
kubectl config set-cluster galaxy-cluster --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 ... |
Print the supported API resources for the specified APIGroup | Command:
```bash
kubectl api-resources --api-group=authorization.k8s.io
```
What it does:
Print the supported API resources on the server.
Syntax:
`kubectl api-resources`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: wide|name. " |
Add a taint with key 'special' on nodes having label region=eu-west-2 | Command:
```bash
kubectl taint node -l region=eu-west-2 special=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": ... |
Execute the command "composer --version" inside the rocket-ranger container in the vpn-service-pod pod and display the output. | Command:
```bash
kubectl exec vpn-service-pod -c rocket-ranger -- 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. I... |
Scale the resource specified in the 'conf.json' file to have 7 replicas | Command:
```bash
kubectl scale --replicas=7 -f conf.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 validated ... |
Create a new ClusterIP service named "analytics-service-clusterip" with port mapping from 9000 to 8000. | Command:
```bash
kubectl create service clusterip analytics-service-clusterip --tcp=9000:8000
```
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": "-... |
Add a taint with key 'app' on nodes having label myLabel and value app-node-6 as PreferNoSchedule | Command:
```bash
kubectl taint node -l myLabel app=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": "Output forma... |
Forward port 3000 in the 'e-commerce-pod' pod to localhost port 8088 for local listening | Command:
```bash
kubectl port-forward pod/e-commerce-pod 8088:3000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected aut... |
Listen on port 9090 on all addresses and forward to port 8888 in the pod named 'proxy-server-pod'. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/proxy-server-pod 9090:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod ... |
Create a new config map named app-name-config by providing properties from the /path/to/configurations/file1.txt file and key1 from the /path/to/preferences/file2.txt file. | Command:
```bash
kubectl create configmap app-name-config --from-file=properties=/path/to/configurations/file1.txt --from-file=key1=/path/to/preferences/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
W... |
View the rollout history of the deployment named "namespace-3" | Command:
```bash
kubectl rollout history deployment/namespace-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 URL to files i... |
Update the annotation 'last-deployment' of pod 'web' with the value '2023-03-15', replacing any existing value | Command:
```bash
kubectl annotate --overwrite pods web 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 i... |
Create a LoadBalancer service named vpn-service-lb with port forwarding from local port 8084 to remote port 8089. | Command:
```bash
kubectl create service loadbalancer vpn-service-lb --tcp=8084:8089
```
What it does:
Create a LoadBalancer service with the specified name.
Syntax:
`kubectl create service loadbalancer NAME [--tcp=port:targetPort] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "def... |
Return snapshot logs from the container monitoring-stack-deployment-1 of the deployment named gateway-pod | Command:
```bash
kubectl logs deployment/monitoring-stack-deployment -c gateway-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 'private-api-ingress' that directs requests to website.com/input to a specific service and port, and use a TLS secret for secure communication | Command:
```bash
kubectl create ingress private-api-ingress --rule="website.com/input=svc1:6379,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "",... |
Forward local ports 8888 to 5000 in the authentication-service-deployment pod, and also forward local port 6000 to port 6000 in the same pod. | Command:
```bash
kubectl port-forward deployment/authentication-service-deployment 8888 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, ... |
Create a new config map named "app-name-config" using the specified files as keys instead of file basenames on disk. | Command:
```bash
kubectl create configmap app-name-config --from-file=settings=/path/to/parameters/file1.txt --from-file=key2=/path/to/profiles/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 creat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.