1+ var AWS = require ( 'aws-sdk' ) ;
2+ var async = require ( 'async' ) ;
3+
4+ module . exports = function ( AWSConfig , collection , callback ) {
5+ var eks = new AWS . EKS ( AWSConfig ) ;
6+ //var autoscaling = new AWS.AutoScaling(AWSConfig);
7+
8+ async . eachLimit ( collection . eks . listClusters [ AWSConfig . region ] . data , 10 , function ( cluster , cb ) {
9+ collection . eks . describeNodegroups [ AWSConfig . region ] [ cluster ] = { } ;
10+ async . each ( collection . eks . listNodegroups [ AWSConfig . region ] [ cluster ] . data , function ( nodeGroup , cb ) {
11+ collection . eks . describeNodegroups [ AWSConfig . region ] [ cluster ] [ nodeGroup ] = { } ;
12+ // Check for the multiple subnets in that single VPC
13+ var params = {
14+ clusterName : cluster ,
15+ nodegroupName : nodeGroup
16+ } ;
17+
18+ eks . describeNodegroup ( params , function ( err , data ) {
19+ if ( err ) {
20+ collection . eks . describeNodegroups [ AWSConfig . region ] [ cluster ] [ nodeGroup ] . err = err ;
21+ }
22+ //var autoScalingGroupNames = [];
23+ collection . eks . describeNodegroups [ AWSConfig . region ] [ cluster ] [ nodeGroup ] . data = data . nodegroup ;
24+ // right now we are taking the maxSize to count the node. But if we decide to count the exact node count
25+ // we need to uncomment the below code.
26+ // collection.eks.describeNodegroups[AWSConfig.region][cluster][nodeGroup].data['nodecount'] = 0;
27+ // data.nodegroup.resources.autoScalingGroups.forEach( autoscalingGroup => {
28+ // autoScalingGroupNames.push(autoscalingGroup.name);
29+ // });
30+ // var params = {
31+ // 'AutoScalingGroupNames':
32+ // autoScalingGroupNames
33+ // };
34+ // console.log(params);
35+ // autoscaling.describeAutoScalingGroups(params, function(err, data1){
36+ // if (err) console.log(err);
37+ // data1.AutoScalingGroups.forEach(autoscalingGroup =>{
38+ // collection.eks.describeNodegroups[AWSConfig.region][cluster][nodeGroup].data['nodecount'] +=
39+ // autoscalingGroup.Instances.length;
40+ // });
41+ // cb();
42+ // });
43+ cb ( ) ;
44+ } ) ;
45+ } , function ( ) {
46+ setTimeout ( function ( ) {
47+ cb ( ) ;
48+ } , 100 ) ;
49+ } ) ;
50+ } , function ( ) {
51+ callback ( ) ;
52+ } ) ;
53+ } ;
0 commit comments