kubernetes-sigs / cluster-api-provider-aws

Kubernetes Cluster API Provider AWS provides consistent deployment and day 2 operations of "self-managed" and EKS Kubernetes clusters on AWS.
http://cluster-api-aws.sigs.k8s.io/
Apache License 2.0
632 stars 559 forks source link

Failed to find AMI for AWSMachine following the documentation quick start #4984

Open jfcavalcante opened 3 months ago

jfcavalcante commented 3 months ago

/kind bug

What steps did you take and what happened: [A clear and concise description of what the bug is.]

After following the ClusterAPI Provider AWS Quick Start, and creating a cluster with the kubernetes version v1.29.2, as described in the documentation, I've faced the following error:

E0518 20:43:26.820802       1 awsmachine_controller.go:520] "unable to create instance" err="failed to create AWSMachine instance: failed to find ami: found no AMIs with the name: \"capa-ami-ubuntu-18.04-?1.29.2-*\""
E0518 20:43:26.839548       1 controller.go:329] "Reconciler error" err="failed to create AWSMachine instance: failed to find ami: found no AMIs with the name: \"capa-ami-ubuntu-18.04-?1.29.2-*\"" controller="awsmachine" controllerGroup="infrastructure.cluster.x-k8s.io" controllerKind="AWSMachine" AWSMachine="default/capi-quickstart-control-plane-ghxb2" namespace="default" name="capi-quickstart-control-plane-ghxb2" reconcileID="0e55d5cb-e196-4aad-8abc-3877a24209a7"

The image name string isn't being parsed correctly, and resulting in an error during reconcile.

What did you expect to happen:

The cluster to be completelly provisioned following the commands of the documentation.

Environment:

k8s-ci-robot commented 3 months ago

This issue is currently awaiting triage.

If CAPA/CAPI contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
jfcavalcante commented 3 months ago

Also tried with kubernetes in v1.27.6, same error occurs.

E0518 21:11:44.458942       1 awsmachine_controller.go:520] "unable to create instance" err="failed to create AWSMachine instance: failed to find ami: found no AMIs with the name: \"capa-ami-ubuntu-18.04-?1.27.6-*\""
jfcavalcante commented 3 months ago

Adding the AMI ID to both AWSMachineTemplate spec solved it for me:

apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
kind: AWSMachineTemplate
metadata:
  name: capi-quickstart-md-0
  namespace: default
spec:
  template:
    spec:
      ami:
        id: ami-0e0ff5dacd34970c0
      iamInstanceProfile: nodes.cluster-api-provider-aws.sigs.k8s.io
      instanceType: t3.large
      sshKeyName: default
athiruma commented 1 month ago

Query clusterawsadm ami list to find the available AMI versions. If you do not find the supported Kubernetes version AMI, use the latest available AMI equivalent to the latest Kubernetes version.

I encountered the same error, and the above trace resolved it for me.