[agent-deploy] - basic accomplish

This commit is contained in:
zeaslity
2024-04-25 16:44:40 +08:00
parent 4e5af5856a
commit 08e5a4d422
51 changed files with 8751 additions and 210 deletions

View File

@@ -0,0 +1,138 @@
package c_app
import (
"github.com/go-playground/validator/v10"
"wdd.io/agent-common/logger"
"wdd.io/agent-operator/deploy/z_dep"
)
var log = logger.Log
type CmiiBackendConfig struct {
z_dep.CommonEnvironmentConfig
AppName string `json:"app_name,omitempty" validate:"required"`
ImageTag string `json:"image_tag,omitempty" validate:"required"`
Replicas string `json:"replicas,omitempty" validate:"required" default:"1"`
NodePort string `json:"node_port,omitempty"`
NeedPvcCache bool `json:"need_pvc_cache,omitempty"`
CustomJvmOpt string `json:"custom_jvm_opt,omitempty"`
}
type CmiiFrontendConfig struct {
z_dep.CommonEnvironmentConfig `json:"z___dep_._common_environment_config"`
AppName string `json:"app_name,omitempty" validate:"required"`
ImageTag string `json:"image_tag,omitempty" validate:"required"`
Replicas string `json:"replicas,omitempty" validate:"required" default:"1"`
ShortName string `json:"short_name,omitempty"`
ClientId string
}
var (
DefaultCmiiBackendConfig = &CmiiBackendConfig{}
DefaultCmiiFrontendConfig = &CmiiFrontendConfig{}
BackendApplyFilePath = ""
FrontendApplyFilePath = ""
SRSApplyFilePath = ""
IngresApplyFilePath = ""
ConfigMapApplyFilePath = ""
)
func init() {
BackendApplyFilePath = z_dep.ApplyFilePrefix + "k8s-backend.yaml"
FrontendApplyFilePath = z_dep.ApplyFilePrefix + "k8s-frontend.yaml"
SRSApplyFilePath = z_dep.ApplyFilePrefix + "k8s-srs.yaml"
IngresApplyFilePath = z_dep.ApplyFilePrefix + "k8s-ingress.yaml"
ConfigMapApplyFilePath = z_dep.ApplyFilePrefix + "k8s-configmap.yaml"
log.DebugF("backend apply file path: %s\n", BackendApplyFilePath)
log.DebugF("frontend apply file path: %s\n", FrontendApplyFilePath)
log.DebugF("srs apply file path: %s\n", SRSApplyFilePath)
log.DebugF("ingress apply file path: %s\n", IngresApplyFilePath)
log.DebugF("config map apply file path: %s\n", ConfigMapApplyFilePath)
}
func (backend *CmiiBackendConfig) BackendDeploy(common *z_dep.CommonEnvironmentConfig) bool {
// copy
z_dep.CopySameFields(common, backend)
validate := validator.New()
err := validate.Struct(backend)
if err != nil {
log.ErrorF("backend config validate error: %v\n", err)
return false
}
if !z_dep.ParseEnvToApplyFile(backend, CmiiBackendDeploymentTemplate, BackendApplyFilePath) {
return false
}
if !z_dep.ParseEnvToApplyFile(backend, CmiiBackendServiceTemplate, BackendApplyFilePath) {
return false
}
// pvc
if backend.NeedPvcCache {
if !z_dep.ParseEnvToApplyFile(backend, CmiiBackendPVCTemplate, BackendApplyFilePath) {
return false
}
}
return true
}
func (frontend *CmiiFrontendConfig) FrontendDeploy(common *z_dep.CommonEnvironmentConfig) bool {
// copy
z_dep.CopySameFields(common, frontend)
validate := validator.New()
err := validate.Struct(frontend)
if err != nil {
log.ErrorF("backend config validate error: %v\n", err)
return false
}
if !z_dep.ParseEnvToApplyFile(frontend, CmiiFrontendDeploymentTemplate, FrontendApplyFilePath) {
return false
}
if !z_dep.ParseEnvToApplyFile(frontend, CmiiFrontendServiceTemplate, FrontendApplyFilePath) {
return false
}
return true
}
func SrsDeploy(commonEnv *z_dep.CommonEnvironmentConfig) bool {
return commonEnv.ParseCommonEnvToApplyFile(CmiiSrsTemplate, SRSApplyFilePath)
}
func IngressDeploy(commonEnv *z_dep.CommonEnvironmentConfig) bool {
if !commonEnv.ParseCommonEnvToApplyFile(CmiiFrontendIngressTemplate, IngresApplyFilePath) {
return false
}
if !commonEnv.ParseCommonEnvToApplyFile(CmiiBackendIngressTemplate, IngresApplyFilePath) {
return false
}
if !commonEnv.ParseCommonEnvToApplyFile(CmiiGatewayIngressTemplate, IngresApplyFilePath) {
return false
}
return true
}
func (frontend *CmiiFrontendConfig) ConfigMapDeploy(commonEnv *z_dep.CommonEnvironmentConfig) bool {
// copy
z_dep.CopySameFields(commonEnv, frontend)
// manual validate
if frontend.ShortName == "" || frontend.ClientId == "" {
log.ErrorF("short name or client id is empty !")
return false
}
return z_dep.ParseEnvToApplyFile(frontend, CmiiFrontendConfigMapTemplate, ConfigMapApplyFilePath)
}

View File

@@ -0,0 +1,18 @@
package c_app
import (
"testing"
)
func TestCmiiBackendDeploymentConfig_ParseToApplyConf(t *testing.T) {
deploymentConfig := CmiiBackendConfig{
Namespace: "uavcloud-dev",
AppName: "cmii-uav-gateway",
ImageTag: "5.2.0-123",
Replicas: "2",
NodePort: "31213",
NeedPvcCache: true,
}
}

View File

@@ -0,0 +1,53 @@
package c_app
var FrontendShortNameMaps = map[string]string{
"cmii-suav-platform-supervision": "supervision",
"cmii-suav-platform-supervisionh5": "supervisionh5",
"cmii-uav-platform": "platform",
"cmii-uav-platform-ai-brain": "ai-brain",
"cmii-uav-platform-armypeople": "armypeople",
"cmii-uav-platform-base": "base",
"cmii-uav-platform-cms-portal": "cmsportal",
"cmii-uav-platform-detection": "detection",
"cmii-uav-platform-emergency-rescue": "emergency",
"cmii-uav-platform-logistics": "logistics",
"cmii-uav-platform-media": "media",
"cmii-uav-platform-multiterminal": "multiterminal",
"cmii-uav-platform-mws": "mws",
"cmii-uav-platform-oms": "oms",
"cmii-uav-platform-open": "open",
"cmii-uav-platform-security": "security",
"cmii-uav-platform-securityh5": "securityh5",
"cmii-uav-platform-seniclive": "seniclive",
"cmii-uav-platform-share": "share",
"cmii-uav-platform-splice": "splice",
"cmii-uav-platform-traffic": "traffic",
}
var FrontendClientIdMaps = map[string]string{
"cmii-suav-platform-supervision": "APP_qqSu82THfexI8PLM",
"cmii-suav-platform-supervisionh5": "APP_qqSu82THfexI8PLM",
"cmii-uav-platform": "empty",
"cmii-uav-platform-ai-brain": "APP_rafnuCAmBESIVYMH",
"cmii-uav-platform-armypeople": "APP_UIegse6Lfou9pO1U",
"cmii-uav-platform-base": "APP_9LY41OaKSqk2btY0",
"cmii-uav-platform-cms-portal": "empty",
"cmii-uav-platform-detection": "APP_FDHW2VLVDWPnnOCy",
"cmii-uav-platform-emergency-rescue": "APP_aGsTAY1uMZrpKdfk",
"cmii-uav-platform-logistics": "APP_PvdfRRRBPL8xbIwl",
"cmii-uav-platform-media": "APP_4AU8lbifESQO4FD6",
"cmii-uav-platform-multiterminal": "APP_PvdfRRRBPL8xbIwl",
"cmii-uav-platform-mws": "APP_uKniXPELlRERBBwK",
"cmii-uav-platform-oms": "empty",
"cmii-uav-platform-open": "empty",
"cmii-uav-platform-qingdao": "empty",
"cmii-uav-platform-qinghaitourism": "empty",
"cmii-uav-platform-security": "APP_JUSEMc7afyWXxvE7",
"cmii-uav-platform-securityh5": "APP_N3ImO0Ubfu9peRHD",
"cmii-uav-platform-seniclive": "empty",
"cmii-uav-platform-share": "APP_4lVSVI0ZGxTssir8",
"cmii-uav-platform-splice": "APP_zE0M3sTRXrCIJS8Y",
"cmii-uav-platform-threedsimulation": "empty",
"cmii-uav-platform-visualization": "empty",
"cmii-uav-platform-traffic": "APP_Jc8i2wOQ1t73QEJS",
}

