I need to use a specific custom Windows AMI as the base image to build an AMI to be used by EKS worker nodes. How do I do that?
Related
Im looking for some advice, this may seem like a silly question but I am having some issues with understanding how AWS EBS autoscaling works and its best practices.
I have a laravel application that is deployed to AWS EBS through bitbucket pipelines. This all works and deploys successfully.
My issue is when the autoscaling triggers it then brings up a new EC2 instance and then load balances the traffic. The problem is that the new EC2 instance in the fleet is a blank AWS Linux2 AMI so just shows the nginx welcome page.
I think the issue is that it's using a blank AMI and not getting my application. I am guessing i could create an image from the EC2 image running my application and then scale with that but i would have to do that every time i do a deployment.
Can you configure the auto scaling group to replicate the running EC2 instance?
Any help or advice as to the best way to accomplish autoscaling with my application would be great.
Its depend on the AMI selected in Launch Configuration..
You need to create AMI of your live EC2 instance after you updated your all required softwares, dbs, configurations and verified(tested) for proper work..
then add this AMI to Auto scale Launch Configuration..
you dont need to create AMI for each deployment..
Whenever you makes changes On Ec2 server , or updates your app source code, you need to create new AMI and need to specify that AMI in Autoscale launch configuration.
best practice is to config the auto scale with a user data script. So when the new AMI boots up during the auto scaling it reads the user data (cloud init/upstart). The user data script can pull the code from the git or what ever source control and run the necessary pre-deployment commands.
I'm aware that there are similar question posted here, but none of them address this specific issue.
How to create an ECS cluster via CLI tools, aws-cli and/or ecs-cli, with using your own custom AMI stored in EC2 as an AMI image?
Is this even possible currently or do I need to turn to CloudFormation?
EDIT: I had a major confusion about the service architecture of ECS in terms of distributing containers on container instances (EC2 instances registered to the cluster).
So the container instance runs on an AMI. Which can be a custom built AMI, but such would needed only in some special circumstances. It's recommended to use an ECS-optimized Amazon Linux AMI by as maintained by AWS and is updated about once a month.
Another confusion point was with Docker Compose approach and the ECS CLI tool. Some experts think that while the ECS CLI is released and maintained by AWS, and being already 3 years old at this point in 2019, it is not suitable for production usage. So am using AWS CLI instead, and dealing with clusters, task definitions, and (task scheduling) services directly.
I would rather run the custom stuff within the container defined by dockerfile on ECS optimized AMI
But to run custom AMI
1) Pre-requisite is to have AMI image with ECS Agent installed
2) Then I would try ecs-cli up command with defined --image-id
ecs-cli up
--keypair <my-keypair>
--launch-type EC2
--size 2
--instance-type t2.micro
--instance-role ECSMediumRole
--vpc <my-vpc>
--image-id ami-XXXXXXXX # Custom Image ID with ECS Agent installed
--cluster-config <my-cluster-config>
--ecs-profile <my-ecs-profile>
--security-group <my-security-group-id>
--region us-east-1
--subnets <my-public-vpc-subnet>
I have created my own EC2 instance in AWS. That AMI is AWS ECS optimized AMI for launching ecs service from my EC2 instance. I previously discussed the same thing. And tried with that approach. The link is below,
Microservice Deployment Using AWS ECS Service
I created my cluster and configured that cluster name when I am creating optimized AMI by following code snippet in advanced userdata section,
#!/bin/bash
echo ECS_CLUSTER=your_cluster_name >> /etc/ecs/ecs.config
I followed the documentation of cluster creation from following link,
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create_cluster.htmlecs
But, no result - when creating cluster and ECS task definitions it creates and launches into one EC2. And again creating another EC2 by specifying above code. So total 2 Ec2. I already created my own ECS optimized.
I am finding for launching ECS service from my own AMI (that I created). Actually I need to launch my ECS service from my Ec2 (I had created my machine Amazon optimized AMI).
The reason behind this requirement is I don't want to launch my services in machine that owned by others. I need to launch from my machine. And also I need to host my angular application in the same my machine. So I need control of my machine. How can I do this?
Sounds like you just need to create a Launch Configuration. With this you can specify the User Data settings that should be applied when a host is setup.
After you create your Launch Configuration, create a new Auto Scaling Group based off of it (there's a drop-down to select the launch configuration you want to use).
From here, any new instances launched under that ASG will apply the settings you've configured in the associated Launch Configuration.
If I create the custom AMI, (This AMI is imported from VMware server using the import-image) can i use the user data while launching the instance from this AMI?Means cloud-init will be available in the custom AMI using the import-image? OS are RHEL..
You would need to install the cloud-init service on the VM you are creating the custom AMI from. That isn't something AWS does for you automatically.
I'm trying to share my AMI with a colleague, who is testing his change to my cluster computing application.
While it is easy to change the permission of my AMI to 'public', I can't find its manifest anywhere, including in my S3 buckets.
Is this feature missing for AMI created in EC2 console?
A manifest is only required for an Instance-Store Backed AMI. This is where the AMI is copied to Instance Store (ephemeral storage) rather than an EBS volume. This method is quite old and these days it is recommended to use a normal AMI that is used to create an EBS boot volume.
AMIs created in the EC2 Management Console can be shared either publicly or with with specific accounts.