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
52
votes
8 answers
kubectl run is deprecated - looking for alternative
I'm using kubectl run with environment parameters to create temporary docker containers for me (e.g. some forwarding for debugging purposes).
Since several weeks kubectl is complaining about kubectl run being deprecated. Unfortunately I can't find…

peez80
- 1,583
- 2
- 15
- 32
52
votes
12 answers
kubeadm init shows kubelet isn't running or healthy
I am trying to run Kubernetes and trying to use sudo kubeadm init.
Swap is off as recommended by official doc.
The issue is it displays the warning:
[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call…

Akshay Sood
- 6,366
- 10
- 36
- 59
52
votes
11 answers
mapping values are not allowed in this context
I'm a novice regarding YAML format and kubernetes.
The following is a dep_prom.yml file.
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
name: prometheus-deployment
name: prometheus
#namespace: prometheus
spec:
…

Westporch
- 717
- 1
- 7
- 13
51
votes
5 answers
Kubernetes POD delete with Pattern Match or Wildcard
When I am using below it deletes the running POD after matching the pattern from commandline:
kubectl get pods -n bi-dev --no-headers=true | awk '/group-react/{print $1}' | xargs kubectl delete -n bi-dev pod
However when I am using this command as…

pauldx
- 833
- 1
- 12
- 22
50
votes
8 answers
Is there anyway to get the external ports of the kubernetes cluster
I have exposed a service on an external port on all nodes in a kubernetes
cluster from:
kubectl create -f nginx-service.yaml
You have exposed your service on an external port on all nodes in your
cluster. If you want to expose this service to the…

kevin
- 501
- 1
- 4
- 4
50
votes
1 answer
Create kubernetes pod with volume using kubectl run
I understand that you can create a pod with Deployment/Job using kubectl run. But is it possible to create one with a volume attached to it? I tried running this command:
kubectl run -i --rm --tty ubuntu --overrides='{ "apiVersion":"batch/v1",…

Kenny Ho
- 3,247
- 5
- 19
- 24
48
votes
4 answers
How to view members of subject with Group kind
There is a default ClusterRoleBinding named cluster-admin.
When I run kubectl get clusterrolebindings cluster-admin -o yaml I get:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
annotations:
…

E235
- 11,560
- 24
- 91
- 141
48
votes
5 answers
How to create a kubectl config file for serviceaccount
I have a kubernetes cluster on Azure and I created 2 namespaces and 2 service accounts because I have two teams deploying on the cluster.
I want to give each team their own kubeconfig file for the serviceaccount I created.
I am pretty new to…

bramvdk
- 1,347
- 4
- 21
- 31
48
votes
5 answers
Finding the name of a new pod with kubectl
I am new to k8s and I am running into a little problem here.
Here's the context:
I need to invoke kubectl delete [podname] via a crontask once a day, and wait until k8s recreates the pod, then log into the container in that pod and run a shell…

Bluz
- 5,980
- 11
- 32
- 40
47
votes
6 answers
How to see logs of terminated pods
I am running selenium hubs and my pods are getting terminated frequently. I would like to look at the logs of the pods which are terminated. How to do it?
NAME READY STATUS RESTARTS …

SunilS
- 2,030
- 5
- 34
- 62
47
votes
5 answers
Wait for kubernetes job to complete on either failure/success using command line
What is the best way to wait for kubernetes job to be complete? I noticed a lot of suggestions to use:
kubectl wait --for=condition=complete job/myjob
but i think that only works if the job is successful. if it fails, i have to do something…

ruazn2
- 745
- 2
- 8
- 15
47
votes
3 answers
Kubectl command to list pods of a deployment in Kubernetes
Is there a way to use kubectl to list only the pods belonging to a deployment?
Currently, I do this to get pods:
kubectl get pods| grep hello
But it seems an overkill to get ALL the pods when I am interested to know only the pods for a given…

Bajal
- 5,487
- 3
- 20
- 25
47
votes
7 answers
Kubernetes Pod fails with CrashLoopBackOff
I 'm Following this guide in order to set up a pod using minikube and pull an image from a private repository hosted at: hub.docker.com
When trying to set up a pod to pull the image i see CrashLoopBackoff
pod config:
apiVersion: v1
kind:…

haim ari
- 971
- 1
- 7
- 8
46
votes
11 answers
How to upgrade kubectl client version
I want to upgrade the kubectl client version to 1.11.3.
I executed brew install kubernetes-cli but the version doesnt seem to be updating.
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.7",…

Madhuka Wickramapala
- 1,344
- 2
- 14
- 28
46
votes
3 answers
kubectl wait --for=condition=complete --timeout=30s
I am trying to check the status of a pod using kubectl wait command through this documentation.
Following is the command that i am trying
kubectl wait --for=condition=complete --timeout=30s -n d1 job/test-job1-oo-9j9kj
Following is the error that i…

Auto-learner
- 1,411
- 7
- 26
- 43