127 lines
3.6 KiB
YAML
127 lines
3.6 KiB
YAML
# Go API workload: owns /api, /uploads, and /generated-results from the first
|
|
# production deployment. The embedded WorkerLoop replaces the Node Worker; do
|
|
# not deploy zhinian-worker in production.
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: zhinian-go-api
|
|
namespace: zhinian
|
|
spec:
|
|
# Keep one replica until generated assets live in shared OSS storage and the
|
|
# RDS/provider connection budget is measured for more.
|
|
replicas: 1
|
|
strategy:
|
|
type: RollingUpdate
|
|
rollingUpdate:
|
|
maxSurge: 1
|
|
maxUnavailable: 0
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: zhinian
|
|
app.kubernetes.io/component: go-api
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: zhinian
|
|
app.kubernetes.io/component: go-api
|
|
spec:
|
|
automountServiceAccountToken: false
|
|
securityContext:
|
|
seccompProfile:
|
|
type: RuntimeDefault
|
|
containers:
|
|
- name: go-api
|
|
image: REGISTRY/PROJECT/zhinian-go-api:REPLACE_TAG
|
|
imagePullPolicy: IfNotPresent
|
|
ports:
|
|
- name: http
|
|
containerPort: 8080
|
|
envFrom:
|
|
- configMapRef:
|
|
name: zhinian-go-runtime
|
|
- secretRef:
|
|
name: zhinian-go-providers
|
|
env:
|
|
- name: DATABASE_URL
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: zhinian-go-db
|
|
key: DATABASE_URL
|
|
# Go alone creates and verifies the browser session cookie. The
|
|
# static Web workload must never receive this signing secret.
|
|
- name: ZHINIAN_AUTH_SESSION_SECRET
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: zhinian-go-auth
|
|
key: ZHINIAN_AUTH_SESSION_SECRET
|
|
- name: ZHINIAN_BOOTSTRAP_ADMIN_PHONE
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: zhinian-go-bootstrap
|
|
key: ZHINIAN_BOOTSTRAP_ADMIN_PHONE
|
|
- name: ZHINIAN_BOOTSTRAP_ADMIN_PASSWORD
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: zhinian-go-bootstrap
|
|
key: ZHINIAN_BOOTSTRAP_ADMIN_PASSWORD
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: /var/lib/zhinian
|
|
- name: tmp
|
|
mountPath: /tmp
|
|
startupProbe:
|
|
httpGet:
|
|
path: /api/health
|
|
port: http
|
|
periodSeconds: 5
|
|
failureThreshold: 24
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /api/ready
|
|
port: http
|
|
periodSeconds: 10
|
|
timeoutSeconds: 5
|
|
failureThreshold: 3
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /api/health
|
|
port: http
|
|
periodSeconds: 20
|
|
timeoutSeconds: 3
|
|
failureThreshold: 3
|
|
resources:
|
|
requests:
|
|
cpu: 250m
|
|
memory: 256Mi
|
|
limits:
|
|
cpu: "1"
|
|
memory: 512Mi
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
capabilities:
|
|
drop: ["ALL"]
|
|
runAsNonRoot: true
|
|
runAsUser: 10001
|
|
runAsGroup: 10001
|
|
readOnlyRootFilesystem: true
|
|
volumes:
|
|
- name: data
|
|
emptyDir: {}
|
|
- name: tmp
|
|
emptyDir: {}
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: zhinian-go-api
|
|
namespace: zhinian
|
|
spec:
|
|
type: ClusterIP
|
|
selector:
|
|
app.kubernetes.io/name: zhinian
|
|
app.kubernetes.io/component: go-api
|
|
ports:
|
|
- name: http
|
|
port: 8080
|
|
targetPort: 8080
|