mirror of
https://github.com/BagelHole/DevOps-Security-Agent-Skills.git
synced 2026-08-22 12:49:53 +02:00
167 lines
3.3 KiB
YAML
167 lines
3.3 KiB
YAML
# Production-Ready Deployment Template
|
|||
|
|
# Customize values marked with <REPLACE>
|
||
|
|
|
||
|
|
apiVersion: apps/v1
|
||
|
|
kind: Deployment
|
||
|
|
metadata:
|
||
|
|
name: <APP_NAME>
|
||
|
|
labels:
|
||
|
|
app: <APP_NAME>
|
||
|
|
version: v1
|
||
|
|
spec:
|
||
|
|
replicas: 3
|
||
|
|
strategy:
|
||
|
|
type: RollingUpdate
|
||
|
|
rollingUpdate:
|
||
|
|
maxSurge: 1
|
||
|
|
maxUnavailable: 0
|
||
|
|
selector:
|
||
|
|
matchLabels:
|
||
|
|
app: <APP_NAME>
|
||
|
|
template:
|
||
|
|
metadata:
|
||
|
|
labels:
|
||
|
|
app: <APP_NAME>
|
||
|
|
version: v1
|
||
|
|
annotations:
|
||
|
|
prometheus.io/scrape: "true"
|
||
|
|
prometheus.io/port: "8080"
|
||
|
|
prometheus.io/path: "/metrics"
|
||
|
|
spec:
|
||
|
|
serviceAccountName: <APP_NAME>
|
||
|
|
|
||
|
|
securityContext:
|
||
|
|
runAsNonRoot: true
|
||
|
|
runAsUser: 1000
|
||
|
|
fsGroup: 1000
|
||
|
|
|
||
|
|
affinity:
|
||
|
|
podAntiAffinity:
|
||
|
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||
|
|
- weight: 100
|
||
|
|
podAffinityTerm:
|
||
|
|
labelSelector:
|
||
|
|
matchLabels:
|
||
|
|
app: <APP_NAME>
|
||
|
|
topologyKey: kubernetes.io/hostname
|
||
|
|
|
||
|
|
containers:
|
||
|
|
- name: <APP_NAME>
|
||
|
|
image: <IMAGE>:<TAG>
|
||
|
|
imagePullPolicy: Always
|
||
|
|
|
||
|
|
ports:
|
||
|
|
- name: http
|
||
|
|
containerPort: 8080
|
||
|
|
protocol: TCP
|
||
|
|
|
||
|
|
env:
|
||
|
|
- name: POD_NAME
|
||
|
|
valueFrom:
|
||
|
|
fieldRef:
|
||
|
|
fieldPath: metadata.name
|
||
|
|
- name: POD_NAMESPACE
|
||
|
|
valueFrom:
|
||
|
|
fieldRef:
|
||
|
|
fieldPath: metadata.namespace
|
||
|
|
|
||
|
|
envFrom:
|
||
|
|
- configMapRef:
|
||
|
|
name: <APP_NAME>-config
|
||
|
|
- secretRef:
|
||
|
|
name: <APP_NAME>-secrets
|
||
|
|
|
||
|
|
resources:
|
||
|
|
requests:
|
||
|
|
memory: "256Mi"
|
||
|
|
cpu: "250m"
|
||
|
|
limits:
|
||
|
|
memory: "512Mi"
|
||
|
|
|
||
|
|
securityContext:
|
||
|
|
readOnlyRootFilesystem: true
|
||
|
|
allowPrivilegeEscalation: false
|
||
|
|
capabilities:
|
||
|
|
drop:
|
||
|
|
- ALL
|
||
|
|
|
||
|
|
livenessProbe:
|
||
|
|
httpGet:
|
||
|
|
path: /healthz
|
||
|
|
port: http
|
||
|
|
initialDelaySeconds: 30
|
||
|
|
periodSeconds: 10
|
||
|
|
timeoutSeconds: 5
|
||
|
|
failureThreshold: 3
|
||
|
|
|
||
|
|
readinessProbe:
|
||
|
|
httpGet:
|
||
|
|
path: /ready
|
||
|
|
port: http
|
||
|
|
initialDelaySeconds: 5
|
||
|
|
periodSeconds: 5
|
||
|
|
timeoutSeconds: 3
|
||
|
|
failureThreshold: 3
|
||
|
|
|
||
|
|
volumeMounts:
|
||
|
|
- name: tmp
|
||
|
|
mountPath: /tmp
|
||
|
|
- name: cache
|
||
|
|
mountPath: /var/cache
|
||
|
|
|
||
|
|
volumes:
|
||
|
|
- name: tmp
|
||
|
|
emptyDir: {}
|
||
|
|
- name: cache
|
||
|
|
emptyDir: {}
|
||
|
|
|
||
|
|
terminationGracePeriodSeconds: 30
|
||
|
|
|
||
|
|
---
|
||
|
|
apiVersion: v1
|
||
|
|
kind: Service
|
||
|
|
metadata:
|
||
|
|
name: <APP_NAME>
|
||
|
|
labels:
|
||
|
|
app: <APP_NAME>
|
||
|
|
spec:
|
||
|
|
type: ClusterIP
|
||
|
|
ports:
|
||
|
|
- port: 80
|
||
|
|
targetPort: http
|
||
|
|
protocol: TCP
|
||
|
|
name: http
|
||
|
|
selector:
|
||
|
|
app: <APP_NAME>
|
||
|
|
|
||
|
|
---
|
||
|
|
apiVersion: autoscaling/v2
|
||
|
|
kind: HorizontalPodAutoscaler
|
||
|
|
metadata:
|
||
|
|
name: <APP_NAME>
|
||
|
|
spec:
|
||
|
|
scaleTargetRef:
|
||
|
|
apiVersion: apps/v1
|
||
|
|
kind: Deployment
|
||
|
|
name: <APP_NAME>
|
||
|
|
minReplicas: 3
|
||
|
|
maxReplicas: 10
|
||
|
|
metrics:
|
||
|
|
- type: Resource
|
||
|
|
resource:
|
||
|
|
name: cpu
|
||
|
|
target:
|
||
|
|
type: Utilization
|
||
|
|
averageUtilization: 70
|
||
|
|
|
||
|
|
---
|
||
|
|
apiVersion: policy/v1
|
||
|
|
kind: PodDisruptionBudget
|
||
|
|
metadata:
|
||
|
|
name: <APP_NAME>
|
||
|
|
spec:
|
||
|
|
minAvailable: 2
|
||
|
|
selector:
|
||
|
|
matchLabels:
|
||
|
|
app: <APP_NAME>
|