Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
431 views
in Technique[技术] by (71.8m points)

kubernetes - How to set EKS server for kubectl to talk to?

I'm new to Kubernetes and was following some examples for setting contexts. Now I can't seem to get any objects on my server, or I'm talking to the wrong server. I see...

$ kubectl config view
apiVersion: v1
clusters:
- cluster:
    server: ""
  name: sandbox
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://redacted.gr7.us-east-1.eks.amazonaws.com
  name: sandbox.us-east-1.eksctl.io
contexts:
- context:
    cluster: sandbox.us-east-1.eksctl.io
    user: [email protected]@sandbox.us-east-1.eksctl.io
  name: [email protected]@sandbox.us-east-1.eksctl.io
- context:
    cluster: sandbox
    namespace: kube-system
    user: ""
  name: sandbox
current-context: sandbox
kind: Config
preferences: {}
users:
- name: [email protected]@sandbox.us-east-1.eksctl.io
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1alpha1
      args:
      - token
      - -i
      - sandbox
      command: aws-iam-authenticator
      env:
      - name: AWS_STS_REGIONAL_ENDPOINTS
        value: regional
      - name: AWS_DEFAULT_REGION
        value: us-east-1

I see the cluster in AWS EKS, and see pods, deployments, etc. But when I do the following

$ kubectl get pods -A
error: the server doesn't have a resource type "pods"
$ kubectl get nodes -A
error: the server doesn't have a resource type "nodes"

What gives?

question from:https://stackoverflow.com/questions/66055337/how-to-set-eks-server-for-kubectl-to-talk-to

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your current context is sandbox, try changing the current-context with kubectl or directly in ~/.kube/config.

$ kubectl config get-contexts
$ kubectl config use-context [email protected]@sandbox.us-east-1.eksctl.io

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...