首页 > 解决方案 > CDK - 无法使用 scaleOnCpuUtilization

问题描述

我正在尝试在 CDK(打字稿)中编写一些简单的东西,但无法使其正常工作:

const cluster = new eks.Cluster(this, "eksCluster", clusterProps);
// Scale up EKS Cluster when above 80% CPU
        cluster.defaultCapacity!.scaleOnCpuUtilization('up', {
            targetUtilizationPercent: 80
        });

每次我运行cdk ls我都会收到以下错误:

TypeError: Cannot read property 'scaleOnCpuUtilization' of undefined

我该如何解决这个问题?

标签: typescriptaws-cdk

解决方案


它说:

property 'scaleOnCpuUtilization' of undefined

这应该意味着cluster.defaultCapacity!是空的。我不是 JavaScript 程序员,但这是什么!


推荐阅读