aws-controllers-k8s / community

AWS Controllers for Kubernetes (ACK) is a project enabling you to manage AWS services from Kubernetes
https://aws-controllers-k8s.github.io/community/
Apache License 2.0
2.39k stars 253 forks source link

EC2 controller - add subnetRef #1863

Open gecube opened 1 year ago

gecube commented 1 year ago

Hi!

Right now I want to create all Ec2 instances and all underlying infra in one go and automatic way.

Unfortunately, subnetID for EC2 instance must be populated manually.

apiVersion: ec2.services.k8s.aws/v1alpha1
kind: Instance
metadata:
  name: test
  namespace: infra-production
spec:
  iamInstanceProfile:
    arn: "arn:aws:iam::966321756598:instance-profile/ssm-instance-profile"
  imageID: ami-0eb260c4d5475b901
  keyName: george
  instanceType: r5n.8xlarge
  subnetID: subnet-0f06902b47c880118 # production-private-eu-west-2a
  securityGroupIDs:
    - sg-05c2348dbc876ab30
  tags:
    - key: Name
      value: test
    - key: env
      value: production
  blockDeviceMappings:
    - deviceName: "/dev/sda1"
      ebs:
        volumeSize: 500
        deleteOnTermination: false
  metadataOptions:
    instanceMetadataTags: enabled

I'd like to have some key called like subnetRef, which will contain like to the name of subnet object, so the controller could get the subnetID from the status field. The same approach already is leveraged in Subnet object when referring to VPC object (vpcRef)

apiVersion: ec2.services.k8s.aws/v1alpha1
kind: Subnet
metadata:
  name: production-public-eu-west-2a
  namespace: infra-production
spec:
  availabilityZone: eu-west-2a
  cidrBlock: 10.3.0.0/20
  mapPublicIPOnLaunch: true
  vpcRef:
    from:
      name: production
  routeTableRefs:
    - from:
        name: production-public-route-table
  tags:
    - key: "Name"
      value: "production-public-eu-west-2a"
    - key: "kubernetes.io/role/elb"
      value: "1"
    - key: "kubernetes.io/cluster/production"
      value: "shared"
ack-bot commented 6 months ago

Issues go stale after 180d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 60d of inactivity and eventually close. If this issue is safe to close now please do so with /close. Provide feedback via https://github.com/aws-controllers-k8s/community. /lifecycle stale

gecube commented 6 months ago

/remove-lifecycle stale

ack-bot commented 4 weeks ago

Issues go stale after 180d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 60d of inactivity and eventually close. If this issue is safe to close now please do so with /close. Provide feedback via https://github.com/aws-controllers-k8s/community. /lifecycle stale

gecube commented 4 weeks ago

/remove-lifecycle stale