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

8/27/2019

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

-- Dhanraj
amazon-eks
aws-eks
kubeadm
kubernetes

3 Answers

8/28/2019

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.

-- Crou
Source: StackOverflow

9/3/2019

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.

-- Anton Kostenko
Source: StackOverflow

8/27/2019

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.

-- Tummala Dhanvi
Source: StackOverflow