feat: update kubernetes deployment

This commit is contained in:
incubator4 2023-08-16 16:58:05 +08:00
parent c2eb9e82f4
commit f1a168e8dd
7 changed files with 120 additions and 45 deletions

View File

@ -53,4 +53,5 @@ COPY --from=build /app/.next/static /app/.next/static
COPY --from=build /app/prisma /app/prisma
COPY --from=build /app/ecosystem.config.js /app/ecosystem.config.js
CMD ["pm2-runtime", "start", "-i", "2", "ecosystem.config.js"]
ENTRYPOINT [ "pm2-runtime" ]
CMD ["start", "-i", "2", "ecosystem.config.js"]

View File

@ -19,7 +19,7 @@ data:
dns cloudflare {env.CF_API_TOKEN}
}
reverse_proxy 127.0.0.1:3000
reverse_proxy xlog-internal.crossbell.svc:3000
}
:8080 {
@ -31,7 +31,7 @@ data:
on_demand
}
reverse_proxy 127.0.0.1:3000
reverse_proxy xlog-internal.crossbell.svc:3000
}
---
apiVersion: v1

View File

@ -1,14 +1,20 @@
apiVersion: apps/v1
kind: StatefulSet
kind: Deployment
metadata:
name: xlog
namespace: crossbell
spec:
progressDeadlineSeconds: 600
replicas: 1
serviceName: "xlog-lb"
revisionHistoryLimit: 5
selector:
matchLabels:
app: xlog
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
@ -32,6 +38,11 @@ spec:
- image: $IMAGE_TAG_RELEASE
imagePullPolicy: Always
name: xlog
args:
- "start"
- "-i"
- "1"
- "ecosystem.config.js"
envFrom:
- secretRef:
name: xlog
@ -40,10 +51,10 @@ spec:
protocol: TCP
resources:
requests:
memory: "6000Mi"
memory: "1000Mi"
cpu: "300m"
limits:
memory: "10000Mi"
memory: "3000Mi"
cpu: "2000m"
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
@ -58,14 +69,38 @@ spec:
port: 3000
initialDelaySeconds: 40
periodSeconds: 20
volumeMounts:
- name: data
mountPath: "/app/.next/cache/images"
subPath: images
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: xlog-caddy
namespace: crossbell
spec:
selector:
matchLabels:
app: xlog-caddy
template:
metadata:
labels:
app: xlog-caddy
spec:
containers:
- name: caddy
image: kindjeff/caddy-tlsredis-docker
imagePullPolicy: Always
command: ["caddy", "run", "-config", "/app/Caddyfile"]
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 100m
memory: 128Mi
envFrom:
- secretRef:
name: xlog-caddy
@ -81,6 +116,13 @@ spec:
image: python
command: ["/bin/sh", "-c"]
args: ["pip install flask requests; flask --app=app run"]
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 100m
memory: 128Mi
ports:
- containerPort: 5000
name: http
@ -88,11 +130,6 @@ spec:
- name: validator
mountPath: /app.py
subPath: app.py
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- name: caddyfile
configMap:
@ -100,12 +137,3 @@ spec:
- name: validator
configMap:
name: xlog-caddy-validator
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: "alicloud-disk-ssd"
resources:
requests:
storage: 20Gi

View File

@ -9,7 +9,7 @@ metadata:
spec:
type: LoadBalancer
selector:
app: xlog
app: xlog-caddy
ports:
- name: http
protocol: TCP
@ -19,3 +19,18 @@ spec:
protocol: TCP
port: 443
targetPort: 443
---
apiVersion: v1
kind: Service
metadata:
name: xlog-internal
namespace: crossbell
spec:
type: ClusterIP
selector:
app: xlog
ports:
- name: http
protocol: TCP
port: 3000
targetPort: 3000

View File

@ -19,7 +19,7 @@ data:
dns cloudflare {env.CF_API_TOKEN}
}
reverse_proxy 127.0.0.1:3000
reverse_proxy xlog-internal.crossbell.svc:3000
}
:8080 {
@ -31,7 +31,7 @@ data:
on_demand
}
reverse_proxy 127.0.0.1:3000
reverse_proxy xlog-internal.crossbell.svc:3000
}
---
apiVersion: v1

View File

@ -53,16 +53,13 @@ spec:
protocol: TCP
resources:
requests:
memory: "6000Mi"
memory: "1000Mi"
cpu: "300m"
limits:
memory: "10000Mi"
memory: "3000Mi"
cpu: "2000m"
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- name: xlog-image
mountPath: /app/.next/cache/images
readinessProbe:
httpGet:
path: /api/healthcheck
@ -74,10 +71,39 @@ spec:
port: 3000
initialDelaySeconds: 40
periodSeconds: 20
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: xlog-caddy
namespace: crossbell
spec:
replicas: 3
selector:
matchLabels:
app: xlog-caddy
template:
metadata:
labels:
app: xlog-caddy
spec:
containers:
- name: caddy
image: kindjeff/caddy-tlsredis-docker
imagePullPolicy: Always
command: ["caddy", "run", "-config", "/app/Caddyfile"]
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 100m
memory: 128Mi
envFrom:
- secretRef:
name: xlog-caddy
@ -93,6 +119,13 @@ spec:
image: python
command: ["/bin/sh", "-c"]
args: ["pip install flask requests; flask --app=app run"]
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 100m
memory: 128Mi
ports:
- containerPort: 5000
name: http
@ -100,18 +133,10 @@ spec:
- name: validator
mountPath: /app.py
subPath: app.py
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- name: caddyfile
configMap:
name: xlog-caddy
- name: validator
configMap:
name: xlog-caddy-validator
- name: xlog-image
persistentVolumeClaim:
claimName: xlog-image # OSS PVC created manually in the ACK console
name: xlog-caddy-validator

View File

@ -1,13 +1,19 @@
apiVersion: autoscaling/v1
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: xlog
namespace: crossbell
spec:
maxReplicas: 11
minReplicas: 8
minReplicas: 7
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: xlog
targetCPUUtilizationPercentage: 70
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70