diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..9a81bec7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM maven:3.8.4-openjdk-8 AS build +WORKDIR /app +COPY pom.xml . +RUN mvn dependency:go-offline +COPY src ./src +RUN mvn clean package -DskipTests + +FROM tomcat:8.5-jre8-alpine +RUN rm -rf /usr/local/tomcat/webapps/* +COPY --from=build /app/target/*.war /usr/local/tomcat/webapps/ROOT.war +EXPOSE 8080 +CMD ["catalina.sh", "run"] \ No newline at end of file diff --git a/README.md b/README.md index 86abd74d..613bc625 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ designed. Please note this example uses and requires Java 8 to work. ![Addressbook Screenshot](addressbook_screenshot.png "Addressbook Screenshot") + Running the example from the command line ------------------- ``` @@ -64,3 +65,4 @@ To use the built in server adapters of Eclipse, instead of doing "Run As -> Mave - Run As -> Run on Server - Select the server you want to run on, e.g. Apache Tomcat 8 and click ok - *Do not use the suggested J2EE Preview server* as it is outdated, deprecated and does not support Servlet 3, which is required for this application +-- diff --git a/deployment.yaml b/deployment.yaml new file mode 100644 index 00000000..989941c4 --- /dev/null +++ b/deployment.yaml @@ -0,0 +1,40 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: addressbook-app + labels: + app: addressbook +spec: + replicas: 2 + selector: + matchLabels: + app: addressbook + template: + metadata: + labels: + app: addressbook + spec: + containers: + - name: addressbook + image: lisandroaws/project-k8s:latest + ports: + - containerPort: 8080 + resources: + requests: + memory: "256Mi" + cpu: "250m" + limits: + memory: "512Mi" + cpu: "500m" + livenessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: 60 + periodSeconds: 30 + readinessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: 30 + periodSeconds: 10 \ No newline at end of file diff --git a/service.yaml b/service.yaml new file mode 100644 index 00000000..1462d574 --- /dev/null +++ b/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: addressbook-service + labels: + app: addressbook +spec: + type: LoadBalancer + ports: + - port: 8081 + targetPort: 8080 + protocol: TCP + selector: + app: addressbook \ No newline at end of file