aws-samples / cdk-eks-karpenter

CDK construct for installing and configuring Karpenter on EKS clusters
Apache License 2.0
34 stars 14 forks source link

no matches for kind "CronJob" in v ersion "batch/v1beta1"\n' #91

Closed badaldavdatcpl closed 1 year ago

badaldavdatcpl commented 1 year ago

Tried deploying with the following -

""" karpenter = Karpenter(self, "karpenter", cluster=cluster)

    provisioner_spec = {
    'requirements': [{
        'key': 'karpenter.sh/capacity-type',
        'operator': 'In',
        'values': ['spot']
    }],
    'limits': {
        'resources': {
        'cpu': 20
        }
    },
    'provider': {
        'subnetSelector': {
        'Name': 'PublicSubnet*'
        },
        'securityGroupSelector': {
        'aws:eks:cluster-name': cluster.cluster_name

        }
    }
    }

    karpenter.add_provisioner('spot-provisioner',provisioner_spec=provisioner_spec)

"""

Received response status [FAILED] from custom resource. Message returned: Error: b'con figmap/aws-auth configured\nerror: error retrieving RESTMappings to prune: invalid res ource batch/v1beta1, Kind=CronJob, Namespaced=true: no matches for kind "CronJob" in v ersion "batch/v1beta1"\n'

Logs: /aws/lambda/MyEksBlueprintStack-awscdkawseksKu-Handler886CB40B-ni5iL3nrGKLh

at invokeUserFunction (/var/task/framework.js:102:19) at processTicksAndRejections (internal/process/task_queues.js:95:5) at async onEvent (/var/task/framework.js:22:27)

Kubernetes v1.25 cdk-eks-karpenter>=0.0.27 aws-cdk-lib==2.73.0

andskli commented 1 year ago

Hi @badaldavdatcpl

This construct should not generate any CronJob objects, and looking at the Karpenter helm chart, it also does not generate any CronJobs. Is there other parts of your CDK code that tries to deploy CronJobs? If so, I would suggest that you upgrade the API version to match your version of Kubernetes. As far as I can tell that API has been stable since Kubernetes v1.21, and is called batch/v1, and not batch/v1beta1 as indicated the logs provided.

badaldavdatcpl commented 1 year ago

Nope.. This is the only CDK code that I have. I am just trying to integrate the cluster example with karpenter example and that is what is causing the issue.

andskli commented 1 year ago

I also stumbled across your issue in the CDK repo, which contains more complete example. FWIW I believe that https://github.com/aws/aws-cdk/issues/24580 reflects your issue.

Could you try specifying the @aws-cdk/lambda-layer-kubectl-vXX as described in this comment? The integration test for this repository does that to mitigate similar issue, see here and here.

badaldavdatcpl commented 1 year ago

Yes. That seems to be a likely issue, I will try out the documented approaches. Thanks for prompt response on this.

Closing this since its not related to cdk-eks-karpenter