prompt stringlengths 13 282 | response stringlengths 128 3.11k |
|---|---|
Add a taint with key 'workload' on nodes having label customer=acme-corp | Command:
```bash
kubectl taint node -l customer=acme-corp workload=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": "", "... |
Update the pod identified by type and name in the "settings.json" file with the git-repo annotation set to 'https://github.com/example/my-app' | Command:
```bash
kubectl annotate -f settings.json git-repo='https://github.com/example/my-app'
```
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 new secret named api-key-secret with keys for each file in the path/to/preferences folder | Command:
```bash
kubectl create secret generic api-key-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 basename o... |
Create a cluster role named "default_role" with the ability to create pods with resource names "cache-redis" and "blog-backend" | Command:
```bash
kubectl create clusterrole default_role --verb=create --resource=pods --resource-name=cache-redis --resource-name=blog-backend
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|clien... |
Forward traffic from local port 3000 to port 3000 in the pod named "mypod" | Command:
```bash
kubectl port-forward pod/mypod 3000:3000
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected automaticall... |
Drain the node named "storage-node-13", even if there are pods not managed by a replication controller, replica set, job, daemon set, or stateful set on it. | Command:
```bash
kubectl drain storage-node-13 --force
```
What it does:
Drain node in preparation for maintenance.
The given node will be marked unschedulable to prevent new pods from arriving. 'drain' evicts the pods if the API server supports https://kubernetes.io/docs/concepts/workloads/pods/disruptions/ . Otherwi... |
create a pod using the parameters.json file as input | Command:
```bash
cat parameters.json | kubectl create -f -
```
What it does:
Create a resource from a file or from stdin.
JSON and YAML formats are accepted.
Syntax:
`kubectl create -f FILENAME`
Helpful flags:
"flag": "--filename", "short": "-f", "default": "[]", "usage": "Filename, directory, or URL to files to use... |
Create a pod named 'hazelcast' using the 'confluentinc/cp-kafka' image and expose port 5432. | Command:
```bash
kubectl run hazelcast --image=confluentinc/cp-kafka --port=5432
```
What it does:
Create and run a particular image in a pod.
Syntax:
`kubectl run NAME --image=image [--env="key=value"] [--port=port] [--dry-run=server|client] [--overrides=inline-json] [--command] -- [COMMAND] [args...]`
Helpful flag... |
Create a deployment named drupal using the centos image with 7 replicas. | Command:
```bash
kubectl create deployment drupal --image=centos --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 of: ... |
Create a new namespace named default | Command:
```bash
kubectl create namespace default
```
What it does:
Create a namespace with the specified name.
Syntax:
`kubectl create namespace NAME [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usage": "Output format. One of: json|yaml|name|go-template|go-templa... |
Create a new config map named app-config-dev with specified keys instead of file basenames on disk | Command:
```bash
kubectl create configmap app-config-dev --from-file=conf=/path/to/properties/file1.txt --from-file=data=/path/to/parameters/file2.txt
```
What it does:
Create a config map based on a file, directory, or specified literal value.
A single config map may package one or more key/value pairs.
When creating... |
List the deployments in YAML output format in the "feature-branch-2.3.0" version of the "mobile-apps" API group | Command:
```bash
kubectl get deployments.feature-branch-2.3.0.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 name... |
Create a deployment named "auth" using the "ubuntu" image and expose port 8010 | Command:
```bash
kubectl create deployment auth --image=ubuntu --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: jso... |
Execute the 'yum install -y wget' command in the 'cyber-sleuth' container of the 'mypod' pod and get the output. | Command:
```bash
kubectl exec mypod -c cyber-sleuth -- yum install -y wget
```
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,... |
Remove all taints with the key 'zone' from the 'db-node-7' node | Command:
```bash
kubectl taint nodes db-node-7 zone-
```
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 resource called 'app-ingress' with a rule that directs requests from 'testing.com/module' to the service 'svc1' on port '9092' | Command:
```bash
kubectl create ingress app-ingress --rule="testing.com/module=svc1:9092,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 single ingress called 'www-ingress' that directs requests to website.com/module to svc1:8443 with the tls secret "my-cert" | Command:
```bash
kubectl create ingress www-ingress --rule="website.com/module=svc1:8443,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... |
Update the 'edge-node-10' node by partially merging the provided JSON patch: {"data":{"key":"new-value"}} | Command:
```bash
kubectl patch node edge-node-10 -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 ... |
Create a role binding named "foo" and assign the cluster role "foo" to the users "admin" and "devops-user", as well as the group "operations-team" | Command:
```bash
kubectl create rolebinding foo --clusterrole=foo --user=admin --user=devops-user --group=operations-team
```
What it does:
Create a role binding for a particular role or cluster role.
Syntax:
`kubectl create rolebinding NAME --clusterrole=NAME|--role=NAME [--user=username] [--group=groupname] [--serv... |
Listen on port 5000 on localhost and IP 10.19.21.23, and forward traffic to port 5000 in the 'backend-pod' pod. | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/backend-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 criteri... |
Expose a ReplicaSet as a service | Command:
```bash
kubectl expose rs ruby --port=9090 --target-port=818100
```
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... |
Add a taint with the key 'environment' and value 'k8s-node-1:PreferNoSchedule' to all nodes with the label 'region=eu-west-2' | Command:
```bash
kubectl taint node -l region=eu-west-2 environment=k8s-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": "", "usag... |
Remove all taints with the key 'app' from the node 'backup-node-14' | Command:
```bash
kubectl taint nodes backup-node-14 app-
```
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|na... |
Forward traffic from port 8888 on your localhost and IP address 10.19.21.23 to port 8000 in the pod "e-commerce-pod" | Command:
```bash
kubectl port-forward --address localhost,10.19.21.23 pod/e-commerce-pod 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 crit... |
Get the output from running the 'node --version' command in the container named 'mycontainer' from the pod named 'media-stream-pod' | Command:
```bash
kubectl exec media-stream-pod -c mycontainer -- node --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 cron job named data-sync with the centos image, scheduled to run every minute, and execute the command "yum install -y wget" | Command:
```bash
kubectl create cronjob data-sync --image=centos --schedule="*/1 * * * *" -- yum install -y wget
```
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":... |
Forward all traffic from port 8081 on all addresses to port 8888 in the api-service-pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/api-service-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 w... |
List deployments in JSON format for the "hotfix-1.1.2" version of the "custom-apps" API group. | Command:
```bash
kubectl get deployments.hotfix-1.1.2.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 y... |
Update the annotation 'team' of the pod 'analytics' to 'frontend-team', overwriting any existing value. | Command:
```bash
kubectl annotate --overwrite pods analytics team='frontend-team'
```
What it does:
Update the annotations on one or more resources.
All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and inc... |
View the details of daemonset revision 1 for the 'test' daemonset | Command:
```bash
kubectl rollout history daemonset/test --revision=1
```
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 to fi... |
Delete the pods and services with names "cdn" and "monitoring" | Command:
```bash
kubectl delete pod,service cdn monitoring
```
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.
... |
List the replication controller named "web", the service named "monitoring-rc", and the pod named "cdn-service-pod" | Command:
```bash
kubectl get rc/web service/monitoring-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 namespa... |
Set the cluster field in the 'app-2-context' context to 'moon-cluster' | Command:
```bash
kubectl config set contexts.app-2-context.cluster moon-cluster
```
What it does:
Set an individual value in a kubeconfig file.
PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.
PROPERTY_VALUE is the new value you wa... |
Import specific keys from a config map into a deployment | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/env-vars deployment/backend-microservice-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 traffic from port 5432 on all addresses to port 8000 in the 'security-service-pod' pod. | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/security-service-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 ... |
Forward traffic from local port 9090 to port 3000 in the frontend-pod | Command:
```bash
kubectl port-forward pod/frontend-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 criteria, a pod will be selected autom... |
Copy the local file "/tmp/foo" to the remote pod "payment-gateway-pod-19" in the container named "api-server-container" at the directory "/etc/kubernetes" | Command:
```bash
kubectl cp :/tmp/foo payment-gateway-pod-19:/etc/kubernetes -c api-server-container
```
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.... |
Forward port 8081 to port 8888 in the backend-pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/backend-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 ... |
Remove all taints with key 'datacenter' from the 'backup-node-14' node | Command:
```bash
kubectl taint nodes backup-node-14 datacenter-
```
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|... |
Wait for the "proxy-server-pod" to have the "Ready" status condition | Command:
```bash
kubectl wait --for=condition=Ready pod/proxy-server-pod
```
What it does:
Experimental: Wait for a specific condition on one or many resources.
The command takes multiple resources and waits until the specified condition is seen in the Status field of every given resource.
Alternatively, the command c... |
Attach to the stardust-shuttle container in the frontend-pod and get the output. | Command:
```bash
kubectl attach frontend-pod -c stardust-shuttle
```
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... |
Forward local port 9090 to the targetPort of the "https" service port in selected pod | Command:
```bash
kubectl port-forward service/web-service 9090:https
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will be selected a... |
Create a new ClusterIP service named frontend-service-clusterip that maps port 5000 of the service to port 8084 of the target | Command:
```bash
kubectl create service clusterip frontend-service-clusterip --tcp=5000:8084
```
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... |
Taint nodes with the label 'app-type=microservice' and add a taint with key 'dedicated' and value 'app-node-6:PreferNoSchedule' | Command:
```bash
kubectl taint node -l app-type=microservice dedicated=app-node-6:PreferNoSchedule
```
What it does:
Update the taints on one or more nodes.
Syntax:
`kubectl taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "u... |
Set the cluster field in a specific context to a new value | Command:
```bash
kubectl config set contexts.app-1-context.cluster kube-cluster-2
```
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 ... |
Retrieve the output of the 'gem --version' command executed in the 'nano-bot' container of the 'email-service-pod' pod. | Command:
```bash
kubectl exec email-service-pod -c nano-bot -- 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 omitte... |
Forward traffic from a local port to a specific port in the pod | Command:
```bash
kubectl port-forward pod/e-commerce-pod :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 automat... |
Set the cluster field of the my-context context to staging-cluster. | Command:
```bash
kubectl config set contexts.app-2-context.cluster staging-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... |
Copy the directory /var/run/secrets/kubernetes.io/serviceaccount/ from the admin-dashboard-pod-16 pod in the istio-system namespace to the /tmp/bar_dir directory locally | Command:
```bash
kubectl cp istio-system/admin-dashboard-pod-16:/var/run/secrets/kubernetes.io/serviceaccount/ /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": "", "u... |
Create a copy of the analytics-pod and change all container images to wordpress. | Command:
```bash
kubectl debug analytics-pod --copy-to=debug-image-1 --set-image=*=wordpress
```
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 r... |
Switch to the raw terminal mode and run a bash shell inside the code-explorer container of the auth-service-pod, allowing input from the client and displaying the output on the client as well. | Command:
```bash
kubectl exec auth-service-pod -c code-explorer -i -t -- bash -il
```
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... |
Forward traffic from localhost:6379 to the pod's localhost:8080 | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/web-app-pod 6379:8080
```
What it does:
Forward one or more local ports to a pod.
Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.
If there are multiple pods matching the criteria, a pod will ... |
Set the cluster field to "star-cluster" in the "my-context" context | Command:
```bash
kubectl config set contexts.dev-context.cluster star-cluster
```
What it does:
Set an individual value in a kubeconfig file.
PROPERTY_NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.
PROPERTY_VALUE is the new value you want... |
Import the API_KEY key from the log-config config map and set it as an environment variable in the frontend-deployment deployment. | Command:
```bash
kubectl set env --keys=API_KEY --from=configmap/log-config deployment/frontend-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one... |
Create a job for rolling out a deployment using a specific image and command | Command:
```bash
kubectl create job deployment-rollout-job --image=golang -- go
```
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... |
Update the pod 'log-aggregator' by adding the label 'unhealthy' with the value 'true'. | Command:
```bash
kubectl label pods log-aggregator 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", "... |
Import environment variables from a secret | Command:
```bash
kubectl set env --from=secret/cert-manager-secret deployment/notification-handler-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in ... |
remove the pods and services with the names "email" and "auth" | Command:
```bash
kubectl delete pod,service email auth
```
What it does:
Delete resources by file names, stdin, resources and names, or by resources and label selector.
JSON and YAML formats are accepted. Only one type of argument may be specified: file names, resources and names, or resources and label selector.
Some... |
Create a NodePort service named analytics-nodeport | Command:
```bash
kubectl create service nodeport analytics-nodeport --tcp=8080:5001
```
What it does:
Create a NodePort service with the specified name.
Syntax:
`kubectl create service nodeport NAME [--tcp=port:targetPort] [--dry-run=server|client|none]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "... |
Create a new secret named git-credentials-secret | Command:
```bash
kubectl create secret generic git-credentials-secret --from-file=ssh-privatekey=path/to/id_rsa --from-literal=passphrase=topsecret
```
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 b... |
Autoscale the replication controller "api" with a target CPU utilization of 20% and a maximum of 5 pods. | Command:
```bash
kubectl autoscale rc api --max=5 --cpu-percent=20
```
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... |
Execute the 'psql' command inside the 'cosmic-container' container in the 'cdn-service-pod' pod and retrieve the output. | Command:
```bash
kubectl exec cdn-service-pod -c cosmic-container -- psql
```
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, ... |
List the deployments in YAML output format, specifically in the "v1.1.1" version of the "my-apps" API group | Command:
```bash
kubectl get deployments.v1.1.1.my-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 will on... |
Return the snapshot logs from the 'log-aggregator-pod-1' container of the 'database-deployment' deployment | Command:
```bash
kubectl logs deployment/database-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:
"fl... |
Copy the local file /tmp/foo_dir to the remote pod backend-pod-13 in the namespace cert-manager, and place it in the directory /etc/kubernetes. | Command:
```bash
kubectl cp /tmp/foo_dir cert-manager/backend-pod-13:/etc/kubernetes
```
What it does:
Copy files and directories to and from containers.
Syntax:
`kubectl cp <file-spec-src> <file-spec-dest>`
Helpful flags:
"flag": "--container", "short": "-c", "default": "", "usage": "Container name. If omitted, use... |
Set the cluster field for a specific context in the kubeconfig file to a specified cluster | Command:
```bash
kubectl config set contexts.client-1-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 ... |
Set the service account of the deployment "analytics-platform-deployment" to "cert-manager" | Command:
```bash
kubectl set serviceaccount deployment analytics-platform-deployment cert-manager
```
What it does:
Update the service account of pod template resources.
Possible resources (case insensitive) can be:
replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset
Syn... |
List the replication controller named 'web', the service named 'frontend-rc', and the pods named 'gateway-pod' | Command:
```bash
kubectl get rc/web service/frontend-rc pods/gateway-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 service for a replicated centos using replica set, which serves on port 8443 and connects to the containers on port 818100. | Command:
```bash
kubectl expose rs centos --port=8443 --target-port=818100
```
What it does:
Expose a resource as a new Kubernetes service.
Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port.... |
Forward traffic from port 9090 on all addresses to port 6379 in the 'mypod' pod | Command:
```bash
kubectl port-forward --address 0.0.0.0 pod/mypod 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 sel... |
Scale the resource specified in the options.yaml file to 1 replica | Command:
```bash
kubectl scale --replicas=1 -f options.yaml
```
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-version is specified, it is validat... |
Scale the deployment named "foo" to 7 replicas, if its current size is 1. | Command:
```bash
kubectl scale --current-replicas=1 --replicas=7 deployment/foo
```
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-version is spec... |
Set the annotation 'owner' of the pod 'security' with the value 'alice smith' | Command:
```bash
kubectl annotate pods security 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... |
Create an ingress called 'myapp-ingress' with the rule that directs requests from "testing.com/input" to the service 'svc1' on port 8181 | Command:
```bash
kubectl create ingress myapp-ingress --rule="testing.com/input=svc1:8181,tls=my-cert"
```
What it does:
Create an ingress with the specified name.
Syntax:
`kubectl create ingress NAME --rule=host/path=service:port[,tls[=secret]]`
Helpful flags:
"flag": "--output", "short": "-o", "default": "", "usag... |
import the specific keys "external_api_url" from the app-settings config map and set them as environment variables for the search-engine-deployment deployment | Command:
```bash
kubectl set env --keys=external_api_url --from=configmap/app-settings deployment/search-engine-deployment
```
What it does:
Update environment variables on a pod template.
List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable de... |
Add a taint with key 'zone' on nodes that have the label 'stack=tech-stack' and the value 'zone=dev-node-4' with the effect 'PreferNoSchedule'. | Command:
```bash
kubectl taint node -l stack=tech-stack zone=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": "Ou... |
Create a cluster role named "foo" with the following properties: | Command:
```bash
kubectl create clusterrole foo --verb=exec --resource=pods --resource-name=staging-app-server --resource-name=identity-provider
```
What it does:
Create a cluster role.
Syntax:
`kubectl create clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run=server|clie... |
Forward local port 8080 to pod port 9090 for the frontend pod | Command:
```bash
kubectl port-forward pod/frontend-pod 8080: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 autom... |
Open the cache-service service for editing using the micro editor as an alternative editor. | Command:
```bash
KUBE_EDITOR="micro" kubectl edit svc/cache-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,... |
Create a cron job named 'system-health-check' using the 'postgres' image, with a schedule of running every minute | Command:
```bash
kubectl create cronjob system-health-check --image=postgres --schedule="*/1 * * * *" -- psql
```
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": "-... |
Remove the taint with key 'app' and effect 'PreferNoSchedule' from node 'storage-node-13' | Command:
```bash
kubectl taint nodes storage-node-13 app: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. On... |
Create a Pod Disruption Budget named cache-cluster-pdb that will select all pods with the label project=my-project | Command:
```bash
kubectl create poddisruptionbudget cache-cluster-pdb --selector=project=my-project --min-available=9
```
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-avail... |
Create a new config map named app-secrets and populate it with the specified keys and their corresponding file paths | Command:
```bash
kubectl create configmap app-secrets --from-file=conf=/path/to/data/file1.txt --from-file=data=/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 config map b... |
Import the SECRET_KEY key from the kube-system-config config map and set it as an environment variable in the user-management-deployment deployment. | Command:
```bash
kubectl set env --keys=SECRET_KEY --from=configmap/kube-system-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 ... |
Add the label 'role=cache' to the pod with the name 'payment' | Command:
```bash
kubectl label pods payment role=cache
```
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 DATABASE_URL key from the db-config ConfigMap and set it as an environment variable in the frontend-deployment deployment. | Command:
```bash
kubectl set env --keys=DATABASE_URL --from=configmap/db-config deployment/frontend-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... |
Attach to the pod named mypod in the container quantum-quark, in an interactive terminal mode | Command:
```bash
kubectl attach mypod -c quantum-quark -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, us... |
Get the password for the kube-cluster-2 user | Command:
```bash
kubectl config view -o jsonpath='{.users[?(@.name == "kube-cluster-2")].user.password}'
```
What it does:
Display merged kubeconfig settings or a specified kubeconfig file.
You can use --output jsonpath={...} to extract specific values using a jsonpath expression.
Syntax:
`kubectl config view`
Helpf... |
Add a taint with key 'datacenter' on nodes having label service=auth, specifying that the node 'kube-master-9' should PreferNoSchedule. | Command:
```bash
kubectl taint node -l service=auth datacenter=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"... |
Create a deployment named prometheus with 5 replicas and the confluentinc/cp-kafka image | Command:
```bash
kubectl create deployment prometheus --image=confluentinc/cp-kafka --replicas=5
```
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": "Outp... |
Delete resources defined in the kustomization.yaml file located in the conf/ directory. | Command:
```bash
kubectl delete -k conf/
```
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.
Some resources, su... |
Create an ingress that directs requests to a specific service and port, with TLS enabled using a specified secret | Command:
```bash
kubectl create ingress app-loadbalancer-ingress --rule="site.com/bar=svc1:5001,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": "",... |
Add a taint with the key 'workload' and the value 'dev-node-4:PreferNoSchedule' on nodes that have the label 'project=project-alpha' | Command:
```bash
kubectl taint node -l project=project-alpha workload=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": "", "us... |
Add a taint with key 'app' on nodes having the label namespace=mynamespace, the taint should be added to the 'node-1' node and set to 'PreferNoSchedule'. | Command:
```bash
kubectl taint node -l namespace=mynamespace app=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": "Ou... |
Create an ingress named 'api-ingress' that directs requests for 'site.com/bar' to the service 'svc1' running on port '5432' with the TLS secret named 'my-cert'. | Command:
```bash
kubectl create ingress api-ingress --rule="site.com/bar=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": "Ou... |
Create a new ClusterIP service named 'messaging-service-clusterip' with a TCP port forwarding from 8082 to 9000 | Command:
```bash
kubectl create service clusterip messaging-service-clusterip --tcp=8082: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": "-... |
Import specific keys from a config map to an environment variable in a deployment. | Command:
```bash
kubectl set env --keys=redis_host --from=configmap/monitoring-config deployment/database-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 role named "bar" with the verb "connect", and the resource "pods" with resource names "order-fulfillment" and "machine-learning" | Command:
```bash
kubectl create role bar --verb=connect --resource=pods --resource-name=order-fulfillment --resource-name=machine-learning
```
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=ser... |
Check if you have permission to list the "certificates-renewal-job" job in the "kube-node-lease" namespace | Command:
```bash
kubectl auth can-i list jobs.batch/certificates-renewal-job -n kube-node-lease
```
What it does:
Check whether an action is allowed.
VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is... |
Forward data between local port 8000 and the pod's port 8000 | Command:
```bash
kubectl port-forward pod/mypod 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 pod will be selected automaticall... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.