Can't able to get externalID ( i.e instanceId provided by aws) of my kubernetes master node
Asked Answered
V

3

8

I did try kubectl describe node masterNodeName ,it gives output as :-

Name:               ip-172-28-3-142
    Roles:              master
    Labels:             beta.kubernetes.io/arch=amd64
                        beta.kubernetes.io/os=linux
                        kubernetes.io/arch=amd64
                        kubernetes.io/hostname=ip-172-28-3-142
                        kubernetes.io/os=linux
                        node-role.kubernetes.io/master=
    Annotations:        kubeadm.alpha.kubernetes.io/cri-socket: /var/run/dockershim.sock
                        node.alpha.kubernetes.io/ttl: 0
                        projectcalico.org/IPv4Address: 172.28.3.142/20
                        projectcalico.org/IPv4IPIPTunnelAddr: 192.163.119.24
                        volumes.kubernetes.io/controller-managed-attach-detach: true
    CreationTimestamp:  Thu, 06 Jun 2019 04:10:28 +0000
    Taints:             <none>
    Unschedulable:      false
    Conditions:
      Type                 Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message
      ----                 ------  -----------------                 ------------------                ------                       -------
      NetworkUnavailable   False   Sat, 24 Aug 2019 12:10:03 +0000   Sat, 24 Aug 2019 12:10:03 +0000   CalicoIsUp                   Calico is running on this node
      MemoryPressure       False   Tue, 27 Aug 2019 14:08:19 +0000   Tue, 11 Jun 2019 14:38:27 +0000   KubeletHasSufficientMemory   kubelet has sufficient memory available
      DiskPressure         False   Tue, 27 Aug 2019 14:08:19 +0000   Tue, 11 Jun 2019 14:38:27 +0000   KubeletHasNoDiskPressure     kubelet has no disk pressure
      PIDPressure          False   Tue, 27 Aug 2019 14:08:19 +0000   Tue, 11 Jun 2019 14:38:27 +0000   KubeletHasSufficientPID      kubelet has sufficient PID available
      Ready                True    Tue, 27 Aug 2019 14:08:19 +0000   Tue, 11 Jun 2019 14:38:27 +0000   KubeletReady                 kubelet is posting ready status. AppArmor enabled
    Addresses:
      InternalIP:  172.28.3.142
      Hostname:    ip-172-28-3-142
    Capacity:
     cpu:                8
     ephemeral-storage:  20263484Ki
     hugepages-1Gi:      0
     hugepages-2Mi:      0
     memory:             32665856Ki
     pods:               110
    Allocatable:
     cpu:                8
     ephemeral-storage:  18674826824
     hugepages-1Gi:      0
     hugepages-2Mi:      0
     memory:             32563456Ki
     pods:               110
    System Info:
     Machine ID:                 121a679a217040c4aed637a6dc1e0582
     System UUID:                EB219C6D-8C25-AC92-9676-D6B04770257A
     Boot ID:                    144b1dt4-faf8-4fcb-229a-51082410bc5e
     Kernel Version:             4.15.0-2043-aws
               Namespace                  Name                                         CPU Requests  CPU Limits  Memory Requests   

Edit: - I am setting up Kubernetes on aws EC2 instance using kubeadm.

I am looking for a way to get the InstanceID as externalID in node configuration.

My V1Node class cluster info is also null

Vivavivace answered 27/8, 2019 at 14:27 Comment(5)
Are you using EKS (managed by AWS) or setting up your own cluster using kops or some other tool?Craddock
If you have created the cluster yourself could you please give more details on how you have created it?Craddock
I just did kubeadm init on master node ..I am also not getting cluster nameVivavivace
Got you, you are using kubeadm to set up the cluster in aws, not eksCraddock
Yes.. so we won't get required parameters?Vivavivace
T
3

ExternalID is deprecated since 1.1.

Unfortunately you cannot get it in versions from 1.11, when it was finally cleaned.

The only way is to rollback/backport that changes and build your own version.

Topotype answered 3/9, 2019 at 11:23 Comment(0)
C
1

Add the cluster name label on ec2 nodes, the value of the label doesn't matter, only the name does. For example

kubernetes.io/cluster/CLUSTER_NAME

kubernetes.io/cluster/dhanvi-test-cluster

Make sure that the IAM policy is set as mentioned at https://github.com/kubernetes/cloud-provider-aws#iam-policy

Use the below config file with kubeadm as kubeadm init --config FILE_NAME.yaml

---
apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
apiServer:
  extraArgs:
    cloud-provider: aws
clusterName: dhanvi-test-cluster
controllerManager:
  extraArgs:
    cloud-provider: aws
kubernetesVersion: stable

---
apiVersion: kubeadm.k8s.io/v1beta2
kind: InitConfiguration
nodeRegistration:
  kubeletExtraArgs:
    cloud-provider: aws

Ideally, by doing the above stuff you should be able to get the providerID when you describe the node, it should have also given you the cluster name.

If you are still missing the providerID as a workaround you can still edit the node and add it manually.

Please consider raising an issue at https://github.com/kubernetes/kubeadm/issues if you not getting the providerID even after giving the cloud-provider in the extraArgs.

Craddock answered 27/8, 2019 at 16:38 Comment(5)
Are they running on EKS if so which version? They could be running using kopsCraddock
They are running on AWS EC2 instanceVivavivace
Are you trying to just get the instanceID or are you trying to get the instanceID as label in Kubernetes?Craddock
I want externalID parameter in kubectl describe node as instanceIdVivavivace
got you! will update the answer to reflect the same.Craddock
R
0

What Tummala Dhanvi said is correct but here is a bit more details.

If you use EKS or GKE (I'm not sure about the others), they have one important thing in common. They are both managed by the cloud. This is mainly done to make Kubernetes easier to use, so you are only responsible for the applications that will be running on the cluster and you don't have to bother with all the configuration of the cluster.

This is also to make your Kubernetes cluster always accessible as cloud will detect and replace unhealthy control plane node and provide on-deamand upgrades and patching and secure as the connection in encrypted between worker nodes and the managed control plane by default.

You can have access to the worker nodes this is possible in both GKE and EKS but you will not have access to the master node.

If you want to have full access to the master and worker nodes you would need to deploy Kubernetes yourself. This is fairly easy and straight forward if you already have virtual machines ready.

You can use kubeadm for that and create a single control-plane cluster or Highly Available cluster.

There are also other tools that does the cluster installation for you like kops and kubespray.

Please read the Picking the Right Solution to run Kubernetes on various platforms, it's a guide to choose a solution that fits your needs.

Robbirobbia answered 28/8, 2019 at 11:7 Comment(6)
Thanks for the information. I configured using kubeadm but can't get Instance ID of aws in any node.Vivavivace
so You used eks or aws and setup the cluster yourself with EC2?Robbirobbia
I am using aws EC2 instances as master node and worker nodeVivavivace
Check thisRobbirobbia
Thanks for that link ..I added instanceId as lable now by using kubectl label nodes nodeName beta.kubernetes.io/instance-id=$(curl 169.254.169.254/latest/meta-data/instance-id)Vivavivace
But still not getting it as externalID. If I got this, I will award you some bounty :)Vivavivace

© 2022 - 2024 — McMap. All rights reserved.