コード例 #1
0
        private static void CreateNodeGroup(string id, Cluster cluster, string nodeGroupName, string instanceType,
                                            ISubnet subnet, AZ az, int actualMinSize = 1, int actualMaxSize = 5)
        {
            var nodegroup = cluster.AddNodegroupCapacity($"{id}-{az}", new NodegroupProps()
            {
                NodegroupName = $"{cluster.ClusterName}-{nodeGroupName}-{az}",
                InstanceType  = new InstanceType(instanceType),
                MinSize       = actualMinSize,
                MaxSize       = actualMaxSize,
                Subnets       = new SubnetSelection {
                    Subnets = new[] { subnet }
                },
                Tags = new Dictionary <string, string>
                {
                    { "k8s.io/cluster-autoscaler/enabled", "" },
                    { "k8s.io/cluster-autoscaler/yoda", "" }
                }
            });

            nodegroup.Role.AddManagedPolicy(ManagedPolicy.FromAwsManagedPolicyName("CloudWatchAgentServerPolicy"));
            nodegroup.Role.AddToPrincipalPolicy(autoScalePolicy);
        }