prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Expose the python deployment as a service on port 3000, connecting to the containers on port 8082 | Command:
```bash
kubectl expose deployment python --port=3000 --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 specifi... |
Create a single ingress that directs requests to a specific service and port, using a TLS secret for secure communication | Command:
```bash
kubectl create ingress external-ingress --rule="site.com/input=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... |
Check if the current authenticated user has the permission to list the job named "cleanup-job" in the "testing" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/cleanup-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 URL that s... |
Get output from running the 'postgres' command in stardust-shuttle from the payment-gateway-pod | Command:
```bash
kubectl exec payment-gateway-pod -c stardust-shuttle -- postgres
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If o... |
Create a copy of the auth-service-pod and change all container images to hazelcast/hazelcast. Save this copy as dgb-img. | Command:
```bash
kubectl debug auth-service-pod --copy-to=dgb-img --set-image=*=hazelcast/hazelcast
```
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 ... |
Create a new service named external-git-service of type ExternalName with the external name documentation-tech.tech | Command:
```bash
kubectl create service externalname external-git-service --external-name documentation-tech.tech
```
What it does:
Create an ExternalName service with the specified name.
ExternalName service references to an external DNS address instead of only pods, which will allow application authors to reference ... |
Forward traffic from port 8000 on localhost and IP 10.19.21.23 to port 8888 in the e-commerce pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/e-commerce-pod 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 crit... |
Create an ingress resource called 'web-ingress' with a rule that directs requests for testing.com/example to svc1:3001 | Command:
```bash
kubectl create ingress web-ingress --rule="testing.com/example=svc1:3001,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
Scale the deployment named db-migration-replicaset to have 7 replicas if its current size is 3 | Command:
```bash
kubectl scale --current-replicas=3 --replicas=7 deployment/db-migration-replicaset
```
What it does:
Set a new size for a deployment, replica set, replication controller, or stateful set.
Scale also allows users to specify one or more preconditions for the scale action.
If --current-replicas or --reso... |
Copy the /var/run/secrets/kubernetes.io/serviceaccount/ file from the local machine to the /etc/kubernetes directory in a remote pod named worker-pod-4 in the ingress-nginx namespace. | Command:
```bash
kubectl cp /var/run/secrets/kubernetes.io/serviceaccount/ ingress-nginx/worker-pod-4:/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":... |
Start a Redis pod with container exposing port 9091. | Command:
```bash
kubectl run hazelcast --image=redis --port=9091
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--fi... |
Create a port forward between the local port 5432 and the pod selected by the 'monitoring-stack-deployment' deployment's port 5000. | Command:
```bash
kubectl port-forward deployment/monitoring-stack-deployment 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 ... |
Embed the certificate authority data for the web-cluster cluster entry by running the command "kubectl config set-cluster web-cluster --embed-certs --certificate-authority=~/.kube/app-cluster/kubernetes.ca.crt" | Command:
```bash
kubectl config set-cluster web-cluster --embed-certs --certificate-authority=~/.kube/app-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 set-c... |
Delete the pods and services with the names "cdn" and "proxy-server" | Command:
```bash
kubectl delete pod,service cdn proxy-server
```
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... |
Create a debug container in vpn-service-pod by copying the container and changing container images. | Command:
```bash
kubectl debug vpn-service-pod -it --copy-to=debug-image-app --image=debian --set-image=mailer=mailer:latest,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 reso... |
Import the 'smtp_server' key from the 'log-config' config map and set it as an environment variable in the 'api-server-deployment' deployment. | Command:
```bash
kubectl set env --keys=smtp_server --from=configmap/log-config deployment/api-server-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions ... |
Import the SECRET_KEY key from the app-config config map into the mydeployment deployment. | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/app-config deployment/mydeployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or ... |
Remove the specified environment variable for the "cloud-user" entry in the kubeconfig file. | Command:
```bash
kubectl config set-credentials cloud-user --exec-env=var-to-remove-
```
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
Bearer token flags... |
Forward local port 5432 to pod port 8080 in the e-commerce-pod | Command:
```bash
kubectl port-forward pod/e-commerce-pod 5432 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 aut... |
Create a cluster role named "reader" with the ability to execute operations on configmaps resources with the names "blog-backend" and "cache-redis" | Command:
```bash
kubectl create clusterrole reader --verb=exec --resource=configmaps --resource-name=blog-backend --resource-name=cache-redis
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|client|... |
Create a copy of the 'chat-app-pod' pod, changing all container images to 'ubuntu'. Name the copy 'my-custom-dbg' | Command:
```bash
kubectl debug chat-app-pod --copy-to=my-custom-dbg --set-image=*=ubuntu
```
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 resou... |
Retrieve the logs of the previous terminated 'cyber-sleuth' container from the 'monitoring-pod' pod. | Command:
```bash
kubectl logs -p -c cyber-sleuth monitoring-pod
```
What it does:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Syntax:
`kubectl logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]`
Helpful flags:
"flag": "--container", "... |
Create a pod disruption budget with specific criteria | Command:
```bash
kubectl create poddisruptionbudget frontend-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-available=N [-... |
Start a new pod named 'nginx' with the image 'docker.elastic.co/elasticsearch/elasticsearch', and override the spec of the pod with a partial set of values parsed from the provided JSON. | Command:
```bash
kubectl run nginx --image=docker.elastic.co/elasticsearch/elasticsearch --overrides='{ "apiVersion": "stable-2.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] [--... |
Create a copy of the payment-gateway-pod, adding a debug container and changing container images to debian for the debug container and mysql:5.7 for the database container. | Command:
```bash
kubectl debug payment-gateway-pod -it --copy-to=my-debugger --image=debian --set-image=database=mysql:5.7,database=mysql:5.7
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resour... |
Forward local port 8888 to port 5432 in the chat-app-pod, allowing local access to the pod's network. | Command:
```bash
kubectl port-forward pod/chat-app-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 autom... |
Import the "my-example-key" key from the "env-vars" ConfigMap and set it as an environment variable in the "monitoring-stack-deployment" deployment. | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/env-vars deployment/monitoring-stack-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable defin... |
Start a redis pod named "nginx" with the image set to "redis", but customize the spec using a partial set of values parsed from JSON. | Command:
```bash
kubectl run nginx --image=redis --overrides='{ "apiVersion": "custom-version", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- ... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=my-example-key --from=configmap/ui-config deployment/api-server-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definition... |
Edit the 'frontend-deployment' deployment in YAML format and save the modified configuration in its annotation. | Command:
```bash
kubectl edit deployment/frontend-deployment -o yaml --save-config
```
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 environ... |
Set environment variable from specific keys in a config map for a deployment | Command:
```bash
kubectl set env --keys=config_file_path --from=configmap/ui-config deployment/gateway-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions... |
Execute the 'redis-cli' command in the 'proxy-service-pod' pod and retrieve the output | Command:
```bash
kubectl exec proxy-service-pod -- 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, use the kubec... |
Retrieve the current phase of a pod | Command:
```bash
kubectl get -o template pod/chat-app-pod --template={{.status.phase}}
```
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... |
Update the 'vpn-service-pod' pod's image version (tag) to v4. | Command:
```bash
kubectl get pod vpn-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 by... |
Output the modified deployment in YAML format without making any changes to the object on the server. | Command:
```bash
kubectl set env deployment/gateway-deployment SMTP_HOST=smtp.example.com -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 or more ... |
Get the output from the code-explorer container in the 'web-app-pod' pod | Command:
```bash
kubectl attach web-app-pod -c code-explorer
```
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, us... |
Forward local port 5432 to port 8000 in the web-app-pod pod | Command:
```bash
kubectl port-forward pod/web-app-pod 5432:8000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automa... |
Create a new ExternalName service named external-third-party-api-service | Command:
```bash
kubectl create service externalname external-third-party-api-service --external-name documentation-tech.tech
```
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 t... |
Forward port 3000 on your local machine to port 9090 in the log-aggregator-pod | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 3000:9090
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected... |
Create a cron job called "daily-report" using the Ubuntu image | Command:
```bash
kubectl create cronjob daily-report --image=ubuntu --schedule="*/1 * * * *" -- docker run -d ubuntu sleep 3600
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag": "--ou... |
Add an annotation to the pod 'chat-app' with the key 'last-deployment' and the value '2023-03-15'. | Command:
```bash
kubectl annotate pods chat-app last-deployment=2023-03-15
```
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 ar... |
Add a taint with the key 'datacenter' on nodes having the label stack=tech-stack with the value 'node-1' and the effect of 'PreferNoSchedule' | Command:
```bash
kubectl taint node -l stack=tech-stack datacenter=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": "... |
Get the output from running the 'elasticsearch' command in the 'nebula-navigator' container of the 'api-service-pod' pod. | Command:
```bash
kubectl exec api-service-pod -c nebula-navigator -- elasticsearch
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If ... |
Create a new config map named 'api-config' using the content of two files, 'file1.txt' located at '/path/to/preferences' and 'file2.txt' located at '/path/to/options'. | Command:
```bash
kubectl create configmap api-config --from-file=settings=/path/to/preferences/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... |
Set the resource limits for a specific container in a deployment to a specified CPU limit and memory size range. | Command:
```bash
kubectl set resources deployment runtime -c=nginx --limits=cpu=100m,memory=1Gi
```
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... |
Create an ingress for site.com/module that directs requests to svc1:27017 with TLS certificate "my-cert" | Command:
```bash
kubectl create ingress rontend-ingress --rule="site.com/module=svc1:27017,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... |
Roll back to the previous deployment with a dry-run | Command:
```bash
kubectl rollout undo --dry-run=server deployment/namespace-2
```
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 identifyi... |
Get the output from running the 'jenkins-plugin-cli' command from the 'monitoring-pod' pod | Command:
```bash
kubectl exec monitoring-pod -- jenkins-plugin-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, use the... |
Create a cron job named "daily-report" that runs the command "pg_dump --version" every minute using the postgres image. | Command:
```bash
kubectl create cronjob daily-report --image=postgres --schedule="*/1 * * * *" -- pg_dump --version
```
What it does:
Create a cron job with the specified name.
Syntax:
`kubectl create cronjob NAME --image=image --schedule='0/5 * * * ?' -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "shor... |
display the logs from the pod 'proxy-server-pod' written in the last hour | Command:
```bash
kubectl logs --since=1h proxy-server-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 job using the MySQL image and run the `mysqld` command. | Command:
```bash
kubectl create job monitoring-job --image=mysql -- mysqld
```
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... |
Add a label 'env' with the value 'production' to the pod named 'chat-app' | Command:
```bash
kubectl label pods chat-app env=production
```
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"... |
Create a copy of payment-gateway-pod with nginx container images | Command:
```bash
kubectl debug payment-gateway-pod --copy-to=debug-image-1 --set-image=*=nginx
```
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... |
Copy the '/tmp/foo_dir' directory from the 'file-server-pod-14' pod in the 'default' namespace to the '/tmp/bar' directory on the local machine. | Command:
```bash
kubectl cp default/file-server-pod-14:/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 kub... |
Create a new secret named 'app-config-secret' from the environment file located at 'path/to/properties.env' | Command:
```bash
kubectl create secret generic app-config-secret --from-env-file=path/to/properties.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 ... |
Forward traffic from port 8081 on localhost and IP address 10.19.21.23 to port 8000 in the analytics-pod pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/analytics-pod 8081:8000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the crite... |
update the server field of the cluster-beta cluster to use the provided IP address | Command:
```bash
kubectl config set clusters.cluster-beta.server https://1.2.3.4
```
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... |
Create a pod named 'hazelcast' using the image 'mcr.microsoft.com/dotnet/core/runtime' and expose port 8088. | Command:
```bash
kubectl run hazelcast --image=mcr.microsoft.com/dotnet/core/runtime --port=8088
```
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...... |
Execute the 'geth version' command inside the e-commerce-pod and display the output. | Command:
```bash
kubectl exec e-commerce-pod -- geth version
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the kubec... |
set the resource requests and limits for all containers in the deployment named "runtime" to 2 CPUs and 64Mi memory for requests, and 200m CPU and 512Mi memory for limits. | Command:
```bash
kubectl set resources deployment runtime --limits=cpu=200m,memory=512Mi --requests=cpu=2,memory=64Mi
```
What it does:
Specify compute resource requirements (CPU, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requeste... |
View the logs from container "user-management-deployment-1" of a deployment named "e-commerce-pod". | Command:
```bash
kubectl logs deployment/user-management-deployment -c e-commerce-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:
... |
Create a role named "admin_role" with ResourceName specified | Command:
```bash
kubectl create role admin_role --verb=use --resource=pods --resource-name=dev-database --resource-name=api-server
```
What it does:
Create a role with single rule.
Syntax:
`kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run=server|clie... |
Create an ingress called 'public-api-ingress' that redirects requests from site.com/module to svc1:3000 with a tls secret named "my-cert" | Command:
```bash
kubectl create ingress public-api-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": "", "u... |
Create a new ClusterIP service named database-service-clusterip and expose port 8089 of the service to port 8010 of the target | Command:
```bash
kubectl create service clusterip database-service-clusterip --tcp=8089:8010
```
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... |
Get the documentation for the 'annotations' field of the 'metadata' section of the services resource | Command:
```bash
kubectl explain resource=services.metadata.annotations
```
What it does:
List the fields for supported resources.
This command describes the fields associated with each supported API resource. Fields are identified via a simple JSONPath identifier:
<type>.<fieldName>[.<fieldName>]
Add the --recursive ... |
Forward local port 5432 to port 8888 of a pod selected by the deployment "mydeployment" | Command:
```bash
kubectl port-forward deployment/mydeployment 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 selecte... |
Update the pod specified in the config.json file by adding the annotation app-version=2.5.1 | Command:
```bash
kubectl annotate -f config.json app-version=2.5.1
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include arbitrary ... |
List deployments in JSON output format using the "beta-1.0" version of the "alpha-apps" API group. | Command:
```bash
kubectl get deployments.beta-1.0.alpha-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 wi... |
Remove all the taints with key 'workload' from the node 'storage-node-13' | Command:
```bash
kubectl taint nodes storage-node-13 workload-
```
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|y... |
Forward local port 8000 to port 9090 in the pod "proxy-server-pod" and listen on all addresses. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/proxy-server-pod 8000: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 ... |
import the 'max_connections' key from the 'monitoring-config' config map and set it as an environment variable for the 'load-balancer-deployment' deployment. | Command:
```bash
kubectl set env --keys=max_connections --from=configmap/monitoring-config deployment/load-balancer-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variabl... |
Add a taint with key 'zone' on nodes having label owner=john-doe with taint value kube-master-9:PreferNoSchedule | Command:
```bash
kubectl taint node -l owner=john-doe zone=kube-master-9:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "O... |
Add a taint with key 'hardware' on nodes having the label 'customer=acme-corp' and set the value to 'testing-node-11:PreferNoSchedule' | Command:
```bash
kubectl taint node -l customer=acme-corp hardware=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": "", "... |
Retrieve snapshot logs from container "media-stream-pod-1" in the deployment "analytics-platform-deployment" | Command:
```bash
kubectl logs deployment/analytics-platform-deployment -c media-stream-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 fl... |
Forward the traffic from port 8081 on localhost and IP 10.19.21.23 to port 8088 in the 'analytics-pod' pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/analytics-pod 8081: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 crite... |
Create a deployment named "wordpress" with 7 replicas, running the "golang" image. | Command:
```bash
kubectl create deployment wordpress --image=golang --replicas=7
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One o... |
Forward traffic from port 8081 on localhost and IP 10.19.21.23 to port 8081 in the 'backend-pod' pod | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/backend-pod 8081: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 criteri... |
Create an ingress object called 'internal-ingress' with a rule that directs requests from foo.com/bar to svc1:8083 | Command:
```bash
kubectl create ingress internal-ingress --rule="foo.com/bar=svc1:8083,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage":... |
Forward local port 3000 to port 8000 in the pod/backend-pod | Command:
```bash
kubectl port-forward pod/backend-pod 3000 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 automa... |
Create a new secret named "oauth-secret" and include keys for each file in the "path/to/data" folder. | Command:
```bash
kubectl create secret generic oauth-secret --from-file=path/to/data
```
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 the fil... |
Remove all taints with key 'special' from the node 'node-2' | Command:
```bash
kubectl taint nodes node-2 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|name|g... |
Create an ingress named 'app-ingress' that routes requests from website.com/module to the service 'svc1' on port 8888, using the TLS secret 'my-cert'. | Command:
```bash
kubectl create ingress app-ingress --rule="website.com/module=svc1:8888,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage... |
Create a deployment named "api" using the "node" image and expose port 8181 | Command:
```bash
kubectl create deployment api --image=node --port=8181
```
What it does:
Create a deployment with the specified name.
Syntax:
`kubectl create deployment NAME --image=image -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json|y... |
Start a MySQL pod and expose port 9092 | Command:
```bash
kubectl run hazelcast --image=mysql --port=9092
```
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... |
Forward traffic from port 5432 on localhost and IP address 10.19.21.23 to port 8888 in the pod named "mypod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/mypod 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 p... |
Create a service named "frontend" for the pod "security-service-pod" that serves on port 5001. | Command:
```bash
kubectl expose pod security-service-pod --port=5001 --name=frontend
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the speci... |
Add a taint to the 'dev-node-4' node with the key 'app', value 'backend', and effect 'PreferNoSchedule' | Command:
```bash
kubectl taint nodes dev-node-4 app=backend: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. ... |
Create a role named "foo" with specific resource names | Command:
```bash
kubectl create role foo --verb=create --resource=pods --resource-name=file-uploader --resource-name=notification-service
```
What it does:
Create a role with single rule.
Syntax:
`kubectl create role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run=serv... |
Expose replica set node on port 5432, forwarding traffic to containers on port 9090 | Command:
```bash
kubectl expose rs node --port=5432 --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. A... |
Rename the context 'dev-context' to 'admin-context' in your kubeconfig file | Command:
```bash
kubectl config rename-context dev-context admin-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... |
Forward local port 8081 to port 6379 in the pod named "mypod" | Command:
```bash
kubectl port-forward pod/mypod 8081:6379
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automaticall... |
List deployments in JSON output format from the "custom-deployments" API group version "alpha-2.0" | Command:
```bash
kubectl get deployments.alpha-2.0.custom-deployments -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 namespac... |
Create an ingress called 'service-ingress' that directs requests from foo.com/input to the service svc1 on port 7000, using the tls secret named "my-cert" | Command:
```bash
kubectl create ingress service-ingress --rule="foo.com/input=svc1:7000,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage"... |
Create a new config map named app-name-config with specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-name-config --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... |
Return the phase value of the 'api-service-pod' pod using the template in the output format | Command:
```bash
kubectl get -o template pod/api-service-pod --template={{.status.phase}}
```
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... |
Create a copy of the 'monitoring-pod' with all container images changed to 'nginx' | Command:
```bash
kubectl debug monitoring-pod --copy-to=my-custom-dbg --set-image=*=nginx
```
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... |
Get the output from running the 'npm --version' command in the mycontainer container of the backend-pod pod. | Command:
```bash
kubectl exec backend-pod -c mycontainer -- npm --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, ... |
Create a service for a replicated nginx, which serves on port 9092 and connects to the containers on port 330600 | Command:
```bash
kubectl expose rc nginx --port=9092 --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. ... |
List the deployments in YAML output format in the "v2.0.0" version of the "extensions" API group | Command:
```bash
kubectl get deployments.v2.0.0.extensions -o yaml
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you will... |
Execute the command 'postgres' on the first container of the first pod of the 'database-deployment' deployment, and get the output. | Command:
```bash
kubectl exec deploy/database-deployment -- postgres
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.