Compare commits

..

6 Commits
dev ... main

Author SHA1 Message Date
syifa 7fb08392cf updated k8s for base kustomization 2025-11-07 04:27:55 +00:00
jenkins e30030631f Update overlays/dev: backend=13, frontend=13 2025-10-23 02:18:30 +00:00
jenkins deae8c0b79 Update overlays/dev: backend=12, frontend=12 2025-10-23 02:16:20 +00:00
jenkins 496ba50f93 Update overlays/production: backend=11, frontend=11 2025-10-22 12:51:23 +00:00
jenkins 977556685d Update overlays/staging: backend=10, frontend=10 2025-10-22 12:46:18 +00:00
jenkins e40591ba19 Update overlays/dev: backend=9, frontend=9 2025-10-22 07:16:21 +00:00
14 changed files with 144 additions and 59 deletions

View File

@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: backend-app-syifa
#namespace: intern-workspace
namespace: intern-workspace
spec:
replicas: 1
selector:
@ -58,7 +58,7 @@ apiVersion: v1
kind: Service
metadata:
name: backend-app-syifa
#namespace: intern-workspace
namespace: intern-workspace
spec:
type: ClusterIP
selector:
@ -66,3 +66,4 @@ spec:
ports:
- port: 5000
targetPort: 5000

View File

@ -2,7 +2,8 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: backend-config-syifa
#namespace: intern-workspace
namespace: intern-workspace
data:
DB_HOST: "mysql-app-syifa"
DB_NAME: "datasiswa"

View File

@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend-app-syifa
#namespace: intern-workspace
namespace: intern-workspace
spec:
replicas: 1
selector:
@ -56,7 +56,7 @@ apiVersion: v1
kind: Service
metadata:
name: frontend-app-syifa
#namespace: intern-workspace
namespace: intern-workspace
spec:
type: NodePort
selector:
@ -64,5 +64,6 @@ spec:
ports:
- port: 3000
targetPort: 3000
nodePort: 30068
nodePort: 30067
protocol: TCP

View File

@ -1,6 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: intern-workspace
resources:
- backend-deployment.yaml
- frontend-deployment.yaml

View File

@ -2,7 +2,7 @@ apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pvc-syifa
#namespace: intern-workspace
namespace: intern-workspace
spec:
accessModes:
- ReadWriteOnce
@ -15,7 +15,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-app-syifa
#namespace: intern-workspace
namespace: intern-workspace
spec:
replicas: 1
selector:
@ -64,7 +64,7 @@ apiVersion: v1
kind: Service
metadata:
name: mysql-app-syifa
#namespace: intern-workspace
namespace: intern-workspace
spec:
type: ClusterIP
selector:
@ -72,3 +72,4 @@ spec:
ports:
- port: 3306
targetPort: 3306

View File

@ -2,7 +2,7 @@ apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-frontend-to-backend
#namespace: intern-workspace
namespace: intern-workspace
spec:
podSelector:
matchLabels:
@ -22,7 +22,7 @@ apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-backend-to-mysql
#namespace: intern-workspace
namespace: intern-workspace
spec:
podSelector:
matchLabels:
@ -51,7 +51,7 @@ apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-backend-egress
#namespace: intern-workspace
namespace: intern-workspace
spec:
podSelector:
matchLabels:
@ -78,7 +78,7 @@ apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-frontend-egress
#namespace: intern-workspace
namespace: intern-workspace
spec:
podSelector:
matchLabels:
@ -100,3 +100,5 @@ spec:
ports:
- protocol: UDP
port: 53

View File

