From c9f6db41be9fbf1b023628bcece707c9e71a05d8 Mon Sep 17 00:00:00 2001 From: cliveseldon Date: Thu, 6 Feb 2020 15:20:58 +0000 Subject: [PATCH 1/2] kubeflow requirements --- .../deployment_seldon-controller-manager.yaml | 1 + .../templates/webhook.yaml | 24 +++++++++++++++++++ operator/config/manager/manager.yaml | 2 ++ operator/helm/split_resources.py | 4 +++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/helm-charts/seldon-core-operator/templates/deployment_seldon-controller-manager.yaml b/helm-charts/seldon-core-operator/templates/deployment_seldon-controller-manager.yaml index 5f02bee22b..cf62b669ac 100644 --- a/helm-charts/seldon-core-operator/templates/deployment_seldon-controller-manager.yaml +++ b/helm-charts/seldon-core-operator/templates/deployment_seldon-controller-manager.yaml @@ -22,6 +22,7 @@ spec: metadata: annotations: prometheus.io/scrape: 'true' + sidecar.istio.io/inject: 'false' labels: app: seldon app.kubernetes.io/instance: seldon1 diff --git a/helm-charts/seldon-core-operator/templates/webhook.yaml b/helm-charts/seldon-core-operator/templates/webhook.yaml index 71d0918bbb..a1388010a3 100644 --- a/helm-charts/seldon-core-operator/templates/webhook.yaml +++ b/helm-charts/seldon-core-operator/templates/webhook.yaml @@ -30,6 +30,10 @@ webhooks: matchExpressions: - key: seldon.io/controller-id operator: DoesNotExist +{{- if .Values.kubeflow }} + matchLabels: + serving.kubeflow.org/inferenceservice: enabled +{{- end }} {{- end }} {{- end }} {{- if .Values.singleNamespace }} @@ -74,6 +78,10 @@ webhooks: matchExpressions: - key: seldon.io/controller-id operator: DoesNotExist +{{- if .Values.kubeflow }} + matchLabels: + serving.kubeflow.org/inferenceservice: enabled +{{- end }} {{- end }} {{- end }} {{- if .Values.singleNamespace }} @@ -118,6 +126,10 @@ webhooks: matchExpressions: - key: seldon.io/controller-id operator: DoesNotExist +{{- if .Values.kubeflow }} + matchLabels: + serving.kubeflow.org/inferenceservice: enabled +{{- end }} {{- end }} {{- end }} {{- if .Values.singleNamespace }} @@ -177,6 +189,10 @@ webhooks: matchExpressions: - key: seldon.io/controller-id operator: DoesNotExist +{{- if .Values.kubeflow }} + matchLabels: + serving.kubeflow.org/inferenceservice: enabled +{{- end }} {{- end }} {{- end }} {{- if .Values.singleNamespace }} @@ -221,6 +237,10 @@ webhooks: matchExpressions: - key: seldon.io/controller-id operator: DoesNotExist +{{- if .Values.kubeflow }} + matchLabels: + serving.kubeflow.org/inferenceservice: enabled +{{- end }} {{- end }} {{- end }} {{- if .Values.singleNamespace }} @@ -265,6 +285,10 @@ webhooks: matchExpressions: - key: seldon.io/controller-id operator: DoesNotExist +{{- if .Values.kubeflow }} + matchLabels: + serving.kubeflow.org/inferenceservice: enabled +{{- end }} {{- end }} {{- end }} {{- if .Values.singleNamespace }} diff --git a/operator/config/manager/manager.yaml b/operator/config/manager/manager.yaml index 3c4f883fdb..a3840301fb 100644 --- a/operator/config/manager/manager.yaml +++ b/operator/config/manager/manager.yaml @@ -19,6 +19,8 @@ spec: replicas: 1 template: metadata: + annotations: + sidecar.istio.io/inject: 'false' labels: control-plane: seldon-controller-manager spec: diff --git a/operator/helm/split_resources.py b/operator/helm/split_resources.py index d592215b3c..815b60143f 100644 --- a/operator/helm/split_resources.py +++ b/operator/helm/split_resources.py @@ -20,6 +20,7 @@ HELM_CERTMANAGER_IF_START = '{{- if .Values.certManager.enabled -}}\n' HELM_NOT_CERTMANAGER_IF_START = '{{- if not .Values.certManager.enabled -}}\n' HELM_VERSION_IF_START= '{{- if semverCompare ">=1.15.0" .Capabilities.KubeVersion.GitVersion }}\n' +HELM_KUBEFLOW_IF_START='{{- if .Values.kubeflow }}\n' #HELM_SECRET_IF_START = '{{- if .Values.webhook.secretProvided -}}\n' HELM_IF_END = '{{- end }}\n' @@ -220,7 +221,8 @@ def helm_release(value: str): # Write webhook related data in 1 file namespaceSelector = " namespaceSelector:\n matchLabels:\n seldon.io/controller-id: " + helm_release("Namespace") + "\n" objectSelector = " objectSelector:\n matchLabels:\n seldon.io/controller-id: " + helm_value("controllerId") + "\n" - webhookData = re.sub(r"(.*namespaceSelector:\n.*matchExpressions:\n.*\n.*\n)",HELM_VERSION_IF_START+HELM_NOT_SINGLE_NAMESPACE_IF_START+r"\1"+HELM_IF_END+HELM_IF_END+HELM_SINGLE_NAMESPACE_IF_START+namespaceSelector+HELM_IF_END,webhookData, re.M) + kubeflowSelector = " matchLabels:\n serving.kubeflow.org/inferenceservice: enabled\n" + webhookData = re.sub(r"(.*namespaceSelector:\n.*matchExpressions:\n.*\n.*\n)",HELM_VERSION_IF_START+HELM_NOT_SINGLE_NAMESPACE_IF_START+r"\1"+HELM_KUBEFLOW_IF_START+kubeflowSelector+HELM_IF_END+HELM_IF_END+HELM_IF_END+HELM_SINGLE_NAMESPACE_IF_START+namespaceSelector+HELM_IF_END,webhookData, re.M) webhookData = re.sub(r"(.*objectSelector:\n.*matchExpressions:\n.*\n.*\n)",HELM_VERSION_IF_START+HELM_NOT_CONTROLLERID_IF_START+r"\1"+HELM_IF_END+HELM_IF_END+HELM_CONTROLLERID_IF_START+objectSelector+HELM_IF_END,webhookData, re.M) filename = args.folder + "/" + "webhook.yaml" From 150f1f6206a8d14062029311795e0b06d087b003 Mon Sep 17 00:00:00 2001 From: cliveseldon Date: Fri, 7 Feb 2020 08:01:19 +0000 Subject: [PATCH 2/2] webhook changes for kubeflow --- .../seldon-core-operator/templates/webhook.yaml | 12 ++++++++++++ helm-charts/seldon-core-operator/values.yaml | 2 ++ operator/helm/split_resources.py | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/helm-charts/seldon-core-operator/templates/webhook.yaml b/helm-charts/seldon-core-operator/templates/webhook.yaml index a1388010a3..28284df8ab 100644 --- a/helm-charts/seldon-core-operator/templates/webhook.yaml +++ b/helm-charts/seldon-core-operator/templates/webhook.yaml @@ -41,6 +41,7 @@ webhooks: matchLabels: seldon.io/controller-id: {{ .Release.Namespace }} {{- end }} +{{- if not .Values.kubeflow }} {{- if semverCompare ">=1.15.0" .Capabilities.KubeVersion.GitVersion }} {{- if not .Values.controllerId }} objectSelector: @@ -53,6 +54,7 @@ webhooks: objectSelector: matchLabels: seldon.io/controller-id: {{ .Values.controllerId }} +{{- end }} {{- end }} rules: - apiGroups: @@ -89,6 +91,7 @@ webhooks: matchLabels: seldon.io/controller-id: {{ .Release.Namespace }} {{- end }} +{{- if not .Values.kubeflow }} {{- if semverCompare ">=1.15.0" .Capabilities.KubeVersion.GitVersion }} {{- if not .Values.controllerId }} objectSelector: @@ -101,6 +104,7 @@ webhooks: objectSelector: matchLabels: seldon.io/controller-id: {{ .Values.controllerId }} +{{- end }} {{- end }} rules: - apiGroups: @@ -137,6 +141,7 @@ webhooks: matchLabels: seldon.io/controller-id: {{ .Release.Namespace }} {{- end }} +{{- if not .Values.kubeflow }} {{- if semverCompare ">=1.15.0" .Capabilities.KubeVersion.GitVersion }} {{- if not .Values.controllerId }} objectSelector: @@ -149,6 +154,7 @@ webhooks: objectSelector: matchLabels: seldon.io/controller-id: {{ .Values.controllerId }} +{{- end }} {{- end }} rules: - apiGroups: @@ -200,6 +206,7 @@ webhooks: matchLabels: seldon.io/controller-id: {{ .Release.Namespace }} {{- end }} +{{- if not .Values.kubeflow }} {{- if semverCompare ">=1.15.0" .Capabilities.KubeVersion.GitVersion }} {{- if not .Values.controllerId }} objectSelector: @@ -212,6 +219,7 @@ webhooks: objectSelector: matchLabels: seldon.io/controller-id: {{ .Values.controllerId }} +{{- end }} {{- end }} rules: - apiGroups: @@ -248,6 +256,7 @@ webhooks: matchLabels: seldon.io/controller-id: {{ .Release.Namespace }} {{- end }} +{{- if not .Values.kubeflow }} {{- if semverCompare ">=1.15.0" .Capabilities.KubeVersion.GitVersion }} {{- if not .Values.controllerId }} objectSelector: @@ -260,6 +269,7 @@ webhooks: objectSelector: matchLabels: seldon.io/controller-id: {{ .Values.controllerId }} +{{- end }} {{- end }} rules: - apiGroups: @@ -296,6 +306,7 @@ webhooks: matchLabels: seldon.io/controller-id: {{ .Release.Namespace }} {{- end }} +{{- if not .Values.kubeflow }} {{- if semverCompare ">=1.15.0" .Capabilities.KubeVersion.GitVersion }} {{- if not .Values.controllerId }} objectSelector: @@ -308,6 +319,7 @@ webhooks: objectSelector: matchLabels: seldon.io/controller-id: {{ .Values.controllerId }} +{{- end }} {{- end }} rules: - apiGroups: diff --git a/helm-charts/seldon-core-operator/values.yaml b/helm-charts/seldon-core-operator/values.yaml index e0bdea5884..c38ffed696 100644 --- a/helm-charts/seldon-core-operator/values.yaml +++ b/helm-charts/seldon-core-operator/values.yaml @@ -51,6 +51,8 @@ istio: enabled: false gateway: seldon-gateway tlsMode: '' +kubeflow: + false predictiveUnit: port: 9000 predictor_servers: diff --git a/operator/helm/split_resources.py b/operator/helm/split_resources.py index 815b60143f..b6f6bd7f36 100644 --- a/operator/helm/split_resources.py +++ b/operator/helm/split_resources.py @@ -21,6 +21,7 @@ HELM_NOT_CERTMANAGER_IF_START = '{{- if not .Values.certManager.enabled -}}\n' HELM_VERSION_IF_START= '{{- if semverCompare ">=1.15.0" .Capabilities.KubeVersion.GitVersion }}\n' HELM_KUBEFLOW_IF_START='{{- if .Values.kubeflow }}\n' +HELM_KUBEFLOW_IF_NOT_START='{{- if not .Values.kubeflow }}\n' #HELM_SECRET_IF_START = '{{- if .Values.webhook.secretProvided -}}\n' HELM_IF_END = '{{- end }}\n' @@ -223,7 +224,7 @@ def helm_release(value: str): objectSelector = " objectSelector:\n matchLabels:\n seldon.io/controller-id: " + helm_value("controllerId") + "\n" kubeflowSelector = " matchLabels:\n serving.kubeflow.org/inferenceservice: enabled\n" webhookData = re.sub(r"(.*namespaceSelector:\n.*matchExpressions:\n.*\n.*\n)",HELM_VERSION_IF_START+HELM_NOT_SINGLE_NAMESPACE_IF_START+r"\1"+HELM_KUBEFLOW_IF_START+kubeflowSelector+HELM_IF_END+HELM_IF_END+HELM_IF_END+HELM_SINGLE_NAMESPACE_IF_START+namespaceSelector+HELM_IF_END,webhookData, re.M) - webhookData = re.sub(r"(.*objectSelector:\n.*matchExpressions:\n.*\n.*\n)",HELM_VERSION_IF_START+HELM_NOT_CONTROLLERID_IF_START+r"\1"+HELM_IF_END+HELM_IF_END+HELM_CONTROLLERID_IF_START+objectSelector+HELM_IF_END,webhookData, re.M) + webhookData = re.sub(r"(.*objectSelector:\n.*matchExpressions:\n.*\n.*\n)",HELM_KUBEFLOW_IF_NOT_START+HELM_VERSION_IF_START+HELM_NOT_CONTROLLERID_IF_START+r"\1"+HELM_IF_END+HELM_IF_END+HELM_CONTROLLERID_IF_START+objectSelector+HELM_IF_END+HELM_IF_END,webhookData, re.M) filename = args.folder + "/" + "webhook.yaml" with open(filename, 'w') as outfile: