Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/lab4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Lab 4 - Helm Chart Grading

on: [push]

jobs:
helm-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Helm
uses: azure/setup-helm@v4.2.0

- name: Run Lab 4 Tests
run: |
chmod +x ./tests/lab4_test.sh
./tests/lab4_test.sh
6 changes: 6 additions & 0 deletions charts/ecommerce-app/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: ecommerce-app
description: Helm chart for ServiceStation project
type: application
version: 0.1.0
appVersion: "1.0.0"
14 changes: 14 additions & 0 deletions charts/ecommerce-app/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
data:
DB_USER: {{ .Values.postgres.dbUser | quote }}
DB_HOST: "db-service"
DB_PORT: "5432"
DB_NAME: {{ .Values.postgres.dbName | quote }}
DATABASE_URL: "postgresql://{{ .Values.postgres.dbUser }}:{{ .Values.secrets.dbPassword }}@db-service:5432/{{ .Values.postgres.dbName }}?schema=public"
PORT: "8080"
JWT_EXPIRE: "1d"
GOOGLE_CALLBACK_URL: "http://localhost:8080/api/auth/google/callback"
CLIENT_URL: "http://localhost:80"
37 changes: 37 additions & 0 deletions charts/ecommerce-app/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ecommerce-app
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: ecommerce-app
template:
metadata:
labels:
app: ecommerce-app
spec:
containers:
- name: ecommerce-app
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 8080
resources:
{{ toYaml .Values.resources | nindent 12 }}
envFrom:
- secretRef:
name: app-secret
- configMapRef:
name: app-config
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 30
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 15
38 changes: 38 additions & 0 deletions charts/ecommerce-app/templates/postgres.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres-deployment
spec:
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: {{ .Values.postgres.image }}
ports:
- containerPort: 5432
env:
- name: POSTGRES_USER
value: {{ .Values.postgres.dbUser | quote }}
- name: POSTGRES_PASSWORD
value: {{ .Values.secrets.dbPassword | quote }}
- name: POSTGRES_DB
value: {{ .Values.postgres.dbName | quote }}
---
apiVersion: v1
kind: Service
metadata:
name: db-service
spec:
type: ClusterIP
selector:
app: postgres
ports:
- port: 5432
targetPort: 5432
10 changes: 10 additions & 0 deletions charts/ecommerce-app/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
name: app-secret
type: Opaque
stringData:
DB_PASSWORD: {{ .Values.secrets.dbPassword | quote }}
JWT_SECRET: {{ .Values.secrets.jwtSecret | quote }}
GOOGLE_CLIENT_ID: {{ .Values.secrets.googleClientId | quote }}
GOOGLE_CLIENT_SECRET: {{ .Values.secrets.googleClientSecret | quote }}
11 changes: 11 additions & 0 deletions charts/ecommerce-app/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: ecommerce-service
spec:
type: ClusterIP
selector:
app: ecommerce-app
ports:
- port: 8080
targetPort: 8080
1 change: 1 addition & 0 deletions charts/ecommerce-app/values-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
replicaCount: 3
25 changes: 25 additions & 0 deletions charts/ecommerce-app/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
replicaCount: 2

image:
repository: ghcr.io/jessfreak/ecommerce-app
tag: latest
pullPolicy: IfNotPresent

resources:
limits:
cpu: 200m
memory: 256Mi
requests:
cpu: 100m
memory: 128Mi

postgres:
image: postgres:15-alpine
dbName: service_station
dbUser: postgres

secrets:
dbPassword: "dummy-password"
jwtSecret: "dummy-secret"
googleClientId: "dummy-id"
googleClientSecret: "dummy-secret"
2 changes: 1 addition & 1 deletion k8s/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
type: ClusterIP
selector:
app: backend-deployment
app: ecommerce-app
ports:
- port: 8080
targetPort: 8080
22 changes: 22 additions & 0 deletions tests/lab4_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
set -e

echo "--- Starting Lab 4 Grading (Helm Check) ---"

# 1. Валідація чарта
echo "Step 1: Running helm lint..."
helm lint ./charts/ecommerce-app

# 2. Перевірка шаблонізації для Prod
echo "Step 2: Checking Production replica count..."
REPLICAS=$(helm template ecommerce ./charts/ecommerce-app -f ./charts/ecommerce-app/values-prod.yaml | grep 'replicas: 3' | xargs)
if [ "$REPLICAS" != "replicas: 3" ]; then
echo "❌ Error: values-prod.yaml should set replicas to 3."
exit 1
fi

# 3. Dry-run install
echo "Step 3: Testing Dry-run installation..."
helm install ecommerce ./charts/ecommerce-app --dry-run --debug

echo "✅ SUCCESS: Lab 4 is passed!"
Loading