Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
15 votes
Accepted

Kubernetes - How to show all service accounts

The command you listed will show you your resources. Instead try: kubectl get serviceAccounts
Wesley Rolnick's user avatar
14 votes

Copy multiple files using * wildcard from kubernetes container

You can do that using this command: kubectl cp -n [NAMESPACE] [POD_NAME]:/[POD_DIRECTORY]/. .
cookiedough's user avatar
13 votes
Accepted

Copy multiple files using * wildcard from kubernetes container

Wildcard support was added to kubectl cp in the #72641 pull request. It is merged but only available in Kubernetes v1.14.0. Take a look at the ChangeLog: Notable Features: [...] • kubectl supports ...
Eduardo Baitello's user avatar
9 votes

Kubernetes - How to show all service accounts

kubectl get sa --all-namespaces This will only provide the service accounts. In general, you can have a comma separated list of resources to display. Example: kubectl get pods,svc,sa,deployments [...
Tanish Islam's user avatar
8 votes
Accepted

Kubernetes configuration with yaml anchors

YAML anchors are supported, but only for the same YAML file. You can't create the anchor (&) on a deployment file and reference (*) the value on another one. If you want to share ENVs values ...
Eduardo Baitello's user avatar
3 votes
Accepted

Get all Deployments referencing given ConfigMap by the ConfigMap's name

You can use kubectl get -o json and parse the output using jq to iterate over the deployments, matching any desired configMapKeyRef.name and returning a uniq list of deployments. This should work: ...
Eduardo Baitello's user avatar
3 votes

Copy multiple files using * wildcard from kubernetes container

I had a similar requirement and finally settled on: mkdir /my/dest/dir kubectl exec $TARGET_POD -n MYNAMESPACE -- tar -zcvf - -C /my/src/directory . | tar -zxvf - -C /my/dest/dir This depends on '...
W Goldfarb's user avatar
3 votes

Copy multiple files using * wildcard from kubernetes container

As there is no wildcard support, a workaround is to do a 2-step process to achieve the same: kubectl exec ... to do make a new tmp directory and wildcard copy/move your desired transfer files into ...
ljs.dev's user avatar
  • 131
3 votes
Accepted

How to get a list of deployments that only have a certain label in the spec section

The easiest solution is probably using jq. To get a list of Deployments that deploy Pods with the label importance: normal, you could do this: kubectl get deploy -o json | jq '.items[]|select(.spec....
larsks's user avatar
  • 680
3 votes
Accepted

With kubectl, I'm getting Unable to connect to the server: x509: certificate signed by unknown authority

This probably means you've got a dangling ~/.kube/config left over from a prior installation where you followed instructions like these to set up ~/.kube/config and you've since reinstalled k3s and ...
Evan Carroll's user avatar
  • 2,161
2 votes

Kops: How to delete the multiple SSHPublicKey

kops delete secret --name cluster-1.dev.transein.com sshpublickey admin 2c:yy
Jithin Kumar S's user avatar
2 votes

Accessing k8s outside of VM

kubectl port-forward forwards connections to a local port to a port on a pod. Compared to kubectl proxy, kubectl port-forward is more generic as it can forward TCP traffic while kubectl proxy can ...
Recoba20's user avatar
  • 632
2 votes

How do I list pod name/version across multiple clusters in Kubernetes

The best I have found so far for part 2 is to use the JSON output of get pods: kubectl get pods -o json | jq '.items[] | select(.metadata.labels."app.kubernetes.io/name") | { name: .metadata.labels."...
Chris Crewdson's user avatar
2 votes

kubectl create deployment not has the option containerPort

From the kubernetes docs I see this example: $ echo 'apiVersion: apps/v1beta1 kind: Deployment metadata: name: deployment-example spec: replicas: 3 revisionHistoryLimit: 10 template: ...
chicks's user avatar
  • 1,848
2 votes

How to get CPU and Memory usage of nodes in a specific Kubernetes instance group?

Do your instance groups have labels identifying the groups they belong to? If so, you can filter to them using the -l/--selector option, like so: kubectl top nodes --selector instance-group=group-1 ...
alastairs's user avatar
  • 121
2 votes

How to read Kubernets secrets values

So the answer was so simple I just have to add -o jsonpath='{.data}' at the end of the command kubectl get secrets/<secrets-name> -n <namespace> -o jsonpath='{.data}'
Dupinder Singh's user avatar
2 votes

kubectl retrieve update time for the resource

Seems like these commands are sufficient $ kubectl rollout history deployment myapp $ kubectl rollout history deployment myapp --revision=76 and to check the difference (use diff or colordiff) ...
Most Wanted's user avatar
2 votes
Accepted

How to run short-lived command using kubectl

Ah, shortly after posting I found a clean solution. Adding --restart=Never makes the command work as expected. % time kubectl run -n kcox-test --image busybox --attach test --restart=Never -- date Thu ...
Kevin Cox's user avatar
  • 141
2 votes

Why do I get different responses either when I use `sudo` before `kubectl` or not?

I think you haven't configured kubeconfig in root user. The sudo command allows you to run programs with the security privileges of another user. When you run sudo kubectl you're running kubectl with ...
sujit patel's user avatar
1 vote

HAProxy Not Working with Kubernetes NodePort for Backend (Bare Metal)

I figured it out, and SELinux is the difference. That is, SELinux on the HAProxy host (not a cluster node): "SELinux only allows the web server to make outbound connections to a limited set of ...
Adam Winter's user avatar
1 vote
Accepted

Change kubernetes resource requests after pod/job has started

LimitRange for the rescue: by setting both Max limits and LimitRequestRatio for pods users must set limits that are lower than Max or request*ratio or apiserver would return 403 Forbidden.
chupasaurus's user avatar
1 vote
Accepted

OIDC token invalid when put into kubeconfig

I have come to the (preliminary) conclusion that this cannot be done. First, I had set the wrong idp-issuer-url. I had selected the IDP that normally serves during OIDC authentication to the ...
rookie099's user avatar
  • 141
1 vote

Scheduling a build using Kubernetes

According the documentation you're giving, you need to remove run-build from the command : $ oc run NAME --image=<image> \ [--generator=<resource>] \ [--port=<port>] \ [--...
Paul Rey's user avatar
  • 233
1 vote

kubectl asking for username (k8s cluster created via kops)

I solved this temporarily with not the safest solution, but is working When creating secret with kops named admin, can use that to generate user field in exported kops config by adding also --admin in ...
Kristi Jorgji's user avatar
1 vote
Accepted

Failed to install kubernetes on centos

When I navigate to the URL, there do not appear to be any packages in the repo. Consider trying a mirror like: mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
James Shewey's user avatar
  • 3,734
1 vote

config.yaml is not setting up a new context

it seems you’re trying to change the config by setting a context and you’re not providing the config to the change context command. So do this kubectl config --kubeconfig=infra_k8/config.yaml use-...
Edward Romero's user avatar
1 vote

Running Two infinite commands on single pod/image

Though it's not advised to have multiple processes inside a container, but you have 2 options: Use a process manager like supervisord or wrapper script to use as CMD (meta code) ...
oryades's user avatar
  • 412
1 vote

How to get server url from kub dashboard?

When running an EKS cluster, the best way to configure your ~/.kube/config is by using the SDK's update-kubeconfig: aws eks update-kubeconfig --name your-cluster-name Make sure to configure your ...
davidmontoyago's user avatar
1 vote

Authentication Error in Kubernetes

I found this same error in StackOverflow, problably that you problem it's about your authentication anonymous If help you: JENKINS Authentication Fails
Vader's user avatar
  • 466
1 vote
Accepted

use different kubectl configs in different terminal sessions

Set the KUBECONFIG environment variable with a value that includes the relevant Kubernetes configuration file, the environment variable only applies to your current session/window.
Evgeny Zislis's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible