forked from mtusi2026/mtusi2026lab3
Prepare verified laboratory 3 implementation and evidence
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: api
|
||||
spec:
|
||||
clusterIP: None
|
||||
selector: {app: api}
|
||||
ports: [{name: http, port: 8080, targetPort: http}]
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: api
|
||||
labels: {app: api}
|
||||
spec:
|
||||
replicas: 2
|
||||
revisionHistoryLimit: 2
|
||||
strategy:
|
||||
rollingUpdate: {maxSurge: 1, maxUnavailable: 0}
|
||||
selector:
|
||||
matchLabels: {app: api}
|
||||
template:
|
||||
metadata:
|
||||
labels: {app: api}
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
terminationGracePeriodSeconds: 35
|
||||
securityContext: {runAsNonRoot: true, runAsUser: 65532, fsGroup: 65532}
|
||||
containers:
|
||||
- name: api
|
||||
image: vp-messenger:local
|
||||
imagePullPolicy: Never
|
||||
ports: [{name: http, containerPort: 8080}]
|
||||
env:
|
||||
- {name: APP_HOST, value: 0.0.0.0}
|
||||
- {name: APP_PORT, value: '8080'}
|
||||
- {name: PG_MAX_CONNS, value: '8'}
|
||||
- {name: SESSION_TTL_SECONDS, value: '3600'}
|
||||
- {name: GOMEMLIMIT, value: 400MiB}
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 128Mi}
|
||||
limits: {cpu: '1', memory: 512Mi}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
capabilities: {drop: [ALL]}
|
||||
lifecycle:
|
||||
preStop:
|
||||
sleep: {seconds: 15}
|
||||
readinessProbe:
|
||||
httpGet: {path: /health/ready, port: http}
|
||||
periodSeconds: 1
|
||||
timeoutSeconds: 2
|
||||
failureThreshold: 1
|
||||
livenessProbe:
|
||||
httpGet: {path: /health/live, port: http}
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 2
|
||||
startupProbe:
|
||||
httpGet: {path: /health/live, port: http}
|
||||
periodSeconds: 1
|
||||
failureThreshold: 60
|
||||
volumeMounts: [{name: credentials, mountPath: /run/secrets, readOnly: true}]
|
||||
volumes:
|
||||
- name: credentials
|
||||
secret:
|
||||
secretName: app-config
|
||||
defaultMode: 0440
|
||||
items:
|
||||
- {key: database_url, path: database_url}
|
||||
- {key: cache_url, path: cache_url}
|
||||
@@ -0,0 +1,9 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: messenger
|
||||
resources: [namespace.yaml, stores.yaml, api.yaml, pingap.yaml]
|
||||
configMapGenerator:
|
||||
- name: pingap-config
|
||||
files: [pingap.toml]
|
||||
generatorOptions:
|
||||
disableNameSuffixHash: true
|
||||
@@ -0,0 +1,6 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: messenger
|
||||
labels:
|
||||
app.kubernetes.io/part-of: vp-coursework
|
||||
@@ -0,0 +1,20 @@
|
||||
[basic]
|
||||
threads = 1
|
||||
grace_period = "8s"
|
||||
graceful_shutdown_timeout = "10s"
|
||||
|
||||
[upstreams.api]
|
||||
addrs = ["api.messenger.svc.cluster.local:8080"]
|
||||
discovery = "dns"
|
||||
update_frequency = "1s"
|
||||
health_check = "http://api/health/ready?connection_timeout=1s&read_timeout=1s&check_frequency=1s&success=1&failure=1"
|
||||
connection_timeout = "1s"
|
||||
read_timeout = "25s"
|
||||
|
||||
[locations.api]
|
||||
path = "/"
|
||||
upstream = "api"
|
||||
|
||||
[servers.http]
|
||||
addr = "0.0.0.0:8080"
|
||||
locations = ["api"]
|
||||
@@ -0,0 +1,35 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata: {name: pingap}
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
allocateLoadBalancerNodePorts: false
|
||||
selector: {app: pingap}
|
||||
ports: [{name: http, port: 80, targetPort: http}]
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: pingap}
|
||||
spec:
|
||||
replicas: 1
|
||||
selector: {matchLabels: {app: pingap}}
|
||||
template:
|
||||
metadata: {labels: {app: pingap}}
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
terminationGracePeriodSeconds: 25
|
||||
containers:
|
||||
- name: pingap
|
||||
image: vp-pingap:local
|
||||
imagePullPolicy: Never
|
||||
args: [-c, /etc/pingap/pingap.toml, --autoreload, --strict]
|
||||
ports: [{name: http, containerPort: 8080}]
|
||||
resources:
|
||||
requests: {cpu: 50m, memory: 32Mi}
|
||||
limits: {cpu: 500m, memory: 128Mi}
|
||||
readinessProbe:
|
||||
tcpSocket: {port: http}
|
||||
periodSeconds: 1
|
||||
volumeMounts: [{name: configuration, mountPath: /etc/pingap, readOnly: true}]
|
||||
volumes:
|
||||
- {name: configuration, configMap: {name: pingap-config}}
|
||||
@@ -0,0 +1,96 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata: {name: postgres}
|
||||
spec:
|
||||
accessModes: [ReadWriteOnce]
|
||||
resources: {requests: {storage: 1Gi}}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata: {name: valkey}
|
||||
spec:
|
||||
accessModes: [ReadWriteOnce]
|
||||
resources: {requests: {storage: 1Gi}}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata: {name: postgres}
|
||||
spec:
|
||||
selector: {app: postgres}
|
||||
ports: [{port: 5432, targetPort: 5432}]
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata: {name: valkey}
|
||||
spec:
|
||||
selector: {app: valkey}
|
||||
ports: [{port: 6379, targetPort: 6379}]
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: postgres}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: Recreate}
|
||||
selector: {matchLabels: {app: postgres}}
|
||||
template:
|
||||
metadata: {labels: {app: postgres}}
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
terminationGracePeriodSeconds: 20
|
||||
containers:
|
||||
- name: postgres
|
||||
image: vp-postgres:local
|
||||
imagePullPolicy: Never
|
||||
env:
|
||||
- {name: POSTGRES_USER, value: messenger}
|
||||
- {name: POSTGRES_DB, value: messenger}
|
||||
- {name: POSTGRES_PASSWORD_FILE, value: /run/secrets/pg_password}
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 128Mi}
|
||||
limits: {cpu: '2', memory: 768Mi}
|
||||
readinessProbe:
|
||||
exec: {command: [pg_isready, -h, 127.0.0.1, -U, messenger, -d, messenger]}
|
||||
periodSeconds: 2
|
||||
volumeMounts:
|
||||
- {name: data, mountPath: /var/lib/postgresql}
|
||||
- {name: credentials, mountPath: /run/secrets, readOnly: true}
|
||||
volumes:
|
||||
- {name: data, persistentVolumeClaim: {claimName: postgres}}
|
||||
- name: credentials
|
||||
secret:
|
||||
secretName: app-config
|
||||
items: [{key: pg_password, path: pg_password}]
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: valkey}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: Recreate}
|
||||
selector: {matchLabels: {app: valkey}}
|
||||
template:
|
||||
metadata: {labels: {app: valkey}}
|
||||
spec:
|
||||
automountServiceAccountToken: false
|
||||
terminationGracePeriodSeconds: 10
|
||||
containers:
|
||||
- name: valkey
|
||||
image: vp-valkey:local
|
||||
imagePullPolicy: Never
|
||||
command: [valkey-server, /run/secrets/valkey_conf]
|
||||
resources:
|
||||
requests: {cpu: 50m, memory: 32Mi}
|
||||
limits: {cpu: 250m, memory: 128Mi}
|
||||
readinessProbe:
|
||||
tcpSocket: {port: 6379}
|
||||
periodSeconds: 2
|
||||
volumeMounts:
|
||||
- {name: data, mountPath: /data}
|
||||
- {name: credentials, mountPath: /run/secrets, readOnly: true}
|
||||
volumes:
|
||||
- {name: data, persistentVolumeClaim: {claimName: valkey}}
|
||||
- name: credentials
|
||||
secret:
|
||||
secretName: app-config
|
||||
items: [{key: valkey_conf, path: valkey_conf}]
|
||||
Reference in New Issue
Block a user