admin pannel k8s

This commit is contained in:
tusuii
2026-02-19 18:53:04 +05:30
parent 94d0aabec6
commit ba2831d491
7 changed files with 174 additions and 2 deletions

20
k8s/configmap.yaml Normal file
View File

@@ -0,0 +1,20 @@
# NOTE: VITE_* variables are embedded into the JS bundle at build time by Vite.
# They cannot be changed at runtime without rebuilding the image.
#
# To deploy with a different API URL, rebuild the image with:
# docker build --build-arg VITE_API_URL=https://api.yourdomain.com \
# --build-arg VITE_APP_NAME="My Admin Panel" \
# -t your-registry/ecommerce-admin-panel:latest .
#
# This ConfigMap is provided for documentation and to store non-build-time
# configuration such as nginx tuning or future runtime injection.
apiVersion: v1
kind: ConfigMap
metadata:
name: ecommerce-admin-panel-config
namespace: ecommerce
labels:
app: ecommerce-admin-panel
data:
VITE_APP_NAME: "VC E-Commerce Admin Panel"
# VITE_API_URL must be set at build time — see note above

60
k8s/deployment.yaml Normal file
View File

@@ -0,0 +1,60 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ecommerce-admin-panel
namespace: ecommerce
labels:
app: ecommerce-admin-panel
spec:
replicas: 2
selector:
matchLabels:
app: ecommerce-admin-panel
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: ecommerce-admin-panel
spec:
containers:
- name: ecommerce-admin-panel
# Replace with your actual registry image
# Build with: docker build --build-arg VITE_API_URL=https://api.yourdomain.com .
image: your-registry/ecommerce-admin-panel:latest
imagePullPolicy: Always
ports:
- containerPort: 80
protocol: TCP
resources:
requests:
memory: "64Mi"
cpu: "50m"
limits:
memory: "128Mi"
cpu: "200m"
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 10
periodSeconds: 30
failureThreshold: 3
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
# Spread pods across nodes for high availability
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app: ecommerce-admin-panel

32
k8s/ingress.yaml Normal file
View File

@@ -0,0 +1,32 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ecommerce-admin-panel
namespace: ecommerce
labels:
app: ecommerce-admin-panel
annotations:
# Required for SPA: rewrite all paths to / so React Router handles routing
nginx.ingress.kubernetes.io/rewrite-target: /
# Enable gzip at the ingress level
nginx.ingress.kubernetes.io/enable-gzip: "true"
# Optional: enable HTTPS redirect (uncomment when TLS is configured)
# nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
ingressClassName: nginx
rules:
- host: admin.yourdomain.com # Replace with your actual domain
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: ecommerce-admin-panel
port:
number: 80
# TLS (uncomment and configure when you have a TLS certificate / cert-manager)
# tls:
# - hosts:
# - admin.yourdomain.com
# secretName: ecommerce-admin-panel-tls

6
k8s/namespace.yaml Normal file
View File

@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: ecommerce
labels:
app: ecommerce-admin-panel

16
k8s/service.yaml Normal file
View File

@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: ecommerce-admin-panel
namespace: ecommerce
labels:
app: ecommerce-admin-panel
spec:
selector:
app: ecommerce-admin-panel
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
type: ClusterIP