HiveBrain v1.2.0
Get Started
← Back to all entries
patternkubernetesMinor

kubectl asking for username (k8s cluster created via kops)

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
createdkopsk8susernameviaforaskingkubectlcluster

Problem

I created a kubernetes cluster using kops and deployed it in AWS (not EKS manual cluster using kops).

Then I export in my local machine the configuration like
kops export kubecfg --state ${KOPS_STATE_STORE} --name ${NAME}

Then running any kubectl command asks for a username, even kubectl version

kubectl version
Please enter Username:


PS: If I ssh into bastion host then ssh into k8s master node, kubectl works fine and its configuration is referring to local user created.

My local config created from export command into ~/.kube/config looks like:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: fakedata=
    server: https://api-test-intern-doesntmatter.eu-central-1.elb.amazonaws.com
  name: test-internet.k8s.local
contexts:
- context:
    cluster: test-internet.k8s.local
    user: test-internet.k8s.local
  name: test-internet.k8s.local
current-context: test-internet.k8s.local
kind: Config
preferences: {}
users:
- name: test-internet.k8s.local
  user: {}


And with the config above I cannot do any kubectl command.
Where can I find the username and password for kubectl?
I have set authentication as RBAC for the cluster and no limitations.

I read all article here https://kubernetes.io/docs/reference/access-authn-authz/authentication/ and still do not understand what is the default username password why am I asked for such credentials I haven't created any role or user.

Solution

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

Context

StackExchange DevOps Q#13632, answer score: 1

Revisions (0)

No revisions yet.