prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Add a taint with the key 'zone' and value 'edge-node-10:PreferNoSchedule' on nodes having the label 'app-type=microservice' | Command:
```bash
kubectl taint node -l app-type=microservice zone=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": "", "usag... |
Display the most recent 53 lines of logs for the pod named log-aggregator-pod | Command:
```bash
kubectl logs --tail=53 log-aggregator-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "short... |
Get logs from the previous terminated cosmic-container container in the chat-app-pod | Command:
```bash
kubectl logs -p -c cosmic-container 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",... |
Run the 'elasticsearch --version' command within the 'lunar-launcher' container of the 'log-aggregator-pod' pod and print the output. | Command:
```bash
kubectl exec log-aggregator-pod -c lunar-launcher -- elasticsearch --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": "Containe... |
Create a cluster role named "default_role" with the ability to create configmaps and specifically access the "payment-processor" and "content-delivery" resources. | Command:
```bash
kubectl create clusterrole default_role --verb=create --resource=configmaps --resource-name=payment-processor --resource-name=content-delivery
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-... |
Create a new ClusterIP service named 'analytics-service-clusterip' that listens on port 3001 and forwards traffic to port 8084 | Command:
```bash
kubectl create service clusterip analytics-service-clusterip --tcp=3001:8084
```
What it does:
Create a ClusterIP service with the specified name.
Syntax:
`kubectl create service clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-... |
Forward traffic from port 8088 on all addresses to port 3000 in the security-service-pod pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/security-service-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 ... |
Import specific keys from a config map into a deployment. | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/monitoring-config deployment/payment-processor-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... |
Start a Redis pod with custom specifications using a JSON override. | Command:
```bash
kubectl run nginx --image=redis --overrides='{ "apiVersion": "stable-2.0.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [C... |
Forward all traffic from port 5000 on all addresses to port 8888 in the 'web-app-pod' pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/web-app-pod 5000: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 ... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/app-name-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 definitio... |
Update the label of the pod 'cdn' to set the 'env' value as 'development' | Command:
```bash
kubectl label pods cdn env=development
```
What it does:
Update the labels on a resource.
Syntax:
`kubectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]`
Helpful flags:
"flag": "--all-namespaces", "short": "-A", "default": "false", "usage": "I... |
Set the annotation 'deployment-script' with the value 'https://example.com/deploy.sh' on the 'database' pod | Command:
```bash
kubectl annotate pods database 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 be larger tha... |
Create a role named "foo" with the verb "connect" and the resource "pods" and resource name "app-worker-1" | Command:
```bash
kubectl create role foo --verb=connect --resource=pods --resource-name=app-worker-1 --resource-name=app-worker-1
```
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|clien... |
Import specific keys from a config map and set them as environment variables in a deployment. | Command:
```bash
kubectl set env --keys=log_level --from=configmap/global-config deployment/api-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... |
Set the service account of the deployment named "proxy-service-deployment" to "gitlab-runner" | Command:
```bash
kubectl set serviceaccount deployment proxy-service-deployment gitlab-runner
```
What it does:
Update the service account of pod template resources.
Possible resources (case insensitive) can be:
replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset
Syntax:... |
Create a new config map named namespace-config with the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap namespace-config --from-file=conf=/path/to/preferences/file1.txt --from-file=data=/path/to/parameters/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... |
Partially update the node specified in the "node-specific.yaml" file using strategic merge patch | Command:
```bash
kubectl patch -f node-specific.yaml -p '{"spec":{"replicas":3}'
```
What it does:
Update fields of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.
JSON and YAML formats are accepted.
Syntax:
`kubectl patch (-f FILENAME | TYPE NAME) [-p PATCH|--patch-file FILE]`
Helpful f... |
Create a copy of the email-service-pod and launch a shell in the nano-bot container of the debug-image-1 pod. | Command:
```bash
kubectl debug email-service-pod -it --copy-to=debug-image-1 --container=nano-bot -- sh
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by defa... |
Listen on port 5432 on localhost and IP address 10.19.21.23, forwarding traffic to port 3000 in the 'proxy-server-pod' pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/proxy-server-pod 5432: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... |
Import the "api_key" key from the "api-config" config map and set it as an environment variable for the "authentication-service-deployment" deployment. | Command:
```bash
kubectl set env --keys=api_key --from=configmap/api-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 variable defi... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=api_key --from=configmap/global-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 definition... |
Import environment variables from a config map with a specified prefix | Command:
```bash
kubectl set env --from=configmap/db-config --prefix=MYSQL_ 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 variable defini... |
Import the "secret_key" from the "app-config" ConfigMap to the "cache-cluster-deployment" deployment | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/app-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 definition... |
Set the resource request and limits for all containers in the 'golang' deployment | Command:
```bash
kubectl set resources deployment golang --limits=cpu=200m,memory=512Mi --requests=cpu=10,memory=256Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource request... |
Check if you have permission to list the job named "data-synchronization-job" in the "development" namespace. | Command:
```bash
kubectl auth can-i list jobs.batch/data-synchronization-job -n development
```
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 p... |
Add an annotation to the pod 'monitoring' with the key 'expiration-date' and the value '2024-12-31' | Command:
```bash
kubectl annotate pods monitoring expiration-date='2024-12-31'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and includ... |
Set the certificate-authority-data field on the testing-cluster cluster | Command:
```bash
kubectl config set clusters.testing-cluster.certificate-authority-data $(echo "cert_data_here" | base64 -i -)
```
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 conta... |
Create a new config map named "app-config-prod" by specifying keys and their corresponding file paths | Command:
```bash
kubectl create configmap app-config-prod --from-file=conf=/path/to/properties/file1.txt --from-file=data=/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.
When creati... |
Set the cluster field in the specified context to the provided cluster | Command:
```bash
kubectl config set contexts.cloud-context.cluster my-k8s-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 ... |
Set the custom TLS server name to "web-cluster" for the galaxy-cluster cluster entry. | Command:
```bash
kubectl config set-cluster galaxy-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] [--certificat... |
Forward local traffic on port 5000 to the target port of the "https" service port in a specific pod selected by the service | Command:
```bash
kubectl port-forward service/analytics-service 5000: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 sele... |
import specific keys from a config map to set as environment variables for a deployment | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/monitoring-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 definit... |
import the DEBUG_MODE key from the db-config config map to the api-server-deployment deployment | Command:
```bash
kubectl set env --keys=DEBUG_MODE --from=configmap/db-config deployment/api-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 in... |
Create a new secret named tls-certificate-secret with keys for each file in the 'path/to/data' folder | Command:
```bash
kubectl create secret generic tls-certificate-secret --from-file=path/to/data
```
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 ... |
Create a single ingress called 'app-gateway-ingress' that directs requests to testing.com/example to svc1:3001 with a tls secret "my-cert" | Command:
```bash
kubectl create ingress app-gateway-ingress --rule="testing.com/example=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": "... |
Execute the 'go' command in the container 'mycontainer' within the pod 'monitoring-pod' and retrieve the output. | Command:
```bash
kubectl exec monitoring-pod -c mycontainer -- go
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the ... |
Run the 'nginx -g "daemon off;"' command in the astro-container from the pod named payment-gateway-pod and get the output. | Command:
```bash
kubectl exec payment-gateway-pod -c astro-container -- 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": "Contain... |
Create a new ClusterIP service named shipping-service-clusterip, mapping port 8181 on the service to port 8083 on the pods | Command:
```bash
kubectl create service clusterip shipping-service-clusterip --tcp=8181:8083
```
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... |
Create a new ClusterIP service named payment-service-clusterip that forwards traffic from port 8181 to port 9091. | Command:
```bash
kubectl create service clusterip payment-service-clusterip --tcp=8181:9091
```
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"... |
Forward local traffic on port 5432 to port 8081 in the mypod pod | Command:
```bash
kubectl port-forward pod/mypod 5432 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 automaticall... |
Show the resource usage metrics for the pods with the label "region=eu-west-2" | Command:
```bash
kubectl top pod -l region=eu-west-2
```
What it does:
Display resource (CPU/memory) usage of pods.
The 'top pod' command allows you to see the resource consumption of pods.
Due to the metrics pipeline delay, they may be unavailable for a few minutes since pod creation.
Syntax:
`kubectl top pod [NAME ... |
Forward local traffic on port 6379 to the pod's port 5432, specifically for the pod named "cdn-service-pod". | Command:
```bash
kubectl port-forward pod/cdn-service-pod 6379: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 au... |
List the replication controller named 'web', the service named 'frontend-rc', and the pod named 'auth-service-pod' | Command:
```bash
kubectl get rc/web service/frontend-rc pods/auth-service-pod
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespac... |
Set the custom TLS server name for the "cloud-cluster" cluster entry to "prod-cluster" | Command:
```bash
kubectl config set-cluster cloud-cluster --tls-server-name=prod-cluster
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-cluster NAME [--server=server] [--certificat... |
Set the resource request and limits for all containers in a Ruby deployment | Command:
```bash
kubectl set resources deployment ruby --limits=cpu=200m,memory=512Mi --requests=cpu=3,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, b... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=DATABASE_URL --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 varia... |
Start a pod with the ethereum/client-go image, but customize its specification using values parsed from a JSON file. | Command:
```bash
kubectl run nginx --image=ethereum/client-go --overrides='{ "apiVersion": "v2.0.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command... |
Update the annotation 'team' of the pod 'foo' with the value 'frontend team'. | Command:
```bash
kubectl annotate pods foo 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 str... |
delete the pods and services named "analytics" and "backend" | Command:
```bash
kubectl delete pod,service analytics backend
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label selecto... |
Output the modified log-aggregator-deployment as YAML with the SMTP_PASSWORD environment variable set to "your-password", without making any changes to the object on the server. | Command:
```bash
kubectl set env deployment/log-aggregator-deployment SMTP_PASSWORD=your-password -o yaml
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one ... |
expose a replication controller as a service on port 8082 that connects to containers on port 500100 | Command:
```bash
kubectl expose rc node --port=8082 --target-port=500100
```
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... |
Rename the context 'dev-context' to 'edge-context' in your kubeconfig file | Command:
```bash
kubectl config rename-context dev-context edge-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 will also be ... |
Apply a taint with the key 'disktype' on nodes that have the label 'region=eu-west-2' with the effect of 'PreferNoSchedule' | Command:
```bash
kubectl taint node -l region=eu-west-2 disktype=db-node-7: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": ... |
Attach to a pod named security-service-pod, specifically to the cyber-sleuth container, in interactive mode with a raw terminal. | Command:
```bash
kubectl attach security-service-pod -c cyber-sleuth -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. ... |
Configure the cluster field in the specified context to the specified cluster | Command:
```bash
kubectl config set contexts.prod-context.cluster prod-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 wan... |
Set the resource request and limits for all containers in the centos deployment | Command:
```bash
kubectl set resources deployment centos --limits=cpu=200m,memory=512Mi --requests=cpu=1,memory=64Mi
```
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... |
Update the server field for the 'moon-cluster' cluster entry without modifying any other values | Command:
```bash
kubectl config set-cluster moon-cluster --server=https://1.2.3.4
```
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-autho... |
Copy the file "/tmp/foo" from your local machine to the "/etc/kubernetes" directory in the remote pod named "admin-dashboard-pod-16" in the "kube-flannel" namespace. | Command:
```bash
kubectl cp /tmp/foo kube-flannel/admin-dashboard-pod-16:/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,... |
Enable autoscaling for the 'backend' replication controller | Command:
```bash
kubectl autoscale rc backend --max=2 --cpu-percent=40
```
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... |
Unset the current Kubernetes context | Command:
```bash
kubectl config unset current-context
```
What it does:
Unset 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.
Syntax:
`kubectl config unset PROPERTY_NAME` |
get rc/web service/frontend-rc pods/api-service-pod | Command:
```bash
kubectl get rc/web service/frontend-rc pods/api-service-pod
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespace... |
Execute the 'nginx' command in the 'e-commerce-pod' pod and retrieve the output. | Command:
```bash
kubectl exec e-commerce-pod -- nginx
```
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.kube... |
Import environment variables from a secret to a deployment | Command:
```bash
kubectl set env --from=secret/payment-gateway-secret deployment/order-processing-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in o... |
Switch to raw terminal mode, attach to the 'monitoring-pod' container named 'quantum-quark', and interact with the container's shell. | Command:
```bash
kubectl attach monitoring-pod -c quantum-quark -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 named 'private-ingress' that sends requests for foo.com/input to svc1:5001 with the TLS secret named "my-cert" | Command:
```bash
kubectl create ingress private-ingress --rule="foo.com/input=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": "", "usage"... |
Set resource limits for a container in a deployment | Command:
```bash
kubectl set resources deployment jenkins -c=nginx --limits=cpu=10,memory=256Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to... |
Start a node pod named 'nginx' with the 'node' image, but override the spec with a partial set of values parsed from the provided JSON in the command. | Command:
```bash
kubectl run nginx --image=node --overrides='{ "apiVersion": "rc-1.1.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAN... |
Remove the taint with key 'special' and effect 'NoSchedule' from node 'node-1' if it exists | Command:
```bash
kubectl taint nodes node-1 special:NoSchedule-
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json|... |
Create a new LoadBalancer service named gateway-lb that maps incoming traffic on port 3001 to port 8081. | Command:
```bash
kubectl create service loadbalancer gateway-lb --tcp=3001:8081
```
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... |
Create a new php pod named "nginx" with custom specifications provided in a JSON format | Command:
```bash
kubectl run nginx --image=php --overrides='{ "apiVersion": "stable-2.0.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COM... |
Display the snapshot logs from all containers in pods that have the label customer=acme-corp | Command:
```bash
kubectl logs -l customer=acme-corp --all-containers=true
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--con... |
List all allowed actions in the "testing" namespace. | Command:
```bash
kubectl auth can-i --list --namespace=testing
```
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 URL that starts with "... |
Create a new ExternalName service named 'external-analytics-service' with the external name 'practice-online.site' | Command:
```bash
kubectl create service externalname external-analytics-service --external-name practice-online.site
```
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 referen... |
Create a copy of the auth-service-pod with a debug container and different container images | Command:
```bash
kubectl debug auth-service-pod -it --copy-to=my-custom-dbg --image=debian --set-image=api=api:v2,worker=my-custom-worker:1.2.3
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by reso... |
Forward local port 3000 to port 9090 in the pod `e-commerce-pod` | Command:
```bash
kubectl port-forward pod/e-commerce-pod 3000: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 aut... |
Start a pod named "hazelcast" using the "ruby" image and configure the container to expose port 3001. | Command:
```bash
kubectl run hazelcast --image=ruby --port=3001
```
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... |
Attach to the vpn-service-pod container stardust-shuttle and get its output. | Command:
```bash
kubectl attach vpn-service-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 omit... |
Retrieve the snapshot logs from the container 'order-processing-deployment-1' of the deployment 'mypod'. | Command:
```bash
kubectl logs deployment/order-processing-deployment -c mypod-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:
"flag": ... |
Create a deployment named 'web' using the 'php' image. | Command:
```bash
kubectl create deployment web --image=php --
```
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|yaml|name|g... |
create a config map from a file | Command:
```bash
kubectl create configmap log-config --from-file=path/to/properties
```
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... |
Create a service for the ruby deployment, serving on port 8082 and connecting to the containers on port 300000 | Command:
```bash
kubectl expose deployment ruby --port=8082 --target-port=300000
```
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... |
Add a taint with key 'cpu-type' and value 'app-node-6:PreferNoSchedule' on nodes having label 'region=eu-west-2' | Command:
```bash
kubectl taint node -l region=eu-west-2 cpu-type=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":... |
update the 'cache-cluster-deployment' deployment by adding a new environment variable 'MONGO_URI' with the value 'mongodb://localhost:27017/mydb' | Command:
```bash
kubectl set env deployment/cache-cluster-deployment MONGO_URI=mongodb://localhost:27017/mydb
```
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 ... |
Create a new config map named app-config-prod using the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-config-prod --from-file=conf=/path/to/profiles/file1.txt --from-file=data=/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 creating a ... |
Create an ingress that directs requests to a specific service and port with a TLS secret | Command:
```bash
kubectl create ingress app1-ingress --rule="website.com/input=svc1:8084,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 an ingress named 'ingress1' using the default class, with the following rules: | Command:
```bash
kubectl create ingress ingress1 --class=default \
--rule="website.com/path*=svc:9000" \
--rule="example.com/admin*=svc2:http"
```
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": "--outp... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=config_file_path --from=configmap/app-name-config deployment/log-aggregator-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variabl... |
Create an ingress resource called 'default-ingress' with a rule that directs requests to testing.com/bar to svc1:9092 | Command:
```bash
kubectl create ingress default-ingress --rule="testing.com/bar=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": "", "usag... |
Forward data between local ports 6379 and 5432 and a pod selected by the monitoring-stack-deployment in the deployment resource. | Command:
```bash
kubectl port-forward deployment/monitoring-stack-deployment 6379 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 ... |
Forward traffic from port 5000 on localhost and IP address 10.19.21.23 to port 5432 in the analytics-pod pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/analytics-pod 5000: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 crite... |
Retrieve the snapshot logs from the container 'analytics-pod-1' in the 'web-app-deployment' deployment. | Command:
```bash
kubectl logs deployment/web-app-deployment -c analytics-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:
"flag": "... |
Import the specific key "my-example-key" from the config map to the deployment named "log-aggregator-deployment" | Command:
```bash
kubectl set env --keys=my-example-key --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 definit... |
import specific keys from a config map into a deployment's environment variables | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/db-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 definitions in on... |
Create a cron job named "system-health-check" that runs the command "dotnet --list-sdks" every minute, using the specified image and schedule. | Command:
```bash
kubectl create cronjob system-health-check --image=mcr.microsoft.com/dotnet/core/runtime --schedule="*/1 * * * *" -- dotnet --list-sdks
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Hel... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/app-config-dev deployment/mydeployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in on... |
Attach and get output from `rocket-ranger` from the `e-commerce-pod` | Command:
```bash
kubectl attach e-commerce-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,... |
update the pod identified by the type and name specified in the "setup.json" file with the annotation "owner" set to "alice smith" | Command:
```bash
kubectl annotate -f setup.json owner='alice smith'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include arbitrary... |
Expose a replication controller named "python" as a service, serving on port 3000 and forwarding connections to the containers on port 909000. | Command:
```bash
kubectl expose rc python --port=3000 --target-port=909000
```
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 new ClusterIP service named frontend-service-clusterip with the ports mapping TCP 7000 to 5000. | Command:
```bash
kubectl create service clusterip frontend-service-clusterip --tcp=7000:5000
```
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.