Skip to content

Commit

Permalink
Merge pull request teamhephy#31 from jianxiaoguo/dev
Browse files Browse the repository at this point in the history
chore(controller): modify database config && remove redis port config…
  • Loading branch information
duanhongyi authored Jan 18, 2021
2 parents 3859f16 + ea5ff4e commit 1579ee4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 43 deletions.
37 changes: 15 additions & 22 deletions charts/controller/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,12 @@ env:
name: builder-key-auth
key: builder-key
{{- if eq .Values.global.database_location "off-cluster" }}
- name: DRYCC_DATABASE_NAME
- name: DRYCC_DATABASE_URL
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 }}
key: url
{{- else if .Values.global.database_location "on-cluster" }}
- name: DRYCC_DATABASE_USER
valueFrom:
secretKeyRef:
Expand All @@ -92,13 +82,16 @@ env:
secretKeyRef:
name: database-creds
key: password
- name: DRYCC_DATABASE_URL
value: "postgres://$DRYCC_DATABASE_USER:$DRYCC_DATABASE_PASSPORT@$DRYCC_DATABASE_SERVICE_HOST:$DRYCC_DATABASE_SERVICE_PORT/$DRYCC_DATABASE_USER"
{{ end }}
- 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}}"
value: "{{range $i := until $redisNodeCount}}drycc-redis-{{$i}}.drycc-redis.{{$.Release.Namespace}}.svc.{{$.Values.global.cluster_domain}}:6379{{if lt (add 1 $i) $redisNodeCount}},{{end}}{{end}}"
{{- else if eq .Values.global.redis_location "off-cluster" }}
- name: DRYCC_REDIS_ADDRS
valueFrom:
Expand All @@ -112,26 +105,26 @@ env:
name: redis-creds
key: password
{{- if eq .Values.global.influxdb_location "off-cluster" }}
- name: "INFLUXDB_URL"
- name: "DRYCC_INFLUXDB_URL"
valueFrom:
secretKeyRef:
name: influxdb-creds
key: url
{{- else }}
- name: "INFLUXDB_URL"
- name: "DRYCC_INFLUXDB_URL"
value: http://$(DRYCC_INFLUXDB_SERVICE_HOST):$(DRYCC_INFLUXDB_SERVICE_PORT_TRANSPORT)
{{- end }}
- name: "INFLUXDB_BUCKET"
- name: "DRYCC_INFLUXDB_BUCKET"
valueFrom:
secretKeyRef:
name: influxdb-creds
key: bucket
- name: "INFLUXDB_ORG"
- name: "DRYCC_INFLUXDB_ORG"
valueFrom:
secretKeyRef:
name: influxdb-creds
key: org
- name: "INFLUXDB_TOKEN"
- name: "DRYCC_INFLUXDB_TOKEN"
valueFrom:
secretKeyRef:
name: influxdb-creds
Expand Down Expand Up @@ -162,6 +155,7 @@ env:
{{- end }}
{{- end }}


{{/* Generate controller deployment limits */}}
{{- define "controller.limits" -}}
{{- if or (.Values.limits_cpu) (.Values.limits_memory) }}
Expand All @@ -177,8 +171,6 @@ resources:
{{- end }}




{{/* Generate controller deployment volumeMounts */}}
{{- define "controller.volumeMounts" -}}
volumeMounts:
Expand All @@ -187,6 +179,7 @@ volumeMounts:
readOnly: true
{{- end }}


{{/* Generate controller deployment volumes */}}
{{- define "controller.volumes" -}}
volumes:
Expand All @@ -196,4 +189,4 @@ volumes:
- name: slugrunner-config
configMap:
name: slugrunner-config
{{- end }}
{{- end }}
1 change: 0 additions & 1 deletion charts/controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ environment:

redis:
replicas: 1
port: '6379'

global:
# Admin email, used for each component to send email to administrator
Expand Down
23 changes: 8 additions & 15 deletions rootfs/api/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import tempfile
import ldap
import json
import dj_database_url

from django_auth_ldap.config import LDAPSearch, GroupOfNamesType

Expand Down Expand Up @@ -433,18 +434,10 @@
# check if we can register users with `drycc register`
REGISTRATION_MODE = os.environ.get('REGISTRATION_MODE', 'enabled')


DRYCC_DATABASE_URL = os.environ.get('DRYCC_DATABASE_URL', 'postgres://:@:5432/drycc')
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ.get(
'DRYCC_DATABASE_NAME', os.environ.get('DRYCC_DATABASE_USER', 'drycc')),
'USER': os.environ.get('DRYCC_DATABASE_USER', ''),
'PASSWORD': os.environ.get('DRYCC_DATABASE_PASSWORD', ''),
'HOST': os.environ.get('DRYCC_DATABASE_SERVICE_HOST', ''),
'PORT': os.environ.get('DRYCC_DATABASE_SERVICE_PORT', 5432),
# https://docs.djangoproject.com/en/1.11/ref/databases/#persistent-connections
'CONN_MAX_AGE': 600,
}
'default': dj_database_url.config(default=DRYCC_DATABASE_URL, conn_max_age=600)
}

APP_URL_REGEX = '[a-z0-9-]+'
Expand Down Expand Up @@ -540,10 +533,10 @@
CELERY_DEFAULT_QUEUE = 'priority.middle'

# Influxdb Configuration Options
INFLUXDB_URL = os.environ.get('DRYCC_INFLUXDB_URL', 'http://localhost:8086')
INFLUXDB_BUCKET = os.environ.get('DRYCC_INFLUXDB_BUCKET', 'drycc')
INFLUXDB_ORG = os.environ.get('DRYCC_INFLUXDB_ORG', 'root')
INFLUXDB_TOKEN = os.environ.get('DRYCC_INFLUXDB_TOKEN', 'root')
DRYCC_INFLUXDB_URL = os.environ.get('DRYCC_INFLUXDB_URL', 'http://localhost:8086')
DRYCC_INFLUXDB_BUCKET = os.environ.get('DRYCC_INFLUXDB_BUCKET', 'drycc')
DRYCC_INFLUXDB_ORG = os.environ.get('DRYCC_INFLUXDB_ORG', 'root')
DRYCC_INFLUXDB_TOKEN = os.environ.get('DRYCC_INFLUXDB_TOKEN', 'root')


# Workflow-manager Configuration Options
Expand Down
6 changes: 3 additions & 3 deletions rootfs/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ def apply_tasks(tasks):
def get_influxdb_client():
if not hasattr(local, "influxdb_client"):
local.influxdb_client = InfluxDBClient(
url=settings.INFLUXDB_URL,
token=settings.INFLUXDB_TOKEN,
org=settings.INFLUXDB_ORG
url=settings.DRYCC_INFLUXDB_URL,
token=settings.DRYCC_INFLUXDB_TOKEN,
org=settings.DRYCC_INFLUXDB_ORG
)
return local.influxdb_client

Expand Down
2 changes: 0 additions & 2 deletions rootfs/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
from api import authentication, models, permissions, serializers, viewsets
from api.models import AlreadyExists, ServiceUnavailable, DryccException, \
UnprocessableEntity
from api.utils import get_influxdb_client

logger = logging.getLogger(__name__)
client = get_influxdb_client()


class ReadinessCheckView(View):
Expand Down
1 change: 1 addition & 0 deletions rootfs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ requests-toolbelt==0.9.1
celery==5.0.2
django_redis==4.12.1
influxdb-client==1.13.0
dj-database-url

0 comments on commit 1579ee4

Please sign in to comment.