Skip to content

Commit

Permalink
Initial K8s deployment setup for local (used with Minikube)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-ka committed Feb 13, 2024
1 parent d5ff90e commit cbc3bdd
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: tla-sample-backend-config
data:
application.properties: |-
# https://spring.io/guides/topicals/spring-on-kubernetes
server.shutdown=graceful
management.endpoints.web.exposure.include=*
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: tla-sample-backend
labels:
app: tla-sample-backend
spec:
replicas: 1
selector:
matchLabels:
app: tla-sample-backend
template:
metadata:
labels:
app: tla-sample-backend
spec:
containers:
- name: tla-sample-backend
image: contextmapper/ddd-cm-tla-sample-application:latest
imagePullPolicy: "Always"
envFrom:
- configMapRef:
name: tla-sample-backend-env-config
- secretRef:
name: tla-sample-backend-secrets
ports:
- containerPort: 8080
name: http
- containerPort: 8443
name: https
resources:
limits:
memory: 1024Mi
requests:
memory: 512Mi
volumeMounts:
- mountPath: /srv/web/conf/application.properties
name: tla-sample-backend-config
subPath: application.properties
readinessProbe:
httpGet:
port: 8080
path: /actuator/health/readiness
initialDelaySeconds: 30
periodSeconds: 5
volumes:
- name: tla-sample-backend-config
configMap:
name: tla-sample-backend-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: tla-sample-backend
labels:
app: tla-sample-backend
spec:
type: NodePort
ports:
- port: 8080
name: http
targetPort: 8080
- port: 1044
name: debug
targetPort: 1044
selector:
app: tla-sample-backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: tla-sample-backend-env-config
data:
DEBUG_OPTS: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044"
JAVA_OPTS: "-Xmx1g -Xms1g -Dspring.profiles.active=local -DSpring.config.additional-location=file:/srv/web/conf/ -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8090 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.io.tmpdir=/srv/web/tmp"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: tla-sample-backend-ingress
spec:
rules:
- host: tla-sample-app.contextmapper.org
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: tla-sample-backend
port:
number: 8080
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: tla-sample-backend-secrets
type: Opaque
data:
SPRING_DATASOURCE_PASSWORD: aGVsbG8tdGxh

# local PW: hello-tla
10 changes: 10 additions & 0 deletions deployment/k8s/tla-sample-db/common/tla-sample-db-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: tla-sample-db-config
labels:
app: tla-sample-db
data:
POSTGRES_DB: "tla-sample"
POSTGRES_USER: "tla-sample"
POSTGRES_SCHEMA: "public"
10 changes: 10 additions & 0 deletions deployment/k8s/tla-sample-db/common/tla-sample-db-data-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: tla-sample-db-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
12 changes: 12 additions & 0 deletions deployment/k8s/tla-sample-db/common/tla-sample-db-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: tla-sample-db
spec:
type: NodePort
selector:
app: tla-sample-db
ports:
- name: "5435"
port: 5432
targetPort: 5432
34 changes: 34 additions & 0 deletions deployment/k8s/tla-sample-db/common/tla-sample-db-statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: tla-sample-db
spec:
replicas: 1
selector:
matchLabels:
app: tla-sample-db
serviceName: "tla-sample-db"
template:
metadata:
labels:
app: tla-sample-db
spec:
containers:
- name: tla-sample-db
image: postgres:16.2-alpine
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 5432
envFrom:
- configMapRef:
name: tla-sample-db-config
- secretRef:
name: tla-sample-db-password-secret
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: tla-sample-db-data
subPath: postgres
volumes:
- name: tla-sample-db-data
persistentVolumeClaim:
claimName: tla-sample-db-data
9 changes: 9 additions & 0 deletions deployment/k8s/tla-sample-db/local/tla-sample-db-secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: tla-sample-db-password-secret
type: Opaque
data:
POSTGRES_PASSWORD: aGVsbG8tdGxh

# local PW: hello-tla

0 comments on commit cbc3bdd

Please sign in to comment.