prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Create a pod named "hazelcast" using the "wordpress" image, and expose port 6379 | Command:
```bash
kubectl run hazelcast --image=wordpress --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": "... |
Forward local port 8081 to pod port 8080 | Command:
```bash
kubectl port-forward pod/proxy-server-pod 8081 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 a... |
Import specific keys from a config map into a deployment's environment variables | Command:
```bash
kubectl set env --keys=REDIS_HOST --from=configmap/app-config-prod 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 defin... |
Create a deployment named "app" that runs the "mongo" image and exposes port 8083. | Command:
```bash
kubectl create deployment app --image=mongo --port=8083
```
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 new config map named app-secrets using the contents of the specified files | Command:
```bash
kubectl create configmap app-secrets --from-file=properties=/path/to/options/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 creating a ... |
Create a new config map named api-config with specified keys instead of file basenames on disk. | Command:
```bash
kubectl create configmap api-config --from-file=conf=/path/to/configurations/file1.txt --from-file=data=/path/to/configs/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a ... |
Forward local port 3000 to port 6379 in the 'frontend-pod' pod | Command:
```bash
kubectl port-forward pod/frontend-pod 3000: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 autom... |
Set the service account for the deployment "monitoring-stack-deployment" to "flux" | Command:
```bash
kubectl set serviceaccount deployment monitoring-stack-deployment flux
```
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 traffic from local port 8081 to port 6379 in the pod named chat-app-pod | Command:
```bash
kubectl port-forward pod/chat-app-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 autom... |
Copy the local file '/tmp/foo' to the '/etc/kubernetes' directory in the 'web-app-pod-1' pod's 'ingress-controller' container. | Command:
```bash
kubectl cp /tmp/foo web-app-pod-1:/etc/kubernetes -c ingress-controller
```
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,... |
Create a cron job named "monthly-audit" using the Jenkins image and schedule it to run every minute | Command:
```bash
kubectl create cronjob monthly-audit --image=jenkins --schedule="*/1 * * * *" -- java -jar /usr/share/jenkins/jenkins.war
```
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:
"f... |
Import the environment variables from the 'gcp-service-account-secret' secret into the 'search-engine-deployment' deployment. | Command:
```bash
kubectl set env --from=secret/gcp-service-account-secret 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 definitions in ... |
Forward local traffic from port 5432 to port 8000 in a pod selected by the 'notification-handler-deployment' deployment | Command:
```bash
kubectl port-forward deployment/notification-handler-deployment 5432 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 ... |
Create a new config map named log-config and provide configuration data from specified files | Command:
```bash
kubectl create configmap log-config --from-file=settings=/path/to/parameters/file1.txt --from-file=key2=/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 creating a ... |
Listen on a local port and forward data to/from a pod's port | Command:
```bash
kubectl port-forward pod/api-service-pod 8080 9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected au... |
Forward port 6379 from your local machine to port 8888 in the web-app-pod | Command:
```bash
kubectl port-forward pod/web-app-pod 6379:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automa... |
Create a NodePort service named "vpn-service-nodeport" | Command:
```bash
kubectl create service nodeport vpn-service-nodeport --tcp=27017:3306
```
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", "default"... |
Forward port 8888 on all addresses to port 6379 in the pod named "api-service-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/api-service-pod 8888: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 w... |
Create a deployment named sonarqube with the jenkins image and expose port 8089 | Command:
```bash
kubectl create deployment sonarqube --image=jenkins --port=8089
```
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 o... |
Forward traffic from port 8088 to port 9090 in the 'analytics-pod' pod, making it accessible on all addresses | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/analytics-pod 8088:9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod wil... |
Create a deployment named "auth" using the "hazelcast/hazelcast" image and expose port 6379 | Command:
```bash
kubectl create deployment auth --image=hazelcast/hazelcast --port=6379
```
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... |
Import specific keys from a config map into the environment of a deployment. | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/app-config-prod 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 varia... |
Execute the 'elasticsearch' command in the 'lunar-launcher' container of the 'cdn-service-pod' pod and display the output. | Command:
```bash
kubectl exec cdn-service-pod -c lunar-launcher -- 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 om... |
Create a service for the replicated python using replica set, which serves on port 6379 and connects to the containers on port 844300 | Command:
```bash
kubectl expose rs python --port=6379 --target-port=844300
```
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.... |
Add the 'release-notes' annotation with the value 'https://example.com/release-notes/v2.5.1' to the pod named 'vpn' | Command:
```bash
kubectl annotate pods vpn release-notes='https://example.com/release-notes/v2.5.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 larger t... |
Import the API_KEY key from the kube-system-config config map into the load-balancer-deployment deployment. | Command:
```bash
kubectl set env --keys=API_KEY --from=configmap/kube-system-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 defin... |
Import the DATABASE_URL key from the app-config-dev config map into the monitoring-stack-deployment deployment | Command:
```bash
kubectl set env --keys=DATABASE_URL --from=configmap/app-config-dev 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 d... |
Forward traffic from port 8088 on all addresses to port 6379 in the pod named "web-app-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/web-app-pod 8088: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 ... |
Switch to raw terminal mode and attach to a specific container in a pod | Command:
```bash
kubectl attach cdn-service-pod -c rocket-ranger -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 o... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=MAX_CONNECTIONS --from=configmap/app-config-dev 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 ... |
Execute the 'geth version' command inside the nano-bot container of the log-aggregator-pod and retrieve the output. | Command:
```bash
kubectl exec log-aggregator-pod -c nano-bot -- geth 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 omitte... |
Create a job for monitoring with a specific command | Command:
```bash
kubectl create job monitoring-job --image=confluentinc/cp-kafka -- kafka-topics --list
```
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": "",... |
Create a pod disruption budget named 'worker-pdb' that will select all pods with the 'tier=frontend' label and require at least four of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget worker-pdb --selector=tier=frontend --min-available=4
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N [--dr... |
Create an ingress called 'web-ingress' that directs requests to 'testing.com/module' to 'svc1:5432' with a TLS secret named "my-cert" | Command:
```bash
kubectl create ingress web-ingress --rule="testing.com/module=svc1:5432,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage... |
Roll back a daemonset to revision 7 | Command:
```bash
kubectl rollout undo daemonset/nginx --to-revision=7
```
What it does:
Roll back to a previous rollout.
Syntax:
`kubectl rollout undo (TYPE NAME | TYPE/NAME) [flags]`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to files identifying the r... |
List the specified resources by their type and names | Command:
```bash
kubectl get rc/web service/gateway-rc pods/log-aggregator-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 namespa... |
Set up autoscaling for the deployment named "vpn" | Command:
```bash
kubectl autoscale deployment vpn --min=2 --max=10
```
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 the... |
Create a new ExternalName service named 'external-security-service' with the external name 'document-company.com' | Command:
```bash
kubectl create service externalname external-security-service --external-name document-company.com
```
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 referenc... |
Update the label of the pod 'foo' by setting the 'status' label to 'unhealthy', overwriting any existing value. | Command:
```bash
kubectl label --overwrite pods foo 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"... |
Embed the certificate authority data for the 'kube-cluster-1' cluster entry using the command `kubectl config set-cluster kube-cluster-1 --embed-certs --certificate-authority=~/.kube/e2e/kubernetes.ca.crt` | Command:
```bash
kubectl config set-cluster kube-cluster-1 --embed-certs --certificate-authority=~/.kube/e2e/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-cluste... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/monitoring-config deployment/frontend-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable def... |
Delete the pods and services with the names "database" and "payment" | Command:
```bash
kubectl delete pod,service database payment
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label selector... |
Roll back the daemonset named development to revision 5 | Command:
```bash
kubectl rollout undo daemonset/development --to-revision=5
```
What it does:
Roll back to a previous rollout.
Syntax:
`kubectl rollout undo (TYPE NAME | TYPE/NAME) [flags]`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to files identifying... |
Copy the contents of the /var/run/secrets/kubernetes.io/serviceaccount/ directory from the remote pod named 'file-server-pod-14' in the 'default' namespace to the local directory /tmp/bar_dir/ | Command:
```bash
kubectl cp default/file-server-pod-14:/var/run/secrets/kubernetes.io/serviceaccount/ /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": "C... |
Create a new NodePort service named proxy-server-nodeport that maps port 8443 on the node to port 8080 on the target pods | Command:
```bash
kubectl create service nodeport proxy-server-nodeport --tcp=8443:8080
```
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", "default"... |
Start a redis pod named 'nginx', but use the JSON provided to override some of its specifications. | Command:
```bash
kubectl run nginx --image=redis --overrides='{ "apiVersion": "v1.0.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND... |
Set the resource request and limits for all containers in the 'runtime' deployment to --limits=cpu=200m,memory=512Mi and --requests=cpu=5,memory=256Mi | Command:
```bash
kubectl set resources deployment runtime --limits=cpu=200m,memory=512Mi --requests=cpu=5,memory=256Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource request... |
Create a pod disruption budget named elastic-search-pdb that will select all pods with the role=worker label and require a minimum of 9 of them to be available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget elastic-search-pdb --selector=role=worker --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... |
Forward port 5432 from all addresses to port 5000 in the frontend-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/frontend-pod 5432: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 pod will... |
Copy a file from a remote pod to a local directory | Command:
```bash
kubectl cp kube-system/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 kub... |
Copy the local file ~/.config/kube to the /tmp/bar_dir directory in the remote pod named message-broker-pod-15 | Command:
```bash
kubectl cp ~/.config/kube message-broker-pod-15:/tmp/bar_dir -c task-processor
```
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 o... |
Create a new NodePort service named my-ns | Command:
```bash
kubectl create service nodeport my-ns --tcp=8088:7000
```
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", "default": "", "usage": "... |
Import the key DEBUG_MODE from the config map 'monitoring-config' into the deployment 'load-balancer-deployment' | Command:
```bash
kubectl set env --keys=DEBUG_MODE --from=configmap/monitoring-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 def... |
Update the node 'testing-node-11' with a taint that has the key 'cpu-type', value 'x86', and effect 'NoSchedule' | Command:
```bash
kubectl taint nodes testing-node-11 cpu-type=x86: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. ... |
Import specific keys from a config map to an environment variable for a deployment. | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/env-vars 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 defini... |
Retrieve the output from running the 'node' command in the 'lunar-launcher' container of the 'payment-gateway-pod' pod. | Command:
```bash
kubectl exec payment-gateway-pod -c lunar-launcher -- node
```
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... |
Execute the command "geth version" inside the frontend-pod, using the first container by default, and print the output. | Command:
```bash
kubectl exec frontend-pod -- geth 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 omitted, use the kubectl... |
Create a new secret named encryption-key-secret using the environment variables specified in the options.env file. | Command:
```bash
kubectl create secret generic encryption-key-secret --from-env-file=path/to/options.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... |
Set a taint on all nodes with the label "team=devops", the taint key should be "zone" and the value should be "app-node-6" with the effect "PreferNoSchedule" | Command:
```bash
kubectl taint node -l team=devops zone=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": "Output ... |
Forward local port 9090 to port 8088 in the pod named "proxy-server-pod" | Command:
```bash
kubectl port-forward pod/proxy-server-pod 9090: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 a... |
Taint a node with a specific key, value, and effect | Command:
```bash
kubectl taint nodes storage-node-13 hardware=gpu:NoExecute
```
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. O... |
Copy the local file /tmp/foo to the remote pod monitoring-agent-pod-6 in the /tmp/bar directory | Command:
```bash
kubectl cp :/tmp/foo monitoring-agent-pod-6:/tmp/bar -c admin-dashboard
```
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,... |
Create an ingress that directs requests from website.com/example to svc1:8888 with a TLS secret called "my-cert" | Command:
```bash
kubectl create ingress public-service-ingress --rule="website.com/example=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"... |
Forward traffic from port 8088 on localhost and IP address 10.19.21.23 to port 8000 in the frontend-pod pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/frontend-pod 8088: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 criter... |
Return the logs of the previous terminated "nano-bot" container from the "vpn-service-pod" pod. | Command:
```bash
kubectl logs -p -c nano-bot vpn-service-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", "sho... |
Create a cron job to rotate logs using the mongo image | Command:
```bash
kubectl create cronjob log-rotation --image=mongo --schedule="*/1 * * * *" -- mongo
```
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": "-o", "defa... |
Create a new pod named "hazelcast" using the image "mongo" and expose port 8000. | Command:
```bash
kubectl run hazelcast --image=mongo --port=8000
```
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 new config map named app-config-dev from an environment file | Command:
```bash
kubectl create configmap app-config-dev --from-env-file=path/to/properties.env
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a config map based on a file, the key will default to ... |
Apply a taint named 'special' with the value 'node-2:PreferNoSchedule' on all nodes that have the label 'myLabel'. | Command:
```bash
kubectl taint node -l myLabel special=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 forma... |
Create a single ingress called 'api-v2-ingress' that directs requests to testing.com/module to service 'svc1' on port 8888, and use the TLS secret named 'my-cert' for secure communication. | Command:
```bash
kubectl create ingress api-v2-ingress --rule="testing.com/module=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": "", "us... |
Forward port 8088 of the pod "log-aggregator-pod" to port 3000 on all addresses. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/log-aggregator-pod 8088:3000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a po... |
Import the 'API_KEY' key from the 'app-name-config' config map and set it as an environment variable for the 'scheduler-app-deployment' deployment. | Command:
```bash
kubectl set env --keys=API_KEY --from=configmap/app-name-config 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 definiti... |
add an annotation to a pod identified by type and name in a setup.json file | Command:
```bash
kubectl annotate -f setup.json SLA='99.9% uptime'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include arbitrary ... |
expose a replica set nginx as a service, serving on port 8083 and connecting to containers on port 909200 | Command:
```bash
kubectl expose rs nginx --port=8083 --target-port=909200
```
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. ... |
Forward local port 8080 to port 8081 in the pod 'log-aggregator-pod' | Command:
```bash
kubectl port-forward 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 criteria, a pod will be selected... |
Update the image of all containers in the 'staging' daemonset to 'python:3.9.7' | Command:
```bash
kubectl set image daemonset staging *=python:3.9.7
```
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:
`kub... |
Embed the certificate authority data for the cluster entry of "app-cluster" | Command:
```bash
kubectl config set-cluster app-cluster --embed-certs --certificate-authority=~/.kube/cluster-alpha/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... |
Replace a pod using the configuration provided in the pod.json file | Command:
```bash
kubectl replace -f ./pod.json
```
What it does:
Replace a resource by file name or stdin.
JSON and YAML formats are accepted. If replacing an existing resource, the complete resource spec must be provided. This can be obtained by
$ kubectl get TYPE NAME -o yaml
Syntax:
`kubectl replace -f FILENAME`
... |
Update the annotation of a pod called 'frontend' with the key 'release-notes' and the value 'https://example.com/release-notes/v2.5.1', overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods frontend release-notes='https://example.com/release-notes/v2.5.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 tha... |
Create a debug pod based on an existing pod, replacing the container image with a Debian image and changing the container image of the database to MySQL 5.7 | Command:
```bash
kubectl debug database-pod -it --copy-to=debug-image-1 --image=debian --set-image=database=mysql:5.7,database=mysql:5.7
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource an... |
Remove all taints with the key 'zone' from the 'node-2' node. | Command:
```bash
kubectl taint nodes node-2 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|go-t... |
Forward local traffic to a specific port in a pod for debugging purposes | Command:
```bash
kubectl port-forward pod/security-service-pod :8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected a... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/global-config deployment/email-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... |
Get the output of the 'gem --version' command in the rocket-ranger container of the proxy-service-pod | Command:
```bash
kubectl exec proxy-service-pod -c rocket-ranger -- gem --version
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If o... |
Display the most recent 12 lines of logs from the web-app-pod pod. | Command:
```bash
kubectl logs --tail=12 web-app-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "short": "-c"... |
Create an ingress named 'private-api-ingress' that routes requests from testing.com/input to svc1:8080 using the TLS secret "my-cert" | Command:
```bash
kubectl create ingress private-api-ingress --rule="testing.com/input=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": "",... |
Create a pod named "hazelcast" using the "docker.elastic.co/elasticsearch/elasticsearch" image and expose port 27017 | Command:
```bash
kubectl run hazelcast --image=docker.elastic.co/elasticsearch/elasticsearch --port=27017
```
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]... |
Start a pod with the mongo image named hazelcast, and set the labels "app=mongo" and "env=prod" in the container | Command:
```bash
kubectl run hazelcast --image=mongo --labels="app=mongo,env=prod"
```
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 fl... |
Automatically scale the replication controller "media-stream" based on CPU utilization | Command:
```bash
kubectl autoscale rc media-stream --max=2 --cpu-percent=40
```
What it does:
Creates an autoscaler that automatically chooses and sets the number of pods that run in a Kubernetes cluster.
Looks up a deployment, replica set, stateful set, or replication controller by name and creates an autoscaler that... |
Listen on port 8088 locally and forward the traffic to port 6379 in the 'e-commerce-pod' pod. | Command:
```bash
kubectl port-forward pod/e-commerce-pod 8088: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... |
Set a custom TLS server name for validation for the "web-cluster" cluster entry. | Command:
```bash
kubectl config set-cluster web-cluster --tls-server-name=app-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-a... |
Embed the certificate authority data for the app-cluster cluster entry by using the command "kubectl config set-cluster app-cluster --embed-certs --certificate-authority=~/.kube/on-prem-cluster/kubernetes.ca.crt" | Command:
```bash
kubectl config set-cluster app-cluster --embed-certs --certificate-authority=~/.kube/on-prem-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... |
Add a taint with key 'dedicated' and value 'k8s-node-1:PreferNoSchedule' on nodes having label 'service=auth' | Command:
```bash
kubectl taint node -l service=auth dedicated=k8s-node-1: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": "O... |
Get the output from running the `redis-server` command in the `cosmic-container` from the pod `log-aggregator-pod`. | Command:
```bash
kubectl exec log-aggregator-pod -c cosmic-container -- 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. I... |
Create a new config map named 'global-config' with the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap global-config --from-file=properties=/path/to/profiles/file1.txt --from-file=key1=/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 creatin... |
Display deployments in YAML format for the "rc-1.1.0" version of the "my-apps" API group | Command:
```bash
kubectl get deployments.rc-1.1.0.my-apps -o yaml
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you will ... |
Forward local port 8000 to the target port of the "https" service port in a selected pod, specifically for the "search-service" service. | Command:
```bash
kubectl port-forward service/search-service 8000: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 selecte... |
Set the CPU limits of the nginx container in the jenkins deployment to "2" and the memory limits to "64Mi" | Command:
```bash
kubectl set resources deployment jenkins -c=nginx --limits=cpu=2,memory=64Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to i... |
Rename a context in kubeconfig file. | Command:
```bash
kubectl config rename-context local-context client-2-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 al... |
Import the REDIS_HOST key from the app-name-config ConfigMap to the scheduler-app-deployment deployment. | Command:
```bash
kubectl set env --keys=REDIS_HOST --from=configmap/app-name-config 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 defin... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.