From 120a8eb68a4ac0d130984a7c5a38d7c1054fd2fb Mon Sep 17 00:00:00 2001 From: Mini256 Date: Tue, 18 May 2021 09:51:39 +0800 Subject: [PATCH] feat: add execute command pod and update values (#38) - add `devstats-execute.yaml` to execute one-time command in the cluster. - reduce grafanaNReplicas - increase limitsCronsMemory --- .../helms/dev/templates/devstats-execute.yaml | 116 ++++++++++++++++++ .../dev/templates/devstats-hourly-sync.yaml | 2 +- .../dev/templates/devstats-provisions.yaml | 2 +- deployments/helms/dev/values.yaml | 25 +++- .../prod/templates/devstats-execute.yaml | 116 ++++++++++++++++++ .../prod/templates/devstats-hourly-sync.yaml | 2 +- .../prod/templates/devstats-provisions.yaml | 2 +- deployments/helms/prod/values.yaml | 11 +- 8 files changed, 264 insertions(+), 12 deletions(-) create mode 100644 deployments/helms/dev/templates/devstats-execute.yaml create mode 100644 deployments/helms/prod/templates/devstats-execute.yaml diff --git a/deployments/helms/dev/templates/devstats-execute.yaml b/deployments/helms/dev/templates/devstats-execute.yaml new file mode 100644 index 00000000..f28120c2 --- /dev/null +++ b/deployments/helms/dev/templates/devstats-execute.yaml @@ -0,0 +1,116 @@ +{{- $executeTargetProject := .Values.executeTargetProject -}} +{{ if $executeTargetProject }} +{{- $root := . -}} +--- +apiVersion: v1 +kind: Pod +metadata: + name: '{{ $root.Values.executePodName }}-{{ $executeTargetProject }}' + labels: + name: devstats + type: 'execute' + proj: {{ $executeTargetProject }} +spec: + containers: + - command: + - {{ $root.Values.executeCommand }} +{{ if $root.Values.executeCommandArgs }} + args: +{{- with $root.Values.executeCommandArgs -}} +{{ toYaml . | nindent 6 }} +{{ end }} +{{ end }} +{{ if $root.Values.useExecuteResourcesLimits }} + resources: + requests: + memory: '{{ $root.Values.requestsExecuteMemory }}' + cpu: '{{ $root.Values.requestsExecuteCPU }}' + limits: + memory: '{{ $root.Values.limitsExecuteMemory }}' + cpu: '{{ $root.Values.limitsExecuteCPU }}' +{{ end }} + env: + - name: ONLY + value: {{ $executeTargetProject }} + - name: GHA2DB_PROPAGATE_ONLY_VAR + value: "1" + - name: GHA2DB_CHECK_PROVISION_FLAG + value: "1" + - name: GHA2DB_CHECK_RUNNING_FLAG + value: "1" + - name: GHA2DB_SET_RUNNING_FLAG + value: "1" + - name: GHA2DB_NCPUS + value: '{{ $root.Values.executeGha2dbCPUs }}' + - name: GHA2DB_DEBUG + value: "1" + - name: GHA2DB_CMDDEBUG + value: '{{ $root.Values.executeCmdDebug }}' + - name: GHA2DB_GITHUB_DEBUG + value: '{{ $root.Values.executeGithubDebug }}' + - name: GHA2DB_QOUT + value: '{{ $root.Values.queryOut }}' + - name: GHA2DB_REPOS_DIR + value: '{{ $root.Values.reposDir }}' + - name: GHA2DB_COMPANY_ACQ_YAML + value: '{{ $root.Values.companyAcq }}' + - name: GHA2DB_AFFILIATIONS_JSON + value: '{{ $root.Values.affiliations }}' + - name: GHA2DB_COMPUTE_ALL + value: '{{ $root.Values.executeForceComputeAll }}' + # Metrics config + - name: GHA2DB_RESETTSDB + value: '{{ $root.Values.executeResetTSDB }}' + - name: GHA2DB_SKIP_METRICS + value: '{{ $root.Values.executeSkipMetrics }}' + - name: GHA2DB_ONLY_METRICS + value: '{{ $root.Values.executeOnlyMetrics }}' + # Tags config + - name: GHA2DB_SKIP_TAGS + value: '{{ $root.Values.executeSkipTags }}' + # Vars config + - name: GHA2DB_ONLY_VARS + value: '{{ $root.Values.executeOnlyVars }}' + - name: GHA2DB_EXCLUDE_VARS + value: '{{ $root.Values.excludeVars }}' + - name: GHA2DB_FORCE_PERIODS + value: '{{ $root.Values.periods }}' + - name: GHA2DB_PROJECTS_YAML + value: {{ $root.Values.projectsFile }} + - name: GHA2DB_GITHUB_OAUTH + valueFrom: + secretKeyRef: + name: {{ $root.Values.oauthSecret }} + key: GHA2DB_GITHUB_OAUTH.secret + - name: PG_HOST + valueFrom: + secretKeyRef: + name: {{ $root.Values.pgSecret }} + key: PG_HOST.secret + - name: PG_PORT + valueFrom: + secretKeyRef: + name: {{ $root.Values.pgSecret }} + key: PG_PORT.secret + - name: PG_PASS + valueFrom: + secretKeyRef: + name: {{ $root.Values.pgSecret }} + key: PG_PASS.secret + image: {{ $root.Values.executeImage }} + imagePullPolicy: {{ $root.Values.imagePullPolicy }} + name: '{{ $root.Values.executePodName }}-{{ $executeTargetProject }}' + volumeMounts: + - name: '{{ $root.Values.volumeMountName }}-{{ $executeTargetProject }}' + mountPath: '{{ $root.Values.volumeMountPath }}' + volumes: + - name: '{{ $root.Values.volumeName }}-{{ $executeTargetProject }}' + persistentVolumeClaim: + claimName: '{{ $root.Values.pvName }}-{{ $executeTargetProject }}' + restartPolicy: {{ $root.Values.executeRestartPolicy }} + nodeSelector: +{{- with $root.Values.appNodeSelector -}} +{{ toYaml . | nindent 4 }} +{{ end }} +{{ end }} + diff --git a/deployments/helms/dev/templates/devstats-hourly-sync.yaml b/deployments/helms/dev/templates/devstats-hourly-sync.yaml index f561c924..abb6a9d4 100644 --- a/deployments/helms/dev/templates/devstats-hourly-sync.yaml +++ b/deployments/helms/dev/templates/devstats-hourly-sync.yaml @@ -55,7 +55,7 @@ spec: - name: GHA2DB_SET_RUNNING_FLAG value: "1" - name: GHA2DB_NCPUS - value: '{{ $root.Values.nCPUs }}' + value: '{{ $root.Values.nSyncCPUs }}' - name: GHA2DB_DEBUG value: '{{ $root.Values.debug }}' - name: GHA2DB_CMDDEBUG diff --git a/deployments/helms/dev/templates/devstats-provisions.yaml b/deployments/helms/dev/templates/devstats-provisions.yaml index bbcaac1e..85d4a7f1 100644 --- a/deployments/helms/dev/templates/devstats-provisions.yaml +++ b/deployments/helms/dev/templates/devstats-provisions.yaml @@ -57,7 +57,7 @@ spec: - name: GHA2DB_PROPAGATE_ONLY_VAR value: "1" - name: GHA2DB_NCPUS - value: '{{ $root.Values.nCPUs }}' + value: '{{ $root.Values.nSyncCPUs }}' - name: GHA2DB_DEBUG value: '{{ $root.Values.debug }}' - name: GHA2DB_CMDDEBUG diff --git a/deployments/helms/dev/values.yaml b/deployments/helms/dev/values.yaml index bf49f346..99adad72 100644 --- a/deployments/helms/dev/values.yaml +++ b/deployments/helms/dev/values.yaml @@ -22,7 +22,6 @@ bootstrapNoCreate: '' bootstrapPodName: devstats-provision-bootstrap bootstrapRestartPolicy: Never bootstrapUDrop: '' -concurrencyPolicy: Forbid requestsBootstrapCPU: '200m' requestsBootstrapMemory: '256Mi' limitsBootstrapCPU: '2000m' @@ -82,6 +81,7 @@ syncCommand: devstats syncImage: 'miniantdev/devstats-minimal-dev:0.2.0' syncPodName: devstats syncRestartPolicy: Never +concurrencyPolicy: Forbid indexCronsFrom: 0 indexCronsTo: 100 limitsCronsCPU: '6000m' @@ -90,6 +90,25 @@ requestsCronsCPU: '1000m' requestsCronsMemory: '2Gi' useCronsResourcesLimits: 1 +# Execute Pod configurations. +executeImage: 'miniantdev/devstats-minimal-dev:0.2.1.beta.1' +executePodName: 'devstats-execute' +executeTargetProject: 'tikv' +executeCommand: 'sleep' +executeCommandArgs: +- "3000" +# example: +# executeCommand: devstats +# executeResetTSDB: '1' +# executeOnlyMetrics: 'first_non_author_activity_company_group' +executeSkipMetrics: '' +executeRestartPolicy: Never +limitsExecuteCPU: '6000m' +limitsExecuteMemory: '32Gi' +requestsExecuteCPU: '1000m' +requestsExecuteMemory: '1Gi' +useExecuteResourcesLimits: 1 + # Ingresses indexes. indexIngressesFrom: 0 indexIngressesTo: 100 @@ -114,7 +133,7 @@ projects: icon: 'pingcap' org: 'PingCAP' repo: 'pingcap/tidb' - cron: '20 * * * *' + cron: '05 * * * *' disk: 50Gi i: 0 - proj: tikv @@ -130,6 +149,6 @@ projects: icon: 'chaosmesh' org: 'ChaosMesh' repo: 'chaos-mesh/chaos-mesh' - cron: '40 * * * *' + cron: '50 * * * *' disk: 50Gi i: 2 diff --git a/deployments/helms/prod/templates/devstats-execute.yaml b/deployments/helms/prod/templates/devstats-execute.yaml new file mode 100644 index 00000000..f28120c2 --- /dev/null +++ b/deployments/helms/prod/templates/devstats-execute.yaml @@ -0,0 +1,116 @@ +{{- $executeTargetProject := .Values.executeTargetProject -}} +{{ if $executeTargetProject }} +{{- $root := . -}} +--- +apiVersion: v1 +kind: Pod +metadata: + name: '{{ $root.Values.executePodName }}-{{ $executeTargetProject }}' + labels: + name: devstats + type: 'execute' + proj: {{ $executeTargetProject }} +spec: + containers: + - command: + - {{ $root.Values.executeCommand }} +{{ if $root.Values.executeCommandArgs }} + args: +{{- with $root.Values.executeCommandArgs -}} +{{ toYaml . | nindent 6 }} +{{ end }} +{{ end }} +{{ if $root.Values.useExecuteResourcesLimits }} + resources: + requests: + memory: '{{ $root.Values.requestsExecuteMemory }}' + cpu: '{{ $root.Values.requestsExecuteCPU }}' + limits: + memory: '{{ $root.Values.limitsExecuteMemory }}' + cpu: '{{ $root.Values.limitsExecuteCPU }}' +{{ end }} + env: + - name: ONLY + value: {{ $executeTargetProject }} + - name: GHA2DB_PROPAGATE_ONLY_VAR + value: "1" + - name: GHA2DB_CHECK_PROVISION_FLAG + value: "1" + - name: GHA2DB_CHECK_RUNNING_FLAG + value: "1" + - name: GHA2DB_SET_RUNNING_FLAG + value: "1" + - name: GHA2DB_NCPUS + value: '{{ $root.Values.executeGha2dbCPUs }}' + - name: GHA2DB_DEBUG + value: "1" + - name: GHA2DB_CMDDEBUG + value: '{{ $root.Values.executeCmdDebug }}' + - name: GHA2DB_GITHUB_DEBUG + value: '{{ $root.Values.executeGithubDebug }}' + - name: GHA2DB_QOUT + value: '{{ $root.Values.queryOut }}' + - name: GHA2DB_REPOS_DIR + value: '{{ $root.Values.reposDir }}' + - name: GHA2DB_COMPANY_ACQ_YAML + value: '{{ $root.Values.companyAcq }}' + - name: GHA2DB_AFFILIATIONS_JSON + value: '{{ $root.Values.affiliations }}' + - name: GHA2DB_COMPUTE_ALL + value: '{{ $root.Values.executeForceComputeAll }}' + # Metrics config + - name: GHA2DB_RESETTSDB + value: '{{ $root.Values.executeResetTSDB }}' + - name: GHA2DB_SKIP_METRICS + value: '{{ $root.Values.executeSkipMetrics }}' + - name: GHA2DB_ONLY_METRICS + value: '{{ $root.Values.executeOnlyMetrics }}' + # Tags config + - name: GHA2DB_SKIP_TAGS + value: '{{ $root.Values.executeSkipTags }}' + # Vars config + - name: GHA2DB_ONLY_VARS + value: '{{ $root.Values.executeOnlyVars }}' + - name: GHA2DB_EXCLUDE_VARS + value: '{{ $root.Values.excludeVars }}' + - name: GHA2DB_FORCE_PERIODS + value: '{{ $root.Values.periods }}' + - name: GHA2DB_PROJECTS_YAML + value: {{ $root.Values.projectsFile }} + - name: GHA2DB_GITHUB_OAUTH + valueFrom: + secretKeyRef: + name: {{ $root.Values.oauthSecret }} + key: GHA2DB_GITHUB_OAUTH.secret + - name: PG_HOST + valueFrom: + secretKeyRef: + name: {{ $root.Values.pgSecret }} + key: PG_HOST.secret + - name: PG_PORT + valueFrom: + secretKeyRef: + name: {{ $root.Values.pgSecret }} + key: PG_PORT.secret + - name: PG_PASS + valueFrom: + secretKeyRef: + name: {{ $root.Values.pgSecret }} + key: PG_PASS.secret + image: {{ $root.Values.executeImage }} + imagePullPolicy: {{ $root.Values.imagePullPolicy }} + name: '{{ $root.Values.executePodName }}-{{ $executeTargetProject }}' + volumeMounts: + - name: '{{ $root.Values.volumeMountName }}-{{ $executeTargetProject }}' + mountPath: '{{ $root.Values.volumeMountPath }}' + volumes: + - name: '{{ $root.Values.volumeName }}-{{ $executeTargetProject }}' + persistentVolumeClaim: + claimName: '{{ $root.Values.pvName }}-{{ $executeTargetProject }}' + restartPolicy: {{ $root.Values.executeRestartPolicy }} + nodeSelector: +{{- with $root.Values.appNodeSelector -}} +{{ toYaml . | nindent 4 }} +{{ end }} +{{ end }} + diff --git a/deployments/helms/prod/templates/devstats-hourly-sync.yaml b/deployments/helms/prod/templates/devstats-hourly-sync.yaml index f561c924..abb6a9d4 100644 --- a/deployments/helms/prod/templates/devstats-hourly-sync.yaml +++ b/deployments/helms/prod/templates/devstats-hourly-sync.yaml @@ -55,7 +55,7 @@ spec: - name: GHA2DB_SET_RUNNING_FLAG value: "1" - name: GHA2DB_NCPUS - value: '{{ $root.Values.nCPUs }}' + value: '{{ $root.Values.nSyncCPUs }}' - name: GHA2DB_DEBUG value: '{{ $root.Values.debug }}' - name: GHA2DB_CMDDEBUG diff --git a/deployments/helms/prod/templates/devstats-provisions.yaml b/deployments/helms/prod/templates/devstats-provisions.yaml index bbcaac1e..85d4a7f1 100644 --- a/deployments/helms/prod/templates/devstats-provisions.yaml +++ b/deployments/helms/prod/templates/devstats-provisions.yaml @@ -57,7 +57,7 @@ spec: - name: GHA2DB_PROPAGATE_ONLY_VAR value: "1" - name: GHA2DB_NCPUS - value: '{{ $root.Values.nCPUs }}' + value: '{{ $root.Values.nSyncCPUs }}' - name: GHA2DB_DEBUG value: '{{ $root.Values.debug }}' - name: GHA2DB_CMDDEBUG diff --git a/deployments/helms/prod/values.yaml b/deployments/helms/prod/values.yaml index 78c6c6c1..5e381339 100644 --- a/deployments/helms/prod/values.yaml +++ b/deployments/helms/prod/values.yaml @@ -10,6 +10,7 @@ skipTemp: 1 volumeMountName: data volumeMountPath: '/root' volumeName: data +nSyncCPUs: 6 # Company configurations. affiliations: 'github_users.json' @@ -22,7 +23,6 @@ bootstrapNoCreate: '' bootstrapPodName: devstats-provision-bootstrap bootstrapRestartPolicy: Never bootstrapUDrop: '' -concurrencyPolicy: Forbid requestsBootstrapCPU: '200m' requestsBootstrapMemory: '256Mi' limitsBootstrapCPU: '2000m' @@ -35,7 +35,7 @@ grafanaCommand: 'grafana_start.sh' grafanaImage: 'miniantdev/devstats-grafana-prod:0.2.0' grafanaMaxSurge: 1 grafanaMaxUnavailable: 1 -grafanaNReplicas: 2 +grafanaNReplicas: 1 grafanaPodName: devstats-grafana grafanaPort: 3000 grafanaRestartPolicy: Always @@ -82,10 +82,11 @@ syncCommand: devstats syncImage: 'miniantdev/devstats-minimal-prod:0.2.0' syncPodName: devstats syncRestartPolicy: Never +concurrencyPolicy: Forbid indexCronsFrom: 0 indexCronsTo: 100 limitsCronsCPU: '6000m' -limitsCronsMemory: '16Gi' +limitsCronsMemory: '32Gi' requestsCronsCPU: '1000m' requestsCronsMemory: '2Gi' useCronsResourcesLimits: 1 @@ -114,7 +115,7 @@ projects: icon: 'pingcap' org: 'PingCAP' repo: 'pingcap/tidb' - cron: '20 * * * *' + cron: '05 * * * *' disk: 50Gi i: 0 - proj: tikv @@ -130,6 +131,6 @@ projects: icon: 'chaosmesh' org: 'ChaosMesh' repo: 'chaos-mesh/chaos-mesh' - cron: '40 * * * *' + cron: '50 * * * *' disk: 50Gi i: 2