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

Unable to locate any tags in provided repository: oci://public.ecr.aws/karpenter/karpenter #92

Closed badaldavdatcpl closed 1 year ago

badaldavdatcpl commented 1 year ago

Getting this error - with v1.24 and 1.25 - Received response status [FAILED] from custom resource. Message returned: Error: b'Log in Succeeded\nError: Unable to locate any tags in provided repository: oci://public.ec r.aws/karpenter/karpenter\n'

from aws_cdk import (
    # Duration,
    Stack,
    # aws_sqs as sqs,
    aws_eks as eks,
    aws_ec2 as ec2,
    aws_iam as iam
)

from aws_cdk.lambda_layer_kubectl_v25 import KubectlV25Layer

from cdk_eks_karpenter import Karpenter
from constructs import Construct

class MyEksBlueprintsStack(Stack):

    def __init__(self, scope: Construct, id: str, **kwargs) -> None:
        super().__init__(scope, id, **kwargs)

        vpc = ec2.Vpc(self, 'EKS-CDK-VPC', cidr='10.0.0.0/16', nat_gateways=1)
        eks_admin_role = iam.Role(self, 'AdminRole',
                                      assumed_by=iam.AccountPrincipal(
                                          account_id=self.account))

        cluster = eks.Cluster(self, "my-eks",
        version=eks.KubernetesVersion.V1_25, vpc=vpc, masters_role=eks_admin_role, output_cluster_name=True, default_capacity=0,
        kubectl_layer=KubectlV25Layer(self, 'kubectl-layer')
        )

        cluster.add_nodegroup_capacity('ondemand', instance_types=[ec2.InstanceType('t3.large')],
                             min_size=1,
                             max_size=1
        )

        # apply a kubernetes manifest to the cluster
        cluster.add_manifest("mypod", {
            "apiVersion": "v1",
            "kind": "Pod",
            "metadata": {"name": "mypod"},
            "spec": {
                "containers": [{
                    "name": "hello",
                    "image": "paulbouwer/hello-kubernetes:1.5",
                    "ports": [{"containerPort": 8080}]
                }
                ]
            }
        })

        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)

Found this issue - https://github.com/aws/karpenter/issues/2729

Can you check if it works with EKS v1.25

Thanks a lot for your help!

badaldavdatcpl commented 1 year ago

Added version -

karpenter = Karpenter(self, "karpenter", cluster=cluster, version='0.27.1')

Still fails - Error: public.ecr.aws/karpenter/karpenter:0.27.1: not found

badaldavdatcpl commented 1 year ago

Tried with -

karpenter = Karpenter(self, "karpenter", cluster=cluster, version='v0.27.1') ## version is mandatory and v before version (0.27.1) is mandatory example vX.YY.Z

It works.

version is mandatory parameter for karpenter it seems and v before version (0.27.1) is mandatory example vX.YY.Z

A validation check to fail on not adding version would help here.

badaldavdatcpl commented 1 year ago

Closing the issue.

Improvements -

  1. Examples for python and TS with full code with eks cluster will help
  2. Validation on adding version as mandatory with 'v' added to it and added in documentation will help