Search code examples
amazon-eksaws-cdk

how do i upgrade eks default nodegroup version using cdk?


Please note this question is a different question than this one. The custom eks node group is defined by me and exposes configurations for me to modify. This question is specifically regarding the default node group, which lack any props or exposed configuration for me to modify.

I would like to upgrade the default node group that was created by CDK when I provisioned the EKS cluster.

this.cluster = new eks.Cluster(this, 'eks-cluster', {
  vpc: props.vpc,
  clusterName: props.clusterName,
  version: eks.KubernetesVersion.V1_22,
  albController: {
    version: eks.AlbControllerVersion.V2_4_1,
  },
  defaultCapacity: 5,
});

However, I do not see any options to modify the version for the default node group. I have already bump the cluster version to v1.22 as well as my custom node groups, but the default node group still uses v1.21.

eks-default-node-group-version

How can I upgrade the default node group version using CDK?


Solution

  • From my experiments and observations, there is nothing special with the default node group that EKS creates, this.cluster.defaultNodegroup. It is just a typical EKS node group with auto-scaling and no taints. I created my own default node group and used a updated AMI release version.

    I disabled the defaultCapacity and set it to 0, and then created my own custom node group with same configurations as the one EKS created by default.

    this.cluster = new eks.Cluster(this, 'eks-cluster', {
      vpc: props.vpc,
      clusterName: props.clusterName,
      version: eks.KubernetesVersion.V1_23,
      kubectlLayer: new KubectlV23Layer(this, 'kubectl'),
      albController: {
        version: eks.AlbControllerVersion.V2_4_1,
      },
      // set this to 0 to disable default node group created by EKS
      defaultCapacity: 0, 
    });
    
    const defaultNodeGroup = new eks.Nodegroup(this, 'default-node-group', {
      cluster: this.cluster,
      releaseVersion: '<updated AMI release version>',
      nodegroupName: 'eks-default-nodegroup',
    });
    

    eks_default_node_group_upgraded