added deployment files
This commit is contained in:
57
k8s/deployment.yaml
Normal file
57
k8s/deployment.yaml
Normal file
@@ -0,0 +1,57 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: ecommerce-web
|
||||
namespace: ecommerce
|
||||
labels:
|
||||
app: ecommerce-web
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: ecommerce-web
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxSurge: 1
|
||||
maxUnavailable: 0
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: ecommerce-web
|
||||
spec:
|
||||
containers:
|
||||
- name: ecommerce-web
|
||||
# Replace with your actual image name after pushing to a registry
|
||||
# e.g., docker.io/<your-dockerhub-username>/ecommerce-web:latest
|
||||
image: ecommerce-web:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 80
|
||||
protocol: TCP
|
||||
resources:
|
||||
requests:
|
||||
cpu: "100m"
|
||||
memory: "64Mi"
|
||||
limits:
|
||||
cpu: "250m"
|
||||
memory: "128Mi"
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: 80
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 15
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: 80
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
failureThreshold: 3
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: false
|
||||
runAsNonRoot: false
|
||||
restartPolicy: Always
|
||||
25
k8s/hpa.yaml
Normal file
25
k8s/hpa.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: ecommerce-web
|
||||
namespace: ecommerce
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: ecommerce-web
|
||||
minReplicas: 2
|
||||
maxReplicas: 8
|
||||
metrics:
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 70
|
||||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 80
|
||||
28
k8s/ingress.yaml
Normal file
28
k8s/ingress.yaml
Normal file
@@ -0,0 +1,28 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: ecommerce-web
|
||||
namespace: ecommerce
|
||||
annotations:
|
||||
# For nginx ingress controller
|
||||
nginx.ingress.kubernetes.io/rewrite-target: /
|
||||
# Uncomment below if using cert-manager for TLS
|
||||
# cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||
spec:
|
||||
ingressClassName: nginx
|
||||
rules:
|
||||
- host: ecommerce.example.com # Replace with your actual domain
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: ecommerce-web
|
||||
port:
|
||||
number: 80
|
||||
# Uncomment and configure for HTTPS/TLS
|
||||
# tls:
|
||||
# - hosts:
|
||||
# - ecommerce.example.com
|
||||
# secretName: ecommerce-web-tls
|
||||
6
k8s/namespace.yaml
Normal file
6
k8s/namespace.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: ecommerce
|
||||
labels:
|
||||
app.kubernetes.io/name: ecommerce-web
|
||||
16
k8s/service.yaml
Normal file
16
k8s/service.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: ecommerce-web
|
||||
namespace: ecommerce
|
||||
labels:
|
||||
app: ecommerce-web
|
||||
spec:
|
||||
selector:
|
||||
app: ecommerce-web
|
||||
ports:
|
||||
- name: http
|
||||
protocol: TCP
|
||||
port: 80
|
||||
targetPort: 80
|
||||
type: ClusterIP
|
||||
Reference in New Issue
Block a user