prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Update the 'email' pod by setting the annotation 'monitoring-tool' to 'Prometheus' | Command:
```bash
kubectl annotate pods email monitoring-tool=Prometheus
```
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 arbit... |
Create a copy of payment-gateway-pod with a debug container and updated container images | Command:
```bash
kubectl debug payment-gateway-pod -it --copy-to=my-debugger --image=debian --set-image=web=nginx:latest,app=app:debug
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and ... |
Create a new config map named global-config using the files file1.txt and file2.txt as values for the keys "properties" and "key1" respectively. | Command:
```bash
kubectl create configmap global-config --from-file=properties=/path/to/parameters/file1.txt --from-file=key1=/path/to/parameters/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When cre... |
Import environment variables from a secret | Command:
```bash
kubectl set env --from=secret/git-credentials-secret deployment/proxy-service-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one ... |
Create a debug container in the security-service-pod using the debian image, and change the container images for the proxy and cache to nginx:1.21 and redis:alpine respectively. | Command:
```bash
kubectl debug security-service-pod -it --copy-to=debug-image-memcached --image=debian --set-image=proxy=nginx:1.21,cache=redis:alpine
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified ... |
Partially update a node by applying a strategic merge patch in YAML format. | Command:
```bash
kubectl patch node node-2 -p $'spec:\n replicas: 3'
```
What it does:
Update fields of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.
JSON and YAML formats are accepted.
Syntax:
`kubectl patch (-f FILENAME | TYPE NAME) [-p PATCH|--patch-file FILE]`
Helpful flags:
"flag"... |
Copy the local file "/tmp/foo" to the directory "/etc/kubernetes" in the remote pod named "backend-pod-13" in the default namespace. | Command:
```bash
kubectl cp /tmp/foo default/backend-pod-13:/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 kube... |
Execute the 'geth' command inside the 'vpn-service-pod' pod and print the output. | Command:
```bash
kubectl exec vpn-service-pod -- geth
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.kube... |
Create a cluster role named "reader" with ResourceName specified | Command:
```bash
kubectl create clusterrole reader --verb=connect --resource=services --resource-name=content-delivery --resource-name=dev-database
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|c... |
Create a pod disruption budget named monitoring-pdb that selects all pods labeled with version=v2, and requires a minimum of four of them to be available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget monitoring-pdb --selector=version=v2 --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... |
Forward local port 8080 to pod port 8000 for a specific deployment | Command:
```bash
kubectl port-forward deployment/authentication-service-deployment 8080 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, ... |
Retrieve the snapshot logs from the container api-service-pod-1 in the deployment frontend-deployment. | Command:
```bash
kubectl logs deployment/frontend-deployment -c api-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 flags:
"flag"... |
Update the 'log-aggregator-deployment' deployment by adding a new environment variable 'DB_PASSWORD' with the value 'secretpassword' | Command:
```bash
kubectl set env deployment/log-aggregator-deployment DB_PASSWORD=secretpassword
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more p... |
Forward ports 3000 and 6000 from the pod to your local machine | Command:
```bash
kubectl port-forward pod/backend-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 automa... |
Rename a context in your kubeconfig file | Command:
```bash
kubectl config rename-context on-prem-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 ... |
Update the 'monitoring' pod with the label 'unhealthy' and the value 'true'. | Command:
```bash
kubectl label pods monitoring unhealthy=true
```
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", "usag... |
Create a LoadBalancer service named log-aggregator-lb that maps port 8443 on the external IP to port 8084 on the service. | Command:
```bash
kubectl create service loadbalancer log-aggregator-lb --tcp=8443:8084
```
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", "... |
Import specific keys from a config map into an environment variable for a deployment. | Command:
```bash
kubectl set env --keys=DATABASE_URL --from=configmap/app-settings deployment/web-app-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions ... |
Set the CPU limit of the nginx container in the amazonlinux deployment to "100m" and the memory limit to "512Mi" | Command:
```bash
kubectl set resources deployment amazonlinux -c=nginx --limits=cpu=100m,memory=512Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst... |
Set a custom TLS server name for the specified cluster entry | Command:
```bash
kubectl config set-cluster dev-cluster --tls-server-name=data-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-... |
List the specified resources by their type and names. | Command:
```bash
kubectl get rc/web service/log-aggregator-rc pods/monitoring-pod
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is name... |
Edit the last-applied-configuration annotations for the deployment 'mcr.microsoft.com/dotnet/core/runtime' in YAML format. | Command:
```bash
kubectl apply edit-last-applied deployment/mcr.microsoft.com/dotnet/core/runtime
```
What it does:
Edit the latest last-applied-configuration annotations of resources from the default editor.
The edit-last-applied command allows you to directly edit any API resource you can retrieve via the command-li... |
Import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=api_key --from=configmap/app-config-prod 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 definiti... |
Create a cluster role named "reader" with the following permissions: watch access for all resources and access to the '/api-docs/*' non-resource URLs. | Command:
```bash
kubectl create clusterrole "reader" --verb=watch --non-resource-url=/api-docs/*
```
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", "s... |
Retrieve previous terminated logs of the warp-drive container from the pod proxy-service-pod | Command:
```bash
kubectl logs -p -c warp-drive proxy-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", ... |
Forward local port 6379 to the pod's port 5000 on both localhost and IP 10.19.21.23 | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/mypod 6379: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 p... |
Create a new config map named kube-system-config with specified keys from file paths | Command:
```bash
kubectl create configmap kube-system-config --from-file=settings=/path/to/configurations/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 cr... |
Forward local port 8080 to port 8000 in the pod | Command:
```bash
kubectl port-forward pod/proxy-server-pod 8080 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 a... |
Create a new config map named env-vars with the specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap env-vars --from-file=settings=/path/to/configs/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 confi... |
Connect to the log-aggregator-pod container named "cyber-sleuth" and switch to the raw terminal mode to interact with the pod | Command:
```bash
kubectl attach log-aggregator-pod -c cyber-sleuth -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... |
Set the custom TLS server name to use for validation for the kube-cluster-2 cluster entry | Command:
```bash
kubectl config set-cluster kube-cluster-2 --tls-server-name=e2e
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-cluster NAME [--server=server] [--certificate-author... |
Execute the command 'elasticsearch-plugin --list' in the first container of the 'analytics-platform-deployment' deployment and display the output. | Command:
```bash
kubectl exec deploy/analytics-platform-deployment -- elasticsearch-plugin --list
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Cont... |
Execute the command "mongo --version" in the stardust-shuttle container of the database-pod pod and print the output. | Command:
```bash
kubectl exec database-pod -c stardust-shuttle -- mongo --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... |
Delete the pods and services with the names "proxy" and "security" | Command:
```bash
kubectl delete pod,service proxy security
```
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.
... |
Start a new nginx pod with the ethereum/client-go image, but override the pod's spec with a partial set of values parsed from a JSON object. | Command:
```bash
kubectl run nginx --image=ethereum/client-go --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... |
Edit the order-service service using the vim editor. | Command:
```bash
KUBE_EDITOR="vim" kubectl edit svc/order-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, o... |
Create a new secret named api-key-secret from the given env file | Command:
```bash
kubectl create secret generic api-key-secret --from-env-file=path/to/configurations.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... |
Get the output from the first pod of the replica set named "alpine" | Command:
```bash
kubectl attach rs/alpine
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubectl.kuber... |
Annotate the pod 'backend' with the annotation 'expiration-date' and the value '2024-12-31', overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods backend 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 a... |
Update the image of all deployments and replication controllers to 'golang:1.17' for the container named 'nginx'. | Command:
```bash
kubectl set image deployments,rc golang=golang:1.17 --all
```
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)
Synta... |
Create a cluster role named "default_role" with specified ResourceName | Command:
```bash
kubectl create clusterrole default_role --verb=exec --resource=pods --resource-name=dashboard-ui --resource-name=backup-service
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|clie... |
Forward traffic from port 8080 on localhost and IP 10.19.21.23 to port 8888 in the pod named "frontend-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/frontend-pod 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 criter... |
Update the pods named 'proxy-server' by annotating them with the annotation 'contact-email' and the value 'support@example.com' | Command:
```bash
kubectl annotate pods proxy-server contact-email=support@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... |
Add an annotation to a pod defined in the "parameters.json" file with the key "monitoring-tool" and the value "Prometheus" | Command:
```bash
kubectl annotate -f parameters.json monitoring-tool=Prometheus
```
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 inclu... |
Create a new config map named app-secrets in the current namespace using the specified files as key-value pairs | Command:
```bash
kubectl create configmap app-secrets --from-file=settings=/path/to/settings/file1.txt --from-file=key2=/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 c... |
Create a cluster role named "admin_role" with permissions to update nodes | Command:
```bash
kubectl create clusterrole "admin_role" --verb=update --non-resource-url=/api/v1/nodes/*
```
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": "--ou... |
Copy the file named "foo" from the "/tmp" directory on a remote pod to the "/etc/kubernetes" directory on your local machine. | Command:
```bash
kubectl exec -n kube-system backend-pod-13 -- tar cf - /tmp/foo | tar xf - -C /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": "Conta... |
Create a deployment named 'monitoring' using the 'wordpress' image and expose port 27017 | Command:
```bash
kubectl create deployment monitoring --image=wordpress --port=27017
```
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. O... |
Add a taint with key 'zone' on nodes having label release=beta | Command:
```bash
kubectl taint node -l release=beta 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... |
Update the image of all containers in the 'app-v2' daemonset to 'debian:11.0' | Command:
```bash
kubectl set image daemonset app-v2 *=debian:11.0
```
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:
`kubec... |
Forward local port 8088 to pod port 8000 | Command:
```bash
kubectl port-forward pod/mypod 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 criteria, a pod will be selected automaticall... |
Create a new config map named 'global-config' using the specified keys and file paths | Command:
```bash
kubectl create configmap global-config --from-file=properties=/path/to/data/file1.txt --from-file=key1=/path/to/parameters/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating ... |
Create a new ExternalName service named external-payment-gateway-service with the external name sample-domain.net. | Command:
```bash
kubectl create service externalname external-payment-gateway-service --external-name sample-domain.net
```
What it does:
Create an ExternalName service with the specified name.
ExternalName service references to an external DNS address instead of only pods, which will allow application authors to refe... |
Create an ingress called 'app-ingress' that directs requests to site.com/input to the service svc1 on port 3000, with a TLS secret named "my-cert". | Command:
```bash
kubectl create ingress app-ingress --rule="site.com/input=svc1:3000,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "... |
Create a deployment named prometheus with the wordpress image, and expose port 9091 | Command:
```bash
kubectl create deployment prometheus --image=wordpress --port=9091
```
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... |
Forward port 8080 on your local machine to port 3000 in the e-commerce-pod pod | Command:
```bash
kubectl port-forward pod/e-commerce-pod 8080: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 aut... |
Retrieve the logs of container "backend-pod-1" from the deployment "authentication-service-deployment" | Command:
```bash
kubectl logs deployment/authentication-service-deployment -c backend-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... |
Set custom TLS server name for cluster-gamma cluster entry | Command:
```bash
kubectl config set-cluster cluster-gamma --tls-server-name=testing-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] [--certifi... |
Set the cluster field in a specific context to a specific cluster | Command:
```bash
kubectl config set contexts.local-context.cluster on-prem-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... |
Create a job using a specific image and command | Command:
```bash
kubectl create job certificate-renewal --image=mcr.microsoft.com/dotnet/core/runtime -- dotnet
```
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", "defau... |
Update the label 'status=unhealthy' for the pod 'log-aggregator' only if the resource is unchanged from version 1. | Command:
```bash
kubectl label pods log-aggregator status=unhealthy --resource-version=1
```
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"... |
Autoscale the deployment "monitoring" with a minimum of 3 pods and a maximum of 9 pods. | Command:
```bash
kubectl autoscale deployment monitoring --min=3 --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 us... |
Add the taint "datacenter=prod-node-5:PreferNoSchedule" to nodes labeled with "app-type=microservice" | Command:
```bash
kubectl taint node -l app-type=microservice datacenter=prod-node-5:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", ... |
Expose a replication controller specified in a YAML file as a service, with specific port mappings | Command:
```bash
kubectl expose -f wordpress-controller.yaml --port=5001 --target-port=500100
```
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 a copy of a pod called log-aggregator-pod, with all container images changed to confluentinc/cp-kafka | Command:
```bash
kubectl debug log-aggregator-pod --copy-to=my-custom-dbg --set-image=*=confluentinc/cp-kafka
```
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 b... |
import specific keys from a config map to a deployment | Command:
```bash
kubectl set env --keys=config_file_path --from=configmap/env-vars 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... |
Forward port 3000 to port 8088 in the pod | Command:
```bash
kubectl port-forward pod/web-app-pod 3000: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 automa... |
Create a new secret named ssh-key-secret using the keys for each file in the "path/to/profiles" folder | Command:
```bash
kubectl create secret generic ssh-key-secret --from-file=path/to/profiles
```
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... |
Set the custom TLS server name to "my-k8s-cluster" for the cluster entry "moon-cluster" in the kubeconfig file | Command:
```bash
kubectl config set-cluster moon-cluster --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] [--certifica... |
Set the custom TLS server name to "kube-cluster-1" for the "on-prem-cluster" cluster entry | Command:
```bash
kubectl config set-cluster on-prem-cluster --tls-server-name=kube-cluster-1
```
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] [--certif... |
Create a copy of "auth-service-pod" and add a "debug" container to it with different container images. | Command:
```bash
kubectl debug auth-service-pod -it --copy-to=dgb-img --image=debian --set-image=mailer=mailer:latest,app=app:debug
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and nam... |
Create a service for the replicated 'alpine' using a replica set, which serves on port 8083 and connects to the containers on port 330600 | Command:
```bash
kubectl expose rs alpine --port=8083 --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 port.... |
Forward local port 6379 to port 8080 in the pod named "mypod" | Command:
```bash
kubectl port-forward pod/mypod 6379:8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automaticall... |
Create a cluster role named "view" with the verb "connect" and the resources "services" and "services/payment-processor" and "services/prod-api-gateway" specified. | Command:
```bash
kubectl create clusterrole view --verb=connect --resource=services --resource-name=payment-processor --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=serve... |
Run the 'python --version' command in the 'mycontainer' container of the 'api-service-pod' pod and display the output. | Command:
```bash
kubectl exec api-service-pod -c mycontainer -- python --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 om... |
Get the output of the 'pip --version' command in the lunar-launcher container of the database-pod pod | Command:
```bash
kubectl exec database-pod -c lunar-launcher -- pip --version
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitt... |
Update the image version (tag) of the single-container pod named 'auth-service-pod' to v4 | Command:
```bash
kubectl get pod auth-service-pod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f -
```
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 b... |
Copy the local file /tmp/foo to the remote pod ingress-controller-pod-8 in the container load-balancer at the path /tmp/bar | Command:
```bash
kubectl cp /tmp/foo ingress-controller-pod-8::/tmp/bar -c load-balancer
```
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 new config map named app-config-prod using specified files from disk | Command:
```bash
kubectl create configmap app-config-prod --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 creat... |
Start a new pod named 'nginx' using the 'ethereum/client-go' image, but override the spec of the pod with a partial set of values parsed from the provided JSON. | Command:
```bash
kubectl run nginx --image=ethereum/client-go --overrides='{ "apiVersion": "v2.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... |
Create an ingress resource named 'public-api-ingress' that routes requests from 'website.com/bar' to the service 'svc1:3306' and uses the TLS secret 'my-cert' for secure communication. | Command:
```bash
kubectl create ingress public-api-ingress --rule="website.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... |
create a new batch-processing job using the php image | Command:
```bash
kubectl create job batch-processing --image=php --
```
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": "Output format. One of: js... |
Embed the certificate authority data for the 'my-k8s-cluster' cluster entry using the command 'kubectl config set-cluster' with the following parameters: --embed-certs and --certificate-authority=~/.kube/kube-cluster-1/kubernetes.ca.crt | Command:
```bash
kubectl config set-cluster my-k8s-cluster --embed-certs --certificate-authority=~/.kube/kube-cluster-1/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 the cluster field in a context to a specific value | Command:
```bash
kubectl config set contexts.admin-context.cluster cluster-beta
```
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 wa... |
Copy the local file `/tmp/foo_dir` to the remote pod `kube-public/backend-pod-13` in the `kube-public` namespace. | Command:
```bash
kubectl cp /tmp/foo_dir kube-public/backend-pod-13::/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 ku... |
Create a cluster role named "default_role" with the ability to delete services and specific resource names like "file-uploader" and "file-storage" | Command:
```bash
kubectl create clusterrole default_role --verb=delete --resource=services --resource-name=file-uploader --resource-name=file-storage
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server... |
Create a pod disruption budget named batch-processing-pdb that will select all pods with the region=us-east label and require at least four of them being available at any point in time | Command:
```bash
kubectl create poddisruptionbudget batch-processing-pdb --selector=region=us-east --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-availa... |
Create a new config map named 'namespace-config' in the current namespace using the files 'file1.txt' and 'file2.txt' as the values for the 'conf' and 'data' keys respectively. | Command:
```bash
kubectl create configmap namespace-config --from-file=conf=/path/to/parameters/file1.txt --from-file=data=/path/to/parameters/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creati... |
Listen on ports 3000 locally, forwarding data to/from port 6379 in a pod selected by the analytics-platform-deployment deployment. | Command:
```bash
kubectl port-forward deployment/analytics-platform-deployment 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 po... |
Start a new pod with the image "node" and set labels "app=node" and "env=prod" | Command:
```bash
kubectl run hazelcast --image=node --labels="app=node,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 flag... |
Set a custom TLS server name for the web-cluster cluster entry. | Command:
```bash
kubectl config set-cluster web-cluster --tls-server-name=dev-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... |
Expose a service for the replication controller specified in "php-controller.yaml", serving on port 9000 and connecting to the containers on port 808200. | Command:
```bash
kubectl expose -f php-controller.yaml --port=9000 --target-port=808200
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the sp... |
Create a pod disruption budget named 'messaging-pdb' that selects all pods with the label 'app=rails' and requires at least one of them to be available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget messaging-pdb --selector=app=rails --min-available=1
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N [--dry... |
Create a new NodePort service named "analytics-nodeport" and map traffic from port 9090 on the host to port 8000 on the target Pods. | Command:
```bash
kubectl create service nodeport analytics-nodeport --tcp=9090:8000
```
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": "... |
View metrics for a specific node | Command:
```bash
kubectl top node gpu-node-12
```
What it does:
Display resource (CPU/memory) usage of nodes.
The top-node command allows you to see the resource consumption of nodes.
Syntax:
`kubectl top node [NAME | -l label]`
Helpful flags:
"flag": "--selector", "short": "-l", "default": "", "usage": "Selector (l... |
Update the annotation of a pod 'foo' with the key 'description' and the value 'Web server for marketing site'. | Command:
```bash
kubectl annotate pods foo description='Web server for marketing site'
```
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 an... |
Listen on port 3000 locally, forwarding traffic to port 5000 in the 'chat-app-pod' pod. | Command:
```bash
kubectl port-forward pod/chat-app-pod 3000:5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected autom... |
List deployments in JSON output format, using a custom version of the "beta-apps" API group. | Command:
```bash
kubectl get deployments.custom-version.beta-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 y... |
Set the resource requests and limits for all containers in the Postgres deployment to allocate CPU and memory resources to the desired levels. | Command:
```bash
kubectl set resources deployment postgres --limits=cpu=200m,memory=512Mi --requests=cpu=3,memory=512Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource reques... |
Forward traffic from localhost and IP address 10.19.21.23 on port 8080 to port 8088 in the pod named "api-service-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/api-service-pod 8080: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 cri... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.