prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Create an ingress called 'app1-ingress' with a rule that directs requests for 'foo.com/bar' to 'svc1:7000' and use the TLS secret 'my-cert' for secure communication. | Command:
```bash
kubectl create ingress app1-ingress --rule="foo.com/bar=svc1:7000,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": "Ou... |
Set a custom TLS server name for the web-cluster cluster entry. | Command:
```bash
kubectl config set-cluster web-cluster --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-authority... |
Create a copy of the frontend-pod with a debug container named dgb-img | Command:
```bash
kubectl debug frontend-pod -it --copy-to=dgb-img --image=debian --set-image=proxy=nginx:1.21,api=api:v2
```
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 wil... |
Partially update a node using a strategic merge patch with a JSON patch | Command:
```bash
kubectl patch node backup-node-14 -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 fla... |
Remove the label 'role' from the pod named 'proxy' | Command:
```bash
kubectl label pods proxy role-
```
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 true, ... |
Retrieve snapshot logs from the 'mypod-1' container of the 'log-aggregator-deployment' deployment | Command:
```bash
kubectl logs deployment/log-aggregator-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": "-... |
Forward local port 3000 to the targetPort of the "https" service port in a selected pod | Command:
```bash
kubectl port-forward service/scheduler-service 3000: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... |
Set the service account of a deployment to kube-scheduler | Command:
```bash
kubectl set serviceaccount deployment web-app-deployment kube-scheduler
```
What it does:
Update the service account of pod template resources.
Possible resources (case insensitive) can be:
replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset
Syntax:
`kub... |
Create a debug container in a pod using a custom debugging image | Command:
```bash
kubectl debug --image=myproj/debug-tools -c debug-image-memcached mypod
```
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 resou... |
Check if you have permission to list the 'cron-job' job in the 'kube-dns' namespace | Command:
```bash
kubectl auth can-i list jobs.batch/cron-job -n kube-dns
```
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 sta... |
Remove an environment variable from a specific container in all deployment configurations | Command:
```bash
kubectl set env deployments --all --containers="quantum-quark" 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... |
Set the annotation 'team' with the value 'frontend team' on the pod named 'email'. | Command:
```bash
kubectl annotate pods email 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 s... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/global-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 definitions... |
Create a Pod Disruption Budget named statefulset-pdb that will select all pods with the label "app=nginx" and requires at least 50% of the selected pods to be available at any point in time. | Command:
```bash
kubectl create pdb statefulset-pdb --selector=app=nginx --min-available=50%
```
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|... |
Start a redis pod with the name 'hazelcast' and let the container inside the pod expose port 8443 | Command:
```bash
kubectl run hazelcast --image=redis --port=8443
```
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... |
Retrieve the output from running the 'elasticsearch' command inside the 'time-machine' container of the 'proxy-server-pod' pod. | Command:
```bash
kubectl exec proxy-server-pod -c time-machine -- 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. If omi... |
Set the CPU and memory limits of a specific container in a deployment. | Command:
```bash
kubectl set resources deployment centos -c=nginx --limits=cpu=200m,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 t... |
Create a cluster role named "foo" with the ResourceName specified | Command:
```bash
kubectl create clusterrole foo --verb=use --resource=services --resource-name=auth-proxy --resource-name=file-storage
```
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]`
... |
Check if you have permission to list the 'deploy-artifacts-job' job in the 'logging' namespace | Command:
```bash
kubectl auth can-i list jobs.batch/deploy-artifacts-job -n logging
```
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... |
Forward data between local port 8000 and port 8080 in the 'api-service-pod' pod | Command:
```bash
kubectl port-forward pod/api-service-pod 8000 8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected au... |
Create a new config map named db-config using the data from a specified folder | Command:
```bash
kubectl create configmap db-config --from-file=path/to/data
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a config map based on a file, the key will default to the basename of the... |
Create a new secret named gcp-service-account-secret in the default namespace using the files in the path/to/settings folder. | Command:
```bash
kubectl create secret generic gcp-service-account-secret --from-file=path/to/settings
```
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 b... |
Embed certificate authority data for a cluster entry named "prod-cluster" | Command:
```bash
kubectl config set-cluster prod-cluster --embed-certs --certificate-authority=~/.kube/sun-cluster/kubernetes.ca.crt
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-... |
Set the cluster field of the 'app-1-context' context to 'cluster-gamma' | Command:
```bash
kubectl config set contexts.app-1-context.cluster cluster-gamma
```
What it does:
Set an individual value in a kubeconfig file.
PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.
PROPERTY_VALUE is the new value you w... |
Forward local port 8000 to port 8000 in the backend-pod | Command:
```bash
kubectl port-forward pod/backend-pod 8000:8000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automa... |
Update a specific node by applying a JSON patch | Command:
```bash
kubectl patch node app-node-6 -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]`
Helpfu... |
Create a cluster role named "view" with specific resource names | Command:
```bash
kubectl create clusterrole view --verb=watch --resource=pods --resource-name=notification-service --resource-name=staging-app-server
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server... |
Update the label of the pod 'foo' to have the value 'backend' with the key 'tier' | Command:
```bash
kubectl label pods foo 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 t... |
Execute the command 'pip --version' in the 'nebula-navigator' container of the 'web-app-pod' pod and display the output. | Command:
```bash
kubectl exec web-app-pod -c nebula-navigator -- pip --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 omit... |
Set the environment variable 'encryption-key' in the 'load-balancer-deployment' deployment, using the value from the 'encryption-key-secret' secret. | Command:
```bash
kubectl set env --from=secret/encryption-key-secret deployment/load-balancer-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one o... |
Get the output from running the 'jenkins-plugin-cli' command in the 'time-machine' container of the 'media-stream-pod' pod. | Command:
```bash
kubectl exec media-stream-pod -c time-machine -- 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. I... |
Create a new config map named "app-name-config" by using specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-name-config --from-file=properties=/path/to/options/file1.txt --from-file=key1=/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 crea... |
Copy the file ~/.config/kube from the local machine to the directory /tmp/bar_dir in the pod named metrics-exporter-pod-10 in the istio-system namespace. | Command:
```bash
kubectl cp ~/.config/kube istio-system/metrics-exporter-pod-10:/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 omit... |
Remove the taint with key 'zone' from node 'prod-node-5' | Command:
```bash
kubectl taint nodes prod-node-5 zone-
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json|yaml|name... |
Forward traffic from port 8888 on localhost and IP 10.19.21.23 to port 5432 in the pod "log-aggregator-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/log-aggregator-pod 8888:5432
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the ... |
Set the cluster field in the 'dev-context' context to 'edge-cluster' | Command:
```bash
kubectl config set contexts.dev-context.cluster edge-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 want... |
Create an ingress called 'internal-ingress' that routes requests for testing.com/bar to svc1:8080 and uses the TLS secret "my-cert" | Command:
```bash
kubectl create ingress internal-ingress --rule="testing.com/bar=svc1:8080,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usa... |
Display only the most recent 5 lines of output in the logs of pod "e-commerce-pod" | Command:
```bash
kubectl logs --tail=5 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", "short": "-... |
Update the service account of the deployment "log-aggregator-deployment" to "metrics-server" | Command:
```bash
kubectl set serviceaccount deployment log-aggregator-deployment metrics-server
```
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
Synta... |
Wait for the pod "e-commerce-pod" to be deleted, with a timeout of 60s, after deleting it. | Command:
```bash
kubectl delete pod/e-commerce-pod
kubectl wait --for=delete pod/busybox1 --timeout=60s
```
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 resourc... |
Copy the `~/.config/kube` file from a remote pod named `api-server-pod-3` to the local `/etc/kubernetes` directory. | Command:
```bash
kubectl cp kube-server/api-server-pod-3:~/.config/kube /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, ... |
Execute the command 'apk add curl' inside the first container of the 'notification-handler-deployment' deployment and display the output. | Command:
```bash
kubectl exec deploy/notification-handler-deployment -- apk add curl
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. I... |
Create a new config map named monitoring-config with specified keys and values from the provided files | Command:
```bash
kubectl create configmap monitoring-config --from-file=conf=/path/to/configs/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 creating... |
Use vi as the editor for editing the analytics-service service | Command:
```bash
KUBE_EDITOR="vi" kubectl edit svc/analytics-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... |
Get the output from running the 'sleep 3600' command in the container 'mycontainer' from the pod 'frontend-pod' | Command:
```bash
kubectl exec frontend-pod -c mycontainer -- sleep 3600
```
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 a new secret named aws-credentials-secret using both a file and a literal value | Command:
```bash
kubectl create secret generic aws-credentials-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 b... |
Update the label of the pod 'backend' to have the key 'app' and the value 'myapp'. | Command:
```bash
kubectl label pods backend 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 ... |
Return the snapshot logs from the 'frontend-pod' container of the 'cache-cluster-deployment-1' deployment. | Command:
```bash
kubectl logs deployment/cache-cluster-deployment -c frontend-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:
"fla... |
Remove a taint from a specific node | Command:
```bash
kubectl taint nodes gpu-node-12 app: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 format. One of... |
Start a pod with a custom spec using JSON overrides | Command:
```bash
kubectl run nginx --image=docker.elastic.co/elasticsearch/elasticsearch --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] [--over... |
Forward local port 6379 to port 5432 in the pod "web-app-pod" | Command:
```bash
kubectl port-forward pod/web-app-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 automa... |
Scale the mysql deployment named frontend-rs to 5 replicas | Command:
```bash
kubectl scale --current-replicas=1 --replicas=5 deployment/frontend-rs
```
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... |
List deployments in the specified API group and version, and display the output in JSON format. | Command:
```bash
kubectl get deployments.dev-2.2.0.my-apps -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... |
import the SECRET_KEY key from the log-config config map into the environment variables of the backend-microservice-deployment deployment | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/log-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 variable def... |
Create a copy of the database-pod in an interactive session and change the command to use the time-machine container | Command:
```bash
kubectl debug database-pod -it --copy-to=debug-image-memcached --container=time-machine -- 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 ... |
Import the value of the 'my-example-key' key from the 'kube-system-config' config map into the environment variables of the 'cache-cluster-deployment' deployment. | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/kube-system-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 variabl... |
Forward traffic from port 9090 on localhost and IP 10.19.21.23 to port 8081 in the pod named 'mypod' | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/mypod 9090: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 p... |
Set the custom TLS server name 'on-prem-cluster' to be used for validation for the 'staging-cluster' cluster entry. | Command:
```bash
kubectl config set-cluster staging-cluster --tls-server-name=on-prem-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] [--certi... |
Update the label of the pod named 'web' to set the 'role' label to 'cache' | Command:
```bash
kubectl label pods web role=cache
```
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 tru... |
Embed the certificate authority data for the 'moon-cluster' cluster entry using the provided certificate authority file. | Command:
```bash
kubectl config set-cluster moon-cluster --embed-certs --certificate-authority=~/.kube/cloud-cluster/kubernetes.ca.crt
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config se... |
Copy the directory "/tmp/foo_dir" from the remote pod "web-app-pod-1" to the local directory "/tmp/bar_dir". | Command:
```bash
kubectl cp rook-ceph/web-app-pod-1:/tmp/foo_dir /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 ku... |
Begin streaming the logs of the 'mycontainer' container in the 'monitoring-pod' pod. | Command:
```bash
kubectl logs -f -c mycontainer monitoring-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... |
Switch to raw terminal mode and attach to the lunar-launcher container in the database-pod | Command:
```bash
kubectl attach database-pod -c lunar-launcher -i -t
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omi... |
Get the logs of container `auth-service-pod-1` in the deployment `analytics-platform-deployment`. | Command:
```bash
kubectl logs deployment/analytics-platform-deployment -c auth-service-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful fl... |
Create a copy of the 'web-app-pod' with all container images changed to 'alpine' and name it 'debug-image-app' | Command:
```bash
kubectl debug web-app-pod --copy-to=debug-image-app --set-image=*=alpine
```
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 reso... |
Create a new config map named "app-name-config" and populate it with values from specific files | Command:
```bash
kubectl create configmap app-name-config --from-file=properties=/path/to/properties/file1.txt --from-file=key1=/path/to/preferences/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When ... |
Create a copy of the security-service-pod named debug-image-api, with a debian based debug container and updated container images for web (nginx:latest) and cache (redis:alpine). | Command:
```bash
kubectl debug security-service-pod -it --copy-to=debug-image-api --image=debian --set-image=web=nginx: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... |
Create a new secret named api-key-secret with specified keys instead of names on disk using the ssh-privatekey and ssh-publickey files located at path/to/id_rsa and path/to/id_rsa.pub, respectively. | Command:
```bash
kubectl create secret generic api-key-secret --from-file=ssh-privatekey=path/to/id_rsa --from-file=ssh-publickey=path/to/id_rsa.pub
```
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 ... |
Add a taint with key 'zone' on nodes having label feature=feature-xyz. Set the taint to 'PreferNoSchedule' on node-2. | Command:
```bash
kubectl taint node -l feature=feature-xyz zone=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": "Out... |
Rename the context 'prod-context' to 'user-b-context' in your kubeconfig file | Command:
```bash
kubectl config rename-context prod-context user-b-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 ... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/app-config-prod 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 variab... |
Create a service for a replica set named "python" using the specified ports | Command:
```bash
kubectl expose rs python --port=3306 --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.... |
Create a debug copy of email-service-pod by adding a debug container and changing container images | Command:
```bash
kubectl debug email-service-pod -it --copy-to=debug-image-memcached --image=debian --set-image=proxy=nginx:1.21,proxy=nginx:1.21
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by re... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/app-secrets deployment/user-management-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defini... |
List specific resources by their types and names. | Command:
```bash
kubectl get rc/web service/proxy-service-rc pods/monitoring-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 names... |
set the resource request and limits for all containers in the mongo deployment. | Command:
```bash
kubectl set resources deployment mongo --limits=cpu=200m,memory=512Mi --requests=cpu=200m,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 reques... |
Execute the 'dotnet' command inside the cosmic-container in the media-stream-pod and retrieve the output | Command:
```bash
kubectl exec media-stream-pod -c cosmic-container -- 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 omitte... |
Attach to the "gateway-pod" pod and get the output from the "nano-bot" container | Command:
```bash
kubectl attach gateway-pod -c nano-bot
```
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, use the... |
Create a cluster role named "foo" that allows the specified API Group actions on deployments.apps resources | Command:
```bash
kubectl create clusterrole foo --verb=use,delete,connect --resource=deployments.apps
```
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... |
Update the nginx container image from a local file without making changes to the server and view the result in YAML format. | Command:
```bash
kubectl set image -f path/to/file.yaml golang=golang:1.17 --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... |
Import the 'max_connections' key from the 'app-config-dev' config map into the 'backend-microservice-deployment' deployment. | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/app-config-dev 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 var... |
Create a debug pod based on the frontend-pod, while replacing all container images with busybox | Command:
```bash
kubectl debug frontend-pod --copy-to=dgb-img --set-image=*=busybox
```
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 i... |
Add a taint with key 'workload' on nodes having label myLabel | Command:
```bash
kubectl taint node -l myLabel workload=backup-node-14:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Out... |
Set the username and password as admin and uXFGweU9l35qcif respectively, for the "john.doe" entry. | Command:
```bash
kubectl config set-credentials john.doe --username=admin --password=uXFGweU9l35qcif
```
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
Be... |
Copy the /var/run/secrets/kubernetes.io/serviceaccount/ local file to the /tmp/bar path in the logging-agent-pod-7 pod in the logging namespace. | Command:
```bash
kubectl cp /var/run/secrets/kubernetes.io/serviceaccount/ logging/logging-agent-pod-7::/tmp/bar
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Con... |
Run the command `kubectl exec backend-pod -c astro-container -- kafka-topics --list` to get the output of the `kafka-topics --list` command in the `astro-container` from the `backend-pod`. | Command:
```bash
kubectl exec backend-pod -c astro-container -- kafka-topics --list
```
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... |
Create a cluster role named "foo" with the verb "watch" and the resources "services" with the resource names "cache-redis" and "notification-service" | Command:
```bash
kubectl create clusterrole foo --verb=watch --resource=services --resource-name=cache-redis --resource-name=notification-service
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|cli... |
Forward local port 9090 to port 5432 in the pod 'proxy-server-pod' and listen locally on port 6000, forwarding data to/from port 6000 in the pod 'proxy-server-pod' | Command:
```bash
kubectl port-forward pod/proxy-server-pod 9090 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 a... |
Set the service account of the "search-engine-deployment" deployment to "fluentd". | Command:
```bash
kubectl set serviceaccount deployment search-engine-deployment fluentd
```
What it does:
Update the service account of pod template resources.
Possible resources (case insensitive) can be:
replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset
Syntax:
`kube... |
Forward port 6379 on all addresses to port 3000 in the pod named "analytics-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/analytics-pod 6379:3000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod wil... |
Create a copy of the log-aggregator-pod and change all container images to centos | Command:
```bash
kubectl debug log-aggregator-pod --copy-to=dgb-img --set-image=*=centos
```
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 resou... |
Import the API_KEY key from the monitoring-config config map to the proxy-service-deployment deployment | Command:
```bash
kubectl set env --keys=API_KEY --from=configmap/monitoring-config deployment/proxy-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 defini... |
Add a taint with the key 'special' on nodes that have the label 'myLabel' | Command:
```bash
kubectl taint node -l myLabel special=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": "", "usage": "... |
Update the label of the pod 'auth' to include 'component=worker' | Command:
```bash
kubectl label pods auth component=worker
```
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": ... |
Create a new ClusterIP service named ldap-service-clusterip with port mapping from local port 8081 to container port 3000 | Command:
```bash
kubectl create service clusterip ldap-service-clusterip --tcp=8081:3000
```
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 a specific label from a pod | Command:
```bash
kubectl label pods frontend release-
```
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 an ingress named 'app-ingress' with a rule that directs requests from 'website.com/bar' to 'svc1:9090' using the TLS secret 'my-cert' | Command:
```bash
kubectl create ingress app-ingress --rule="website.com/bar=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": ... |
Create a new ExternalName service named external-identity-provider-service and set the external name to sample-domain.net | Command:
```bash
kubectl create service externalname external-identity-provider-service --external-name sample-domain.net
```
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 re... |
Create a single ingress called 'app1-ingress' that directs requests to site.com/bar to svc1:8888 with a tls secret named "my-cert" | Command:
```bash
kubectl create ingress app1-ingress --rule="site.com/bar=svc1:8888,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": "O... |
Add a taint with key 'dedicated' on nodes having label stack=tech-stack to prevent scheduling new pods on those nodes. | Command:
```bash
kubectl taint node -l stack=tech-stack dedicated=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": "", "usa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.