Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

container initial port #15

Open
davidlondono opened this issue Nov 27, 2023 · 9 comments
Open

container initial port #15

davidlondono opened this issue Nov 27, 2023 · 9 comments

Comments

@davidlondono
Copy link

The initial port 5000 cannot be deployed as the initial image doesn't have this port enabled and fail to health check

@jasonmimick-aws
Copy link
Contributor

Hi @davidlondono -

Thanks for reporting the issue you're facing.

There is an addPortMappings section in the cdk code which should accomplish this. See https://github.com/search?q=repo%3Aaws-samples%2Famazon-ecs-fargate-cdk-v2-cicd%205000&type=code

Possibly something has changed in the CDK libs or how things are getting deployed.

Do you have any more information, logs, or details you can share?

Feel free to ping me on slack @mimjasov

@rverton
Copy link

rverton commented Jan 25, 2024

Hi @jasonmimick-aws,
but there is no http service (with a /health endpoint) for the amazonlinux:2022 image running on port 5000, so the initial deployment will get stuck when ECS is provisioned, isn't it?

const baseImage = 'public.ecr.aws/amazonlinux/amazonlinux:2022'

Thanks

@saurabhmarwaha
Copy link

@jasonmimick-aws My stack is also stuck in progress endlessly. Is there a different image and port number we can use for initial deployment?

@rverton
Copy link

rverton commented Jan 30, 2024

Hey @saurabhmarwaha,
you can use public.ecr.aws/nginx/nginx-unprivileged as a 'dummy' container. I'm using it with port 8080. If you want/need port 80, you can use http://public.ecr.aws/nginx/nginx. They are also available as ARM containers.

@saurabhmarwaha
Copy link

@rverton Container / Task is still taking unusually longer with below changes due to which stack continues to be In progress status. Is that how you are using a dummy container.

const baseImage = 'public.ecr.aws/nginx/nginx-unprivileged'

container.addPortMappings({
  containerPort: **8080**,
  protocol: ecs.Protocol.TCP
});

@rverton
Copy link

rverton commented Jan 30, 2024

@rverton Container / Task is still taking unusually longer with below changes due to which stack continues to be In progress status. Is that how you are using a dummy container.

const baseImage = 'public.ecr.aws/nginx/nginx-unprivileged'

container.addPortMappings({
  containerPort: **8080**,
  protocol: ecs.Protocol.TCP
});

You also need to adjust the health check because the nginx container will not have a /health endpoint:

    const fgService = new ecs_patterns.ApplicationLoadBalancedFargateService(this, `${id}-ecs-service`, {
      cluster,
      // ...
    });

    fgService.targetGroup.configureHealthCheck({
      path: "/",
    });

@saurabhmarwaha
Copy link

Still no progress. Stack is stuck in progress and task stopped eventually

const baseImage = 'public.ecr.aws/nginx/nginx-unprivileged'
const container = taskDef.addContainer('nodejs-docker-example', {
  image: ecs.ContainerImage.fromRegistry(baseImage),
  memoryLimitMiB: 256,
  cpu: 256,
  logging
});

container.addPortMappings({
  containerPort: 8080,
  protocol: ecs.Protocol.TCP
});

const fargateService = new ecs_patterns.ApplicationLoadBalancedFargateService(this, "ecs-service", {
  cluster: cluster,
  taskDefinition: taskDef,
  publicLoadBalancer: true,
  desiredCount: 1,
  listenerPort: 80,
});

fargateService.targetGroup.configureHealthCheck({
  path: "/",
});

Task stopped at: 2024-01-30T08:41:02.149Z
CannotPullContainerError: pull image manifest has been retried 5 time(s): failed to resolve ref public.ecr.aws/nginx/nginx-unprivileged:latest: failed to do request: Head "https://public.ecr.aws/v2/nginx/nginx-unprivileged/manifests/latest": dial tcp 75.2.101.78:443: i/o timeout

Container

Container-2

@rverton
Copy link

rverton commented Jan 30, 2024

As I understand this error, ECS is not able to pull the container. Does your ECS service have a route to the public ECR repository?

@saurabhmarwaha
Copy link

saurabhmarwaha commented Jan 30, 2024

@rverton I believe you mean if subnet where cluster is created have access to Internet (IGW). I will check the routing and will verify.
Could be related to Auto-assign public IP.

Will come back to in a few hours..Here it's 4:00 am..Getting some sleep...:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants