189 lines
5.1 KiB
Go
Executable File
189 lines
5.1 KiB
Go
Executable File
package d_app
|
|
|
|
const CmiiBackendDeploymentTemplate = `
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ .AppName }}
|
|
namespace: {{ .Namespace }}
|
|
labels:
|
|
cmii.type: backend
|
|
cmii.app: {{ .AppName }}
|
|
octopus/control: backend-app-1.0.0
|
|
app.kubernetes.io/managed-by: octopus
|
|
app.kubernetes.io/app-version: {{ .TagVersion }}
|
|
spec:
|
|
replicas: {{ .Replicas }}
|
|
strategy:
|
|
rollingUpdate:
|
|
maxUnavailable: 1
|
|
selector:
|
|
matchLabels:
|
|
cmii.type: backend
|
|
cmii.app: {{ .AppName }}
|
|
template:
|
|
metadata:
|
|
labels:
|
|
cmii.type: backend
|
|
cmii.app: {{ .AppName }}
|
|
spec:
|
|
affinity:
|
|
nodeAffinity:
|
|
requiredDuringSchedulingIgnoredDuringExecution:
|
|
nodeSelectorTerms:
|
|
- matchExpressions:
|
|
- key: uavcloud.env
|
|
operator: In
|
|
values:
|
|
- {{ .TenantEnv }}
|
|
imagePullSecrets:
|
|
- name: harborsecret
|
|
containers:
|
|
- name: {{ .AppName }}
|
|
{{- if .HarborPort }}
|
|
image: {{ .HarborIP }}:{{ .HarborPort }}/cmii/{{ .AppName }}:{{ .ImageTag }}
|
|
{{- else }}
|
|
image: {{ .HarborIP }}{{ .AppName }}:{{ .ImageTag }}
|
|
{{- end }}
|
|
imagePullPolicy: Always
|
|
env:
|
|
- name: K8S_NAMESPACE
|
|
value: {{ .Namespace }}
|
|
- name: APPLICATION_NAME
|
|
value: {{ .AppName }}
|
|
- name: CUST_JAVA_OPTS
|
|
value: "-Xms200m -Xmx1500m -Dlog4j2.formatMsgNoLookups=true"
|
|
- name: NACOS_REGISTRY
|
|
value: "helm-nacos:8848"
|
|
- name: NACOS_DISCOVERY_IP
|
|
valueFrom:
|
|
fieldRef:
|
|
fieldPath: status.podIP
|
|
- name: NACOS_DISCOVERY_PORT
|
|
value: "8080"
|
|
- name: BIZ_CONFIG_GROUP
|
|
value: {{ .TagVersion }}
|
|
- name: SYS_CONFIG_GROUP
|
|
value: {{ .TagVersion }}
|
|
- name: IMAGE_VERSION
|
|
value: {{ .TagVersion }}
|
|
- name: NACOS_USERNAME
|
|
value: "developer"
|
|
- name: NACOS_PASSWORD
|
|
value: "Deve@9128201"
|
|
ports:
|
|
- name: pod-port
|
|
containerPort: 8080
|
|
protocol: TCP
|
|
resources:
|
|
limits:
|
|
memory: 2Gi
|
|
cpu: "2"
|
|
requests:
|
|
memory: 200Mi
|
|
cpu: 200m
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /cmii/health
|
|
port: pod-port
|
|
scheme: HTTP
|
|
initialDelaySeconds: 60
|
|
timeoutSeconds: 5
|
|
periodSeconds: 20
|
|
successThreshold: 1
|
|
failureThreshold: 3
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /cmii/health
|
|
port: pod-port
|
|
scheme: HTTP
|
|
initialDelaySeconds: 60
|
|
timeoutSeconds: 5
|
|
periodSeconds: 20
|
|
successThreshold: 1
|
|
failureThreshold: 3
|
|
startupProbe:
|
|
httpGet:
|
|
path: /cmii/health
|
|
port: pod-port
|
|
scheme: HTTP
|
|
initialDelaySeconds: 60
|
|
timeoutSeconds: 3
|
|
periodSeconds: 20
|
|
successThreshold: 1
|
|
failureThreshold: 5
|
|
volumeMounts:
|
|
- name: nfs-backend-log-volume
|
|
mountPath: /cmii/logs
|
|
readOnly: false
|
|
subPath: {{ .Namespace }}/{{ .AppName }}
|
|
{{- if .NeedPvcCache }}
|
|
- name: data-cache-volume
|
|
mountPath: /cmii/cache
|
|
readOnly: false
|
|
subPath: {{ .Namespace }}/{{ .AppName }}
|
|
{{- end }}
|
|
volumes:
|
|
- name: nfs-backend-log-volume
|
|
persistentVolumeClaim:
|
|
claimName: nfs-backend-log-pvc
|
|
{{- if .NeedPvcCache }}
|
|
- name: data-cache-volume
|
|
persistentVolumeClaim:
|
|
claimName: {{ .AppName }}-cache
|
|
{{- end }}
|
|
`
|
|
|
|
const CmiiBackendServiceTemplate = `
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: {{ .AppName }}
|
|
namespace: {{ .Namespace }}
|
|
labels:
|
|
cmii.type: backend
|
|
cmii.app: {{ .AppName }}
|
|
octopus/control: backend-app-1.0.0
|
|
app.kubernetes.io/managed-by: octopus
|
|
app.kubernetes.io/app-version: {{ .TagVersion }}
|
|
spec:
|
|
{{- if .NodePort }}
|
|
type: NodePort
|
|
{{- else }}
|
|
type: ClusterIP
|
|
{{- end }}
|
|
selector:
|
|
cmii.type: backend
|
|
cmii.app: {{ .AppName }}
|
|
ports:
|
|
- name: backend-tcp
|
|
port: 8080
|
|
protocol: TCP
|
|
targetPort: 8080
|
|
{{- if .NodePort }}
|
|
nodePort: {{ .NodePort }}
|
|
{{- end }}
|
|
`
|
|
|
|
const CmiiBackendPVCTemplate = `
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata:
|
|
name: {{ .AppName }}-cache
|
|
namespace: {{ .Namespace }}
|
|
labels:
|
|
cmii.type: backend
|
|
cmii.app: {{ .AppName }}
|
|
octopus/control: backend-app-1.0.0
|
|
app.kubernetes.io/managed-by: octopus
|
|
app.kubernetes.io/app-version: {{ .TagVersion }}
|
|
spec:
|
|
storageClassName: nfs-prod-distribute
|
|
accessModes:
|
|
- ReadWriteMany
|
|
volumeMode: Filesystem
|
|
resources:
|
|
requests:
|
|
storage: 15Gi
|
|
`
|