prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Set the custom TLS server name for the moon-cluster cluster entry to "cluster-beta". | Command:
```bash
kubectl config set-cluster moon-cluster --tls-server-name=cluster-beta
```
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 service for the ruby deployment with the following parameters:
- Port: 80
- Target port: 888800 | Command:
```bash
kubectl expose deployment ruby --port=80 --target-port=888800
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified p... |
Copy the directory /tmp/foo_dir from the pod named database-pod-2 in the argocd namespace to the local directory /etc/kubernetes. | Command:
```bash
kubectl cp argocd/database-pod-2:/tmp/foo_dir /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 k... |
Create an ingress called 'website-ingress' that directs requests to testing.com/bar to svc1:9000 and uses the TLS secret "my-cert" | Command:
```bash
kubectl create ingress website-ingress --rule="testing.com/bar=svc1:9000,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... |
Forward local traffic to a pod on ports 8081 and 6000 | Command:
```bash
kubectl port-forward pod/proxy-server-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 criteria, a pod will be selected a... |
Create a single ingress named 'myapp-ingress' with the rules that directs requests from testing.com/bar to svc1:5000 and include the tls secret "my-cert" | Command:
```bash
kubectl create ingress myapp-ingress --rule="testing.com/bar=svc1:5000,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage"... |
Listen on port 8888 locally and forward data to port 8000 in the specified deployment | Command:
```bash
kubectl port-forward deployment/mydeployment 8888 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 selecte... |
Create a cluster role binding for app-operator, sysadmin, and security-auditors using the view cluster role. | Command:
```bash
kubectl create clusterrolebinding view --clusterrole=view --user=app-operator --user=sysadmin --group=security-auditors
```
What it does:
Create a cluster role binding for a particular cluster role.
Syntax:
`kubectl create clusterrolebinding NAME --clusterrole=NAME [--user=username] [--group=groupnam... |
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/configurations/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 cr... |
Forward traffic from a local port to a specific port in a pod | Command:
```bash
kubectl port-forward pod/e-commerce-pod :8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automat... |
Replace a pod with the configuration provided in the conf.json file | Command:
```bash
kubectl replace -f ./conf.json
```
What it does:
Replace a resource by file name or stdin.
JSON and YAML formats are accepted. If replacing an existing resource, the complete resource spec must be provided. This can be obtained by
$ kubectl get TYPE NAME -o yaml
Syntax:
`kubectl replace -f FILENAME`
... |
Listen on ports 8088 and 6000 locally, forwarding data to/from ports 6379 and 6000 in a pod selected by the 'authentication-service-deployment' deployment | Command:
```bash
kubectl port-forward deployment/authentication-service-deployment 8088 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, ... |
Set the cluster field of the 'user-a-context' context to 'on-prem-cluster' | Command:
```bash
kubectl config set contexts.user-a-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 yo... |
Forward local port 6379 to port 5432 in the pod named 'frontend-pod' | Command:
```bash
kubectl port-forward pod/frontend-pod 6379: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... |
Update the label of the pod named 'payment' with the key 'env' and the value 'production' | Command:
```bash
kubectl label pods payment 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":... |
Switch to raw terminal mode; connect to the cosmic-container in the analytics-pod and interact with the 'bash' shell | Command:
```bash
kubectl attach analytics-pod -c cosmic-container -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 ... |
Import the keys REDIS_HOST from the app-config-prod config map and set them as environment variables for the gateway-deployment deployment. | Command:
```bash
kubectl set env --keys=REDIS_HOST --from=configmap/app-config-prod 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... |
Stream the logs of the "stardust-shuttle" container in the "backend-pod" pod. | Command:
```bash
kubectl logs -f -c stardust-shuttle 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", ... |
Start a new pod named "nginx" with the image "ethereum/client-go" and override the pod's specification by passing a JSON object containing the desired changes. | Command:
```bash
kubectl run nginx --image=ethereum/client-go --overrides='{ "apiVersion": "beta-1.0", "spec": { ... } }'
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--comma... |
Set the cluster field in the context named prod-context to dev-cluster | Command:
```bash
kubectl config set contexts.prod-context.cluster dev-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 want... |
Copy the local file ~/.config/kube to the directory /tmp/bar_dir in the remote pod front-end-pod-12 within the kube-public namespace. | Command:
```bash
kubectl cp ~/.config/kube kube-public/front-end-pod-12:/tmp/bar_dir
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use... |
List the replication controllers with the name 'web', the service 'gateway-rc', and the pod 'chat-app-pod' | Command:
```bash
kubectl get rc/web service/gateway-rc pods/chat-app-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 yo... |
Create a new ClusterIP service named notification-service-clusterip with the TCP port mapping 9092:9092. | Command:
```bash
kubectl create service clusterip notification-service-clusterip --tcp=9092:9092
```
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":... |
Add the label 'component=web' to the pod named 'media-stream' | Command:
```bash
kubectl label pods media-stream component=web
```
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", "usa... |
Create a service for the replication controller specified in the "nginx-controller.yaml" file | Command:
```bash
kubectl expose -f nginx-controller.yaml --port=8089 --target-port=808800
```
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 ... |
Execute 'java -jar /usr/share/jenkins/jenkins.war' command on the first pod of the deployment 'analytics-platform-deployment' | Command:
```bash
kubectl exec deploy/analytics-platform-deployment -- java -jar /usr/share/jenkins/jenkins.war
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "... |
View the previous terminated logs of the quantum-quark container in the cdn-service-pod pod. | Command:
```bash
kubectl logs -p -c quantum-quark cdn-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",... |
Create a copy of the cdn-service-pod, changing all container images to busybox | Command:
```bash
kubectl debug cdn-service-pod --copy-to=debug-image-api --set-image=*=busybox
```
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... |
Create a deployment named "db" using the "postgres" image and expose port 8081. | Command:
```bash
kubectl create deployment db --image=postgres --port=8081
```
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: jso... |
Add a taint to nodes with a specific label | Command:
```bash
kubectl taint node -l feature=feature-xyz workload=web-node-8: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... |
Update the 'compliance-level' annotation of the 'proxy' pod with the value 'PCI-DSS', overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods proxy 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 i... |
Import specific keys from a config map into an environment variable of a deployment. | Command:
```bash
kubectl set env --keys=api_key --from=configmap/db-config deployment/user-management-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions ... |
Forward ports from local machine to the pod and listen on local ports 5000 and 6000 | Command:
```bash
kubectl port-forward pod/security-service-pod 5000 5000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be select... |
List the deployments in the "rc-1.1.0" version of the "custom-apps" API group in JSON format. | Command:
```bash
kubectl get deployments.rc-1.1.0.custom-apps -o json
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you w... |
Output the authentication-service-deployment deployment with the modified SMTP_HOST environment variable in YAML format, without altering the object on the server. | Command:
```bash
kubectl set env deployment/authentication-service-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 ... |
Create a job named 'image-build-job' with the 'ruby' image, and execute the command 'gem --version' inside the job | Command:
```bash
kubectl create job image-build-job --image=ruby -- gem --version
```
What it does:
Create a job with the specified name.
Syntax:
`kubectl create job NAME --image=image [--from=cronjob/name] -- [COMMAND] [args...]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output form... |
Create a new ExternalName service named external-logging-service that points to the external domain document-company.com | Command:
```bash
kubectl create service externalname external-logging-service --external-name document-company.com
```
What it does:
Create an ExternalName service with the specified name.
ExternalName service references to an external DNS address instead of only pods, which will allow application authors to reference... |
Create a copy of a pod, changing all container images to postgres for debugging purposes. | Command:
```bash
kubectl debug email-service-pod --copy-to=debug-image-app --set-image=*=postgres
```
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... |
Create a cron job with a given schedule and command | Command:
```bash
kubectl create cronjob report-generation --image=mysql --schedule="*/1 * * * *" -- mysqld
```
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", "short": "-o",... |
Describe the on-prem-context context in your kubeconfig file | Command:
```bash
kubectl config get-contexts on-prem-context
```
What it does:
Display one or many contexts from the kubeconfig file.
Syntax:
`kubectl config get-contexts [(-o|--output=)name)]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: name " |
Run a proxy to the Kubernetes API server on port 3000, serving static content from the './local/www/' directory. | Command:
```bash
kubectl proxy --port=3000 --www=./local/www/
```
What it does:
Creates a proxy server or application-level gateway between localhost and the Kubernetes API server. It also allows serving static content over specified HTTP path. All incoming data enters through one port and gets forwarded to the remote... |
Forward local traffic from port 8000 to a pod selected by the deployment "notification-handler-deployment" on port 8000. | Command:
```bash
kubectl port-forward deployment/notification-handler-deployment 8000 8000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a ... |
Listen on port 6379 on localhost and IP address 10.19.21.23, and forward the traffic to port 9090 in the 'chat-app-pod' pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/chat-app-pod 6379: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 criter... |
Create an ingress resource named 'website-ingress' that routes incoming requests from foo.com/example to the service named 'svc1' on port 8081 | Command:
```bash
kubectl create ingress website-ingress --rule="foo.com/example=svc1:8081,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
Run the 'kafka-console-producer --broker-list localhost:9092 --topic test' command from the 'cyber-sleuth' container in the 'gateway-pod' pod and retrieve the output. | Command:
```bash
kubectl exec gateway-pod -c cyber-sleuth -- kafka-console-producer --broker-list localhost:9092 --topic test
```
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", "... |
Switch to raw terminal mode for the nebula-navigator container in the proxy-service-pod | Command:
```bash
kubectl attach proxy-service-pod -c nebula-navigator -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.... |
Update the label of the pod 'payment' to have the key 'tier' and the value 'database' | Command:
```bash
kubectl label pods payment tier=database
```
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": ... |
Forward traffic from a local port to a specific port in a pod | Command:
```bash
kubectl port-forward pod/analytics-pod :8081
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automati... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=CONFIG_FILE_PATH --from=configmap/app-secrets 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 defini... |
Attach to a specific container in a pod and enter raw terminal mode | Command:
```bash
kubectl attach api-service-pod -c astro-container -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... |
Update the image of the container named "kubernetes-serve-hostname" in the "proxy-server-pod" pod | Command:
```bash
kubectl patch pod proxy-server-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve-hostname","image":"new image"}]}}'
```
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 FIL... |
List deployments in JSON format using the "extensions" API group and version "v1.1.0". | Command:
```bash
kubectl get deployments.v1.1.0.extensions -o json
```
What it does:
Display one or many resources.
Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you will... |
Check permission to list jobs with name "content-import-job" in the namespace "cert-manager" | Command:
```bash
kubectl auth can-i list jobs.batch/content-import-job -n cert-manager
```
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 partia... |
Create a new secret named monitoring-credentials-secret using the properties from the env file located at path/to/properties.env | Command:
```bash
kubectl create secret generic monitoring-credentials-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 def... |
Forward local port 5000 to port 8888 in the pod 'log-aggregator-pod' | Command:
```bash
kubectl port-forward pod/log-aggregator-pod 5000 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... |
Create a ClusterIP service named "database-service-clusterip" that routes traffic from port 8888 to port 9000. | Command:
```bash
kubectl create service clusterip database-service-clusterip --tcp=8888:9000
```
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... |
Update the image of the 'kubernetes-serve-hostname' container in the 'auth-service-pod' pod | Command:
```bash
kubectl patch pod auth-service-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve-hostname","image":"new image"}]}}'
```
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 FIL... |
Add a taint to node 'prod-node-5' with the key 'disktype' and no value | Command:
```bash
kubectl taint nodes prod-node-5 disktype:NoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: ... |
Add a taint with key 'cpu-type' on nodes that have the label 'project=project-alpha' | Command:
```bash
kubectl taint node -l project=project-alpha cpu-type=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"... |
Import specific keys from a config map | Command:
```bash
kubectl set env --keys=debug_mode --from=configmap/api-config deployment/cache-cluster-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... |
resume the rollout of the "test" deployment | Command:
```bash
kubectl rollout resume deployment/test
```
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`
Helpful ... |
Forward local ports 5000 to 8080 in the pod named "mypod" | Command:
```bash
kubectl port-forward pod/mypod 5000 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... |
Listen on port 8088 on your local machine, forwarding to port 5000 in the backend-pod pod. | Command:
```bash
kubectl port-forward pod/backend-pod 8088: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 automa... |
Add a taint with key 'disktype' on nodes having label myLabel | Command:
```bash
kubectl taint node -l myLabel disktype=edge-node-10: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": "Outpu... |
Update the annotation 'scaling-policy' of pod 'web' with the value 'auto-horizontal-scaling', overwriting any existing value | Command:
```bash
kubectl annotate --overwrite pods web scaling-policy='auto-horizontal-scaling'
```
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 ... |
Create a deployment named logging that runs the redis image and expose port 6379 | Command:
```bash
kubectl create deployment logging --image=redis --port=6379
```
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... |
Set the last-applied-configuration of a resource to match the contents of the settings.yaml file, creating the annotation if it does not already exist. | Command:
```bash
kubectl apply set-last-applied -f settings.yaml --create-annotation=true
```
What it does:
Set the latest last-applied-configuration annotations by setting it to match the contents of a file. This results in the last-applied-configuration being updated as though 'kubectl apply -f ' was run, without up... |
Execute the 'kafka-server-start /etc/kafka/server.properties' command in the rocket-ranger container of the frontend-pod pod and get the output. | Command:
```bash
kubectl exec frontend-pod -c rocket-ranger -- kafka-server-start /etc/kafka/server.properties
```
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": "", "... |
Forward local traffic on port 8081 to the security-service-pod's port 8081. | Command:
```bash
kubectl port-forward pod/security-service-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 criteria, a pod will be select... |
List deployments in YAML output format, for the "v1.1.1" version of the "mobile-apps" API group | Command:
```bash
kubectl get deployments.v1.1.1.mobile-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... |
Return the log snapshots from the container 'cdn-service-pod-1' of the deployment 'database-deployment'. | Command:
```bash
kubectl logs deployment/database-deployment -c cdn-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"... |
Create a copy of the security-service-pod and change all container images to amazonlinux | Command:
```bash
kubectl debug security-service-pod --copy-to=debug-image-web --set-image=*=amazonlinux
```
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 defa... |
Scale the deployment named webapp-replicaset from 7 replicas to 5 replicas | Command:
```bash
kubectl scale --current-replicas=7 --replicas=5 deployment/webapp-replicaset
```
What it does:
Set a new size for a deployment, replica set, replication controller, or stateful set.
Scale also allows users to specify one or more preconditions for the scale action.
If --current-replicas or --resource-v... |
Set the resource request and limits for all containers in the 'node' deployment to limits of 200m CPU and 512Mi memory, and requests of 2 CPU and 128Mi memory. | Command:
```bash
kubectl set resources deployment node --limits=cpu=200m,memory=512Mi --requests=cpu=2,memory=128Mi
```
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,... |
stream the logs of the "rocket-ranger" container in the "backend-pod" pod | Command:
```bash
kubectl logs -f -c rocket-ranger 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", "sh... |
Create an ingress named 'public-ingress' with the following routing rules: | Command:
```bash
kubectl create ingress public-ingress --rule="website.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": "", "us... |
Get the version of MongoDB running in the "rocket-ranger" container of the "analytics-pod" pod. | Command:
```bash
kubectl exec analytics-pod -c rocket-ranger -- 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 omi... |
Create a new pod based on an existing pod with additional debug container and modified container images | Command:
```bash
kubectl debug log-aggregator-pod -it --copy-to=dgb-img --image=debian --set-image=logger=logging-app:debug,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 resou... |
Add a taint with key 'dedicated' and no value to node 'node-1'. | Command:
```bash
kubectl taint nodes node-1 dedicated:NoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json... |
Partially update the node using strategic merge patch | Command:
```bash
kubectl patch -f cni.conf -p '{"data":{"key":"new-value"}'
```
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:... |
Assign the label 'tier' with the value 'frontend' to the pod named 'database' | Command:
```bash
kubectl label pods database tier=frontend
```
What it does:
Update the labels on a resource.
Syntax:
`kubectl label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]`
Helpful flags:
"flag": "--all-namespaces", "short": "-A", "default": "false", "usage":... |
Retrieve the output of the 'gem --version' command from the 'cosmic-container' container running in the 'backend-pod' pod. | Command:
```bash
kubectl exec backend-pod -c cosmic-container -- gem --version
```
What it does:
Execute a command in a container.
Syntax:
`kubectl exec (POD | TYPE/NAME) [-c CONTAINER] [flags] -- COMMAND [args...]`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omit... |
Delete the pods and services named "security" and "backend" | Command:
```bash
kubectl delete pod,service security backend
```
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... |
Copy the local file /tmp/foo_dir to the remote pod payment-gateway-pod-19 in the namespace velero, and place it in the directory /tmp/bar. | Command:
```bash
kubectl cp /tmp/foo_dir velero/payment-gateway-pod-19::/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... |
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/e2e/kubernetes.ca.crt" | Command:
```bash
kubectl config set-cluster web-cluster --embed-certs --certificate-authority=~/.kube/e2e/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-cluster N... |
Switch to raw terminal mode and attach to the 'proxy-server-pod' pod, using the 'nano-bot' container. | Command:
```bash
kubectl attach proxy-server-pod -c nano-bot -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 omitt... |
Create a debug container of the analytics-pod, and change container images | Command:
```bash
kubectl debug analytics-pod -it --copy-to=debug-image-api --image=debian --set-image=mailer=mailer:latest,api=api:v2
```
What it does:
Debug cluster resources using interactive debugging containers.
'debug' provides automation for common debugging tasks for cluster objects identified by resource and n... |
Create a new config map named kube-system-config from an environment file | Command:
```bash
kubectl create configmap kube-system-config --from-env-file=path/to/configurations.env
```
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 def... |
Copy the file /tmp/foo from your local machine to the /tmp/bar_dir directory in the front-end-pod-12 pod in the kube-system namespace. | Command:
```bash
kubectl cp :/tmp/foo kube-system/front-end-pod-12:/tmp/bar_dir
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use the ... |
Edit the configuration of the service named 'monitoring-service' | Command:
```bash
kubectl edit svc/monitoring-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, or fall back t... |
Set the resource requests and limits for all containers in the WordPress deployment | Command:
```bash
kubectl set resources deployment wordpress --limits=cpu=200m,memory=512Mi --requests=cpu=100m,memory=256Mi
```
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 re... |
Create a copy of the e-commerce pod with all container images changed to use the 'mongo' image. | Command:
```bash
kubectl debug e-commerce-pod --copy-to=debug-image-web --set-image=*=mongo
```
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 re... |
Start a pod named 'nginx' using the Amazon Linux image. | Command:
```bash
kubectl run nginx --image=amazonlinux
```
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": "--filename", "... |
Remove taints with key 'dedicated' from node 'dev-node-4' | Command:
```bash
kubectl taint nodes dev-node-4 dedicated-
```
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|... |
Auto scale the deployment "vpn" with a minimum of 6 pods and a maximum of 11 pods. | Command:
```bash
kubectl autoscale deployment vpn --min=6 --max=11
```
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... |
Rename a context in the kubeconfig file. | Command:
```bash
kubectl config rename-context testing-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 als... |
Forward port 8088 on all addresses to port 8000 in the pod "log-aggregator-pod" and listen for incoming connections | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/log-aggregator-pod 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 po... |
Create a pod disruption budget named web-app-pdb that will select all pods with the release=1.0.0 label and require at least four of them to be available at any point in time | Command:
```bash
kubectl create poddisruptionbudget web-app-pdb --selector=release=1.0.0 --min-available=4
```
What it does:
Create a pod disruption budget with the specified name, selector, and desired minimum available pods.
Syntax:
`kubectl create poddisruptionbudget NAME --selector=SELECTOR --min-available=N [--d... |
Set up autoscaling for the "gateway" deployment with a minimum of 3 pods and a maximum of 14 pods, using the default autoscaling policy. | Command:
```bash
kubectl autoscale deployment gateway --min=3 --max=14
```
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... |
Create a single ingress called 'app1-ingress' that directs requests to 'testing.com/example' and points to 'svc1:8888' with a TLS secret called "my-cert" | Command:
```bash
kubectl create ingress app1-ingress --rule="testing.com/example=svc1:8888,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.