prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Embed certificate authority data for the on-prem-cluster cluster entry. | Command:
```bash
kubectl config set-cluster on-prem-cluster --embed-certs --certificate-authority=~/.kube/moon-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 ... |
Create a pod named "hazelcast" with the Redis image and expose port 8084. | Command:
```bash
kubectl run hazelcast --image=redis --port=8084
```
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 api-config from the key=value pairs in the file "path/to/properties" | Command:
```bash
kubectl create configmap api-config --from-file=path/to/properties
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a config map based on a file, the key will default to the basename... |
Retrieve the snapshot logs from the monitoring-pod with only one container. | Command:
```bash
kubectl logs 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", "short": "-c", "defa... |
create a pod using a JSON configuration passed from stdin | Command:
```bash
cat conf.json | kubectl create -f -
```
What it does:
Create a resource from a file or from stdin.
JSON and YAML formats are accepted.
Syntax:
`kubectl create -f FILENAME`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to files to use to cr... |
Autoscale the deployment "proxy-server" between 1 and 10 pods using the default autoscaling policy. | Command:
```bash
kubectl autoscale deployment proxy-server --min=1 --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... |
Create an ingress called 'api-v1-ingress' with a rule that directs requests for website.com/example to svc1:3001 using the TLS secret "my-cert" | Command:
```bash
kubectl create ingress api-v1-ingress --rule="website.com/example=svc1:3001,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "u... |
Start a pod named 'nginx' with the 'ethereum/client-go' image, but override the specification with a partial set of values parsed from a JSON file. | Command:
```bash
kubectl run nginx --image=ethereum/client-go --overrides='{ "apiVersion": "rc-1.1.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--comma... |
Open a raw terminal for the proxy-service-pod, connecting to the rocket-ranger container. | Command:
```bash
kubectl attach proxy-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... |
Copy /tmp/foo from the remote pod argocd/load-balancer-pod-9 to /etc/kubernetes locally | Command:
```bash
kubectl cp argocd/load-balancer-pod-9::/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... |
Scale the resource specified in the "docker-registry.yaml" file to 7 replicas. | Command:
```bash
kubectl scale --replicas=7 -f docker-registry.yaml
```
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... |
Forward port 5000 on all addresses to port 6379 in the pod named "cdn-service-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/cdn-service-pod 5000: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... |
View the last 12 lines of logs for the e-commerce-pod pod | Command:
```bash
kubectl logs --tail=12 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": "... |
Create a role named "bar" with the following permissions: | Command:
```bash
kubectl create role bar --verb=watch --resource=pods --resource-name=machine-learning --resource-name=app-worker-2
```
What it does:
Create a role with single rule.
Syntax:
`kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run=server|cli... |
Add a taint to nodes labeled with component=proxy | Command:
```bash
kubectl taint node -l component=proxy workload=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": ... |
import the "redis_host" key from the "app-secrets" ConfigMap and set it as an environment variable in the "frontend-deployment" deployment | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/app-secrets 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... |
Add a taint with key 'zone' on nodes having label region=eu-west-2 | Command:
```bash
kubectl taint node -l region=eu-west-2 zone=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":... |
Start a Ruby pod with custom specifications parsed from a JSON file | Command:
```bash
kubectl run nginx --image=ruby --overrides='{ "apiVersion": "feature-branch-2.3.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... |
Import specific keys from a config map into a deployment's environment variables | Command:
```bash
kubectl set env --keys=config_file_path --from=configmap/app-config-dev 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 defin... |
Create an ingress called 'api-gateway-ingress' that directs requests to 'foo.com/module' to a service named svc1 on port 5432 | Command:
```bash
kubectl create ingress api-gateway-ingress --rule="foo.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": "", "u... |
Get the output from running the 'pg_dump --version' command in the stardust-shuttle container of the log-aggregator-pod | Command:
```bash
kubectl exec log-aggregator-pod -c stardust-shuttle -- pg_dump --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 na... |
Update the pod identified by type and name in "config.json" with release notes annotation. | Command:
```bash
kubectl annotate -f config.json 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 la... |
Create a new secret named api-key-secret with keys for each file in the folder path/to/settings | Command:
```bash
kubectl create secret generic api-key-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 basename of t... |
Create a deployment named 'ingress' using the 'amazonlinux' image with 6 replicas | Command:
```bash
kubectl create deployment ingress --image=amazonlinux --replicas=6
```
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. On... |
Run the 'apk add curl' command in the code-explorer container of the log-aggregator-pod | Command:
```bash
kubectl exec log-aggregator-pod -c code-explorer -- 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. If o... |
Forward traffic from port 8888 on both localhost and IP 10.19.21.23 to port 3000 in the pod "chat-app-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/chat-app-pod 8888: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... |
Create a cluster role named "admin_role" with a non-resource URL specified as "/version" and assign the verb "connect". | Command:
```bash
kubectl create clusterrole "admin_role" --verb=connect --non-resource-url=/version
```
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",... |
Create a debug copy of the media-stream-pod, with a custom name (my-custom-dbg), using the debian image for the additional container, and modify the container image for the existing containers to use nginx:latest for the web container and logging-app:debug for the logger container. | Command:
```bash
kubectl debug media-stream-pod -it --copy-to=my-custom-dbg --image=debian --set-image=web=nginx:latest,logger=logging-app:debug
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by res... |
Copy the local file /tmp/foo_dir to the remote pod database-pod-2 at location /tmp/bar, specifically in the container monitoring-agent. | Command:
```bash
kubectl cp /tmp/foo_dir database-pod-2:/tmp/bar -c monitoring-agent
```
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... |
Scale the deployment named dev-environment-rs to 3 replicas, assuming its current size is 7. | Command:
```bash
kubectl scale --current-replicas=7 --replicas=3 deployment/dev-environment-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-... |
Embed certificate authority data for the cloud-cluster cluster entry | Command:
```bash
kubectl config set-cluster cloud-cluster --embed-certs --certificate-authority=~/.kube/kube-cluster-2/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 ... |
Create an ingress called 'service-ingress' with the following rules: | Command:
```bash
kubectl create ingress service-ingress --rule="foo.com/bar=svc1:9091,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": ... |
Update the pod 'log-aggregator' by setting the annotation 'deployment-script' to 'https://example.com/deploy.sh' and overwrite any existing value. | Command:
```bash
kubectl annotate --overwrite pods log-aggregator 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... |
Display the last 53 lines of logs for the 'analytics-pod' pod. | Command:
```bash
kubectl logs --tail=53 analytics-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": "-... |
Create an ingress named 'public-service-ingress' that routes requests to foo.com/module to svc1:5000 with the tls secret "my-cert" | Command:
```bash
kubectl create ingress public-service-ingress --rule="foo.com/module=svc1:5000,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": "",... |
Port forward from local ports 3000 to pod port 5432 for the e-commerce pod. | Command:
```bash
kubectl port-forward pod/e-commerce-pod 3000 5432
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected aut... |
Create a service for a replicated WordPress using a replica set, which serves on port 3000 and connects to the containers on port 8084. | Command:
```bash
kubectl expose rs wordpress --port=3000 --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 po... |
Execute the 'elasticsearch' command in the 'quantum-quark' container of the 'web-app-pod' pod and fetch its output. | Command:
```bash
kubectl exec web-app-pod -c quantum-quark -- 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 omitted... |
Create a role named "bar" with the `delete`, `update`, and `proxy` verbs and the `namespaces` and `namespaces/status` resources specified. | Command:
```bash
kubectl create role bar --verb=delete,update,proxy --resource=namespaces,namespaces/status
```
What it does:
Create a role with single rule.
Syntax:
`kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run=server|client|none]`
Helpful flag... |
Get output from running the 'redis-server' command in the 'astro-container' from the 'database-pod' | Command:
```bash
kubectl exec database-pod -c astro-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. If omitt... |
Create a config map named ui-config with specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap ui-config --from-file=properties=/path/to/preferences/file1.txt --from-file=key1=/path/to/settings/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating... |
Add a taint with key 'app' and value 'kube-master-9:PreferNoSchedule' on nodes having the label 'project=project-alpha' | Command:
```bash
kubectl taint node -l project=project-alpha app=kube-master-9:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/global-config deployment/gateway-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 i... |
Create a debug container with the same configuration as cdn-service-pod, but with all container images changed to alpine | Command:
```bash
kubectl debug cdn-service-pod --copy-to=debug-image-memcached --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 ... |
Forward local ports 5000 and 6000 to ports 8000 and 6000 in the pod "api-service-pod" | Command:
```bash
kubectl port-forward pod/api-service-pod 5000 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 au... |
Get the output of the 'gem --version' command from the 'mycontainer' container in the 'monitoring-pod' pod. | Command:
```bash
kubectl exec monitoring-pod -c mycontainer -- 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 omitte... |
Create a copy of the "auth-service-pod" pod, replacing all container images with "alpine", and name the new pod "debug-image-web". | Command:
```bash
kubectl debug auth-service-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... |
Set the service account of the 'gateway-deployment' deployment to 'kube-proxy' | Command:
```bash
kubectl set serviceaccount deployment gateway-deployment kube-proxy
```
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:
`kubectl... |
Create a new LoadBalancer service named backend-lb that maps port 9000 on the load balancer to port 8080 on the backend pods. | Command:
```bash
kubectl create service loadbalancer backend-lb --tcp=9000:8080
```
What it does:
Create a LoadBalancer service with the specified name.
Syntax:
`kubectl create service loadbalancer NAME [--tcp=port:targetPort] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "default... |
scale the deployment named webapp-replicaset's current size to 3 pods | Command:
```bash
kubectl scale --current-replicas=3 --replicas=3 deployment/webapp-replicaset
```
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-v... |
Import the SMTP_SERVER key from the ui-config ConfigMap into the environment variables of the payment-processor-deployment deployment. | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/ui-config deployment/payment-processor-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defini... |
Update the annotation 'alert-email' with the value 'alerts@example.com' for the pod 'proxy-server' | Command:
```bash
kubectl annotate pods proxy-server alert-email=alerts@example.com
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and in... |
Create a service for a replicated WordPress application using a replica set, which serves on port 8181 and connects to the containers on port 3306. | Command:
```bash
kubectl expose rs wordpress --port=8181 --target-port=330600
```
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... |
List the deployments in the "rc-1.1.0" version of the "prod-apps" API group in JSON output format. | Command:
```bash
kubectl get deployments.rc-1.1.0.prod-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... |
rename a context in the kubeconfig file | Command:
```bash
kubectl config rename-context testing-context app-1-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 als... |
Forward local port 8888 to port 9090 in the selected pod by the deployment to establish a connection and exchange data. | Command:
```bash
kubectl port-forward deployment/monitoring-stack-deployment 8888 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 ... |
Describe pods with the label "zone=us-east-1" | Command:
```bash
kubectl describe po -l zone=us-east-1
```
What it does:
Show details of a specific resource or group of resources.
Print a detailed description of the selected resources, including related resources such as events or controllers. You may select a single object by name, all objects of that type, provid... |
Begin streaming the logs of the 'stardust-shuttle' container in the 'security-service-pod' pod | Command:
```bash
kubectl logs -f -c stardust-shuttle security-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": "--con... |
Execute the 'sleep 3600' command in the 'warp-drive' container of the 'analytics-pod' pod. | Command:
```bash
kubectl exec analytics-pod -c warp-drive -- 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 an ingress named 'app1-ingress' that maps requests from foo.com/input to the service named 'svc1' on port 8000, using the TLS secret named 'my-cert'. | Command:
```bash
kubectl create ingress app1-ingress --rule="foo.com/input=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": "", "usage": "... |
Forward local port 6379 to port 8888 in a pod selected by the "log-aggregator-deployment" deployment | Command:
```bash
kubectl port-forward deployment/log-aggregator-deployment 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 wi... |
Set the custom TLS server name to use for validation of the prod-cluster cluster entry. | Command:
```bash
kubectl config set-cluster prod-cluster --tls-server-name=moon-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... |
Update the 'cluster' field in the 'admin-context' context to 'sun-cluster' | Command:
```bash
kubectl config set contexts.admin-context.cluster sun-cluster
```
What it does:
Set an individual value in a kubeconfig file.
PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.
PROPERTY_VALUE is the new value you wan... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/app-config-prod 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 definit... |
Create a new ExternalName service named 'external-analytics-service' with an external name of 'example-domain.com' | Command:
```bash
kubectl create service externalname external-analytics-service --external-name example-domain.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 reference... |
Copy the file "/tmp/foo" from your local machine to the "/tmp/bar" directory inside the pod named "monitoring/admin-dashboard-pod-16" in the given namespace. | Command:
```bash
kubectl cp /tmp/foo monitoring/admin-dashboard-pod-16:/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 ... |
Listen on port 8088 locally, forwarding data to/from port 8088 in the log-aggregator-pod. | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 8088 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... |
Forward traffic from port 8000 on localhost and IP 10.19.21.23 to port 8000 in the 'analytics-pod' pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/analytics-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 crite... |
Wait for a specific pod to be deleted after issuing the delete command, with a timeout of 60 seconds. | Command:
```bash
kubectl delete pod/proxy-server-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 resou... |
Create a pod named hazelcast using the ethereum/client-go image and expose port 9000. | Command:
```bash
kubectl run hazelcast --image=ethereum/client-go --port=9000
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
... |
Import environment variables from a config map with a specific prefix | Command:
```bash
kubectl set env --from=configmap/app-config-prod --prefix=MYSQL_ 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 defin... |
Create a new config map named app-config with the specified keys by using files on disk. | Command:
```bash
kubectl create configmap app-config --from-file=properties=/path/to/settings/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 ... |
Return the logs from the 'e-commerce-pod' pod with only one container | Command:
```bash
kubectl logs 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": "-c", "defa... |
Create an ingress named 'internal-ingress' that routes requests for site.com/bar to svc1:5001, with the tls secret "my-cert" | Command:
```bash
kubectl create ingress internal-ingress --rule="site.com/bar=svc1:5001,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage"... |
Create a new config map named `namespace-config` using the key=value pairs from the file at `path/to/configs` | Command:
```bash
kubectl create configmap namespace-config --from-file=path/to/configs
```
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 basen... |
Add a taint with key 'special' and no value to the node 'backup-node-14' | Command:
```bash
kubectl taint nodes backup-node-14 special:NoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of... |
Check if you have authorization to list the job named "cache-warming-job" in the "logging" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/cache-warming-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 URL ... |
Return a snapshot of the previous terminated 'astro-container' container logs from the 'e-commerce-pod' pod. | Command:
```bash
kubectl logs -p -c astro-container 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"... |
Run the 'redis-server' command inside the warp-drive container of the e-commerce-pod pod and display the output. | Command:
```bash
kubectl exec e-commerce-pod -c warp-drive -- redis-server
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted,... |
Create a new resource quota named 'ingress-quota' with a limit of 2 ingresses. | Command:
```bash
kubectl create quota ingress-quota --hard=ingresses=2
```
What it does:
Create a resource quota with the specified name, hard limits, and optional scopes.
Syntax:
`kubectl create quota NAME [--hard=key1=value1,key2=value2] [--scopes=Scope1,Scope2] [--dry-run=server|client|none]`
Helpful flags:
"flag... |
Retrieve the output from running the 'postgres' command within the first container of the first pod of the 'email-service' service. | Command:
```bash
kubectl exec svc/email-service -- postgres
```
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 kubect... |
Create a role binding for multiple users and a group using a specific cluster role | Command:
```bash
kubectl create rolebinding foo --clusterrole=foo --user=developer3 --user=k8s-admin --group=qa-engineers
```
What it does:
Create a role binding for a particular role or cluster role.
Syntax:
`kubectl create rolebinding NAME --clusterrole=NAME|--role=NAME [--user=username] [--group=groupname] [--serv... |
Import the 'DEBUG_MODE' key from the 'monitoring-config' config map into the 'scheduler-app-deployment' deployment. | Command:
```bash
kubectl set env --keys=DEBUG_MODE --from=configmap/monitoring-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 def... |
Forward the local 8088 port to the target port of the 'https' service port in a pod selected by the 'logging-service' service. | Command:
```bash
kubectl port-forward service/logging-service 8088: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 select... |
Add a taint on nodes with label 'stack=tech-stack' | Command:
```bash
kubectl taint node -l stack=tech-stack environment=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": "", "u... |
Create a cluster role named "bar" with the ability to connect to pods and specific resource names like "identity-provider" and "prod-api-gateway" | Command:
```bash
kubectl create clusterrole bar --verb=connect --resource=pods --resource-name=identity-provider --resource-name=prod-api-gateway
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|cli... |
Create a copy of the mypod pod named debug-image-web, and change all container images to mysql. | Command:
```bash
kubectl debug mypod --copy-to=debug-image-web --set-image=*=mysql
```
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 is... |
Start a CentOS pod called "nginx" with custom overrides | Command:
```bash
kubectl run nginx --image=centos --overrides='{ "apiVersion": "hotfix-1.1.2", "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] -- [... |
Create a job named "batch-processing" with the python image, and pass the python --version command. | Command:
```bash
kubectl create job batch-processing --image=python -- python --version
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Outpu... |
Import the environment variables from the jwt-secret secret into the mydeployment deployment. | Command:
```bash
kubectl set env --from=secret/jwt-secret deployment/mydeployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more pod templates (w... |
Import the environment variables from the 'tls-certificate-secret' secret into the 'email-server-deployment' deployment. | Command:
```bash
kubectl set env --from=secret/tls-certificate-secret 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 definitions in one o... |
Expose a replication controller named "python" by creating a service | Command:
```bash
kubectl expose rc python --port=3000 --target-port=808300
```
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.... |
Copy the ~/.config/kube local file to /tmp/bar_dir in the remote pod named `ingress-controller-pod-8`, with the container named `front-end-container`. | Command:
```bash
kubectl cp ~/.config/kube ingress-controller-pod-8:/tmp/bar_dir -c front-end-container
```
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 na... |
Import the MAX_CONNECTIONS key from the config map named namespace-config into the monitoring-stack-deployment deployment. | Command:
```bash
kubectl set env --keys=MAX_CONNECTIONS --from=configmap/namespace-config deployment/monitoring-stack-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment varia... |
Forward local port 5000 to port 5000 in the 'log-aggregator-pod' pod | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 5000: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 be selected... |
Create a service with the name "frontend" that exposes the pod "cdn-service-pod" on port 444. | Command:
```bash
kubectl expose pod cdn-service-pod --port=6379 --name=frontend
```
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 ... |
Setup autoscaling for the replication controller "cdn" with a target CPU utilization of 90%, and ensure the number of pods remains between 1 and 7. | Command:
```bash
kubectl autoscale rc cdn --max=7 --cpu-percent=90
```
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... |
Get the output from running the 'redis-cli' command in the 'nebula-navigator' container from the 'api-service-pod' pod. | Command:
```bash
kubectl exec api-service-pod -c nebula-navigator -- redis-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. If omit... |
Create a service for the replicated ruby controller with the exposed port 8083 and the target port 300100. | Command:
```bash
kubectl expose rc ruby --port=8083 --target-port=300100
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port. A... |
Forward local port 6379 to port 6379 in the pod "frontend-pod" | Command:
```bash
kubectl port-forward pod/frontend-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 autom... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.