prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Forward traffic from port 9090 on localhost and IP 10.19.21.23 to port 8888 in the pod named "web-app-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/web-app-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 criteri... |
Add an annotation to the pod 'log-aggregator' with the key 'contact-email' and the value 'support@example.com' | Command:
```bash
kubectl annotate pods log-aggregator contact-email=support@example.com
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels a... |
Get the documentation for the "name" field in the metadata section of the pods resource | Command:
```bash
kubectl explain resource=pods.metadata.name
```
What it does:
List the fields for supported resources.
This command describes the fields associated with each supported API resource. Fields are identified via a simple JSONPath identifier:
<type>.<fieldName>[.<fieldName>]
Add the --recursive flag to dis... |
Execute the command 'nginx -g "daemon off;"' in the 'quantum-quark' container of the 'security-service-pod' pod and display the output. | Command:
```bash
kubectl exec security-service-pod -c quantum-quark -- 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": "Containe... |
Return snapshot logs from the container payment-processor-deployment-1 of the web-app-pod deployment | Command:
```bash
kubectl logs deployment/payment-processor-deployment -c web-app-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:
"... |
Copy the file /tmp/foo from the remote pod monitoring-agent-pod-6 in the kube-proxy namespace to the local directory /etc/kubernetes. | Command:
```bash
kubectl cp kube-proxy/monitoring-agent-pod-6:/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, u... |
Create a service for a replication controller identified by the specifications in the "nginx-controller.yaml" file, which serves on port 8181 and connects to the containers on port 8080. | Command:
```bash
kubectl expose -f nginx-controller.yaml --port=8181 --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 ... |
Import the SMTP_SERVER key from the ui-config config map to the analytics-platform-deployment deployment. | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/ui-config deployment/analytics-platform-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... |
Run the 'jenkins-plugin-cli' command in the quantum-quark container of the auth-service-pod pod and print the output | Command:
```bash
kubectl exec auth-service-pod -c quantum-quark -- 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. ... |
Listen on a random local port and forward traffic to the 'mypod' pod's port 8080. | Command:
```bash
kubectl port-forward pod/mypod :8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automatically. T... |
Set the service account of the deployment "payment-processor-deployment" to "prometheus" | Command:
```bash
kubectl set serviceaccount deployment payment-processor-deployment prometheus
```
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... |
Partially update the node named db-node-7 by applying a strategic merge patch with the JSON provided | Command:
```bash
kubectl patch node db-node-7 -p '{"spec":{"type":"LoadBalancer"}'
```
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... |
Update the image of all containers in the 'prod' daemonset to 'postgres:13.4' | Command:
```bash
kubectl set image daemonset prod *=postgres:13.4
```
What it does:
Update existing container image(s) of resources.
Possible resources include (case insensitive):
pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), statefulset (sts), cronjob (cj), replicaset (rs)
Syntax:
`kubec... |
Add a taint to a specific node to mark it for a particular environment. | Command:
```bash
kubectl taint nodes testing-node-11 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": "Outpu... |
Auto scale the replication controller "analytics" with a target CPU utilization at 20%, allowing the number of pods to range between 1 and 2. | Command:
```bash
kubectl autoscale rc analytics --max=2 --cpu-percent=20
```
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 us... |
Taint nodes with the label 'tier=frontend' with a taint key 'datacenter' and value 'monitoring-node-15:PreferNoSchedule' | Command:
```bash
kubectl taint node -l tier=frontend datacenter=monitoring-node-15: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 the key 'special' and value 'dev-node-4:PreferNoSchedule' on nodes that have the label 'release=beta' | Command:
```bash
kubectl taint node -l release=beta special=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": "Out... |
Use nano as the editor to edit the authentication-service service configuration | Command:
```bash
KUBE_EDITOR="nano" kubectl edit svc/authentication-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 va... |
Update the 'api' pod by setting the annotation 'git-repo' with the value 'https://github.com/example/my-app'. | Command:
```bash
kubectl annotate pods api 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 labels a... |
Forward local port 8081 to port 5432 in the 'e-commerce-pod' pod | Command:
```bash
kubectl port-forward pod/e-commerce-pod 8081:5432
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected aut... |
Run the 'mysql' command in the 'proxy-server-pod' pod and display the output. | Command:
```bash
kubectl exec proxy-server-pod -- mysql
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.ku... |
Create a new config map named 'ui-config' with the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap ui-config --from-file=settings=/path/to/settings/file1.txt --from-file=key2=/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 creating a... |
Update the image of the container 'kubernetes-serve-hostname' in the pod 'email-service-pod' with the 'new image' | Command:
```bash
kubectl patch pod email-service-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve-hostname","image":"new image"}]}}'
```
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 FI... |
Create a new ClusterIP service named analytics-service-clusterip | Command:
```bash
kubectl create service clusterip analytics-service-clusterip --tcp=3001:5001
```
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": "-... |
Start a mysql pod named hazelcast and expose port 9000 in the container | Command:
```bash
kubectl run hazelcast --image=mysql --port=9000
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--fi... |
Create a deployment named web running the nginx image and exposing port 8081. | Command:
```bash
kubectl create deployment web --image=nginx --port=8081
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json|... |
Create a cron job named "daily-report" that runs the command "jenkins --version" every minute, using the "jenkins" image. | Command:
```bash
kubectl create cronjob daily-report --image=jenkins --schedule="*/1 * * * *" -- jenkins --version
```
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... |
Set the cluster field in a specific context to a given cluster name | Command:
```bash
kubectl config set contexts.app-2-context.cluster sun-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... |
Create a new config map named namespace-config with the specified keys by using the properties file located at /path/to/configurations/file1.txt and the key1 file located at /path/to/options/file2.txt | Command:
```bash
kubectl create configmap namespace-config --from-file=properties=/path/to/configurations/file1.txt --from-file=key1=/path/to/options/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When... |
Apply a taint with the key 'workload' on nodes that have a label 'release=beta' | Command:
```bash
kubectl taint node -l release=beta workload=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": "Ou... |
Create a pod disruption budget with a specific selector and minimum availability requirement | Command:
```bash
kubectl create poddisruptionbudget api-service-pdb --selector=env=production --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... |
List deployments in YAML output format for the "v1.0.0" version of the "api-v2" API group. | Command:
```bash
kubectl get deployments.v1.0.0.api-v2 -o yaml
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you will onl... |
Listen on a random port locally, forwarding to port 8080 in the frontend-pod pod | Command:
```bash
kubectl port-forward pod/frontend-pod :8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automatic... |
Create a service for the 'nginx' replication controller, which serves on port 8081 and connects to the containers on port 700000 | Command:
```bash
kubectl expose rc nginx --port=8081 --target-port=700000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port. ... |
Execute the 'elasticsearch' command in the first pod of the 'notification-handler-deployment' deployment and retrieve the output. | Command:
```bash
kubectl exec deploy/notification-handler-deployment -- 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. ... |
Create a debug container in a pod by copying it and changing the container image | Command:
```bash
kubectl debug auth-service-pod -it --copy-to=debug-image-memcached --image=debian --set-image=logger=logging-app:debug,scheduler=my-scheduler:1.0
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects... |
Add a taint on nodes with a specific label | Command:
```bash
kubectl taint node -l version=v1.0.0 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": "", "usage": "Ou... |
Import the 'API_KEY' key from the 'api-config' ConfigMap and set it as an environment variable in 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... |
Retrieve the logs from container named 'gateway-pod-1' of the deployment 'mydeployment' | Command:
```bash
kubectl logs deployment/mydeployment -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:
"flag": "--contai... |
Expose a replicated node as a service, listening on port 3000 and forwarding traffic to containers on port 8081 | Command:
```bash
kubectl expose rc node --port=3000 --target-port=808100
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port. A... |
Forward all incoming traffic on port 3000, from all addresses, to port 8080 in the web-app-pod pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/web-app-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 ... |
Create an ingress called 'app-proxy-ingress' that directs requests from foo.com/example to the service 'svc1' on port 9090, and use the TLS secret 'my-cert' for secure communication. | Command:
```bash
kubectl create ingress app-proxy-ingress --rule="foo.com/example=svc1:9090,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "us... |
Check if you have the permission to list the "virus-scan-job" job in the "kube-public" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/virus-scan-job -n kube-public
```
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... |
Check to see if you have permission to list the "data-synchronization-job" job in the "kube-system" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/data-synchronization-job -n kube-system
```
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... |
Create a new ClusterIP service named billing-service-clusterip and expose port 8089 on the service to port 8082 on the pod | Command:
```bash
kubectl create service clusterip billing-service-clusterip --tcp=8082:8089
```
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"... |
Remove the environment variable 'ENV' from the 'time-machine' container in all deployment configurations | Command:
```bash
kubectl set env deployments --all --containers="time-machine" ENV-
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more pod templates ... |
Forward local port 5432 to port 8088 in the pod `api-service-pod` | Command:
```bash
kubectl port-forward pod/api-service-pod 5432: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 au... |
Rollback the deployment named "development" to the previous version | Command:
```bash
kubectl rollout undo deployment/development
```
What it does:
Manage the rollout of a resource.
Valid resource types include:
Syntax:
`kubectl rollout SUBCOMMAND` |
Create a new configmap named 'env-vars' with the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap env-vars --from-file=settings=/path/to/configurations/file1.txt --from-file=key2=/path/to/properties/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creati... |
Get the output from running the 'elasticsearch' command in the first container of the first pod of the 'authentication-service-deployment' deployment. | Command:
```bash
kubectl exec deploy/authentication-service-deployment -- 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... |
Output the modified deployment in YAML format without making any changes to the actual object on the server | Command:
```bash
kubectl set env deployment/proxy-service-deployment CACHE_SIZE=64MB -o yaml
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more pod t... |
Set the cpu limits of the postgres deployment container to "200m" and the memory limits to "2Gi" | Command:
```bash
kubectl set resources deployment postgres -c=nginx --limits=cpu=200m,memory=2Gi
```
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 t... |
Listen on port 5000 on localhost and IP address 10.19.21.23, and forward the traffic to port 8888 in the proxy-server-pod pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/proxy-server-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 cr... |
Create a job called "image-build-job" with the image "mongo" and the command "mongo" | Command:
```bash
kubectl create job image-build-job --image=mongo -- mongo
```
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... |
Import environment variables from the 'global-config' config map with the 'MYSQL_' prefix into the 'cache-cluster-deployment' deployment. | Command:
```bash
kubectl set env --from=configmap/global-config --prefix=MYSQL_ 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 definitio... |
Create a new config map named db-config using the files file1.txt and file2.txt, located at /path/to/configs and /path/to/properties respectively | Command:
```bash
kubectl create configmap db-config --from-file=conf=/path/to/configs/file1.txt --from-file=data=/path/to/properties/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a confi... |
Create a copy of cdn-service-pod, called dgb-img, but replace all container images with the nginx image. | Command:
```bash
kubectl debug cdn-service-pod --copy-to=dgb-img --set-image=*=nginx
```
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 ... |
Create a pod named 'hazelcast' using the 'confluentinc/cp-kafka' image, and expose port 9092 on the container. | Command:
```bash
kubectl run hazelcast --image=confluentinc/cp-kafka --port=9092
```
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 flag... |
Give more information about the pods with the label "service=auth" | Command:
```bash
kubectl describe po -l service=auth
```
What it does:
Show details of a specific resource or group of resources.
Print a detailed description of the selected resources, including related resources such as events or controllers. You may select a single object by name, all objects of that type, provide ... |
Forward traffic from port 8080 on localhost and IP 10.19.21.23 to port 5432 in the "chat-app-pod" pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/chat-app-pod 8080: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 criter... |
Forward local port 8000 to port 8088 in the pod named "e-commerce-pod" | Command:
```bash
kubectl port-forward pod/e-commerce-pod 8000: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 aut... |
Create a new secret named gcp-service-account-secret using the file located at path/to/id_rsa as the ssh-privatekey and set the passphrase as topsecret | Command:
```bash
kubectl create secret generic gcp-service-account-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 secr... |
Retrieve the logs of the previous terminated lunar-launcher container from the pod named database-pod | Command:
```bash
kubectl logs -p -c lunar-launcher database-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 new ClusterIP service named frontend-service-clusterip that forwards traffic from port 7000 on the service to port 8010 on the target | Command:
```bash
kubectl create service clusterip frontend-service-clusterip --tcp=7000:8010
```
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... |
Import the specific keys 'DATABASE_URL' from the 'global-config' config map and set them as environment variables for the 'log-aggregator-deployment' deployment. | Command:
```bash
kubectl set env --keys=DATABASE_URL --from=configmap/global-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 variable defi... |
Add the label "tier=backend" to the pod named "email" | Command:
```bash
kubectl label pods email tier=backend
```
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 copy of the 'database-pod' pod, change all container images to 'postgres' and name the new pod 'debug-image-app' | Command:
```bash
kubectl debug database-pod --copy-to=debug-image-app --set-image=*=postgres
```
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 r... |
Import the 'api_key' key from the 'monitoring-config' config map into the deployment named 'search-engine-deployment' | Command:
```bash
kubectl set env --keys=api_key --from=configmap/monitoring-config deployment/search-engine-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defini... |
Scale a replica set named 'baz' to 5 replicas | Command:
```bash
kubectl scale --replicas=5 rs/baz
```
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 before... |
Rename the context 'cloud-context' to 'team-alpha-context' in your kubeconfig file | Command:
```bash
kubectl config rename-context cloud-context team-alpha-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 ... |
Create a cluster role named "reader" with the non-resource URL "/apis/*" and the verb "update" | Command:
```bash
kubectl create clusterrole "reader" --verb=update --non-resource-url=/apis/*
```
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", "shor... |
Copy the local file /tmp/foo_dir to the remote pod kube-dns/load-balancer-pod-9:/tmp/bar_dir in the specified namespace. | Command:
```bash
kubectl cp /tmp/foo_dir kube-dns/load-balancer-pod-9:/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 t... |
Execute the 'redis-server' command within the pod named 'vpn-service-pod' and retrieve the output | Command:
```bash
kubectl exec vpn-service-pod -- redis-server
```
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 kube... |
Create an ingress resource with the name 'frontend-ingress' that directs requests to foo.com/module to the service 'svc1' on port 9090 | Command:
```bash
kubectl create ingress rontend-ingress --rule="foo.com/module=svc1:9090,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage... |
Retrieve the logs of the previously terminated "nano-bot" container from the "database-pod" pod. | Command:
```bash
kubectl logs -p -c nano-bot database-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"... |
Update the pod identified by the type and name in "preferences.yaml" and set the label 'status' to 'unhealthy' | Command:
```bash
kubectl label -f preferences.yaml status=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",... |
Start a proxy to the Kubernetes API server on port 8181, and serve static content from the ./local/www/ directory. | Command:
```bash
kubectl proxy --port=8181 --www=./local/www/
```
What it does:
Creates a proxy server or application-level gateway between localhost and the Kubernetes API server. It also allows serving static content over specified HTTP path. All incoming data enters through one port and gets forwarded to the remote... |
Import the 'secret_key' key from the 'monitoring-config' config map into the 'monitoring-stack-deployment' deployment. | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/monitoring-config deployment/monitoring-stack-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable ... |
Execute the command 'nginx -g "daemon off;"' inside the 'warp-drive' container of the 'proxy-server-pod' pod and print the output. | Command:
```bash
kubectl exec proxy-server-pod -c warp-drive -- nginx -g "daemon off;"
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name.... |
Create a new config map named global-config and include the contents of file1.txt as the 'conf' key and file2.txt as the 'data' key. | Command:
```bash
kubectl create configmap global-config --from-file=conf=/path/to/configurations/file1.txt --from-file=data=/path/to/data/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 a job with a command by running a composer command using the php image | Command:
```bash
kubectl create job deployment-rollout-job --image=php -- composer --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": "... |
Import the 'smtp_server' key from the 'monitoring-config' config map and set it as an environment variable in the 'notification-handler-deployment' deployment. | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/monitoring-config deployment/notification-handler-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment vari... |
Copy a file from a local directory to a remote pod in a specific namespace, preserving the file names and directory structure. | Command:
```bash
kubectl cp :/tmp/foo default/cache-pod-5::/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 the kubectl.kube... |
List the deployments in YAML output format, specifically in the "v1.1.1" version of the "api-v1" API group. | Command:
```bash
kubectl get deployments.v1.1.1.api-v1 -o yaml
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you will onl... |
Forward local traffic from port 9090 to port 8888 in a pod selected by the deployment named "authentication-service-deployment" | Command:
```bash
kubectl port-forward deployment/authentication-service-deployment 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, ... |
Create a secret named app-config-secret from an env file | Command:
```bash
kubectl create secret generic app-config-secret --from-env-file=path/to/settings.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 ba... |
Copy the ~/.config/kube directory from the "api-server-pod-3" pod in the "default" namespace to the "/tmp/bar_dir" directory on your local machine. | Command:
```bash
kubectl cp default/api-server-pod-3:~/.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 omitted, use the... |
List deployments in JSON output format, using the "v1.1.0" version of the "api-v2" API group. | Command:
```bash
kubectl get deployments.v1.1.0.api-v2 -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 you will onl... |
Remove the taint with key 'disktype' and effect 'NoSchedule' from node 'node-2' if it exists. | Command:
```bash
kubectl taint nodes node-2 disktype: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... |
forward the traffic on port 5432 from all available addresses to port 9090 in the 'chat-app-pod' pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/chat-app-pod 5432:9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will... |
Create a cluster role named "bar" and specify the resources and resource names with the desired permissions | Command:
```bash
kubectl create clusterrole bar --verb=update --resource=configmaps --resource-name=audit-logger --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-run=server|cli... |
Create a copy of the security-service-pod and change all container images to php for debugging. | Command:
```bash
kubectl debug security-service-pod --copy-to=debug-image-api --set-image=*=php
```
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 n... |
Add a taint to nodes with a specific label | Command:
```bash
kubectl taint node -l release=beta workload=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... |
Create a new generic secret named private-key-secret in the current namespace with keys for each file in the folder path/to/configs. | Command:
```bash
kubectl create secret generic private-key-secret --from-file=path/to/configs
```
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 o... |
Forward local traffic from port 8088 to the pod selected by the 'search-engine-deployment' deployment on port 8081 | Command:
```bash
kubectl port-forward deployment/search-engine-deployment 8088 8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod wil... |
Add a taint with key 'app' on nodes having label tier=frontend | Command:
```bash
kubectl taint node -l tier=frontend app=worker-node-3: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... |
Wait for the pod named "gateway-pod" to become ready | Command:
```bash
kubectl wait --for=condition=Ready pod/gateway-pod
```
What it does:
Experimental: Wait for a specific condition on one or many resources.
The command takes multiple resources and waits until the specified condition is seen in the Status field of every given resource.
Alternatively, the command can wa... |
Forward traffic from port 5000 on all addresses to port 8081 in the frontend-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/frontend-pod 5000: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... |
Retrieve the logs of the previously terminated nano-bot container from the payment-gateway-pod pod | Command:
```bash
kubectl logs -p -c nano-bot payment-gateway-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 deployment named 'auth' using the 'confluentinc/cp-kafka' image and expose port 8010 | Command:
```bash
kubectl create deployment auth --image=confluentinc/cp-kafka --port=8010
```
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 form... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.