Hot answers tagged

11

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 copying files with wild card (#72641, @dixudx) However, as stated on the issue #78854 the PR was made without proper tests and the feature is actually broken. ...


6

You can do that using this command: kubectl cp -n [NAMESPACE] [POD_NAME]:/[POD_DIRECTORY]/. .


3

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 across multiple Deployments, you can create a ConfigMap with the ENVs and use the envFrom spec. Example: apiVersion: v1 kind: ConfigMap metadata: name: my-...


2

kops delete secret --name cluster-1.dev.transein.com sshpublickey admin 2c:yy


2

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 only forward HTTP traffic. Generally speaking, using port forwarding you could get on your ‘localhost’ any services launched in your cluster. https://...


2

From the kubernetes docs I see this example: $ echo 'apiVersion: apps/v1beta1 kind: Deployment metadata: name: deployment-example spec: replicas: 3 revisionHistoryLimit: 10 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.11 ports: - containerPort: 80 ' | ...


2

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: kubectl get deployments --all-namespaces -o json | jq -r '.items | map(select(.spec.template.spec.containers[]?.env[]?.valueFrom.configMapKeyRef.name == "...


1

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 This assumes that the label name is instance-group and the label value for the group you want to query is group-1.


1

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

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}'


1

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 Kubernetes cluster. But $token (or $CI_JOB_JWT in GitLab CI/CD parlance) was not generated there but by GitLab instead. Inspection e.g. at jwt.io indicates "iss&...


1

According the documentation you're giving, you need to remove run-build from the command : $ oc run NAME --image=<image> \ [--generator=<resource>] \ [--port=<port>] \ [--replicas=<replicas>] \ [--dry-run=<bool>] \ [--overrides=<inline_json>] \ [options]


1

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 the export command


1

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

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-context test-sim The setters are used when you want to add more entries to the config file, so you don’t need that command when changing context.


1

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."app.kubernetes.io/name", version: .metadata.labels."app.kubernetes.io/version" }' produces { "name": "db", "version": "0.0.1" } { "name": "app", "...


1

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) start_first_process_in_bg if START_FAILED exit start_second_process_in_bg if START_FAILED exit while sleep 5; do check_first_process check_second_process if ...


1

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 credentials as AWS_* environment variables. Or even better use something like aws-vault.


1

I found this same error in StackOverflow, problably that you problem it's about your authentication anonymous If help you: JENKINS Authentication Fails


1

kubernetes is picky and case-sensitive: kind: Pod should do it. Also, spec should not be in metadata: apiVersion: v1 kind: Pod metadata: name: Testing spec: containers: - name: mysql image: mysql imagePullPolicy: Always command: ["echo", "SUCCESS"]


1

It is the address of the DNS server (probably CoreDNS but possibly kube-dns) for the cluster. Kubernetes uses a DNS server within the cluster so pods can find each other using service names. This is the "cluster DNS" server. Every time a service is created, it gets registered in the DNS server. In Linux, the /etc/resolv.conf file is where the DNS server ...


1

The --service-cluster-ip-range will define the range of IP address that Kubernetes will assign when you create a ClusterIP Service. It's different from your VPC CIDR which correspond to your nodes (EC2) IPs. You can let the default 10.32.0.0/24 as is or change it but make sure that it does not overlap with your VPC CIDR.


1

weave-net is trying unsuccessfully to talk to the apiserver at 10.32.0.1 (port 443). Verify your master node is indeed at that IP address, it has network connectivity to the node where this is barfing, and that the firewall on the master node has port 443 open. If they are all running on the same host, verify the apiserver is running.


1

Not sure why this is required since Kubernetes is declarative and will not do anything is nothing has changed. Nonetheless, you can run it with the --server-dry-run=true flag. What attributes are going to be changed in the resource will not be mentioned but it does mention which resource(s) will be changed in the apply. You will need to parse the output ...


1

The command you listed will show you your resources. Instead try: kubectl get serviceAccounts


1

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.


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