16
votes
Copy multiple files using * wildcard from kubernetes container
You can do that using this command:
kubectl cp -n [NAMESPACE] [POD_NAME]:/[POD_DIRECTORY]/. .
15
votes
Accepted
Kubernetes - How to show all service accounts
The command you listed will show you your resources.
Instead try: kubectl get serviceAccounts
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 ...
10
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 [-...
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 ...
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:
...
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 '...
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 ...
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....
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 ...
2
votes
Kops: How to delete the multiple SSHPublicKey
kops delete secret --name cluster-1.dev.transein.com sshpublickey admin 2c:yy
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 ...
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."...
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:
...
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
...
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}'
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)
...
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 ...
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 ...
2
votes
Bandwidth utilization by pod on Kubernetes
Prometheus (and Thanos or Cortex, usually with some Grafana), is what you are looking for.
You have a Kubernetes (vanilla, OpenShift, ...), then kubelet/cadvisor should already be exposing some ...
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 ...
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.
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 ...
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>] \
[--...
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 ...
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
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-...
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)
...
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 ...
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
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
kubectl × 59kubernetes × 53
docker × 6
kubeadm × 4
amazon-web-services × 3
networking × 3
k3s × 3
containers × 2
yaml × 2
eks × 2
minikube × 2
google-kubernetes-engine × 2
network-monitoring × 2
kops × 2
ingress-nginx × 2
gcloud × 2
jenkins × 1
jenkins-pipeline × 1
docker-compose × 1
amazon-ec2 × 1
deployment × 1
jenkins-plugins × 1
linux × 1
dockerfile × 1
security × 1