forked from teamhephy/controller
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request teamhephy#30 from jianxiaoguo/main
feat(controller): push data to influx
- Loading branch information
Showing
16 changed files
with
481 additions
and
179 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
{{/* | ||
Set apiVersion based on .Capabilities.APIVersions | ||
*/}} | ||
{{- define "rbacAPIVersion" -}} | ||
{{- if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1beta1" -}} | ||
rbac.authorization.k8s.io/v1beta1 | ||
{{- else if .Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1alpha1" -}} | ||
rbac.authorization.k8s.io/v1alpha1 | ||
{{- else -}} | ||
rbac.authorization.k8s.io/v1 | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
|
||
{{/* Generate controller deployment envs */}} | ||
{{- define "controller.envs" -}} | ||
{{ $redisNodeCount := .Values.redis.replicas | int }} | ||
env: | ||
- name: REGISTRATION_MODE | ||
value: {{ .Values.registration_mode }} | ||
# NOTE(bacongobbler): use drycc/registry_proxy to work around Docker --insecure-registry requirements | ||
- name: "DRYCC_REGISTRY_PROXY_HOST" | ||
value: "127.0.0.1" | ||
# Environmental variable value for $INGRESS_CLASS | ||
- name: "DRYCC_INGRESS_CLASS" | ||
value: "{{ .Values.global.ingress_class }}" | ||
- name: "DRYCC_PLATFORM_DOMAIN" | ||
value: "{{ .Values.global.platform_domain }}" | ||
- name: "K8S_API_VERIFY_TLS" | ||
value: "{{ .Values.k8s_api_verify_tls }}" | ||
- name: "DRYCC_REGISTRY_PROXY_PORT" | ||
value: "{{ .Values.global.registry_proxy_port }}" | ||
- name: "APP_STORAGE" | ||
value: "{{ .Values.global.storage}}" | ||
- name: "DRYCC_REGISTRY_LOCATION" | ||
value: "{{ .Values.global.registry_location }}" | ||
- name: "DRYCC_REGISTRY_SECRET_PREFIX" | ||
value: "{{ .Values.global.registry_secret_prefix }}" | ||
- name: "IMAGE_PULL_POLICY" | ||
value: "{{ .Values.app_image_pull_policy }}" | ||
- name: "KUBERNETES_CLUSTER_DOMAIN" | ||
value: "{{ .Values.global.cluster_domain }}" | ||
{{- if (.Values.app_storage_class) }} | ||
- name: "DRYCC_APP_STORAGE_CLASS" | ||
value: "{{ .Values.app_storage_class }}" | ||
{{- end }} | ||
- name: "TZ" | ||
value: {{ .Values.time_zone | default "UTC" | quote }} | ||
{{- if (.Values.deploy_hook_urls) }} | ||
- name: DRYCC_DEPLOY_HOOK_URLS | ||
value: "{{ .Values.deploy_hook_urls }}" | ||
- name: DRYCC_DEPLOY_HOOK_SECRET_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: deploy-hook-key | ||
key: secret-key | ||
{{- end }} | ||
- name: DRYCC_SECRET_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: django-secret-key | ||
key: secret-key | ||
- name: DRYCC_BUILDER_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: builder-key-auth | ||
key: builder-key | ||
{{- if eq .Values.global.database_location "off-cluster" }} | ||
- name: DRYCC_DATABASE_NAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: database-creds | ||
key: name | ||
- name: DRYCC_DATABASE_SERVICE_HOST | ||
valueFrom: | ||
secretKeyRef: | ||
name: database-creds | ||
key: host | ||
- name: DRYCC_DATABASE_SERVICE_PORT | ||
valueFrom: | ||
secretKeyRef: | ||
name: database-creds | ||
key: port | ||
{{- end }} | ||
- name: DRYCC_DATABASE_USER | ||
valueFrom: | ||
secretKeyRef: | ||
name: database-creds | ||
key: user | ||
- name: DRYCC_DATABASE_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: database-creds | ||
key: password | ||
- name: WORKFLOW_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
{{ if eq .Values.global.redis_location "on-cluster"}} | ||
- name: DRYCC_REDIS_ADDRS | ||
value: "{{range $i := until $redisNodeCount}}drycc-redis-{{$i}}.drycc-redis.{{$.Release.Namespace}}.svc.{{$.Values.global.cluster_domain}}:{{$.Values.redis.port}}{{if lt (add 1 $i) $redisNodeCount}},{{end}}{{end}}" | ||
{{- else if eq .Values.global.redis_location "off-cluster" }} | ||
- name: DRYCC_REDIS_ADDRS | ||
valueFrom: | ||
secretKeyRef: | ||
name: redis-creds | ||
key: addrs | ||
{{- end }} | ||
- name: DRYCC_REDIS_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: redis-creds | ||
key: password | ||
{{- if eq .Values.global.influxdb_location "off-cluster" }} | ||
- name: "INFLUXDB_URL" | ||
valueFrom: | ||
secretKeyRef: | ||
name: influxdb-creds | ||
key: url | ||
{{- else }} | ||
- name: "INFLUXDB_URL" | ||
value: http://$(DRYCC_INFLUXDB_SERVICE_HOST):$(DRYCC_INFLUXDB_SERVICE_PORT_TRANSPORT) | ||
{{- end }} | ||
- name: "INFLUXDB_BUCKET" | ||
valueFrom: | ||
secretKeyRef: | ||
name: influxdb-creds | ||
key: bucket | ||
- name: "INFLUXDB_ORG" | ||
valueFrom: | ||
secretKeyRef: | ||
name: influxdb-creds | ||
key: org | ||
- name: "INFLUXDB_TOKEN" | ||
valueFrom: | ||
secretKeyRef: | ||
name: influxdb-creds | ||
key: token | ||
{{- range $key, $value := .Values.environment }} | ||
- name: {{ $key }} | ||
value: {{ $value | quote }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* Generate controller deployment limits */}} | ||
{{- define "controller.limits" -}} | ||
{{- if or (.Values.limits_cpu) (.Values.limits_memory) }} | ||
resources: | ||
limits: | ||
{{- if (.Values.limits_cpu) }} | ||
cpu: {{.Values.limits_cpu}} | ||
{{- end }} | ||
{{- if (.Values.limits_memory) }} | ||
memory: {{.Values.limits_memory}} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
|
||
{{/* Generate controller deployment volumeMounts */}} | ||
{{- define "controller.volumeMounts" -}} | ||
volumeMounts: | ||
- mountPath: /etc/slugrunner | ||
name: slugrunner-config | ||
readOnly: true | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: drycc-controller-celery | ||
labels: | ||
heritage: drycc | ||
annotations: | ||
component.drycc.cc/version: {{ .Values.image_tag }} | ||
spec: | ||
replicas: {{ .Values.celery_replicas }} | ||
strategy: | ||
rollingUpdate: | ||
maxSurge: 1 | ||
maxUnavailable: 0 | ||
type: RollingUpdate | ||
selector: | ||
matchLabels: | ||
app: drycc-controller-celery | ||
template: | ||
metadata: | ||
labels: | ||
app: drycc-controller-celery | ||
spec: | ||
serviceAccount: drycc-controller-celery | ||
containers: | ||
- name: drycc-controller-celery-high | ||
image: {{.Values.image_registry}}{{.Values.org}}/controller:{{.Values.image_tag}} | ||
command: | ||
- /bin/bash | ||
- -c | ||
args: | ||
- celery -A api worker -Q priority.high --autoscale=32,1 --loglevel=WARNING | ||
imagePullPolicy: {{.Values.image_pull_policy}} | ||
{{- include "controller.limits" . | indent 10 }} | ||
{{- include "controller.envs" . | indent 10 }} | ||
volumeMounts: | ||
- mountPath: /etc/slugrunner | ||
name: slugrunner-config | ||
readOnly: true | ||
- name: drycc-controller-celery-middle | ||
image: {{.Values.image_registry}}{{.Values.org}}/controller:{{.Values.image_tag}} | ||
command: | ||
- /bin/bash | ||
- -c | ||
args: | ||
- celery -A api worker -Q priority.middle --autoscale=16,1 --loglevel=WARNING | ||
{{- include "controller.limits" . | indent 10 }} | ||
{{- include "controller.envs" . | indent 10 }} | ||
volumeMounts: | ||
- mountPath: /etc/slugrunner | ||
name: slugrunner-config | ||
readOnly: true | ||
imagePullPolicy: {{.Values.image_pull_policy}} | ||
- name: drycc-controller-celery-low | ||
image: {{.Values.image_registry}}{{.Values.org}}/controller:{{.Values.image_tag}} | ||
command: | ||
- /bin/bash | ||
- -c | ||
args: | ||
- celery -A api worker -Q priority.low --autoscale=8,1 --loglevel=WARNING | ||
{{- include "controller.limits" . | indent 10 }} | ||
{{- include "controller.envs" . | indent 10 }} | ||
volumeMounts: | ||
- mountPath: /etc/slugrunner | ||
name: slugrunner-config | ||
readOnly: true | ||
imagePullPolicy: {{.Values.image_pull_policy}} | ||
volumes: | ||
- name: slugrunner-config | ||
configMap: | ||
name: slugrunner-config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
apiVersion: batch/v1beta1 | ||
kind: CronJob | ||
metadata: | ||
name: drycc-controller-cronjob-daily | ||
labels: | ||
heritage: drycc | ||
annotations: | ||
component.drycc.cc/version: {{ .Values.image_tag }} | ||
spec: | ||
failedJobsHistoryLimit: 1 | ||
schedule: "0 0 * * *" | ||
successfulJobsHistoryLimit: 3 | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
restartPolicy: OnFailure | ||
containers: | ||
- image: {{.Values.image_registry}}{{.Values.org}}/controller:{{.Values.image_tag}} | ||
imagePullPolicy: {{.Values.image_pull_policy}} | ||
name: drycc-controller-push-data-to-influxdb | ||
command: | ||
- /bin/bash | ||
- -c | ||
args: | ||
- python /app/manage.py push_data_to_influxdb | ||
{{- include "controller.envs" . | indent 12 }} | ||
volumeMounts: | ||
- mountPath: /etc/slugrunner | ||
name: slugrunner-config | ||
readOnly: true | ||
- image: {{.Values.image_registry}}{{.Values.org}}/controller:{{.Values.image_tag}} | ||
imagePullPolicy: {{.Values.pull_policy}} | ||
name: drycc-controller-load-db-state-to-k8s | ||
command: | ||
- /bin/bash | ||
- -c | ||
args: | ||
- python -u /app/manage.py load_db_state_to_k8s | ||
{{- include "controller.envs" . | indent 12 }} | ||
volumeMounts: | ||
- mountPath: /etc/slugrunner | ||
name: slugrunner-config | ||
readOnly: true | ||
volumes: | ||
- name: slugrunner-config | ||
configMap: | ||
name: slugrunner-config |
Oops, something went wrong.