View File

@@ -0,0 +1,184 @@
package c_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:
- demo
imagePullSecrets:
- name: harborsecret
containers:
- name: {{ .AppName }}
image: {{ .HarborIP }}:{{ .HarborPort }}/cmii/{{ .AppName }}:{{ .ImageTag }}
imagePullPolicy: Always
env:
- name: K8S_NAMESPACE
value: {{ .Namespace }}
- name: APPLICATION_NAME
value: {{ .AppName }}
- name: CUST_JAVA_OPTS
value: "-Xms500m -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: 1Gi
cpu: 200m
livenessProbe:
httpGet:
path: /cmii/ping
port: pod-port
scheme: HTTP
initialDelaySeconds: 60
timeoutSeconds: 5
periodSeconds: 20
successThreshold: 1
failureThreshold: 3
readinessProbe:
httpGet:
path: /cmii/ping
port: pod-port
scheme: HTTP
initialDelaySeconds: 60
timeoutSeconds: 5
periodSeconds: 20
successThreshold: 1
failureThreshold: 3
startupProbe:
httpGet:
path: /cmii/ping
port: pod-port
scheme: HTTP
initialDelaySeconds: 60
timeoutSeconds: 3
periodSeconds: 20
successThreshold: 1
failureThreshold: 5
volumeMounts:
- name: glusterfs-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: glusterfs-backend-log-volume
persistentVolumeClaim:
claimName: glusterfs-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
`

View File

@@ -0,0 +1,103 @@
package c_app
const CmiiFrontendDeploymentTemplate = `
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .AppName }}
namespace: {{ .Namespace }}
labels:
cmii.type: frontend
cmii.app: {{ .AppName }}
octopus.control: frontend-app-wdd
app.kubernetes.io/app-version: {{ .TagVersion }}
spec:
replicas: {{ .Replicas }}
strategy:
rollingUpdate:
maxUnavailable: 1
selector:
matchLabels:
cmii.type: frontend
cmii.app: {{ .AppName }}
template:
metadata:
labels:
cmii.type: frontend
cmii.app: {{ .AppName }}
spec:
imagePullSecrets:
- name: harborsecret
containers:
- name: {{ .AppName }}
image: {{ .HarborIP }}:{{ .HarborPort }}/cmii/{{ .AppName }}:{{ .ImageTag }}
imagePullPolicy: Always
env:
- name: K8S_NAMESPACE
value: {{ .Namespace }}
- name: APPLICATION_NAME
value: {{ .AppName }}
ports:
- name: platform-9528
containerPort: 9528
protocol: TCP
resources:
limits:
cpu: "1"
memory: 1Gi
requests:
cpu: 500m
memory: 500Mi
volumeMounts:
- name: nginx-conf
mountPath: /usr/local/nginx/conf/nginx.conf
subPath: nginx.conf
- name: default-nginx-conf
mountPath: /etc/nginx/conf.d/default.conf
subPath: default.conf
- name: tenant-prefix
subPath: ingress-config.js
mountPath: /home/cmii-platform/dist/ingress-config.js
volumes:
- name: nginx-conf
configMap:
name: nginx-cm
items:
- key: nginx.conf
path: nginx.conf
- name: default-nginx-conf
configMap:
name: default-nginx-cm
items:
- key: default.conf
path: default.conf
- name: tenant-prefix
configMap:
name: tenant-prefix-{{ .ShortName }}
items:
- key: ingress-config.js
path: ingress-config.js
`
const CmiiFrontendServiceTemplate = `
apiVersion: v1
kind: Service
metadata:
name: {{ .AppName }}
namespace: {{ .Namespace }}
labels:
cmii.type: frontend
cmii.app: {{ .AppName }}
octopus.control: frontend-app-wdd
app.kubernetes.io/version: {{ .TagVersion }}
spec:
type: ClusterIP
selector:
cmii.type: frontend
cmii.app: {{ .AppName }}
ports:
- name: web-svc-port
port: 9528
protocol: TCP
targetPort: 9528
`

View File

@@ -0,0 +1,502 @@
package c_app
const CmiiSrsTemplate = `
kind: ConfigMap
apiVersion: v1
metadata:
name: helm-live-srs-cm
namespace: {{ .Namespace }}
labels:
cmii.app: live-srs
cmii.type: live
octopus.control: wdd
app.kubernetes.io/managed-by: octopus
helm.sh/chart: cmlc-live-srs-rtc-2.0.0
data:
srs.rtc.conf: |-
listen 30935;
max_connections 4096;
srs_log_tank console;
srs_log_level info;
srs_log_file /home/srs.log;
daemon off;
http_api {
enabled on;
listen 1985;
crossdomain on;
}
stats {
network 0;
}
http_server {
enabled on;
listen 8080;
dir /home/hls;
}
srt_server {
enabled on;
listen 30556;
maxbw 1000000000;
connect_timeout 4000;
peerlatency 600;
recvlatency 600;
}
rtc_server {
enabled on;
listen 30090;
candidate $CANDIDATE;
}
vhost __defaultVhost__ {
http_hooks {
enabled on;
on_publish http://helm-live-op-svc-v2:8080/hooks/on_push;
}
http_remux {
enabled on;
}
rtc {
enabled on;
rtmp_to_rtc on;
rtc_to_rtmp on;
keep_bframe off;
}
tcp_nodelay on;
min_latency on;
play {
gop_cache off;
mw_latency 100;
mw_msgs 10;
}
publish {
firstpkt_timeout 8000;
normal_timeout 4000;
mr on;
}
dvr {
enabled off;
dvr_path /home/dvr/[app]/[stream]/[2006][01]/[timestamp].mp4;
dvr_plan session;
}
hls {
enabled on;
hls_path /home/hls;
hls_fragment 10;
hls_window 60;
hls_m3u8_file [app]/[stream].m3u8;
hls_ts_file [app]/[stream]/[2006][01][02]/[timestamp]-[duration].ts;
hls_cleanup on;
hls_entry_prefix http://{{ .WebIP }}:{{ .WebPort }};
}
}
---
kind: Service
apiVersion: v1
metadata:
name: helm-live-srs-svc-exporter
namespace: {{ .Namespace }}
labels:
octopus.control: wdd
app.kubernetes.io/managed-by: octopus
spec:
ports:
- name: rtmp
protocol: TCP
port: 30935
targetPort: 30935
nodePort: 30935
- name: rtc
protocol: UDP
port: 30090
targetPort: 30090
nodePort: 30090
- name: rtc-tcp
protocol: TCP
port: 30090
targetPort: 30090
nodePort: 30090
- name: srt
protocol: UDP
port: 30556
targetPort: 30556
nodePort: 30556
- name: api
protocol: TCP
port: 1985
targetPort: 1985
nodePort: 30557
selector:
srs-role: rtc
type: NodePort
sessionAffinity: None
externalTrafficPolicy: Cluster
---
kind: Service
apiVersion: v1
metadata:
name: helm-live-srs-svc
namespace: {{ .Namespace }}
labels:
octopus.control: wdd
app.kubernetes.io/managed-by: octopus
spec:
ports:
- name: http
protocol: TCP
port: 8080
targetPort: 8080
- name: api
protocol: TCP
port: 1985
targetPort: 1985
selector:
srs-role: rtc
type: ClusterIP
sessionAffinity: None
---
kind: Service
apiVersion: v1
metadata:
name: helm-live-srsrtc-svc
namespace: {{ .Namespace }}
labels:
octopus.control: wdd
app.kubernetes.io/managed-by: octopus
spec:
ports:
- name: rtmp
protocol: TCP
port: 30935
targetPort: 30935
selector:
srs-role: rtc
type: ClusterIP
sessionAffinity: None
---
kind: StatefulSet
apiVersion: apps/v1
metadata:
name: helm-live-srs-rtc
namespace: {{ .Namespace }}
labels:
octopus.control: wdd
app.kubernetes.io/managed-by: octopus
cmii.app: live-srs
cmii.type: live
helm.sh/chart: cmlc-live-srs-rtc-2.0.0
srs-role: rtc
spec:
replicas: 1
selector:
matchLabels:
srs-role: rtc
template:
metadata:
creationTimestamp: null
labels:
srs-role: rtc
spec:
volumes:
- name: srs-conf-file
configMap:
name: helm-live-srs-cm
items:
- key: srs.rtc.conf
path: docker.conf
defaultMode: 420
- name: srs-vol
emptyDir:
sizeLimit: 8Gi
containers:
- name: srs-rtc
image: {{ .HarborIP }}:{{ .HarborPort }}/cmii/srs:v5.0.195
ports:
- name: srs-rtmp
containerPort: 30935
protocol: TCP
- name: srs-api
containerPort: 1985
protocol: TCP
- name: srs-flv
containerPort: 8080
protocol: TCP
- name: srs-webrtc
containerPort: 30090
protocol: UDP
- name: srs-webrtc-tcp
containerPort: 30090
protocol: TCP
- name: srs-srt
containerPort: 30556
protocol: UDP
env:
- name: CANDIDATE
value: {{ .WebIP }}
resources:
limits:
cpu: 1200m
memory: 6Gi
requests:
cpu: 100m
memory: 256Mi
volumeMounts:
- name: srs-conf-file
mountPath: /usr/local/srs/conf/docker.conf
subPath: docker.conf
- name: srs-vol
mountPath: /home/dvr
subPath: {{ .Namespace }}/helm-live/dvr
- name: srs-vol
mountPath: /home/hls
subPath: {{ .Namespace }}/helm-live/hls
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: Always
- name: oss-adaptor
image: {{ .HarborIP }}:{{ .HarborPort }}/cmii/cmii-srs-oss-adaptor:2023-SA
env:
- name: OSS_ENDPOINT
value: 'http://{{ .MinioInnerIP }}:9000'
- name: OSS_AK
value: cmii
- name: OSS_SK
value: 'B#923fC7mk'
- name: OSS_BUCKET
value: live-cluster-hls
- name: SRS_OP
value: 'http://helm-live-op-svc-v2:8080'
- name: MYSQL_ENDPOINT
value: 'helm-mysql:3306'
- name: MYSQL_USERNAME
value: k8s_admin
- name: MYSQL_PASSWORD
value: fP#UaH6qQ3)8
- name: MYSQL_DATABASE
value: cmii_live_srs_op
- name: MYSQL_TABLE
value: live_segment
- name: LOG_LEVEL
value: info
- name: OSS_META
value: 'yes'
resources:
limits:
cpu: 1200m
memory: 4Gi
requests:
cpu: 100m
memory: 256Mi
volumeMounts:
- name: srs-vol
mountPath: /cmii/share/hls
subPath: {{ .Namespace }}/helm-live/hls
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: Always
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
securityContext: {}
imagePullSecrets:
- name: harborsecret
affinity: {}
schedulerName: default-scheduler
serviceName: helm-live-srsrtc-svc
podManagementPolicy: OrderedReady
updateStrategy:
type: RollingUpdate
rollingUpdate:
partition: 0
revisionHistoryLimit: 10
---
# live-srs部分
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: helm-live-op-v2
namespace: {{ .Namespace }}
labels:
octopus.control: wdd
app.kubernetes.io/managed-by: octopus
cmii.app: live-engine
cmii.type: live
helm.sh/chart: cmlc-live-live-op-2.0.0
live-role: op-v2
spec:
replicas: 1
selector:
matchLabels:
live-role: op-v2
template:
metadata:
creationTimestamp: null
labels:
live-role: op-v2
spec:
volumes:
- name: srs-conf-file
configMap:
name: helm-live-op-cm-v2
items:
- key: live.op.conf
path: bootstrap.yaml
defaultMode: 420
containers:
- name: helm-live-op-v2
image: {{ .HarborIP }}:{{ .HarborPort }}/cmii/cmii-live-operator:5.2.0
ports:
- name: operator
containerPort: 8080
protocol: TCP
resources:
limits:
cpu: 4800m
memory: 4Gi
requests:
cpu: 100m
memory: 256Mi
volumeMounts:
- name: srs-conf-file
mountPath: /cmii/bootstrap.yaml
subPath: bootstrap.yaml
livenessProbe:
httpGet:
path: /cmii/ping
port: 8080
scheme: HTTP
initialDelaySeconds: 60
timeoutSeconds: 5
periodSeconds: 20
successThreshold: 1
failureThreshold: 3
readinessProbe:
httpGet:
path: /cmii/ping
port: 8080
scheme: HTTP
initialDelaySeconds: 60
timeoutSeconds: 5
periodSeconds: 20
successThreshold: 1
failureThreshold: 3
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: Always
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
securityContext: {}
imagePullSecrets:
- name: harborsecret
affinity: {}
schedulerName: default-scheduler
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 25%
maxSurge: 25%
revisionHistoryLimit: 10
progressDeadlineSeconds: 600
---
kind: Service
apiVersion: v1
metadata:
name: helm-live-op-svc-v2
namespace: {{ .Namespace }}
labels:
octopus.control: wdd
app.kubernetes.io/managed-by: octopus
spec:
ports:
- protocol: TCP
port: 8080
targetPort: 8080
nodePort: 30333
selector:
live-role: op-v2
type: NodePort
sessionAffinity: None
---
kind: Service
apiVersion: v1
metadata:
name: helm-live-op-svc
namespace: {{ .Namespace }}
labels:
octopus.control: wdd
app.kubernetes.io/managed-by: octopus
spec:
ports:
- protocol: TCP
port: 8080
targetPort: 8080
selector:
live-role: op
type: ClusterIP
sessionAffinity: None
---
kind: ConfigMap
apiVersion: v1
metadata:
name: helm-live-op-cm-v2
namespace: {{ .Namespace }}
labels:
octopus.control: wdd
app.kubernetes.io/managed-by: octopus
cmii.app: live-engine
cmii.type: live
data:
live.op.conf: |-
server:
port: 8080
spring:
main:
allow-bean-definition-overriding: true
allow-circular-references: true
application:
name: cmii-live-operator
platform:
info:
name: cmii-live-operator
description: cmii-live-operator
version: {{ .TagVersion }}
scanPackage: com.cmii.live.op
cloud:
nacos:
config:
username: developer
password: N@cos14Good
server-addr: helm-nacos:8848
extension-configs:
- data-id: cmii-live-operator.yml
group: {{ .TagVersion }}
refresh: true
shared-configs:
- data-id: cmii-backend-system.yml
group: {{ .TagVersion }}
refresh: true
discovery:
enabled: false
live:
engine:
type: srs
endpoint: 'http://helm-live-srs-svc:1985'
proto:
rtmp: 'rtmp://{{ .WebIP }}:30935'
rtsp: 'rtsp://{{ .WebIP }}:30554'
srt: 'srt://{{ .WebIP }}:30556'
flv: 'http://{{ .WebIP }}:30500'
hls: 'http://{{ .WebIP }}:30500'
rtc: 'webrtc://{{ .WebIP }}:30557'
replay: 'https://{{ .WebIP }}:30333'
minio:
endpoint: http://{{ .MinioInnerIP }}:9000
access-key: cmii
secret-key: B#923fC7mk
bucket: live-cluster-hls
`

View File

@@ -0,0 +1,610 @@
package c_app
const CmiiFrontendConfigMapTemplate = `
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ .AppName }}
namespace: {{ .Namespace }}
data:
ingress-config.js: |-
var GlobalIngressConfig = {
TenantEnvironment: "{{ .TenantEnv }}",
CloudHOST: "{{ .WebIP }}:{{ .WebPort }}",
ApplicationShortName: "{{ .ShortName }}",
AppClientId: "{{ .ClientId }}"
}
`
const CmiiFrontendDefaultNginxConfTemplate = `
kind: ConfigMap
apiVersion: v1
metadata:
name: nginx-cm
namespace: {{ .Namespace }}
labels:
cmii.type: frontend
data:
nginx.conf: |
user root;
worker_processes auto;
events {
worker_connections 1024;
use_epoll on;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 600;
server {
listen 9528;
server_name localhost;
gzip on;
location / {
root /home/cmii-platform/dist;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
`
const CmiiFrontendIngressTemplate = `
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: frontend-applications-ingress
namespace: {{ .Namespace }}
labels:
type: frontend
octopus.control: all-ingress-config-wdd
app.kubernetes.io/managed-by: octopus-control
app.kubernetes.io/version: {{ .TagVersion }}
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$1
nginx.ingress.kubernetes.io/configuration-snippet: |
rewrite ^(/green)$ $1/ redirect;
rewrite ^(/supervision)$ $1/ redirect;
rewrite ^(/inspection)$ $1/ redirect;
rewrite ^(/park)$ $1/ redirect;
rewrite ^(/pangu)$ $1/ redirect;
rewrite ^(/ai-brain)$ $1/ redirect;
rewrite ^(/base)$ $1/ redirect;
rewrite ^(/cms)$ $1/ redirect;
rewrite ^(/cmsportal)$ $1/ redirect;
rewrite ^(/detection)$ $1/ redirect;
rewrite ^(/emergency)$ $1/ redirect;
rewrite ^(/hyper)$ $1/ redirect;
rewrite ^(/logistics)$ $1/ redirect;
rewrite ^(/mws)$ $1/ redirect;
rewrite ^(/mws-admin)$ $1/ redirect;
rewrite ^(/oms)$ $1/ redirect;
rewrite ^(/open)$ $1/ redirect;
rewrite ^(/security)$ $1/ redirect;
rewrite ^(/share)$ $1/ redirect;
rewrite ^(/splice)$ $1/ redirect;
rewrite ^(/splice-visual)$ $1/ redirect;
rewrite ^(/traffic)$ $1/ redirect;
rewrite ^(/visualization)$ $1/ redirect;
rewrite ^(/communication)$ $1/ redirect;
rewrite ^(/infrastructure)$ $1/ redirect;
rewrite ^(/media)$ $1/ redirect;
rewrite ^(/seniclive)$ $1/ redirect;
spec:
rules:
- host: fake-domain.{{ .Namespace }}.io
http:
paths:
- path: /inspection/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform
servicePort: 9528
- path: /supervision/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-suav-platform-supervision
servicePort: 9528
- path: /supervisionh5/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-suav-platform-supervisionh5
servicePort: 9528
- path: /green/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform
servicePort: 9528
- path: /park/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform
servicePort: 9528
- path: /pangu/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform
servicePort: 9528
- path: /emersupport/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform
servicePort: 9528
- path: /infrastructure/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform
servicePort: 9528
- path: /?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-cms-portal
servicePort: 9528
- path: /ai-brain/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-ai-brain
servicePort: 9528
- path: /base/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-base
servicePort: 9528
- path: /cms/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-cms
servicePort: 9528
- path: /cmsportal/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-cms-portal
servicePort: 9528
- path: /detection/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-detection
servicePort: 9528
- path: /emergency/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-emergency-rescue
servicePort: 9528
- path: /hyper/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-hyperspectral
servicePort: 9528
- path: /logistics/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-logistics
servicePort: 9528
- path: /mws/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-mws
servicePort: 9528
- path: /mws-admin/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-mws-admin
servicePort: 9528
- path: /oms/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-oms
servicePort: 9528
- path: /open/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-open
servicePort: 9528
- path: /security/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform
servicePort: 9528
- path: /share/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-share
servicePort: 9528
- path: /splice/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-splice
servicePort: 9528
- path: /splice-visual/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-splice-visual
servicePort: 9528
- path: /traffic/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform
servicePort: 9528
- path: /visualization/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-visualization
servicePort: 9528
- path: /communication/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform
servicePort: 9528
- path: /media/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-media
servicePort: 9528
- path: /seniclive/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-seniclive
servicePort: 9528
- path: /jiangsuwenlv/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-jiangsuwenlv
servicePort: 9528
- path: /qinghaitourism/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-qinghaitourism
servicePort: 9528
- path: /securityh5/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform-securityh5
servicePort: 9528
- path: /fireRescue/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-platform
servicePort: 9528
`
const CmiiBackendIngressTemplate = `
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: backend-applications-ingress
namespace: {{ .Namespace }}
labels:
type: backend
octopus.control: all-ingress-config-wdd
app.kubernetes.io/managed-by: octopus-control
app.kubernetes.io/version: {{ .TagVersion }}
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/enable-cors: "true"
spec:
rules:
- host: cmii-admin-data.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-admin-data
servicePort: 8080
- host: cmii-admin-gateway.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-admin-gateway
servicePort: 8080
- host: cmii-admin-user.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-admin-user
servicePort: 8080
- host: cmii-open-gateway.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-open-gateway
servicePort: 8080
- host: cmii-uav-airspace.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-airspace
servicePort: 8080
- host: cmii-uav-brain.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-brain
servicePort: 8080
- host: cmii-uav-clusters.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-clusters
servicePort: 8080
- host: cmii-uav-cms.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-cms
servicePort: 8080
- host: cmii-uav-data-post-process.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-data-post-process
servicePort: 8080
- host: cmii-uav-developer.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-developer
servicePort: 8080
- host: cmii-uav-device.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-device
servicePort: 8080
- host: cmii-uav-gateway.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-gateway
servicePort: 8080
- host: cmii-uav-industrial-portfolio.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-industrial-portfolio
servicePort: 8080
- host: cmii-uav-kpi-monitor.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-kpi-monitor
servicePort: 8080
- host: cmii-uav-live.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-live
servicePort: 8080
- host: cmii-uav-cloud-live.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-cloud-live
servicePort: 8080
- host: cmii-uav-logger.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-logger
servicePort: 8080
- host: cmii-uav-material-warehouse.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-material-warehouse
servicePort: 8080
- host: cmii-uav-mission.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-mission
servicePort: 8080
- host: cmii-uav-monitor.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-monitor
servicePort: 8080
- host: cmii-uav-mqtthandler.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-mqtthandler
servicePort: 8080
- host: cmii-uav-notice.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-notice
servicePort: 8080
- host: cmii-uav-oauth.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-oauth
servicePort: 8080
- host: cmii-uav-process.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-process
servicePort: 8080
- host: cmii-uav-security-system.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-security-system
servicePort: 8080
- host: cmii-uav-surveillance.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-surveillance
servicePort: 8080
- host: cmii-uav-user.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-user
servicePort: 8080
- host: cmii-uav-waypoint.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-waypoint
servicePort: 8080
- host: cmii-uav-alarm.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-alarm
servicePort: 8080
- host: cmii-uav-emergency.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-emergency
servicePort: 8080
- host: cmii-uav-integration.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-integration
servicePort: 8080
- host: cmii-suav-supervision.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-suav-supervision
servicePort: 8080
- host: cmii-uav-gis-server.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-gis-server
servicePort: 8080
- host: cmii-uav-grid-datasource.uavcloud-{{ .Namespace }}.io
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-grid-datasource
servicePort: 8080
`
const CmiiGatewayIngressTemplate = `
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: all-gateways-ingress
namespace: {{ .Namespace }}
labels:
type: api-gateway
octopus.control: all-ingress-config-1.1.0
app.kubernetes.io/managed-by: octopus-control
app.kubernetes.io/version: {{ .TagVersion }}
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$1
nginx.ingress.kubernetes.io/configuration-snippet: |
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
spec:
rules:
- host: fake-domain.{{ .Namespace }}.io
http:
paths:
- path: /oms/api/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-admin-gateway
servicePort: 8080
- path: /open/api/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-open-gateway
servicePort: 8080
- path: /api/?(.*)
pathType: ImplementationSpecific
backend:
serviceName: cmii-uav-gateway
servicePort: 8080
`