prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Forward the local port 8080 to the pod port 8888 in the 'frontend-pod' pod. | Command:
```bash
kubectl port-forward pod/frontend-pod 8080:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected autom... |
Add or update a taint with the specified key, value, and effect on the node 'worker-node-3' | Command:
```bash
kubectl taint nodes worker-node-3 environment=production:NoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output ... |
Set the cpu limit of the 'postgres' deployment's container to "3" and the memory limit to "512Mi" | Command:
```bash
kubectl set resources deployment postgres -c=nginx --limits=cpu=3,memory=512Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to... |
Create a deployment named 'mattermost' using the 'php' image, and expose port 27017 | Command:
```bash
kubectl create deployment mattermost --image=php --port=27017
```
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:... |
Attach to the web-app-pod and get output from the nebula-navigator container | Command:
```bash
kubectl attach web-app-pod -c nebula-navigator
```
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 an ingress called 'api-gateway-ingress' that routes requests from site.com/input to a service named 'svc1' on port 8010, using the TLS secret 'my-cert'. | Command:
```bash
kubectl create ingress api-gateway-ingress --rule="site.com/input=svc1:8010,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... |
Forward traffic from port 9090 on localhost and IP 10.19.21.23 to port 8080 in the analytics-pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/analytics-pod 9090: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 crite... |
Create a new ClusterIP service named ldap-service-clusterip | Command:
```bash
kubectl create service clusterip ldap-service-clusterip --tcp=8888:5432
```
What it does:
Create a ClusterIP service with the specified name.
Syntax:
`kubectl create service clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "... |
Check if you have the permission to list the "security-scan-job" job in the "production" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/security-scan-job -n production
```
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 U... |
Create a pod disruption budget named logging-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 logging-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-available=N... |
create service for replicated centos using replica set to listen on port 80 and connect to containers on port 8000 | Command:
```bash
kubectl expose rs centos --port=8084 --target-port=300100
```
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 copy of the proxy-server-pod and add a debug container to it | Command:
```bash
kubectl debug proxy-server-pod -it --copy-to=debug-image-app --image=debian --set-image=mailer=mailer:latest,cache=redis:alpine
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by res... |
List all deployments in the "rc-1.1.0" version of the "mobile-apps" API group in YAML output format | Command:
```bash
kubectl get deployments.rc-1.1.0.mobile-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 w... |
Create a job named 'database-seeding-job' using the 'mongo' image, and run the command 'mongo --version' inside the container | Command:
```bash
kubectl create job database-seeding-job --image=mongo -- mongo --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... |
Update the pod 'chat-app' with the annotation 'git-repo' and set its value to 'https://github.com/example/my-app'. | Command:
```bash
kubectl annotate pods chat-app git-repo='https://github.com/example/my-app'
```
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 lab... |
Get the output from running the 'dotnet' command on the first pod of the search-engine-deployment deployment. | Command:
```bash
kubectl exec deploy/search-engine-deployment -- 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, us... |
Create an ingress named 'private-api-ingress' that directs requests from testing.com/bar to svc1:3001 and uses the TLS secret "my-cert" | Command:
```bash
kubectl create ingress private-api-ingress --rule="testing.com/bar=svc1:3001,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "... |
Auto scale the replication controller "proxy-server" with a target CPU utilization of 50%, allowing the number of pods to range from 1 to a maximum of 3. | Command:
```bash
kubectl autoscale rc proxy-server --max=3 --cpu-percent=50
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that... |
Enable the new exec auth plugin for the "security-user" entry by setting the exec command to "/path/to/the/executable" and the exec api version to "client.authentication.k8s.io/v1beta1" | Command:
```bash
kubectl config set-credentials security-user --exec-command=/path/to/the/executable --exec-api-version=client.authentication.k8s.io/v1beta1
```
What it does:
Set a user entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values.
Client-certificate flags:... |
Copy the kube config file from your local machine to a specific directory in a remote pod. | Command:
```bash
kubectl cp ~/.config/kube cert-manager/task-processor-pod-17:/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, u... |
Update the 'payment' pod by removing the 'bar' label if it exists | Command:
```bash
kubectl label pods payment unhealthy-
```
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... |
Create a new config map named 'app-config-prod' using the key=value pairs in the file located at 'path/to/options' | Command:
```bash
kubectl create configmap app-config-prod --from-file=path/to/options
```
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 basena... |
Create a service for a replicated node using replica set, which serves on port 9091 and connects to the containers on port 808800 | Command:
```bash
kubectl expose rs node --port=9091 --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. A... |
Update the description of all services in the namespace | Command:
```bash
kubectl annotate services --all description='my frontend running nginx'
```
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 ... |
Forward ports 9090 and 6000 locally to a pod selected by the web-app-deployment deployment | Command:
```bash
kubectl port-forward deployment/web-app-deployment 9090 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 s... |
Forward traffic from port 8081 on all addresses to port 9090 in the pod named "mypod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/mypod 8081:9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be sel... |
Create a new config map named ui-config with the specified keys from the specified files. | Command:
```bash
kubectl create configmap ui-config --from-file=settings=/path/to/settings/file1.txt --from-file=key2=/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 con... |
Forward traffic between local ports 8081 and 6000 to ports 8081 and 6000 in a pod selected by the deployment "email-server-deployment". | Command:
```bash
kubectl port-forward deployment/email-server-deployment 8081 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 into a deployment | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/app-config-prod 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 variab... |
Listen on all addresses on port 8080 and forward the traffic to port 9090 in the frontend-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/frontend-pod 8080: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... |
Create a new ClusterIP service named frontend-service-clusterip | Command:
```bash
kubectl create service clusterip frontend-service-clusterip --tcp=8010:8088
```
What it does:
Create a ClusterIP service with the specified name.
Syntax:
`kubectl create service clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o... |
Add the taint with key 'datacenter' and value 'storage-node-13:PreferNoSchedule' on the nodes that have the label 'release=beta'. | Command:
```bash
kubectl taint node -l release=beta datacenter=storage-node-13:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
Start a pod named "hazelcast" using the "node" image and expose port 7000 | Command:
```bash
kubectl run hazelcast --image=node --port=7000
```
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... |
Copy the file '/tmp/foo' from the remote pod 'file-server-pod-14' to the local directory '/tmp/bar_dir' | Command:
```bash
kubectl cp kube-dns/file-server-pod-14::/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 k... |
Create a new LoadBalancer service named backend-lb that will map port 9000 on the cluster to port 8010 on the backend-lb service. | Command:
```bash
kubectl create service loadbalancer backend-lb --tcp=9000:8010
```
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", "default... |
Add a taint with key 'datacenter' on nodes having label namespace=mynamespace | Command:
```bash
kubectl taint node -l namespace=mynamespace datacenter=kube-master-9:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": ""... |
Create a pod disruption budget named "messaging-pdb" that will select all pods with the label "app=nginx" and require at least 70% of the selected pods to be available at any given time. | Command:
```bash
kubectl create pdb messaging-pdb --selector=app=nginx --min-available=70%
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N [--dry-run=server|cl... |
Forward traffic from port 8081 on localhost and IP 10.19.21.23 to port 8081 in the pod named log-aggregator-pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/log-aggregator-pod 8081: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 ... |
Import the DEBUG_MODE key from the config map named 'app-config-prod' into the 'log-aggregator-deployment' deployment. | Command:
```bash
kubectl set env --keys=DEBUG_MODE --from=configmap/app-config-prod deployment/log-aggregator-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defi... |
Create a copy of the 'cdn-service-pod' pod and add a debug container to it, using the 'debian' image | Command:
```bash
kubectl debug cdn-service-pod -it --copy-to=debug-image-1 --image=debian --set-image=app=app:debug,app=app:debug
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name.... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=external_api_url --from=configmap/env-vars deployment/log-aggregator-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defin... |
Set the custom TLS server name "e2e" to use for validation for the "cluster-alpha" cluster entry. | Command:
```bash
kubectl config set-cluster cluster-alpha --tls-server-name=e2e
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-cluster NAME [--server=server] [--certificate-authori... |
Add the label 'unhealthy=true' to the pod 'vpn' | Command:
```bash
kubectl label pods vpn unhealthy=true
```
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... |
Add a 'PreferNoSchedule' taint with key 'datacenter' on nodes having the label 'region=eu-west-2' with the name 'testing-node-11' | Command:
```bash
kubectl taint node -l region=eu-west-2 datacenter=testing-node-11: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": "", "... |
Expose a replica set named "python" as a service, which listens on port 3000 and forwards the traffic to the containers running on port 8084. | Command:
```bash
kubectl expose rs python --port=3000 --target-port=808400
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port.... |
Copy the kube config file from a remote pod to a local directory | Command:
```bash
kubectl cp cert-manager/admin-dashboard-pod-16:~/.config/kube :/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,... |
Start port forwarding on your local machine, listening on port 8080 and forwarding data to port 3000 in the pod selected by the api-server-deployment deployment | Command:
```bash
kubectl port-forward deployment/api-server-deployment 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 criteria, a pod will b... |
Start streaming the logs of the 'quantum-quark' container in the 'chat-app-pod' pod | Command:
```bash
kubectl logs -f -c quantum-quark chat-app-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "s... |
Auto scale the replication controller "auth" with a target CPU utilization of 50% and a maximum of 7 pods. | Command:
```bash
kubectl autoscale rc auth --max=7 --cpu-percent=50
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that uses th... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/monitoring-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 vari... |
Forward local port 8088 to port 8088 in the analytics-pod | Command:
```bash
kubectl port-forward pod/analytics-pod 8088:8088
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected auto... |
List the replication controller 'web', the service 'vpn-service-rc', and the pod 'payment-gateway-pod' | Command:
```bash
kubectl get rc/web service/vpn-service-rc pods/payment-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 na... |
Set the service account of the deployment 'frontend-deployment' to 'kube-controller-manager' | Command:
```bash
kubectl set serviceaccount deployment frontend-deployment kube-controller-manager
```
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
Sy... |
Create an ingress called 'api-ingress' with the following rule: foo.com/module should be directed to svc1:3000 | Command:
```bash
kubectl create ingress api-ingress --rule="foo.com/module=svc1:3000,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 job named "batch-processing" using the "centos" image, and run the command "yum install -y wget" inside the job. | Command:
```bash
kubectl create job batch-processing --image=centos -- yum install -y wget
```
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": "Ou... |
Update the environment variables of the log-aggregator-deployment deployment, by importing only the redis_host key from the config map named env-vars | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/env-vars deployment/log-aggregator-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions... |
Create a deployment named prometheus using the amazonlinux image and expose port 3001 | Command:
```bash
kubectl create deployment prometheus --image=amazonlinux --port=3001
```
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 traffic from port 6379 on localhost and IP 10.19.21.23 to port 3000 in the log-aggregator-pod pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/log-aggregator-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 ... |
create a secret named ssh-key-secret from an environment file | Command:
```bash
kubectl create secret generic ssh-key-secret --from-env-file=path/to/data.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 basename ... |
Add a taint with the key 'cpu-type' on nodes that have the label 'myLabel' and set the value to 'dev-node-4:PreferNoSchedule'. | Command:
```bash
kubectl taint node -l myLabel 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": "", "usage": "Output ... |
Execute the 'dotnet' command inside the backend-pod container and display the output | Command:
```bash
kubectl exec backend-pod -- 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.kubern... |
Update the nginx container image to version 1.21.3 as specified in the local file "path/to/file.yaml", then print the result in YAML format without actually applying the changes to the server. | Command:
```bash
kubectl set image -f path/to/file.yaml nginx=nginx:1.21.3 --local -o yaml
```
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), replic... |
Forward port 8080 on localhost and IP address 10.19.21.23 to port 9090 in the cdn-service-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/cdn-service-pod 8080: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 cri... |
View the details of revision 3 of the daemonset named app-v2 | Command:
```bash
kubectl rollout history daemonset/app-v2 --revision=3
```
What it does:
View previous rollout revisions and configurations.
Syntax:
`kubectl rollout history (TYPE NAME | TYPE/NAME) [flags]`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to ... |
Update the status of the pod named 'payment' only if it has not changed from version 1. | Command:
```bash
kubectl label pods payment status=unhealthy --resource-version=1
```
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", "defa... |
Retrieve the previous terminated logs from the 'nebula-navigator' container in the 'e-commerce-pod' pod | Command:
```bash
kubectl logs -p -c nebula-navigator e-commerce-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... |
Create a cluster role named "view" and specify the resource names it can access | Command:
```bash
kubectl create clusterrole view --verb=exec --resource=services --resource-name=payment-processor --resource-name=monitoring-prometheus
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=ser... |
Open the `user-service` service for editing using the `notepad` editor. | Command:
```bash
KUBE_EDITOR="notepad" kubectl edit svc/user-service
```
What it does:
Edit a resource from the default editor.
The edit command allows you to directly edit any API resource you can retrieve via the command-line tools. It will open the editor defined by your KUBE_EDITOR, or EDITOR environment variables... |
Set up an automatic scaling for the "gateway" deployment | Command:
```bash
kubectl autoscale deployment gateway --min=6 --max=15
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that uses... |
Retrieve logs from container "database-pod-1" in the deployment "user-management-deployment" | Command:
```bash
kubectl logs deployment/user-management-deployment -c database-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... |
Get the output from running the 'elasticsearch' command in the nebula-navigator container of the payment-gateway-pod pod | Command:
```bash
kubectl exec payment-gateway-pod -c nebula-navigator -- elasticsearch
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name.... |
Attach to the cyber-sleuth container in the security-service-pod and retrieve its output. | Command:
```bash
kubectl attach security-service-pod -c cyber-sleuth
```
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... |
Forward port 5000 on localhost and IP 10.19.21.23 to port 6379 in the frontend-pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/frontend-pod 5000: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 criter... |
Remove all taints with the key 'dedicated' from the node 'testing-node-11' | Command:
```bash
kubectl taint nodes testing-node-11 dedicated-
```
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|... |
create a service for the nginx replica set, which serves on port 80 and connects to the containers on port 8000 | Command:
```bash
kubectl expose rc nginx --port=6379 --target-port=808900
```
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. ... |
Update the "prod-user" entry in the kubeconfig file to only set the "client-key" field and keep other values intact. | Command:
```bash
kubectl config set-credentials prod-user --client-key=~/.kube/admin.key
```
What it does:
Set a user entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values.
Client-certificate flags:
--client-certificate=certfile --client-key=keyfile
Bearer token f... |
Create an ingress named 'default-ingress' with a rule that redirects requests for 'site.com/bar' to 'svc1:5432' using the TLS secret 'my-cert' | Command:
```bash
kubectl create ingress default-ingress --rule="site.com/bar=svc1:5432,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 "auth" with the ruby image and expose port 8080 | Command:
```bash
kubectl create deployment auth --image=ruby --port=8080
```
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|... |
Rename a context in your kubeconfig file | Command:
```bash
kubectl config rename-context cluster-1-context client-1-context
```
What it does:
Renames a context from the kubeconfig file.
CONTEXT_NAME is the context name that you want to change.
NEW_NAME is the new name you want to set.
Note: If the context being renamed is the 'current-context', this field wil... |
execute the 'mongod' command in the stardust-shuttle container of the database-pod and get the output | Command:
```bash
kubectl exec database-pod -c stardust-shuttle -- mongod
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, u... |
Update the label of a pod with a specific value | Command:
```bash
kubectl label pods chat-app app=myapp
```
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... |
Create a secret named ssh-key-secret with a file and literal value | Command:
```bash
kubectl create secret generic ssh-key-secret --from-file=ssh-privatekey=path/to/id_rsa --from-literal=passphrase=topsecret
```
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 ... |
Get the output from the 'php --version' command running inside the astro-container from the pod cdn-service-pod. | Command:
```bash
kubectl exec cdn-service-pod -c astro-container -- php --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... |
Create a new LoadBalancer service named vpn-service-lb and forward traffic from port 3001 to port 27017. | Command:
```bash
kubectl create service loadbalancer vpn-service-lb --tcp=3001:27017
```
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", "de... |
Forward traffic from port 8000 on all addresses to port 9090 in the pod named "analytics-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/analytics-pod 8000: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 wil... |
Add a taint on nodes with a specific label | Command:
```bash
kubectl taint node -l stack=tech-stack app=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": "Output ... |
Copy the file /tmp/foo from the logging-agent-pod-7 pod to the /etc/kubernetes directory locally. | Command:
```bash
kubectl cp logging/logging-agent-pod-7:/tmp/foo /etc/kubernetes
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the... |
Import specific keys from a config map for a deployment | Command:
```bash
kubectl set env --keys=database_url --from=configmap/namespace-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 definit... |
Create a single ingress called 'website-ingress' that directs requests to site.com/bar to svc1:8000 with a tls secret "my-cert" | Command:
```bash
kubectl create ingress website-ingress --rule="site.com/bar=svc1:8000,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":... |
Listen on port 8080 on your local machine and forward traffic to port 3000 in the 'proxy-server-pod' pod. | Command:
```bash
kubectl port-forward 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 criteria, a pod will be selected a... |
Create a new secret named encryption-key-secret using the parameters specified in the path/to/parameters.env file | Command:
```bash
kubectl create secret generic encryption-key-secret --from-env-file=path/to/parameters.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 ... |
Forward local port 8081 to port 8888 in the 'api-service-pod' pod | Command:
```bash
kubectl port-forward pod/api-service-pod 8081: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... |
Update the last-deployment annotation of the pod specified in the "parameters.json" file to "2023-03-15". | Command:
```bash
kubectl annotate -f parameters.json 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 inclu... |
Create an ingress called 'public-service-ingress' that directs requests to foo.com/module to svc # svc1:9092 with a tls secret "my-cert" | Command:
```bash
kubectl create ingress public-service-ingress --rule="foo.com/module=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": "",... |
Create a pod disruption budget named 'load-balancer-pdb' that will select all pods with the 'region=us-east' label and require at least one of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget load-balancer-pdb --selector=region=us-east --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... |
Get the output from running the 'jenkins-plugin-cli' command on the first pod of the 'database-deployment' deployment. | Command:
```bash
kubectl exec deploy/database-deployment -- jenkins-plugin-cli
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omit... |
Create a copy of the "web-app-pod" with all container images changed to "mysql" | Command:
```bash
kubectl debug web-app-pod --copy-to=my-custom-dbg --set-image=*=mysql
```
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 resourc... |
Create a cluster role named "foo" with the verb "update" and the NonResourceURL "/healthz" specified | Command:
```bash
kubectl create clusterrole "foo" --verb=update --non-resource-url=/healthz
```
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", "short"... |
Copy the '/tmp/foo' file from the 'message-broker-pod-15' pod in the 'argocd' namespace to the '/etc/kubernetes' directory locally. | Command:
```bash
kubectl exec -n argocd message-broker-pod-15 -- tar cf - :/tmp/foo | tar xf - -C /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": "Co... |
Create a new config map named app-config from an environment file | Command:
```bash
kubectl create configmap app-config --from-env-file=path/to/options.env
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a config map based on a file, the key will default to the bas... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.