This commit is contained in:
2025-10-25 08:43:42 +08:00
parent e5cd2700aa
commit d207146423
10 changed files with 687 additions and 10 deletions

View File

@@ -0,0 +1,94 @@
# Kubernetes Deployment Configuration
apiVersion: apps/v1
kind: Deployment
metadata:
name: blog
namespace: ${KUBERNETES_NAMESPACE}
labels:
app: blog
spec:
replicas: ${KUBERNETES_DEPLOYMENT_REPLICAS}
selector:
matchLabels:
app: blog
template:
metadata:
labels:
app: blog
spec:
imagePullSecrets:
- name: regcred
containers:
- name: blog
image: ${CONTAINER_REGISTRY_URL}/${CONTAINER_REGISTRY_NAMESPACE}/${CONTAINER_IMAGE_NAME}:${CONTAINER_IMAGE_TAG}
imagePullPolicy: Always
ports:
- name: http
containerPort: 8888
protocol: TCP
readinessProbe:
httpGet:
path: /api/blog/ping
port: http
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
livenessProbe:
httpGet:
path: /api/blog/ping
port: http
initialDelaySeconds: 15
periodSeconds: 20
timeoutSeconds: 5
failureThreshold: 3
resources:
requests:
memory: "128Mi"
cpu: "200m"
limits:
memory: "512Mi"
cpu: "1000m"
env:
- name: TZ
value: "UTC"
- name: DATABASE_DSN
valueFrom:
secretKeyRef:
name: blog-secrets
key: database-dsn
- name: JWT_SECRET
valueFrom:
secretKeyRef:
name: blog-secrets
key: jwt-secret
- name: JWT_ISSUER
value: "${JWT_ISSUER}"
- name: JWT_EXPIRES_IN
value: "${JWT_EXPIRES_IN}"
- name: S3_REGION
value: "${S3_REGION}"
- name: S3_BUCKET
value: "${S3_BUCKET}"
- name: S3_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: blog-secrets
key: s3-access-key-id
- name: S3_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: blog-secrets
key: s3-secret-access-key
- name: S3_ENDPOINT
value: "${S3_ENDPOINT}"
- name: S3_PRESIGNED_URL_EXPIRATION
value: "${S3_PRESIGNED_URL_EXPIRATION}"

25
script/k8s/ingress.yaml Normal file
View File

@@ -0,0 +1,25 @@
# Kubernetes Ingress Configuration for Traefik
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: blog
namespace: ${KUBERNETES_NAMESPACE}
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web
labels:
app: blog
spec:
rules:
- host: ${KUBERNETES_INGRESS_HOST}
http:
paths:
- path: /api/blog
pathType: Prefix
backend:
service:
name: blog
port:
number: 8888

View File

@@ -0,0 +1,7 @@
# Kubernetes Namespace Configuration
apiVersion: v1
kind: Namespace
metadata:
name: ${KUBERNETES_NAMESPACE}
labels:
name: ${KUBERNETES_NAMESPACE}

19
script/k8s/service.yaml Normal file
View File

@@ -0,0 +1,19 @@
# Kubernetes Service Configuration
apiVersion: v1
kind: Service
metadata:
name: blog
namespace: ${KUBERNETES_NAMESPACE}
labels:
app: blog
spec:
type: ClusterIP
selector:
app: blog
ports:
- name: http
port: 8888
targetPort: http
protocol: TCP