The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs.
Questions tagged [kubectl]
3648 questions
45
votes
3 answers
How can I find the list of field selectors supported by kubectl for a given resource type?
I've recently learned about kubectl --field-selector flag, but ran into errors when trying to use it with various objects.
For example :
$ kubectl delete jobs.batch --field-selector status.succeeded==1
Error from server (BadRequest): Unable to find…

toadjaune
- 801
- 1
- 6
- 11
45
votes
3 answers
Kubernetes Port Forwarding - Connection refused
I am getting the following error when forwarding port. Can anyone help?
mjafary$ sudo kubectl port-forward sa-frontend 88:82
Forwarding from 127.0.0.1:88 -> 82
Forwarding from [::1]:88 -> 82
The error log :
Handling connection for 88
Handling…

Jaf
- 811
- 2
- 7
- 9
44
votes
1 answer
Can I connect one service account to multiple namespaces in Kubernetes?
I have couple of namespaces - assume NS1 and NS2. I have serviceaccounts created in those - sa1 in NS1 and sa2 in NS2. I have created roles and rolebindings for sa1 to do stuff within NS1 and sa2 within NS2.
What I want is give sa1 certain access…

rahul
- 3,018
- 4
- 29
- 28
44
votes
10 answers
How to fix issue of 'Unable to connect to the server: EOF' Kubernetes - Kubectl
When I try any kubectl command, it always returns:
Unable to connect to the server: EOF
I followed these…

Carlos Andres
- 12,740
- 7
- 18
- 34
42
votes
3 answers
kubernetes configmap set from-file in yaml configuration
how can I describe this command in yaml format?
kubectl create configmap somename --from-file=./conf/nginx.conf
I'd expect to do something like the following yaml, but it doesn't work
apiVersion: v1
kind: ConfigMap
metadata:
name: somename
…

Maoz Zadok
- 4,871
- 3
- 33
- 43
42
votes
9 answers
How do you find the cluster & service CIDR of a Kubernetes cluster?
How do you find the cluster/service CIDR for a Kubernetes cluster, once it is already running?
I know for Minikube, it is 10.0.0.1/24.
For GKE, you can find out via
gcloud container clusters describe XXXXXXX --zone=XXXXXX |
grep -e clusterIpv4Cidr…

richizy
- 2,002
- 3
- 21
- 26
40
votes
3 answers
How to generate yaml template with kubectl command?
Is it possible to generate yaml with kubernetes kubectl command ? to clarify - I'm not talking about generating yaml from existing deployments like kubectl get XXXX -o yaml, but merely about generating yamls for the very first time for pod, service,…

Andy
- 2,706
- 3
- 13
- 22
40
votes
1 answer
Kubernetes: understanding memory usage for "kubectl top node"
How do I interpret the memory usage returned by "kubectl top node". E.g. if it returns:
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
ip-XXX.ec2.internal 222m 11% 3237Mi 41%
…

Kirill Kireyev
- 401
- 1
- 4
- 4
39
votes
4 answers
Getting "ErrImageNeverPull" in pods
Am using minikube to test out the deployment and was going through this link
And my manifest file for deployment is like
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: webapp
spec:
replicas: 1
template:
metadata:
…

Prateek Naik
- 2,522
- 4
- 18
- 38
39
votes
12 answers
Kubernetes - delete all jobs in bulk
I can delete all jobs inside a custer running
kubectl delete jobs --all
However, jobs are deleted one after another which is pretty slow (for ~200 jobs I had the time to write this question and it was not even done).
Is there a faster approach ?

Overdrivr
- 6,296
- 5
- 44
- 70
39
votes
5 answers
Can I use autocompletion for kubectl in zsh?
I daily find myself doing...
$ kubectl --context=foo get pods
< copy text manually >
$ kubectl --context=foo logs dep1-12345678-10101
I would like to cycle through matching resources with
$ kubectl --context=foo logs dep1
but this doesn't…

Plato
- 10,812
- 2
- 41
- 61
39
votes
5 answers
Is there a way to view the Kubernetes image download progress during pod initialization?
Is there a way to obtain log information about what is happening with Kubernetes after creating a pod. The kubectl get pods only provides a basic status message. In the case of downloading a large image this can take time and the kubectl log…

Alex Beggs
- 1,187
- 2
- 11
- 17
38
votes
7 answers
Homebrew Install Specific Version of Formula
Specifically kubernetes-cli. I have 1.12.0 installed. I need 1.11.x, but I don't have that installed.
I've reviewed and tried every answer in this thread and nothing worked: Homebrew install specific version of formula?
I've tried brew search but…

clay
- 18,138
- 28
- 107
- 192
38
votes
5 answers
Kubernetes has a ton of pods in error state that can't seem to be cleared
I was originally trying to run a Job that seemed to get stuck in a CrashBackoffLoop. Here was the service file:
apiVersion: batch/v1
kind: Job
metadata:
name: es-setup-indexes
namespace: elk-test
spec:
template:
metadata:
name:…

xamox
- 2,599
- 4
- 27
- 30
37
votes
11 answers
kubectl versions Error: exec plugin is configured to use API version client.authentication.k8s.io/v1alpha1
I was setting up my new Mac for my eks environment.
After the installation of kubectl, aws-iam-authenticator and the kubeconfig file placement in default location. I ran the command kubectl command and got this error mentioned below in command…

Saravana
- 595
- 1
- 6
- 15