community icon indicating copy to clipboard operation
community copied to clipboard

EC2 controller - add subnetRef

Open gecube opened this issue 1 year ago • 2 comments

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"

gecube avatar Jul 28 '23 12:07 gecube

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

ack-bot avatar Feb 11 '24 19:02 ack-bot

/remove-lifecycle stale

gecube avatar Feb 11 '24 19:02 gecube

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

ack-bot avatar Aug 09 '24 20:08 ack-bot

/remove-lifecycle stale

gecube avatar Aug 10 '24 10:08 gecube