diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..711a86b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +# Use an official Python runtime as a parent image +FROM python:3.9-slim + +# Set the working directory in the container +WORKDIR /app + +# Copy the current directory contents into the container at /app +COPY . /app + +# Install any needed packages specified in requirements.txt +RUN pip install --no-cache-dir -r requirements.txt + +# Install Java (OpenJDK) in the container +RUN apt-get update && apt-get install -y openjdk-11-jdk + +# Set environment variables for Java +ENV JAVA_HOME /usr/lib/jvm/java-11-openjdk-amd64 +ENV PATH $JAVA_HOME/bin:$PATH + +# Define the command to run your Python script which interacts with Java +CMD ["python", "config.py"] \ No newline at end of file diff --git a/helm/charts.yml b/helm/charts.yml new file mode 100644 index 0000000..311adaa --- /dev/null +++ b/helm/charts.yml @@ -0,0 +1,4 @@ +apiVersion: v2 +name: java-app-chart +description: A Helm chart for deploying a Java application +version: 0.1.0 diff --git a/helm/templates/deployment.yml b/helm/templates/deployment.yml new file mode 100644 index 0000000..8f7fc88 --- /dev/null +++ b/helm/templates/deployment.yml @@ -0,0 +1,22 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "java-app-chart.fullname" . }} + labels: + app: {{ include "java-app-chart.name" . }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ include "java-app-chart.name" . }} + template: + metadata: + labels: + app: {{ include "java-app-chart.name" . }} + spec: + containers: + - name: java-app + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - containerPort: 8080 diff --git a/helm/templates/hpa.yml b/helm/templates/hpa.yml new file mode 100644 index 0000000..b18f43c --- /dev/null +++ b/helm/templates/hpa.yml @@ -0,0 +1,18 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "java-app-chart.fullname" . }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "java-app-chart.name" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} +{{- end }} diff --git a/helm/templates/service.yml b/helm/templates/service.yml new file mode 100644 index 0000000..2528127 --- /dev/null +++ b/helm/templates/service.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.service.name }} +spec: + selector: + app: {{ include "java-app-chart.name" . }} + ports: + - protocol: TCP + port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} diff --git a/helm/values.yml b/helm/values.yml new file mode 100644 index 0000000..4f7095b --- /dev/null +++ b/helm/values.yml @@ -0,0 +1,20 @@ +# Default values for java-app-chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 3 + +image: + repository: your-java-image + tag: latest + pullPolicy: IfNotPresent + +service: + name: java-app + port: 80 + targetPort: 8080 + +autoscaling: + enabled: true + minReplicas: 2 + maxReplicas: 5 + targetCPUUtilizationPercentage: 50