EKS : Running a particular service (pods) on particular AWS autoscaling group

12/13/2018

I have an EKS cluster and I have multiple AWS autoscaling groups for worker nodes registered with the EKS master. Now I have a scenario where I want to run a particular service (deployment pods) on a particular AWS autoscaling group.

For running particular deployment pods on nodes can be achieved using nodeSelector and node labels, but in case of AWS autoscaling group, the autoscaling group will scale up and down and hence concept of node labels and nodeselector is not that suitable here. How can I achieve this scenario?

-- Abhizer Saifee
amazon-eks
amazon-web-services
autoscaling
kubernetes

1 Answer

12/13/2018

I think that using Kops tool will be suitable for your case. Kops provides a lot of managing AWS Kubernetes cluster features, and basically it can be also used for maintaining AutoScalingGroup (ASG) in AWS. Kops initially is serving Instance group as an equivalent of ASG, and therefore can handle all the operations with real Autoscaling groups in the cluster.

You can create InstanceGroup and match nodeLabels:

apiVersion: kops/v1alpha2
kind: InstanceGroup
metadata:
  creationTimestamp: 2017-11-12T07:25:23Z
  labels:
    kops.k8s.io/cluster: cluster.k8s.local
  name: p2
spec:
  image: kope.io/k8s-1.7-debian-jessie-amd64-hvm-ebs-2017-07-28
  machineType: p2.xlarge
  maxSize: 2
  minSize: 2
  nodeLabels:
    type: p2-ig
  role: Node
  subnets:
  - us-east-1d
  - us-east-1e

And schedule Pod on previously created InstanceGroup:

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  nodeSelector:
    type: p2-ig

You can find more information about using Kops Instance Groups here.

-- mk_sta
Source: StackOverflow