Questions tagged [kubectl]

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.

3648 questions
31
votes
4 answers

kubectl list / delete all completed jobs

I'm looking for a kubectl command to list / delete all completed jobs I've try: kubectl get job --field-selector status.succeeded=1 But I get: enfield selector "status.succeeded=1": field label "status.succeeded" not supported for batchv1.Jobter…
31
votes
11 answers

Kubernetes - Pod Remains in ContainerCreating Status

I am new to all things Kubernetes so still have much to learn. Have created a two node Kubernetes cluster and both nodes (master and worker) are ready to do work which is good: [monkey@k8s-dp1 nginx-test]# kubectl get nodes NAME STATUS ROLES…
Going Bananas
  • 2,265
  • 3
  • 43
  • 83
31
votes
8 answers

How to stop kubectl proxy

I executed below command: kubectl proxy --port=8081 & kubectl proxy --port=8082 & and of course I have 2 accessible endpoints: curl http://localhost:8081/api/ curl http://localhost:8082/api/ But in the same time two running processes serving the…
itiic
  • 3,284
  • 4
  • 20
  • 31
30
votes
4 answers

kubectl exec into a container without using the random guid at the end of the pod name

To exec into a container in a pod, I use the following two commands (note the template flag in the first command trims the output to print just the name of the pods): $ kubectl get pods --template '{{range…
Johnny Metz
  • 5,977
  • 18
  • 82
  • 146
30
votes
5 answers

kubectl exec fails with the error "Unable to use a TTY - input is not a terminal or the right kind of file"

I am running a jenkins pipeline with the following command: kubectl exec -it kafkacat-5f8fcfcc57-2txhc -- kafkacat -b cord-kafka -C -t BBSim-OLT-0-Events -o s@1585031458 which is running fine on the terminal of the machine the pipeline is running…
Shrey Baid
  • 343
  • 1
  • 3
  • 10
30
votes
5 answers

no endpoints available for service \"kubernetes-dashboard\"

I'm trying to follow GitHub - kubernetes/dashboard: General-purpose web UI for Kubernetes clusters. deploy/access: # export KUBECONFIG=/etc/kubernetes/admin.conf # kubectl create -f…
alexus
  • 7,256
  • 12
  • 44
  • 66
30
votes
10 answers

How to use "kubectl" command instead of "sudo kubectl"

For every command with kubectl I need to use sudo kubectl. I understand the security perspective but I am working on a test environment and I want to be able use it without sudo. I tried to run sudo -i and use the root account to runkubectl get…
E235
  • 11,560
  • 24
  • 91
  • 141
29
votes
4 answers

"kubectl create job" from CronJob fails with "error: unknown object type *v1beta1.CronJob"

I have a Kubernetes cluster with following versions: $ kubectl version Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.1", GitCommit:"632ed300f2c34f6d6d15ca4cef3d3c7073412212", GitTreeState:"clean",…
29
votes
9 answers

Unable to Copy data from POD to local using kubectl cp command

I need to copy dump data from pod to local. Below the commands I am trying but I am getting error: unexpected EOF kubectl cp device-database-79fc964c8-q7ncc:tmp /Users/raja error: unexpected EOF or kubectl cp…
User1984
  • 587
  • 2
  • 5
  • 14
29
votes
8 answers

kubectl: get specific value from a secret in plaintext

I want to get the value of a specific field of a secret in a shell script. From the kubectl get secret documentation, it seems the standard way to get a secret returns the whole thing, in a specified format, with the values base64 encoded. So, to…
davnicwil
  • 28,487
  • 16
  • 107
  • 123
29
votes
2 answers

Can you pass an environment variables into kubectl exec without bash -c?

I have a script in a pod called script01 and it can take parameters. I run the script through the following: POD= runScript="kubectl -n nmspc exec $POD -- script01" $runScript --command "do stuff" The reason I run it this way is that I…
Alex oh
  • 465
  • 1
  • 4
  • 6
29
votes
6 answers

Can not delete pods in Kubernetes

I tried installing dgraph (single server) using Kubernetes. I created pod using: kubectl create -f https://raw.githubusercontent.com/dgraph-io/dgraph/master/contrib/config/kubernetes/dgraph-single.yaml Now all I need to do is to delete the created…
29
votes
8 answers

The connection to the server localhost:8080 was refused - did you specify the right host or port?

when i am trying to test the configuration of kubectl kubectl get svc i am getting this error: the server doesn't have a resource type "svc" when I try this command kubectl get services i am getting error: The connection to the server…
Harshin_
  • 431
  • 2
  • 5
  • 6
29
votes
5 answers

Update kubernetes secrets doesn't update running container env vars

Currenly when updating a kubernetes secrets file, in order to apply the changes, I need to run kubectl apply -f my-secrets.yaml. If there was a running container, it would still be using the old secrets. In order to apply the new secrets on the…
OmriToptix
  • 1,219
  • 1
  • 15
  • 22
28
votes
2 answers

shortcut for typing kubectl --all-namespaces everytime

Is there any alias we can make for all-namespace as kubectl don't recognise the command kubectl --all-namespaces or any kind of shortcut to minimize the typing of the whole command.
Tinkaal Gogoi
  • 4,344
  • 4
  • 27
  • 36