prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Import specific keys from a config map to a deployment. | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/app-settings 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 def... |
Update the pod specified in "params.json" by adding the annotation "deployment-script" with the value "https://example.com/deploy.sh" | Command:
```bash
kubectl annotate -f params.json 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 th... |
Expose a replication controller specified in a YAML file as a service, serving on port 9092 and connecting to the containers on port 8080 | Command:
```bash
kubectl expose -f ruby-controller.yaml --port=9092 --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 s... |
Add a taint with the key 'workload' and value 'prod-node-5:PreferNoSchedule' on nodes with the label 'owner=john-doe' | Command:
```bash
kubectl taint node -l owner=john-doe workload=prod-node-5:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": ... |
Expose a replicated node as a service, serving on port 80 and connecting to the containers on port 8000 | Command:
```bash
kubectl expose rc node --port=9090 --target-port=818100
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port. A... |
Start a mysql pod with the name "nginx", using the mysql image and override some of the specifications using a JSON file. | Command:
```bash
kubectl run nginx --image=mysql --overrides='{ "apiVersion": "dev-2.2.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] -- [COMM... |
Create a new ClusterIP service named monitoring-service-clusterip with port mapping of port 7000 on the service to port 5001 on the target pods | Command:
```bash
kubectl create service clusterip monitoring-service-clusterip --tcp=7000: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": "... |
Import specific keys from a config map into a deployment's environment variables | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/monitoring-config 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 ... |
Output the modified api-server-deployment deployment in YAML format after setting the environment variable SECRET_KEY to "your-secret-key", and do not alter the deployment on the server. | Command:
```bash
kubectl set env deployment/api-server-deployment SECRET_KEY=your-secret-key -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 mo... |
Create a service for the 'centos' deployment that serves on port 80 and connects to the containers on port 8000 | Command:
```bash
kubectl expose deployment centos --port=3001 --target-port=500000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specifi... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=database_url --from=configmap/app-settings 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... |
Set the service account of the deployment "notification-handler-deployment" to "jenkins" | Command:
```bash
kubectl set serviceaccount deployment notification-handler-deployment jenkins
```
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... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=api_key --from=configmap/env-vars deployment/scheduler-app-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 pod named "hazelcast" using the Ubuntu image and configure it to expose port 6379. | Command:
```bash
kubectl run hazelcast --image=ubuntu --port=6379
```
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": "--f... |
Create an ingress called 'internal-ingress' that directs requests to site.com/example to a service called 'svc1' on port 8181, and use the TLS secret 'my-cert' for secure communication. | Command:
```bash
kubectl create ingress internal-ingress --rule="site.com/example=svc1:8181,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... |
Copy a file from a pod to your local machine | Command:
```bash
kubectl cp velero/api-server-pod-3:/tmp/foo /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.ku... |
List the deployments in the "v2.0.0" version of the "mobile-apps" API group, and output the results in JSON format. | Command:
```bash
kubectl get deployments.v2.0.0.mobile-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 wil... |
Get the output from running the 'elasticsearch-plugin --list' command on the first pod of the 'cache-cluster-deployment' deployment | Command:
```bash
kubectl exec deploy/cache-cluster-deployment -- elasticsearch-plugin --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... |
Scale the replica set named 'web' to 7 replicas | Command:
```bash
kubectl scale --replicas=7 rs/web
```
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... |
Create a new NodePort service named ingress-controller-nodeport that maps port 8081 of the cluster to port 3001 of the service. | Command:
```bash
kubectl create service nodeport ingress-controller-nodeport --tcp=8081:3001
```
What it does:
Create a NodePort service with the specified name.
Syntax:
`kubectl create service nodeport NAME [--tcp=port:targetPort] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "de... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/app-name-config 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 ... |
Import environment variables with a prefix MYSQL_ from the config map app-settings into the frontend-deployment deployment | Command:
```bash
kubectl set env --from=configmap/app-settings --prefix=MYSQL_ 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 ... |
Import specific keys from a config map into the environment variables of a deployment | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/app-name-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 definiti... |
Add a taint with key 'hardware' on nodes having the label region=eu-west-2 | Command:
```bash
kubectl taint node -l region=eu-west-2 hardware=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":... |
Forward local port 6379 to port 6379 in the pod named "web-app-pod" | Command:
```bash
kubectl port-forward pod/web-app-pod 6379:6379
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automa... |
Forward traffic from port 8080 on localhost and IP 10.19.21.23 to port 8081 in the log-aggregator-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/log-aggregator-pod 8080: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 ... |
Copy the file '/tmp/foo' from the remote pod 'ingress-controller-pod-8' in the 'kube-dns' namespace to the local directory '/tmp/bar' | Command:
```bash
kubectl cp kube-dns/ingress-controller-pod-8:/tmp/foo /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 ... |
Add a label "tier=database" to the pod named "analytics" | Command:
```bash
kubectl label pods analytics tier=database
```
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"... |
Add a taint with key 'datacenter' on nodes having the label 'namespace=mynamespace' | Command:
```bash
kubectl taint node -l namespace=mynamespace datacenter=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": "", "u... |
Create a deployment named 'web' with the image 'ethereum/client-go' and 7 replicas. | Command:
```bash
kubectl create deployment web --image=ethereum/client-go --replicas=7
```
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.... |
Listen on port 8888 locally, forwarding to the targetPort of the service's port named "https" in the pod selected by the service "order-service" | Command:
```bash
kubectl port-forward service/order-service 8888: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 selected... |
Create a pod disruption budget named database-pdb that will select all pods with the project=my-project label and require at least one of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget database-pdb --selector=project=my-project --min-available=1
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=... |
Configure the certificate authority data for the "galaxy-cluster" cluster entry | Command:
```bash
kubectl config set-cluster galaxy-cluster --embed-certs --certificate-authority=~/.kube/star-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 s... |
Return the snapshot logs from the container 'frontend-pod-1' of the 'email-server-deployment' deployment | Command:
```bash
kubectl logs deployment/email-server-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:
"flag... |
Set the resource request and limits for all containers in the Redis deployment. | Command:
```bash
kubectl set resources deployment redis --limits=cpu=200m,memory=512Mi --requests=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 requeste... |
Create an ingress that directs requests to a specific service with TLS encryption | Command:
```bash
kubectl create ingress rontend-ingress --rule="site.com/example=svc1:3000,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usa... |
Create a new config map named log-config from a file containing key=value pairs | Command:
```bash
kubectl create configmap log-config --from-file=path/to/parameters
```
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 new secret named database-secret in the default namespace, using the specified keys instead of names on disk | Command:
```bash
kubectl create secret generic database-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... |
Import the 'config_file_path' key from the 'log-config' config map into the 'load-balancer-deployment' deployment | Command:
```bash
kubectl set env --keys=config_file_path --from=configmap/log-config 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 defi... |
Import specific keys from a config map for a deployment | Command:
```bash
kubectl set env --keys=REDIS_HOST --from=configmap/ui-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 defi... |
Set a custom TLS server name for the "moon-cluster" cluster entry | Command:
```bash
kubectl config set-cluster moon-cluster --tls-server-name=star-cluster
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-cluster NAME [--server=server] [--certificate... |
Create an ingress rule that directs requests to a specific service and port, with TLS enabled for a specific domain. | Command:
```bash
kubectl create ingress public-ingress --rule="website.com/module=svc1:8000,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "us... |
Copy the directory "/tmp/foo_dir" from the remote pod "worker-pod-4" in the "kube-proxy" namespace to the local "/tmp/bar" directory. | Command:
```bash
kubectl cp kube-proxy/worker-pod-4:/tmp/foo_dir /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 kubect... |
Add a taint with the key 'app' to all nodes having the label feature=feature-xyz | Command:
```bash
kubectl taint node -l feature=feature-xyz app=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": "", "u... |
Execute the command 'apache2ctl -D FOREGROUND' in the quantum-quark container of the web-app-pod pod and display the output. | Command:
```bash
kubectl exec web-app-pod -c quantum-quark -- apache2ctl -D FOREGROUND
```
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.... |
Forward traffic from port 6379 on localhost and IP 10.19.21.23 to port 3000 in the frontend-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/frontend-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 criter... |
Attach to the 'mycontainer' container in the 'vpn-service-pod' pod, enabling interactive mode and switching to raw terminal mode | Command:
```bash
kubectl attach vpn-service-pod -c mycontainer -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... |
Set the service account of the deployment "notification-handler-deployment" to "fluentd" | Command:
```bash
kubectl set serviceaccount deployment notification-handler-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... |
import environment variables from a secret for a deployment | Command:
```bash
kubectl set env --from=secret/tls-certificate-secret deployment/scheduler-app-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 ... |
Copy the file "/tmp/foo" from the pod "web-app-pod-1" in the "logging" namespace to the local directory "/etc/kubernetes". | Command:
```bash
kubectl cp logging/web-app-pod-1:/tmp/foo /etc/kubernetes
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubec... |
Execute the 'irb' command inside the time-machine container of the gateway-pod and display the output. | Command:
```bash
kubectl exec gateway-pod -c time-machine -- irb
```
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 k... |
Create a new secret named private-key-secret with keys for each file in the specified folder | Command:
```bash
kubectl create secret generic private-key-secret --from-file=path/to/preferences
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, the key will default to the basena... |
Create a copy of the 'analytics-pod' with the name 'my-custom-dbg' and change all container images to 'alpine' | Command:
```bash
kubectl debug analytics-pod --copy-to=my-custom-dbg --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 an ingress called 'api-v1-ingress' that directs requests for testing.com/input to svc1:6379 using a TLS secret named "my-cert" | Command:
```bash
kubectl create ingress api-v1-ingress --rule="testing.com/input=svc1:6379,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usa... |
Import the 'DATABASE_URL' key from the 'app-name-config' config map and set it as an environment variable for the 'authentication-service-deployment' deployment. | Command:
```bash
kubectl set env --keys=DATABASE_URL --from=configmap/app-name-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 var... |
Update the description annotation of the 'foo' pod if the resource version is still 1 | Command:
```bash
kubectl annotate pods foo description='my frontend running nginx' --resource-version=1
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larg... |
Copy the /tmp/foo file from your local machine to the /tmp/bar directory in the remote pod named file-server-pod-14 in the kube-node-lease namespace. | Command:
```bash
kubectl cp /tmp/foo kube-node-lease/file-server-pod-14:/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... |
Forward port 8081 of the pod named "e-commerce-pod" to port 8081 on all addresses | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/e-commerce-pod 8081:8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod wi... |
Import the 'MAX_CONNECTIONS' key from the 'kube-system-config' config map to the 'web-app-deployment' deployment | Command:
```bash
kubectl set env --keys=MAX_CONNECTIONS --from=configmap/kube-system-config deployment/web-app-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... |
Attach to the 'vpn-service-pod' pod and get output from the 'rocket-ranger' container | Command:
```bash
kubectl attach vpn-service-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... |
Add a taint with the key 'disktype' and value 'app-node-6:PreferNoSchedule', on nodes that have the label 'customer=acme-corp'. | Command:
```bash
kubectl taint node -l customer=acme-corp disktype=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... |
Create a new config map named ui-config with the specified keys and values sourced from the specified file locations | Command:
```bash
kubectl create configmap ui-config --from-file=settings=/path/to/preferences/file1.txt --from-file=key2=/path/to/configurations/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... |
Create a cron job named "data-processing" with the image "ubuntu" and schedule it to run every minute | Command:
```bash
kubectl create cronjob data-processing --image=ubuntu --schedule="*/1 * * * *" -- docker run ubuntu echo "Hello
```
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": "--o... |
Create a new config map named "monitoring-config" using the specified files as key-value pairs | Command:
```bash
kubectl create configmap monitoring-config --from-file=settings=/path/to/configs/file1.txt --from-file=key2=/path/to/profiles/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creati... |
Attach to a specific container within a pod to get its output | Command:
```bash
kubectl attach cdn-service-pod -c mycontainer
```
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, ... |
Return snapshot logs from all containers in pods that are labeled as 'tier=frontend' | Command:
```bash
kubectl logs -l tier=frontend --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": "--containe... |
Forward local port 8081 to port 6379 in the 'e-commerce-pod' pod | Command:
```bash
kubectl port-forward pod/e-commerce-pod 8081:6379
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected aut... |
Return the snapshot logs from container analytics-platform-deployment-1 of a deployment named mypod. | Command:
```bash
kubectl logs deployment/analytics-platform-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"... |
Import the LOG_LEVEL key from the app-name-config config map and set it as an environment variable in the authentication-service-deployment deployment. | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/app-name-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 variab... |
Create a copy of the proxy-server-pod named debug-image-web with all container images changed to alpine | Command:
```bash
kubectl debug proxy-server-pod --copy-to=debug-image-web --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... |
deny the Certificate Signing Request (CSR) with the name 'csr-redis-11' | Command:
```bash
kubectl certificate deny csr-redis-11
```
What it does:
Deny a certificate signing request.
kubectl certificate deny allows a cluster admin to deny a certificate signing request (CSR). This action tells a certificate signing controller to not to issue a certificate to the requestor.
Syntax:
`kubectl ... |
Update the 'scheduler-app-deployment' deployment with a new environment variable. | Command:
```bash
kubectl set env deployment/scheduler-app-deployment DB_PASSWORD=secretpassword
```
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 po... |
Create a cluster role named "reader" with specific resource names. | Command:
```bash
kubectl create clusterrole reader --verb=create --resource=services --resource-name=error-logger --resource-name=nginx-proxy
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|client|... |
Create a pod disruption budget named auth-service-pdb that will select all pods with the env=production label and require at least one of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget auth-service-pdb --selector=env=production --min-available=1
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=... |
Copy the local file /tmp/foo_dir to the remote pod kube-dns/logging-agent-pod-7 in the /tmp/bar_dir directory in the namespace | Command:
```bash
kubectl cp /tmp/foo_dir kube-dns/logging-agent-pod-7:/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... |
Forward local traffic from port 3000 to pod port 5000 for a specific deployment | Command:
```bash
kubectl port-forward deployment/analytics-platform-deployment 3000 5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a po... |
Forward traffic from local port 5000 to port 3000 in the 'proxy-server-pod' pod | Command:
```bash
kubectl port-forward pod/proxy-server-pod 5000:3000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected a... |
Copy the contents of the /var/run/secrets/kubernetes.io/serviceaccount/ directory from the task-processor-pod-17 pod in the kube-public namespace to the /tmp/bar directory on your local machine. | Command:
```bash
kubectl cp kube-public/task-processor-pod-17:/var/run/secrets/kubernetes.io/serviceaccount/ /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":... |
Listen on port 6379 locally and forward data to/from port 3000 in the log-aggregator-deployment pod | Command:
```bash
kubectl port-forward deployment/log-aggregator-deployment 6379 3000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod wi... |
Forward local port 3000 to port 8081 in the analytics-pod. | Command:
```bash
kubectl port-forward pod/analytics-pod 3000:8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected auto... |
Copy the file named "foo" located at "/tmp" directory on the pod named "file-server-pod-14" in the "rook-ceph" namespace to the "/tmp" directory locally. | Command:
```bash
kubectl cp rook-ceph/file-server-pod-14:/tmp/foo /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 kubec... |
Get output from running 'geth' command in the first pod of the email-service service. | Command:
```bash
kubectl exec svc/email-service -- geth
```
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... |
Start a redis pod with the busybox image, and keep it running in the foreground. Do not restart the pod if it exits. | Command:
```bash
kubectl run -i -t busybox --image=redis --restart=Never
```
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... |
Forward data between local ports 5000 and 6000, and ports 5432 and 6000 in the security-service-pod pod | Command:
```bash
kubectl port-forward pod/security-service-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 criteria, a pod will be select... |
Update the image of all containers in the daemonset named "namespace-1" to "openjdk:16.0.2". | Command:
```bash
kubectl set image daemonset namespace-1 *=openjdk:16.0.2
```
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... |
Auto scale the replication controller "backend" by setting the maximum number of pods to 4 and target CPU utilization at 50% | Command:
```bash
kubectl autoscale rc backend --max=4 --cpu-percent=50
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that uses... |
Set the cluster entry for "edge-cluster" and embed the certificate authority data. | Command:
```bash
kubectl config set-cluster edge-cluster --embed-certs --certificate-authority=~/.kube/testing-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 ... |
Copy the local directory ~/.config/kube_dir to the remote pod payment-gateway-pod-19 in the default namespace, and place it in the /tmp/bar_dir directory. | Command:
```bash
kubectl cp ~/.config/kube_dir payment-gateway-pod-19::/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 ... |
Copy the local file "/tmp/foo_dir" to the remote pod "prometheus/file-server-pod-14" in the namespace, and place it in the "/tmp/bar_dir" directory. | Command:
```bash
kubectl cp /tmp/foo_dir prometheus/file-server-pod-14:/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 ... |
Update the label of the 'email' pod to have the label 'tier' with the value 'frontend' | Command:
```bash
kubectl label pods email tier=frontend
```
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... |
List deployments in YAML output format using the beta-1.0 version of the extensions API group. | Command:
```bash
kubectl get deployments.beta-1.0.extensions -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 wi... |
create a service using a replication controller configuration file | Command:
```bash
kubectl expose -f ubuntu-controller.yaml --port=5000 --target-port=808200
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the... |
Create a service for the replicated hazelcast with port 80, which connects to the container on port 8000. | Command:
```bash
kubectl expose rc hazelcast --port=3306 --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 po... |
Retrieve previous terminated container logs from a specific pod | Command:
```bash
kubectl logs -p -c mycontainer backend-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", "shor... |
Forward traffic from port 8081 on all addresses to port 8000 in the security-service-pod pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/security-service-pod 8081: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 ... |
Listen on port 6379 on all addresses and forward the traffic to port 8080 in the api-service-pod pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/api-service-pod 6379:8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod w... |
Expose the replication controller defined in "hazelcast-controller.yaml" as a service, serving on port 5432 and connecting to containers on port 801000. | Command:
```bash
kubectl expose -f hazelcast-controller.yaml --port=5432 --target-port=801000
```
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 ... |
Execute the 'irb' command inside the pod named frontend-pod and display the output. | Command:
```bash
kubectl exec frontend-pod -- irb
```
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.kubernet... |
Get the output from running the 'elasticsearch --version' command on the first pod of the 'web-app-deployment' deployment. | Command:
```bash
kubectl exec deploy/web-app-deployment -- 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": "Container name. If ... |
Get the output from the `cosmic-container` inside the `cdn-service-pod`. | Command:
```bash
kubectl attach cdn-service-pod -c cosmic-container
```
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.