prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Create a deployment named "drupal" that runs the "mcr.microsoft.com/dotnet/core/runtime" image and exposes port 9000 | Command:
```bash
kubectl create deployment drupal --image=mcr.microsoft.com/dotnet/core/runtime --port=9000
```
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": "", "us... |
Create a service for a replication controller specified in a YAML file, serving on port 80 and connecting to the containers on port 8888 | Command:
```bash
kubectl expose -f python-controller.yaml --port=80 --target-port=888800
```
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 the label 'role' with the value 'frontend' to the pod 'chat-app' | Command:
```bash
kubectl label pods chat-app role=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":... |
Add a taint on nodes with a specific label | Command:
```bash
kubectl taint node -l namespace=mynamespace dedicated=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"... |
Get the output from running the 'kafka-topics --list' command in the cosmic-container from the pod auth-service-pod | Command:
```bash
kubectl exec auth-service-pod -c cosmic-container -- kafka-topics --list
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container na... |
Create a pod named 'hazelcast' using the 'jenkins' image and expose port 8888 | Command:
```bash
kubectl run hazelcast --image=jenkins --port=8888
```
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": "--... |
Create a copy of the "chat-app-pod" pod, with the "astro-container" container, for debugging purposes. | Command:
```bash
kubectl debug chat-app-pod -it --copy-to=my-custom-dbg --container=astro-container -- sh
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and name. Pods will be used by de... |
Create a service for the replicated wordpress resource, which serves on port 80 and connects to the containers on port 8000 | Command:
```bash
kubectl expose rc wordpress --port=8084 --target-port=909000
```
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... |
Create a cluster role named "admin_role" with the verb "proxy" and the resource "services", specifying the resource names "auth-proxy" and "document-storage" | Command:
```bash
kubectl create clusterrole admin_role --verb=proxy --resource=services --resource-name=auth-proxy --resource-name=document-storage
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|c... |
Execute the 'java -jar /usr/share/jenkins/jenkins.war' command inside the pod named 'monitoring-pod' and retrieve the output. | Command:
```bash
kubectl exec monitoring-pod -- java -jar /usr/share/jenkins/jenkins.war
```
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 nam... |
Forward traffic from port 8888 on all addresses to port 8080 in the 'web-app-pod' pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/web-app-pod 8888: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 ... |
Remove the taint with key 'zone' and effect 'PreferNoSchedule' from node 'testing-node-11' if it exists. | Command:
```bash
kubectl taint nodes testing-node-11 zone:PreferNoSchedule-
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. O... |
Create a pod disruption budget with the specified criteria | Command:
```bash
kubectl create poddisruptionbudget notification-service-pdb --selector=version=v2 --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-availa... |
Forward local port 6379 to port 3000 in the pod | Command:
```bash
kubectl port-forward pod/web-app-pod 6379:3000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automa... |
Create an ingress called 'public-ingress' that directs requests to site.com/example to svc1:8089 with tls secret 'my-cert' | Command:
```bash
kubectl create ingress public-ingress --rule="site.com/example=svc1:8089,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": "", "usag... |
Remove a taint from a specific node if it exists | Command:
```bash
kubectl taint nodes node-2 environment: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: j... |
Check if you have permission to list the "image-processing-job" job in the "kube-node-lease" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/image-processing-job -n kube-node-lease
```
What it does:
Check whether an action is allowed.
VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is a p... |
force replace the resource specified in the settings.json file | Command:
```bash
kubectl replace --force -f ./settings.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 -... |
Set the custom TLS server name for cluster-alpha to "my-k8s-cluster" | Command:
```bash
kubectl config set-cluster cluster-alpha --tls-server-name=my-k8s-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] [--certific... |
Create a job with a command | Command:
```bash
kubectl create job cleanup --image=docker.elastic.co/elasticsearch/elasticsearch -- elasticsearch --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":... |
List deployments in YAML output format, for the "v1.0.0" version of the "third-party-apps" API group. | Command:
```bash
kubectl get deployments.v1.0.0.third-party-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 yo... |
Create an ingress rule named 'public-api-ingress' that directs requests to 'testing.com/bar' to 'svc1:3306' with the TLS secret named "my-cert" | Command:
```bash
kubectl create ingress public-api-ingress --rule="testing.com/bar=svc1:3306,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... |
Embed the certificate authority data for the "edge-cluster" cluster entry. | Command:
```bash
kubectl config set-cluster edge-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 ... |
Create an ingress called 'api-gateway-ingress' that directs requests to a specific service and port, with a TLS secret for encryption | Command:
```bash
kubectl create ingress api-gateway-ingress --rule="website.com/input=svc1:3306,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 an ingress called 'private-service-ingress' that directs requests for 'foo.com/bar' to 'svc1:8181' with a TLS secret named "my-cert" | Command:
```bash
kubectl create ingress private-service-ingress --rule="foo.com/bar=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": "", "... |
Set the cluster field to "star-cluster" for the "my-context" context in the user-b context. | Command:
```bash
kubectl config set contexts.user-b-context.cluster star-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 w... |
Copy a file, /tmp/foo, from a specific remote pod to your local machine's /tmp/bar directory. | Command:
```bash
kubectl cp velero/task-processor-pod-17:/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 kube... |
Forward data from local ports 5000 to 8081 in a pod selected by the web-app-deployment deployment | Command:
```bash
kubectl port-forward deployment/web-app-deployment 5000 8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be s... |
Execute the 'node' command in the 'code-explorer' container of the 'api-service-pod' pod | Command:
```bash
kubectl exec api-service-pod -c code-explorer -- 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, use... |
Copy the ~/.config/kube local file to :/tmp/bar in a remote pod within the kube-system namespace. | Command:
```bash
kubectl cp ~/.config/kube kube-system/web-app-pod-1::/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 k... |
Create a new pod named 'nginx' using the MySQL container image, but customize the pod's specifications with values from a JSON override. | Command:
```bash
kubectl run nginx --image=mysql --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] [--command] -- [COMMA... |
Open the backend-service service for editing using the nvim editor | Command:
```bash
KUBE_EDITOR="nvim" kubectl edit svc/backend-service
```
What it does:
Edit a resource from the default editor.
The edit command allows you to directly edit any API resource you can retrieve via the command-line tools. It will open the editor defined by your KUBE_EDITOR, or EDITOR environment variables... |
Forward local port 9090 to port 8088 in the pod named "security-service-pod" | Command:
```bash
kubectl port-forward pod/security-service-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 select... |
Display the details of the 'rc/web' replication controller, the 'service/media-stream-rc' service, and the 'pods/log-aggregator-pod' pod. | Command:
```bash
kubectl get rc/web service/media-stream-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 na... |
Copy the local file /tmp/foo to the remote pod named backend-pod-13 in the istio-system namespace, and place it in the directory /tmp/bar_dir. | Command:
```bash
kubectl cp /tmp/foo istio-system/backend-pod-13:/tmp/bar_dir
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the ku... |
Auto scale the deployment "cdn" with a minimum of 4 pods and a maximum of 9 pods. | Command:
```bash
kubectl autoscale deployment cdn --min=4 --max=9
```
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 ... |
Change the service account of the deployment "authentication-service-deployment" to "flux" | Command:
```bash
kubectl set serviceaccount deployment authentication-service-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:... |
Copy the local kube config file to a remote pod in the specified namespace. | Command:
```bash
kubectl cp ~/.config/kube argocd/database-pod-2::/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... |
Set the CPU and memory limits for a deployment's container | Command:
```bash
kubectl set resources deployment ruby -c=nginx --limits=cpu=200m,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... |
Create a deployment named monitoring using the ruby image and expose port 8083. | Command:
```bash
kubectl create deployment monitoring --image=ruby --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:... |
Create a new ExternalName service named external-payment-gateway-service that maps to the external website dummy-website.io | Command:
```bash
kubectl create service externalname external-payment-gateway-service --external-name dummy-website.io
```
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 refer... |
Execute the 'wp' command in the 'rocket-ranger' container within the 'gateway-pod' pod and display the output. | Command:
```bash
kubectl exec gateway-pod -c rocket-ranger -- wp
```
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 Pod Disruption Budget named web-app-pdb that selects pods with the release=1.0.0 label, and ensure that at least four of them are available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget web-app-pdb --selector=release=1.0.0 --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 [--d... |
Create a service for the nginx replication controller, specified in the "nginx-controller.yaml" file | Command:
```bash
kubectl expose -f nginx-controller.yaml --port=8080 --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 ... |
Forward traffic from local port 9090 to port 5432 in the pod named "e-commerce-pod" on all addresses (0.0.0.0). | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/e-commerce-pod 9090:5432
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod wi... |
Import environment variables prefixed with "MYSQL_" from the config map "app-name-config" into the deployment "notification-handler-deployment" | Command:
```bash
kubectl set env --from=configmap/app-name-config --prefix=MYSQL_ deployment/notification-handler-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable ... |
Start a new pod named "hazelcast" using the nginx image and have it expose port 8081. | Command:
```bash
kubectl run hazelcast --image=nginx --port=8081
```
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 an ingress called 'app1-ingress' with the following rules: | Command:
```bash
kubectl create ingress app1-ingress --rule="testing.com/example=svc1:8081,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 service for the replicated centos containers, which serves on port 8080 and connects to the containers on port 8000 | Command:
```bash
kubectl expose rc centos --port=8080 --target-port=800000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port.... |
Execute the 'redis-server --version' command inside the vpn-service-pod pod and display the output. | Command:
```bash
kubectl exec vpn-service-pod -- redis-server --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, us... |
Copy the file /tmp/foo from the remote pod named ingress-controller-pod-8 in the rook-ceph namespace to the local directory /tmp/bar | Command:
```bash
kubectl cp rook-ceph/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 th... |
create a service for the replication controller specified in "node-controller.yaml" which serves on port 5000 and connects to the containers on port 888800 | Command:
```bash
kubectl expose -f node-controller.yaml --port=5000 --target-port=888800
```
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... |
Create a secret named my-secret using values from an environment file | Command:
```bash
kubectl create secret generic my-secret --from-env-file=path/to/configs.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 basename of... |
Update the annotation 'compliance-level' of the pod 'web' to 'PCI-DSS', replacing any existing value. | Command:
```bash
kubectl annotate --overwrite pods web compliance-level='PCI-DSS'
```
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 inc... |
Copy the service account information from a remote pod to a local directory. | Command:
```bash
kubectl cp prometheus/auth-service-pod-11:/var/run/secrets/kubernetes.io/serviceaccount/ /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": "", "usa... |
Forward traffic from port 8888 on localhost and IP 10.19.21.23 to port 5000 in the pod named web-app-pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/web-app-pod 8888: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 criteri... |
Rename the context 'staging-context' to 'client-1-context' in your kubeconfig file. | Command:
```bash
kubectl config rename-context staging-context client-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 ... |
Partially update a node by setting the 'unschedulable' field to true. | Command:
```bash
kubectl patch node web-node-8 -p $'spec:\n unschedulable: true'
```
What it does:
Update fields of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.
JSON and YAML formats are accepted.
Syntax:
`kubectl patch (-f FILENAME | TYPE NAME) [-p PATCH|--patch-file FILE]`
Helpful f... |
import the SECRET_KEY key from the app-secrets config map and set it as an environment variable in the user-management-deployment deployment | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/app-secrets deployment/user-management-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definit... |
Update the pod 'email' by adding the annotation 'expiration-date' with the value '2024-12-31' | Command:
```bash
kubectl annotate pods email expiration-date='2024-12-31'
```
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 arb... |
Create or update the exec auth plugin environment variables for the "api-user" entry. Set key1 to val1 and key2 to val2. | Command:
```bash
kubectl config set-credentials api-user --exec-env=key1=val1 --exec-env=key2=val2
```
What it does:
Set a user entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values.
Client-certificate flags:
--client-certificate=certfile --client-key=keyfile
Bear... |
Forward traffic from port 8080 on localhost and IP 10.19.21.23 to port 8888 in the 'mypod' pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/mypod 8080: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 p... |
Set the service account of the deployment 'notification-handler-deployment' to 'kube-controller-manager' | Command:
```bash
kubectl set serviceaccount deployment notification-handler-deployment kube-controller-manager
```
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), sta... |
Create an ingress called 'private-ingress' with a rule that directs requests to website.com/bar to svc1:8081 and use the TLS secret "my-cert" | Command:
```bash
kubectl create ingress private-ingress --rule="website.com/bar=svc1:8081,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": "", "usag... |
Create a deployment named gitlab running the jenkins image and exposing port 5432. | Command:
```bash
kubectl create deployment gitlab --image=jenkins --port=5432
```
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: ... |
Create a new config map named kube-system-config with the specified keys and their corresponding file paths. | Command:
```bash
kubectl create configmap kube-system-config --from-file=settings=/path/to/data/file1.txt --from-file=key2=/path/to/parameters/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creati... |
Rename the context 'cloud-context' to 'service-account-context' in your kubeconfig file | Command:
```bash
kubectl config rename-context cloud-context service-account-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 ... |
Create a LoadBalancer service named "database-lb" with a TCP port mapping of 3001 to 8000. | Command:
```bash
kubectl create service loadbalancer database-lb --tcp=3001:8000
```
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", "defaul... |
Create a service for a replication controller specified in "hazelcast-controller.yaml", which connects to containers on port 8000 and serves on port 8010. | Command:
```bash
kubectl expose -f hazelcast-controller.yaml --port=8010 --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 ... |
Create an ingress with TLS enabled using the default ingress certificate and different path types | Command:
```bash
kubectl create ingress ingtls --class=default \
--rule="website.com/=svc:https,tls" \
--rule="foo.com/path/subpath*=othersvc:3001"
```
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": "-... |
import environment variables from a secret to a deployment | Command:
```bash
kubectl set env --from=secret/cert-manager-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 or m... |
Update the 'order-processing-deployment' deployment by adding a new environment variable called 'MAX_CONNECTIONS' with a value of '100' | Command:
```bash
kubectl set env deployment/order-processing-deployment MAX_CONNECTIONS=100
```
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 te... |
Set the service account for the 'payment-processor-deployment' deployment to 'tekton' | Command:
```bash
kubectl set serviceaccount deployment payment-processor-deployment tekton
```
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:
`k... |
import the 'redis_host' key from the 'api-config' config map to the 'log-aggregator-deployment' deployment. | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/api-config deployment/log-aggregator-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitio... |
import the 'redis_host' key from the 'app-secrets' config map and set it as an environment variable in the 'order-processing-deployment' deployment | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/app-secrets deployment/order-processing-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... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=secret_key --from=configmap/namespace-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... |
Update the cluster role binding for the metrics-server by setting the subject to the specified service account. | Command:
```bash
kubectl set subject clusterrolebinding admin --serviceaccount=namespace:metrics-server
```
What it does:
Update the user, group, or service account in a role binding or cluster role binding.
Syntax:
`kubectl set subject (-f FILENAME | TYPE NAME) [--user=username] [--group=groupname] [--serviceaccount... |
Apply the configuration in the manifest.yaml file to create or update the resources that have the label component=proxy | Command:
```bash
kubectl apply --prune -f manifest.yaml -l component=proxy
```
What it does:
Apply a configuration to a resource by file name or stdin. The resource name must be specified. This resource will be created if it doesn't exist yet. To use 'apply', always create the resource initially with either 'apply' or... |
Forward port 8080 on localhost and IP address 10.19.21.23 to port 6379 in the pod "e-commerce-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/e-commerce-pod 8080: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 crit... |
Forward local port 3000 to port 3000 in the analytics-pod | Command:
```bash
kubectl port-forward pod/analytics-pod 3000: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 auto... |
Return the snapshot logs from container monitoring-stack-deployment-1 of the deployment named proxy-service-pod | Command:
```bash
kubectl logs deployment/monitoring-stack-deployment -c proxy-service-pod-1
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful fla... |
Copy the local file named "foo" located in the "/tmp" directory to the "/tmp/bar_dir" directory in the remote pod named "ingress-controller-pod-8" in the "kube-system" namespace. | Command:
```bash
kubectl cp :/tmp/foo kube-system/ingress-controller-pod-8:/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, ... |
Copy the ~/.config/kube local file to the /tmp/bar directory in the load-balancer-pod-9 pod running in the kube-proxy namespace. | Command:
```bash
kubectl cp ~/.config/kube kube-proxy/load-balancer-pod-9::/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 ... |
create a new config map named app-config-prod using the specified files | Command:
```bash
kubectl create configmap app-config-prod --from-file=settings=/path/to/options/file1.txt --from-file=key2=/path/to/data/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating a c... |
delete the pods and services that have the label service=auth | Command:
```bash
kubectl delete pods,services -l service=auth
```
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 selecto... |
Create a single ingress called 'web-ingress' that directs requests to testing.com/example to svc1:8888 with a tls secret named "my-cert" | Command:
```bash
kubectl create ingress web-ingress --rule="testing.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": "", "usag... |
Get a list of deployments in the JSON format using the "v3.0.0" version of the "custom-apps" API group. | Command:
```bash
kubectl get deployments.v3.0.0.custom-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... |
List deployments in the "v1.0.0" version of the "apps" API group in JSON output format. | Command:
```bash
kubectl get deployments.v1.0.0.apps -o json
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you will only ... |
Forward local port to pod port for accessing the API service | Command:
```bash
kubectl port-forward pod/api-service-pod :8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automa... |
Create a pod using the Python image and expose port 8089 | Command:
```bash
kubectl run hazelcast --image=python --port=8089
```
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 a service for the 'centos' ReplicaSet, which serves on port 8082 and connects to the containers on port 909000. | Command:
```bash
kubectl expose rs centos --port=8082 --target-port=909000
```
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 a taint with key 'special' and no value to the node 'storage-node-13' | Command:
```bash
kubectl taint nodes storage-node-13 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 o... |
Add a taint with the key 'zone' and value 'node-1:PreferNoSchedule' on nodes that have the label 'component=proxy' | Command:
```bash
kubectl taint node -l component=proxy zone=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": "Output ... |
Set the cluster field in a specific context to a given value | Command:
```bash
kubectl config set contexts.on-prem-context.cluster moon-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 ... |
Scale the deployment named payment-service-rs to have 7 replicas if its current size is 3. | Command:
```bash
kubectl scale --current-replicas=3 --replicas=7 deployment/payment-service-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-... |
Remove the 'description' annotation from pod 'foo' | Command:
```bash
kubectl annotate pods foo description-
```
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 string valu... |
Create a pod disruption budget named logging-pdb that will select all pods with the release=1.0.0 label and require a minimum of four of them being available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget logging-pdb --selector=release=1.0.0 --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 [--d... |
Create a new config map named 'monitoring-config' using the specified data files | Command:
```bash
kubectl create configmap monitoring-config --from-file=properties=/path/to/data/file1.txt --from-file=key1=/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... |
Create a new config map named "app-name-config" using the key=value pairs found in the specified file. | Command:
```bash
kubectl create configmap app-name-config --from-file=path/to/settings
```
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... |
Embed the certificate authority data for the my-k8s-cluster cluster entry by running the command: "kubectl config set-cluster my-k8s-cluster --embed-certs --certificate-authority=~/.kube/testing-cluster/kubernetes.ca.crt" | Command:
```bash
kubectl config set-cluster my-k8s-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 confi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.