Skip to content

Commit 30114c0

Browse files
authored
Merge pull request #32 from bnc-projects/add-task-healthcheck
Add task healthcheck
2 parents dce1fa0 + 094b6f0 commit 30114c0

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
FROM openjdk:8u171-jre-alpine3.8
1+
FROM openjdk:8u181-jre-slim
22

33
ARG JAR_FILE
44

5+
RUN apt-get update && apt-get install -y wget
6+
57
COPY ${JAR_FILE} app.jar
68
RUN mkdir newrelic && wget https://download.newrelic.com/newrelic/java-agent/newrelic-agent/4.4.0/newrelic-agent-4.4.0.jar -O newrelic/newrelic.jar
79
COPY newrelic.yml newrelic/newrelic.yml
@@ -10,5 +12,5 @@ EXPOSE 8080
1012

1113
ENTRYPOINT exec java $JAVA_OPTS -jar app.jar
1214

13-
HEALTHCHECK --start-period=90s \
15+
HEALTHCHECK --start-period=300s \
1416
CMD wget --quiet --tries=1 --spider --timeout=30 http://localhost:8080/actuator/health || exit 1

deployment/templates/service.yaml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Metadata:
1515
Parameters:
1616
- ContainerName
1717
- DesiredCount
18+
- CPUReservation
1819
- MemoryLimit
1920
- MemoryReservation
2021
- HealthCheckGracePeriodSeconds
@@ -51,7 +52,7 @@ Parameters:
5152

5253
HealthCheckGracePeriodSeconds:
5354
Type: Number
54-
Default: 60
55+
Default: 300
5556

5657
TaskDeregistrationDelay:
5758
Type: Number
@@ -66,12 +67,20 @@ Parameters:
6667
SpringProfile:
6768
Type: String
6869

70+
CPUReservation:
71+
Description: The number of cpu units to reserve for the container. This is only enforced when CPU cycles are constrained.
72+
Type: Number
73+
Default: 128
74+
AllowedValues: [0, 10, 20, 32, 64, 128, 256, 512, 1024, 2048, 4096]
75+
6976
MemoryReservation:
77+
Description: The memory reservation for the task, this is the expected upper limit during normal operations.
7078
Type: Number
7179
Default: 768
7280
AllowedValues: [16, 32, 64, 128, 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096]
7381

7482
MemoryLimit:
83+
Description: The memory limit for the task, when reached the task will be automatically terminated
7584
Type: Number
7685
Default: 768
7786
AllowedValues: [16, 32, 64, 128, 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096]
@@ -164,8 +173,15 @@ Resources:
164173
- Name: !Ref ContainerName
165174
Image: !Join ['', ["Fn::Sub": '${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/', "Fn::ImportValue": {"Fn::Sub":'${AWS::StackName}-RepositoryName'}, ':latest']]
166175
Essential: true
176+
Cpu: !Ref CPUReservation
167177
Memory: !Ref MemoryLimit
168178
MemoryReservation: !Ref MemoryReservation
179+
HealthCheck:
180+
Command:
181+
- "CMD-SHELL"
182+
- "wget --quiet --tries=1 --spider --timeout=30 http://localhost:8080/actuator/health || exit 1"
183+
StartPeriod: !Ref HealthCheckGracePeriodSeconds
184+
Timeout: 30
169185
PortMappings:
170186
- ContainerPort: 8080
171187
LogConfiguration:

0 commit comments

Comments
 (0)