prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Create a port forwarding to a pod selected by the deployment, so you can listen on local ports 8000 and 6000 and forward data to/from ports 8888 and 6000 respectively. | Command:
```bash
kubectl port-forward deployment/log-aggregator-deployment 8000 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... |
Create a copy of the 'payment-gateway-pod' with a debug container in it, using the 'debian' image | Command:
```bash
kubectl debug payment-gateway-pod -it --copy-to=debug-image-api --image=debian --set-image=web=nginx:latest,proxy=nginx:1.21
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resour... |
Roll back the deployment to the previous version | Command:
```bash
kubectl rollout undo deployment/app-v2
```
What it does:
Roll back to a previous rollout.
Syntax:
`kubectl rollout undo (TYPE NAME | TYPE/NAME) [flags]`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to files identifying the resource to get... |
Start a hazelcast pod named 'nginx', using the image 'hazelcast/hazelcast', and provide a partial set of spec values parsed from JSON using the given overrides. | Command:
```bash
kubectl run nginx --image=hazelcast/hazelcast --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] [--comman... |
Create a cluster role named "foo" with ResourceName specified | Command:
```bash
kubectl create clusterrole foo --verb=use --resource=configmaps --resource-name=billing-service --resource-name=audit-logger
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|client|... |
Fetch a JSON formatted list of deployments in the "alpha-2.0" version of the "mobile-apps" API group | Command:
```bash
kubectl get deployments.alpha-2.0.mobile-apps -o json
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you ... |
Apply the configuration in the 'manifest.yaml' file that matches the label 'app-type=microservice' and delete all other resources that are not in the file and match the label 'app=nginx' | Command:
```bash
kubectl apply --prune -f manifest.yaml -l app-type=microservice
```
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 'app... |
Create a copy of the "security-service-pod" with all container images changed to "mysql" | Command:
```bash
kubectl debug security-service-pod --copy-to=dgb-img --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 reso... |
View the details of the revision 3 of the daemonset "services" | Command:
```bash
kubectl rollout history daemonset/services --revision=3
```
What it does:
View previous rollout revisions and configurations.
Syntax:
`kubectl rollout history (TYPE NAME | TYPE/NAME) [flags]`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL t... |
Display the most recent 31 lines of logs for the 'backend-pod' pod | Command:
```bash
kubectl logs --tail=31 backend-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "short": "-c"... |
Display the most recent 23 lines of output in the logs of the pod named "gateway-pod" | Command:
```bash
kubectl logs --tail=23 gateway-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "short": "-c"... |
Create a new secret named 'email-credentials-secret', and include keys for each file in the 'bar' folder. | Command:
```bash
kubectl create secret generic email-credentials-secret --from-file=path/to/configurations
```
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 t... |
Forward traffic from port 8081 on your local machine to port 9090 inside the security-service-pod pod. | Command:
```bash
kubectl port-forward pod/security-service-pod 8081:9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be select... |
Start a hazelcast pod with custom configuration values provided in a JSON file | Command:
```bash
kubectl run nginx --image=hazelcast/hazelcast --overrides='{ "apiVersion": "alpha-2.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--com... |
Import the 'my-example-key' key from the 'app-secrets' config map into the 'authentication-service-deployment' deployment. | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/app-secrets deployment/authentication-service-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment varia... |
Forward local port 5432 to the pod port 5000 | Command:
```bash
kubectl port-forward pod/frontend-pod 5432:5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected autom... |
Create an ingress called 'website-ingress' that directs requests to website.com/bar to svc # svc1:8088 using the tls secret "my-cert" | Command:
```bash
kubectl create ingress website-ingress --rule="website.com/bar=svc1:8088,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... |
Import the environment variables from the 'aws-credentials-secret' secret into the 'scheduler-app-deployment' deployment. | Command:
```bash
kubectl set env --from=secret/aws-credentials-secret deployment/scheduler-app-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one ... |
Switch to raw terminal mode; send stdin to 'bash' in the mycontainer container from the backend-pod pod, and send stdout/stderr from 'bash' back to the client. | Command:
```bash
kubectl attach backend-pod -c mycontainer -i -t
```
What it does:
Attach to a process that is already running inside an existing container.
Syntax:
`kubectl attach (POD | TYPE/NAME) -c CONTAINER`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted... |
Enable the autoscaling feature for the deployment named "frontend" with a minimum of 6 pods and a maximum of 10 pods. | Command:
```bash
kubectl autoscale deployment frontend --min=6 --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 use... |
Set the service account of the deployment "gateway-deployment" to "argocd" | Command:
```bash
kubectl set serviceaccount deployment gateway-deployment argocd
```
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 set... |
Forward traffic from port 9090 on localhost and IP 10.19.21.23 to port 3000 in the 'log-aggregator-pod' pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/log-aggregator-pod 9090: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 ... |
Create a Pod Disruption Budget named "logging-pdb" that selects all pods with the "version=v2" label and requires a minimum of four of them to be available at any point in time. | Command:
```bash
kubectl create poddisruptionbudget logging-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 [--dry-... |
Disable certificate checking for the dev cluster entry | Command:
```bash
kubectl config set-cluster edge-cluster --insecure-skip-tls-verify=true
```
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] [--certificat... |
Create a service for the replicated 'ubuntu' using replica set | Command:
```bash
kubectl expose rs ubuntu --port=8010 --target-port=909100
```
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 an owner annotation to the pod in "pod.json" | Command:
```bash
kubectl annotate -f pod.json owner='alice smith'
```
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 s... |
Update the environment variables of the deployment "proxy-service-deployment" by importing the "smtp_server" key from the config map "app-secrets". | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/app-secrets 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 definiti... |
Create a job named "log-collection" using the Elasticsearch Docker image with a specific version | Command:
```bash
kubectl create job log-collection --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", "... |
Delete the pods and services with the names "media-stream" and "vpn" | Command:
```bash
kubectl delete pod,service media-stream vpn
```
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 centos pod with overridden values from JSON | Command:
```bash
kubectl run nginx --image=centos --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] -- [COMM... |
Update the pod named 'monitoring' with the label 'tier' and the value 'backend' | Command:
```bash
kubectl label pods monitoring tier=backend
```
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"... |
Listen on port 8888 and forward traffic to port 9090 in the pod named "chat-app-pod". Forward traffic from all addresses. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/chat-app-pod 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 will... |
Copy the content of /var/run/secrets/kubernetes.io/serviceaccount/ from the pod named 'database-pod-2' to the local directory /tmp/bar. | Command:
```bash
kubectl cp kube-server/database-pod-2:/var/run/secrets/kubernetes.io/serviceaccount/ :/tmp/bar
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Cont... |
Retrieve the output from running the 'wp' command in the container 'cyber-sleuth' of the pod 'monitoring-pod' | Command:
```bash
kubectl exec monitoring-pod -c cyber-sleuth -- 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... |
Add a taint with key 'cpu-type' on nodes having label zone=us-east-1 and assign the taint PreferNoSchedule to the testing-node-11 node. | Command:
```bash
kubectl taint node -l zone=us-east-1 cpu-type=testing-node-11: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... |
Create a copy of the email-service-pod with all container images changed to alpine for debugging | Command:
```bash
kubectl debug email-service-pod --copy-to=debug-image-api --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 n... |
Output the modified deployment in YAML format without making any changes on the server | Command:
```bash
kubectl set env deployment/log-aggregator-deployment SECRET_KEY=your-secret-key -o yaml
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one o... |
Apply a taint with the key 'dedicated' and value 'dev-node-4:PreferNoSchedule' on nodes that have the label 'service=auth' | Command:
```bash
kubectl taint node -l service=auth dedicated=dev-node-4:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "O... |
Display the most recent 53 lines of logs for the "auth-service-pod" pod. | Command:
```bash
kubectl logs --tail=53 auth-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", "short":... |
Create a deployment named logging with the mongo image running and port 8010 exposed | Command:
```bash
kubectl create deployment logging --image=mongo --port=8010
```
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: j... |
Import the environment variables from the cert-manager-secret secret into the scheduler-app-deployment deployment. | Command:
```bash
kubectl set env --from=secret/cert-manager-secret deployment/scheduler-app-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or ... |
Create a cron job for generating reports using Kafka image, with a schedule for every minute | Command:
```bash
kubectl create cronjob report-generation --image=confluentinc/cp-kafka --schedule="*/1 * * * *" -- kafka-server-start /etc/kafka/server.properties
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [arg... |
Create a new ClusterIP service named auth-service-clusterip with the mapping of port 9092 to port 8443. | Command:
```bash
kubectl create service clusterip auth-service-clusterip --tcp=9092:8443
```
What it does:
Create a ClusterIP service with the specified name.
Syntax:
`kubectl create service clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "... |
Start streaming the logs of the 'nano-bot' container in the 'web-app-pod' pod | Command:
```bash
kubectl logs -f -c nano-bot web-app-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "short":... |
Resume a paused deployment named "namespace-2" | Command:
```bash
kubectl rollout resume deployment/namespace-2
```
What it does:
Resume a paused resource.
Paused resources will not be reconciled by a controller. By resuming a resource, we allow it to be reconciled again. Currently only deployments support being resumed.
Syntax:
`kubectl rollout resume RESOURCE`
H... |
Listen on port 8081 locally and forward to port 8888 in the e-commerce-pod pod. | Command:
```bash
kubectl port-forward pod/e-commerce-pod 8081:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected aut... |
Import environment variables from a secret for a deployment | Command:
```bash
kubectl set env --from=secret/ssl-key-secret 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 definitions in one or more ... |
Create an ingress called 'app-ingress' that routes requests from site.com/input to svc1:5432 with SSL/TLS enabled using the secret "my-cert" | Command:
```bash
kubectl create ingress app-ingress --rule="site.com/input=svc1:5432,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "... |
Create a copy of the "monitoring-pod" pod, replacing the command of the "cyber-sleuth" container with a shell session | Command:
```bash
kubectl debug monitoring-pod -it --copy-to=dgb-img --container=cyber-sleuth -- 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 default i... |
List deployments in YAML output format from the "custom-apps" API group with version "v2.1.0" | Command:
```bash
kubectl get deployments.v2.1.0.custom-apps -o yaml
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you wil... |
Create an ingress named 'public-ingress' to route requests from testing.com/input to svc1:3000 using the TLS secret "my-cert" | Command:
```bash
kubectl create ingress public-ingress --rule="testing.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": "", "usa... |
Execute the 'redis-cli' command in the nebula-navigator container of the database-pod pod and retrieve the output. | Command:
```bash
kubectl exec database-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 omitted... |
Create a secret named "aws-credentials-secret" with keys for each file in the folder "path/to/preferences" | Command:
```bash
kubectl create secret generic aws-credentials-secret --from-file=path/to/preferences
```
What it does:
Create a secret based on a file, directory, or specified literal value.
A single secret may package one or more key/value pairs.
When creating a secret based on a file, the key will default to the ba... |
Set the custom TLS server name for the 'kube-cluster-2' cluster entry to 'cloud-cluster' | Command:
```bash
kubectl config set-cluster kube-cluster-2 --tls-server-name=cloud-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... |
rename the context from 'dev-context' to 'app-2-context' in the kubeconfig file | Command:
```bash
kubectl config rename-context dev-context app-2-context
```
What it does:
Renames a context from the kubeconfig file.
CONTEXT_NAME is the context name that you want to change.
NEW_NAME is the new name you want to set.
Note: If the context being renamed is the 'current-context', this field will also be... |
Remove all the taints with key 'special' from the node 'kube-master-9' | Command:
```bash
kubectl taint nodes kube-master-9 special-
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json|yaml... |
Retrieve the logs of the vpn-service-pod pod, which has only one container | Command:
```bash
kubectl logs vpn-service-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "short": "-c", "def... |
Create a cluster role named "view" with specific resource names. | Command:
```bash
kubectl create clusterrole view --verb=delete --resource=configmaps --resource-name=auth-proxy --resource-name=web-frontend
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|client|n... |
Apply a strategic merge patch to update a specific container in a worker node's resources | Command:
```bash
kubectl patch node worker-node-3 -p $'spec:\n containers:\n- name: container-name\n resources:\n limits:\n cpu: 200m'
```
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... |
Create a service for the replicated node using the replica set "node", which serves on port 80 and connects to the containers on port 637900. | Command:
```bash
kubectl expose rs node --port=80 --target-port=637900
```
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 d... |
Forward local port 8088 to port 5432 in a pod selected by the log-aggregator-deployment deployment. | Command:
```bash
kubectl port-forward deployment/log-aggregator-deployment 8088 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... |
Forward the local port 8888 to the port 5432 in the pod 'backend-pod' | Command:
```bash
kubectl port-forward pod/backend-pod 8888: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 automa... |
Update the 'auth' pod with the annotation 'compliance-level' and set its value to 'PCI-DSS' | Command:
```bash
kubectl annotate --overwrite pods auth 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 in... |
Create a new ClusterIP service named payment-service-clusterip with a mapping from port 6379 to port 8083. | Command:
```bash
kubectl create service clusterip payment-service-clusterip --tcp=6379:8083
```
What it does:
Create a ClusterIP service with the specified name.
Syntax:
`kubectl create service clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o"... |
Create a new config map named app-config from the key=value pairs in the file located at path/to/options. | Command:
```bash
kubectl create configmap app-config --from-file=path/to/options
```
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 of... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=LOG_LEVEL --from=configmap/app-name-config deployment/load-balancer-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defini... |
List the replication controller named "web", service named "web-app-rc", and pod named "cdn-service-pod" | Command:
```bash
kubectl get rc/web service/web-app-rc pods/cdn-service-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 namespaced... |
Update the label of the pod 'api' to 'unhealthy=true' | Command:
```bash
kubectl label pods api 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", "usage": "If... |
Import the 'SMTP_SERVER' key from the 'api-config' ConfigMap and set it as an environment variable in the 'email-server-deployment' deployment. | Command:
```bash
kubectl set env --keys=SMTP_SERVER --from=configmap/api-config deployment/email-server-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definition... |
Import the "debug_mode" key from the "monitoring-config" config map into the environment variables of the "proxy-service-deployment" deployment. | Command:
```bash
kubectl set env --keys=debug_mode --from=configmap/monitoring-config 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 def... |
Create a service for the Hazelcast deployment that serves on port 5432 and connects to the containers on port 500000. | Command:
```bash
kubectl expose deployment hazelcast --port=5432 --target-port=500000
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the spec... |
create a new config map named app-settings with specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-settings --from-file=conf=/path/to/properties/file1.txt --from-file=data=/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 co... |
Set up autoscaling for the replication controller "vpn" | Command:
```bash
kubectl autoscale rc vpn --max=7 --cpu-percent=81
```
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... |
Import the environment variables from the secret 'azure-storage-secret' and set them for the 'email-server-deployment' deployment. | Command:
```bash
kubectl set env --from=secret/azure-storage-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 ... |
Retrieve the snapshot logs from the container named backend-pod-1 in the web-app-deployment deployment. | Command:
```bash
kubectl logs deployment/web-app-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 flags:
"flag": "--... |
List the replication controller 'cdn-service-rc' in the ps output format | Command:
```bash
kubectl get replicationcontroller cdn-service-rc
```
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 ... |
delete the pods and services named "analytics" and "api" | Command:
```bash
kubectl delete pod,service analytics api
```
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.
S... |
Update the 'someField' field of the 'web-node-8' node by using a strategic merge patch with the value 'newValue' | Command:
```bash
kubectl patch node web-node-8 -p '{"spec":{"someField":"newValue"}'
```
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]`
Helpf... |
Embed the certificate authority data for the 'kube-cluster-1' cluster entry by running the command `kubectl config set-cluster kube-cluster-1 --embed-certs --certificate-authority=~/.kube/on-prem-cluster/kubernetes.ca.crt` | Command:
```bash
kubectl config set-cluster kube-cluster-1 --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 confi... |
Listen on port 5432 locally, forwarding to port 3000 in the backend-pod pod | Command:
```bash
kubectl port-forward pod/backend-pod 5432: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 a new ClusterIP service named catalog-service-clusterip | Command:
```bash
kubectl create service clusterip catalog-service-clusterip --tcp=8082:8888
```
What it does:
Create a ClusterIP service with the specified name.
Syntax:
`kubectl create service clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o"... |
Copy the /tmp/foo_dir directory from the front-end-pod-12 pod in the kube-public namespace to the /tmp/bar directory on your local machine. | Command:
```bash
kubectl cp kube-public/front-end-pod-12:/tmp/foo_dir /tmp/bar
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the k... |
Forward local port 5432 to port 8888 in the pod named "analytics-pod" | Command:
```bash
kubectl port-forward pod/analytics-pod 5432:8888
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected auto... |
Forward traffic from port 5000 on all addresses to port 9090 in the pod named "log-aggregator-pod" | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/log-aggregator-pod 5000: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 po... |
Check if you have permission to list the job named "database-indexing-job" in the "testing" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/database-indexing-job -n testing
```
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 ... |
Add a taint with key 'workload' on nodes having label customer=acme-corp | Command:
```bash
kubectl taint node -l customer=acme-corp workload=node-2:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "... |
Return the snapshot logs from the container 'log-aggregator-pod-1' of the 'gateway-deployment' deployment. | Command:
```bash
kubectl logs deployment/gateway-deployment -c log-aggregator-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:
"fla... |
Create a pod named "hazelcast" with the Golang image and expose port 9000. | Command:
```bash
kubectl run hazelcast --image=golang --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:
"flag": "--f... |
Begin streaming the logs of the code-explorer container in the chat-app-pod pod | Command:
```bash
kubectl logs -f -c code-explorer chat-app-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "s... |
Forward local port 8888 to port 6379 in the pod named "security-service-pod" and listen on port 6000 locally, forwarding data to/from port 6000 in the pod. | Command:
```bash
kubectl port-forward pod/security-service-pod 8888 6379
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be select... |
Create an ingress called 'private-service-ingress' that directs requests to site.com/module to svc1:3000 with a TLS secret named "my-cert" | Command:
```bash
kubectl create ingress private-service-ingress --rule="site.com/module=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": "... |
Create a job called "indexing" using the "node" image and executing the "node" command | Command:
```bash
kubectl create job indexing --image=node -- node
```
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: json... |
Forward local port 9090 to remote port 6379 in the specified pod | Command:
```bash
kubectl port-forward pod/proxy-server-pod 9090: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 a... |
Set a custom TLS server name for the cluster-beta cluster entry | Command:
```bash
kubectl config set-cluster cluster-beta --tls-server-name=prod-cluster
```
What it does:
Set a cluster entry in kubeconfig.
Specifying a name that already exists will merge new fields on top of existing values for those fields.
Syntax:
`kubectl config set-cluster NAME [--server=server] [--certificate... |
Create a copy of e-commerce-pod with a debug container and different container images | Command:
```bash
kubectl debug e-commerce-pod -it --copy-to=debug-image-memcached --image=debian --set-image=proxy=nginx:1.21,database=mysql:5.7
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by res... |
Add a taint with key 'hardware' on nodes having label zone=us-east-1 | Command:
```bash
kubectl taint node -l zone=us-east-1 hardware=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... |
Run the 'node' command inside the web-app-pod and get the output | Command:
```bash
kubectl exec web-app-pod -- 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 the kubectl.kubernet... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=DATABASE_URL --from=configmap/global-config 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 defin... |
Forward local port 8000 to port 8088 in the pod named cdn-service-pod. | Command:
```bash
kubectl port-forward pod/cdn-service-pod 8000: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 au... |
Create a new config map named api-config from the key=value pairs in the file at the specified path | Command:
```bash
kubectl create configmap api-config --from-file=path/to/data
```
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 of th... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.