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
72
votes
8 answers

How to pass image pull secret while using 'kubectl run' command?

I am trying to use kubectl run command to pull an image from private registry and run a command from that. But I don't see an option to specify image pull secret. It looks like it is not possible to pass image secret as part for run command. Is…
noorul
  • 1,283
  • 1
  • 8
  • 18
71
votes
7 answers

Install Google Cloud components error from gcloud command

I am trying to install several GCP components from the gcloud command-line tool and always get the same error: $ gcloud components list Your current Cloud SDK version is: 146.0.0 The latest available version is:…
Ivan Fernandez
  • 4,173
  • 5
  • 25
  • 30
70
votes
4 answers

Kubernetes check serviceaccount permissions

When deploying a service via a Helm Chart, the installation failed because the tiller serviceaccount was not allowed to create a ServiceMonitor resource. Note: ServiceMonitor is a CRD defined by the Prometheus Operator to automagically get metrics…
Joost den Boer
  • 4,556
  • 4
  • 25
  • 39
69
votes
6 answers

What is the difference between kubectl apply and kubectl replace

I am learning Kubernetes recently, and I am not very clear about the difference between "kubectl apply" and "kubectl replace". Is there any situation that we can only use one of them?
JimmyCYJ
  • 771
  • 1
  • 5
  • 12
68
votes
6 answers

kubectl port forwarding timeout issue

While using kubectl port-forward function I was able to succeed in port forwarding a local port to a remote port. However it seems that after a few minutes idling the connection is dropped. Not sure why that is so. Here is the command used to…
Stanley
  • 2,798
  • 5
  • 22
  • 44
67
votes
7 answers

How to Delete Kubernetes Service

The command kubectl get service returns a list of services that were created at one point in time: NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE car-example-service 10.0.0.129
joe the coder
  • 739
  • 2
  • 8
  • 15
65
votes
7 answers

Kubectl error: the object has been modified; please apply your changes to the latest version and try again

I am getting below error while trying to apply patch : core@dgoutam22-1-coreos-5760 ~ $ kubectl apply -f ads-central-configuration.yaml Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl…
Goutam
  • 839
  • 1
  • 7
  • 9
63
votes
4 answers

Is there a way to kubectl apply all the files in a directory?

I am writing an ansible playbook right now that deploys a dockerized application in kubernetes. However, for molecularity purposes I would rather not hard code the files that need to be apply after doing kompose convert -f docker-compose.yaml…
James Ukilin
  • 851
  • 2
  • 12
  • 17
63
votes
6 answers

How to format the output of kubectl describe to JSON

kubectl get command has this flag -o to format the output. Is there a similar way to format the output of the kubectl describe command? For example: kubectl describe -o="jsonpath={...}" pods my-rc would print a JSON format for the list of pods in…
Gabriel Petrovay
  • 20,476
  • 22
  • 97
  • 168
61
votes
3 answers

Can I set a default namespace in Kubernetes?

Can I set the default namespace? That is: $ kubectl get pods -n NAMESPACE It saves me having to type it in each time especially when I'm on the one namespace for most of the day.
mac
  • 1,479
  • 3
  • 11
  • 21
61
votes
4 answers

How to view logs of failed jobs with kubectl?

I've created a Kubernetes job that has now failed. Where can I find the logs to this job? I'm not sure how to find the associated pod (I assume once the job fails it deletes the pod)? Running kubectl describe job does not seem to show any relevant…
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
57
votes
2 answers

Kubernetes describe pod - Error from server (NotFound)

I am trying to debug a pod with the status "ImagePullBackOff". The pod is in the namespace minio-operator, but when I try to to describe the pod, it is apparently not found. Why does that happen? [psr-admin@zon-psr-2-u001 ~]$ kubectl get all -n…
Kim Tang
  • 2,330
  • 2
  • 9
  • 34
56
votes
9 answers

how to pass environment variable in kubectl deployment?

I am setting up the kubernetes setup for django webapp. I am passing environment variable while creating deployment as below kubectl create -f deployment.yml -l key1=value1 I am getting error as below error: no objects passed to create Able to…
rakeshh92
  • 885
  • 2
  • 10
  • 18
54
votes
2 answers

Define size for /dev/shm on container engine

I'm running Chrome with xvfb on Debian 8. It works until I open a tab and try to load content. The process dies silently... Fortunately, I have gotten it to run smoothly on my local docker using docker run --shm-size=1G. There is a known bug in…
53
votes
2 answers

kubectl how to rename a context

I have many contexts, one for staging, one for production, and many for dev clusters. Copy and pasting the default cluster names is tedious and hard, especially over time. How can I rename them to make context switching easier?
arshbot
  • 12,535
  • 14
  • 48
  • 71