Skip to content

Commit a1910b3

Browse files
committed
chore(ingress): change global.use_ingress to ingress.enabled
1 parent 10ba262 commit a1910b3

7 files changed

Lines changed: 57 additions & 31 deletions

File tree

charts/controller/templates/controller-clusterrole.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ rules:
5050
- apiGroups: ["extensions", "autoscaling"]
5151
resources: ["horizontalpodautoscalers"]
5252
verbs: ["get", "list", "create", "update", "delete"]
53-
{{ if .Values.global.use_ingress }}
53+
{{ if .Values.ingress.enabled }}
5454
- apiGroups: ["extensions"]
5555
resources: ["ingresses"]
5656
verbs: ["get", "list", "watch", "create", "update", "delete"]

charts/controller/templates/controller-deployment.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ metadata:
66
heritage: drycc
77
annotations:
88
component.drycc.cc/version: {{ .Values.docker_tag }}
9+
{{- range $key, $value := .Values.ingress.annotations }}
10+
{{ $key }}: {{ $value | quote }}
11+
{{- end }}
912
spec:
1013
replicas: 1
1114
strategy:
@@ -58,10 +61,16 @@ spec:
5861
# NOTE(bacongobbler): use drycc/registry_proxy to work around Docker --insecure-registry requirements
5962
- name: "DRYCC_REGISTRY_SERVICE_HOST"
6063
value: "127.0.0.1"
61-
# Environmental variable value for $USE_NATIVE_INGRESS
62-
- name: "USE_NATIVE_INGRESS"
63-
value: "{{ .Values.global.use_ingress }}"
64-
- name: "INGRESS_HOSTNAME"
64+
# Environmental variable value for $INGRESS_ENABLED
65+
- name: "DRYCC_INGRESS_ENABLED"
66+
value: "{{ .Values.ingress.enabled }}"
67+
{{- if index $.Values.ingress "annotations" }}
68+
- name: "DRYCC_INGRESS_CLASS"
69+
value: "{{ (index $.Values.ingress.annotations "kubernetes.io/ingress.class" | default "") }}"
70+
- name: "DRYCC_INGRESS_TLS_ACME"
71+
value: "{{ (index $.Values.ingress.annotations "kubernetes.io/tls-acme" | default "true") }}"
72+
{{- end -}}
73+
- name: "DRYCC_PLATFORM_DOMAIN"
6574
value: "{{ .Values.platform_domain }}"
6675
- name: "K8S_API_VERIFY_TLS"
6776
value: "{{ .Values.k8s_api_verify_tls }}"

charts/controller/templates/controller-ingress.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{ if .Values.global.use_ingress }}
1+
{{ if .Values.ingress.enabled }}
22
apiVersion: extensions/v1beta1
33
kind: Ingress
44
metadata:

charts/controller/values.yaml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,16 @@ global:
5050
registry_service_port: 5555
5151
# Prefix for the imagepull secret created when using private registry
5252
secret_prefix: "private-registry"
53-
# Experimental feature to toggle using kubernetes ingress instead of the Drycc router.
54-
#
55-
# Valid values are:
56-
# - true: The drycc controller will now create Kubernetes ingress rules for each app, and ingress rules will automatically be created for the controller itself.
57-
# - false: The default mode, and the default behavior of Drycc workflow.
58-
use_ingress: false
5953
# Role-Based Access Control for Kubernetes >= 1.5
6054
use_rbac: false
55+
56+
ingress:
57+
# Experimental feature to use Kubernetes ingress instead of Workflow's drycc-router.
58+
#
59+
# Valid values are:
60+
# - true: drycc-router will not be deployed. Workflow will not be usable until a Kubernetes ingress controller is installed.
61+
# - false: drycc-router will be deployed (default).
62+
enabled: false
63+
# annotations:
64+
# kubernetes.io/ingress.class: nginx
65+
# kubernetes.io/tls-acme: 'true'

rootfs/api/models/app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,16 @@ def create(self, *args, **kwargs): # noqa
230230

231231
try:
232232
# In order to create an ingress, we must first have a namespace.
233-
if settings.USE_NATIVE_INGRESS:
233+
if settings.INGRESS_ENABLED:
234234
if ingress == "":
235235
raise ServiceUnavailable('Empty hostname')
236236
try:
237237
self._scheduler.ingress.get(ingress)
238238
except KubeException:
239239
self.log("creating Ingress {}".format(namespace), level=logging.INFO)
240-
self._scheduler.ingress.create(ingress,
241-
namespace,
242-
settings.INGRESS_HOSTNAME)
240+
self._scheduler.ingress.create(
241+
ingress, namespace, settings.PLATFORM_DOMAIN,
242+
settings.INGRESS_CLASS, settings.INGRESS_TLS_ACME)
243243
except KubeException as e:
244244
raise ServiceUnavailable('Could not create Ingress in Kubernetes') from e
245245
try:

rootfs/api/settings/production.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,12 @@
261261
BUILDER_KEY = os.environ.get('DRYCC_BUILDER_KEY', random_secret)
262262

263263
# experimental native ingress
264-
USE_NATIVE_INGRESS = bool(strtobool(
265-
os.environ.get('USE_NATIVE_INGRESS', 'false')))
266-
INGRESS_HOSTNAME = os.environ.get('INGRESS_HOSTNAME', '')
264+
INGRESS_ENABLED = bool(strtobool(
265+
os.environ.get('DRYCC_INGRESS_ENABLED', 'false')))
266+
INGRESS_CLASS = os.environ.get('DRYCC_INGRESS_CLASS', '')
267+
INGRESS_TLS_ACME = bool(strtobool(
268+
os.environ.get('DRYCC_INGRESS_TLS_ACME', 'false')))
269+
PLATFORM_DOMAIN = os.environ.get('DRYCC_PLATFORM_DOMAIN', '')
267270

268271
# k8s image policies
269272
SLUGRUNNER_IMAGE = os.environ.get('SLUGRUNNER_IMAGE_NAME', 'quay.io/drycc/slugrunner:canary') # noqa

rootfs/scheduler/resources/ingress.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,40 @@ def get(self, name=None, **kwargs):
2222

2323
return response
2424

25-
def create(self, ingress, namespace, hostname):
25+
def create(self, ingress, namespace, hostname, ingress_class, tls_acme):
2626
url = "/apis/extensions/v1beta1/namespaces/%s/ingresses" % namespace
2727

2828
data = {
2929
"kind": "Ingress",
3030
"apiVersion": "extensions/v1beta1",
3131
"metadata": {
3232
"name": ingress
33+
"annotations": {
34+
"kubernetes.io/tls-acme": tls_acme
35+
}
3336
},
3437
"spec": {
3538
"rules": [
36-
{"host": ingress + "." + hostname,
37-
"http": {
38-
"paths": [
39-
{"path": "/",
40-
"backend": {
41-
"serviceName": ingress,
42-
"servicePort": 80
43-
}}
44-
]
45-
}
46-
}
39+
{
40+
"host": ingress + "." + hostname,
41+
"http": {
42+
"paths": [
43+
{
44+
"path": "/",
45+
"backend": {
46+
"serviceName": ingress,
47+
"servicePort": 80
48+
}
49+
}
50+
]
51+
}
52+
}
4753
]
4854
}
4955
}
56+
if ingress_class:
57+
data["metadata"]["annotations"].update({
58+
"kubernetes.io/ingress.class": ingress_class})
5059
response = self.http_post(url, json=data)
5160

5261
if not response.status_code == 201:

0 commit comments

Comments
 (0)