@ -5,13 +5,13 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: frontend-sa-syifa
#namespace: intern-workspace
namespace: intern-workspace
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: frontend-role-syifa
#namespace: intern-workspace
namespace: intern-workspace
rules:
# Frontend boleh baca Service (buat resolve endpoint backend)
- apiGroups: [""]
@ -22,11 +22,11 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: frontend-rolebinding-syifa
#namespace: intern-workspace
namespace: intern-workspace
subjects:
- kind: ServiceAccount
name: frontend-sa-syifa
#namespace: intern-workspace
namespace: intern-workspace
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
@ -40,13 +40,13 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: backend-sa-syifa
#namespace: intern-workspace
namespace: intern-workspace
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: backend-role-syifa
#namespace: intern-workspace
namespace: intern-workspace
rules:
# Backend boleh baca ConfigMap dan Secret (buat env)
- apiGroups: [""]
@ -61,11 +61,11 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: backend-rolebinding-syifa
#namespace: intern-workspace
namespace: intern-workspace
subjects:
- kind: ServiceAccount
name: backend-sa-syifa
#namespace: intern-workspace
namespace: intern-workspace
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
@ -79,13 +79,13 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: mysql-sa-syifa
#namespace: intern-workspace
namespace: intern-workspace
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: mysql-role-syifa
#namespace: intern-workspace
namespace: intern-workspace
rules:
- apiGroups: [""]
resources: ["configmaps", "secrets"]
@ -95,12 +95,13 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: mysql-rolebinding-syifa
#namespace: intern-workspace
namespace: intern-workspace
subjects:
- kind: ServiceAccount
name: mysql-sa-syifa
#namespace: intern-workspace
namespace: intern-workspace
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: mysql-role-syifa

View File

@ -2,8 +2,9 @@ apiVersion: v1
kind: Secret
metadata:
name: backend-secret-syifa
#namespace: intern-workspace
namespace: intern-workspace
type: Opaque
data:
DB_USER: cm9vdA== # hasil base64 dari "root"
DB_PASSWORD: "" # kosong, tetap valid

View File

@ -1,14 +1,18 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namePrefix: dev-
labels:
- pairs:
environment: dev
# Referensi ke base
resources:
- ../../k8s
# Namespace & prefix untuk semua resource
namespace: intern-workspace
namePrefix: dev-
# Label tambahan untuk menandai environment
commonLabels:
environment: dev
# Gabungkan patch deployment kamu
patchesStrategicMerge:
- patch-deployment.yaml

View File

@ -1,42 +1,29 @@
# ==========================
# PATCH DEPLOYMENT BACKEND
# BACKEND PATCH
# ==========================
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend-app-syifa
spec:
replicas: 1
template:
spec:
containers:
- name: backend
image: docker.io/syifamaulidya/backend-app:23
env:
- name: DB_HOST
value: "dev-mysql-app-syifa"
- name: DB_NAME
value: "datasiswa"
envFrom:
- configMapRef:
name: dev-backend-config-syifa
- secretRef:
name: dev-backend-secret-syifa
image: docker.io/syifamaulidya/backend-app:13 # <-- Jenkins nanti ganti otomatis ke vX
---
# ==========================
# PATCH DEPLOYMENT FRONTEND
# FRONTEND PATCH
# ==========================
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend-app-syifa
spec:
replicas: 1
template:
spec:
containers:
- name: frontend
image: docker.io/syifamaulidya/frontend-app:23
env:
- name: REACT_APP_API_URL
value: "http://dev-backend-app-syifa:5000/api/auth/login"
image: docker.io/syifamaulidya/frontend-app:13 # <-- Jenkins juga ganti otomatis

View File

@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../k8s
namespace: intern-workspace
namePrefix: prod-
commonLabels:
environment: production
patchesStrategicMerge:
- patch-deployment.yaml

View File

@ -0,0 +1,29 @@
# ==========================
# BACKEND PATCH
# ==========================
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend-app-syifa
spec:
replicas: 3
template:
spec:
containers:
- name: backend
image: docker.io/syifamaulidya/backend-app:11 # <-- Jenkins nanti ganti otomatis ke vX
---
# ==========================
# FRONTEND PATCH
# ==========================
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend-app-syifa
spec:
replicas: 3
template:
spec:
containers:
- name: frontend
image: docker.io/syifamaulidya/frontend-app:11 # <-- Jenkins juga ganti otomatis

View File

@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../k8s
namespace: intern-workspace
namePrefix: staging-
commonLabels:
environment: staging
patchesStrategicMerge:
- patch-deployment.yaml

View File

@ -0,0 +1,29 @@
# ==========================
# BACKEND PATCH
# ==========================
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend-app-syifa
spec:
replicas: 2
template:
spec:
containers:
- name: backend
image: docker.io/syifamaulidya/backend-app:10 # <-- Jenkins nanti ganti otomatis ke vX
---
# ==========================
# FRONTEND PATCH
# ==========================
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend-app-syifa
spec:
replicas: 2
template:
spec:
containers:
- name: frontend
image: docker.io/syifamaulidya/frontend-app:10 # <-- Jenkins juga ganti otomatis