diff --git a/doc/source/examples/go_example.nblink b/doc/source/examples/go_example.nblink index 925f8a78a1..a81b861945 100644 --- a/doc/source/examples/go_example.nblink +++ b/doc/source/examples/go_example.nblink @@ -1,3 +1,3 @@ { - "path": "../../../examples/wrappers/go/SeldonGoModel.ipynb" + "path": "../../../incubating/wrappers/s2i/go/SeldonGoModel.ipynb" } diff --git a/doc/source/workflow/install.md b/doc/source/workflow/install.md index 0dae10fa18..0ffd6df5ac 100644 --- a/doc/source/workflow/install.md +++ b/doc/source/workflow/install.md @@ -81,6 +81,7 @@ The [Kustomize](https://github.com/kubernetes-sigs/kustomize) installation can b To use the template directly there is a Makefile which has a set of useful commands: +For kubernetes <1.15 comment the patch_object_selector [here](https://github.com/SeldonIO/seldon-core/blob/master/operator/config/webhook/kustomization.yaml) Install cert-manager @@ -122,7 +123,11 @@ See our [upgrading notes](../reference/upgrading.md) ## Advanced Usage -### Install Seldon Core in a single namespace +### Install Seldon Core in a single namespace (version >=1.0) + +**You will need a k8s cluster >= 1.15** + +#### Helm You can install the Seldon Core Operator so it only manages resources in its namespace. An example to install in a namespace `seldon-ns1` is shown below: @@ -146,12 +151,27 @@ helm install seldon-namespaced seldon-core-operator --repo https://storage.goog We set `crd.create=true` to create the CRD. If you are installing a Seldon Core Operator after you have installed a previous Seldon Core Operator on the same cluster you will need to set `crd.create=false`. + +#### Kustomize + +An example install is provided in the Makefile in the Operator folder: + +``` +make deploy-namespaced1 +``` + + See the [multiple server example notebook](../examples/multiple_operators.html). -### Label focused Seldon Core Operator +### Label focused Seldon Core Operator (version >=1.0) + +**You will need a k8s cluster >= 1.15** You can install the Seldon Core Operator so it manages only SeldonDeployments with the label `seldon.io/controller-id` where the value of the label matches the controller-id of the running operator. An example for a namespace `seldon-id1` is shown below: + +#### Helm + ```bash kubectl create namespace seldon-id1 ``` @@ -171,5 +191,15 @@ helm install seldon-controllerid seldon-core-operator --repo https://storage.go We set `crd.create=true` to create the CRD. If you are installing a Seldon Core Operator after you have installed a previous Seldon Core Operator on the same cluster you will need to set `crd.create=false`. +For kustomize you will need to uncomment the patch_object_selector [here](https://github.com/SeldonIO/seldon-core/blob/master/operator/config/webhook/kustomization.yaml) + +#### Kustomize + +An example install is provided in the Makefile in the Operator folder: + +``` +make deploy-controllerid +``` + See the [multiple server example notebook](../examples/multiple_operators.html). diff --git a/helm-charts/seldon-core-operator/templates/webhook.yaml b/helm-charts/seldon-core-operator/templates/webhook.yaml index ce7de50a9e..e0a1b7d9a5 100644 --- a/helm-charts/seldon-core-operator/templates/webhook.yaml +++ b/helm-charts/seldon-core-operator/templates/webhook.yaml @@ -24,23 +24,27 @@ webhooks: path: /validate-machinelearning-seldon-io-v1alpha2-seldondeployment failurePolicy: Fail name: vseldondeployment.kb.io +{{- if semverCompare ">=1.15.0" .Capabilities.KubeVersion.Version }} {{- if not .Values.singleNamespace }} namespaceSelector: matchExpressions: - key: seldon.io/controller-id operator: DoesNotExist {{- end }} +{{- end }} {{- if .Values.singleNamespace }} namespaceSelector: matchLabels: seldon.io/controller-id: {{ .Release.Namespace }} {{- end }} +{{- if semverCompare ">=1.15.0" .Capabilities.KubeVersion.Version }} {{- if not .Values.controllerId }} objectSelector: matchExpressions: - key: seldon.io/controller-id operator: DoesNotExist {{- end }} +{{- end }} {{- if .Values.controllerId }} objectSelector: matchLabels: @@ -79,23 +83,27 @@ webhooks: path: /mutate-machinelearning-seldon-io-v1alpha2-seldondeployment failurePolicy: Fail name: mseldondeployment.kb.io +{{- if semverCompare ">=1.15.0" .Capabilities.KubeVersion.Version }} {{- if not .Values.singleNamespace }} namespaceSelector: matchExpressions: - key: seldon.io/controller-id operator: DoesNotExist {{- end }} +{{- end }} {{- if .Values.singleNamespace }} namespaceSelector: matchLabels: seldon.io/controller-id: {{ .Release.Namespace }} {{- end }} +{{- if semverCompare ">=1.15.0" .Capabilities.KubeVersion.Version }} {{- if not .Values.controllerId }} objectSelector: matchExpressions: - key: seldon.io/controller-id operator: DoesNotExist {{- end }} +{{- end }} {{- if .Values.controllerId }} objectSelector: matchLabels: diff --git a/notebooks/seldon_core_setup.ipynb b/notebooks/seldon_core_setup.ipynb index 43039d9329..9a739cbe95 100644 --- a/notebooks/seldon_core_setup.ipynb +++ b/notebooks/seldon_core_setup.ipynb @@ -29,57 +29,24 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "namespace/seldon created\r\n" - ] - } - ], + "outputs": [], "source": [ "!kubectl create namespace seldon" ] }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Context \"gke_dev-george_us-central1-a_standard-cluster-1\" modified.\r\n" - ] - } - ], + "outputs": [], "source": [ "!kubectl config set-context $(kubectl config current-context) --namespace=seldon" ] }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "clusterrolebinding.rbac.authorization.k8s.io/kube-system-cluster-admin created\r\n" - ] - } - ], - "source": [ - "!kubectl create clusterrolebinding kube-system-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:default" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -95,87 +62,27 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\"stable\" has been added to your repositories\r\n" - ] - } - ], + "outputs": [], "source": [ "!helm repo add stable https://kubernetes-charts.storage.googleapis.com/" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hang tight while we grab the latest from your chart repositories...\n", - "...Successfully got an update from the \"jetstack\" chart repository\n", - "...Successfully got an update from the \"stable\" chart repository\n", - "Update Complete. ⎈ Happy Helming!⎈ \n" - ] - } - ], + "outputs": [], "source": [ "!helm repo update" ] }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "manifest_sorter.go:175: info: skipping unknown hook: \"crd-install\"\n", - "manifest_sorter.go:175: info: skipping unknown hook: \"crd-install\"\n", - "manifest_sorter.go:175: info: skipping unknown hook: \"crd-install\"\n", - "manifest_sorter.go:175: info: skipping unknown hook: \"crd-install\"\n", - "manifest_sorter.go:175: info: skipping unknown hook: \"crd-install\"\n", - "manifest_sorter.go:175: info: skipping unknown hook: \"crd-install\"\n", - "manifest_sorter.go:175: info: skipping unknown hook: \"crd-install\"\n", - "manifest_sorter.go:175: info: skipping unknown hook: \"crd-install\"\n", - "manifest_sorter.go:175: info: skipping unknown hook: \"crd-install\"\n", - "manifest_sorter.go:175: info: skipping unknown hook: \"crd-install\"\n", - "manifest_sorter.go:175: info: skipping unknown hook: \"crd-install\"\n", - "manifest_sorter.go:175: info: skipping unknown hook: \"crd-install\"\n", - "manifest_sorter.go:175: info: skipping unknown hook: \"crd-install\"\n", - "NAME: ambassador\n", - "LAST DEPLOYED: Fri Dec 6 11:31:58 2019\n", - "NAMESPACE: seldon\n", - "STATUS: deployed\n", - "REVISION: 1\n", - "NOTES:\n", - "Congratulations! You've successfully installed Ambassador.\n", - "\n", - "For help, visit our Slack at https://d6e.co/slack or view the documentation online at https://www.getambassador.io.\n", - "\n", - "To get the IP address of Ambassador, run the following commands:\n", - "NOTE: It may take a few minutes for the LoadBalancer IP to be available.\n", - " You can watch the status of by running 'kubectl get svc -w --namespace seldon ambassador'\n", - "\n", - " On GKE/Azure:\n", - " export SERVICE_IP=$(kubectl get svc --namespace seldon ambassador -o jsonpath='{.status.loadBalancer.ingress[0].ip}')\n", - "\n", - " On AWS:\n", - " export SERVICE_IP=$(kubectl get svc --namespace seldon ambassador -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')\n", - "\n", - " echo http://$SERVICE_IP:\n" - ] - } - ], + "outputs": [], "source": [ "!helm install ambassador stable/ambassador --set crds.keep=false" ] @@ -189,20 +96,9 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Waiting for deployment \"ambassador\" rollout to finish: 0 of 3 updated replicas are available...\n", - "Waiting for deployment \"ambassador\" rollout to finish: 1 of 3 updated replicas are available...\n", - "Waiting for deployment \"ambassador\" rollout to finish: 2 of 3 updated replicas are available...\n", - "deployment \"ambassador\" successfully rolled out\n" - ] - } - ], + "outputs": [], "source": [ "!kubectl rollout status deployment.apps/ambassador" ] @@ -240,17 +136,9 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "namespace/seldon-system created\r\n" - ] - } - ], + "outputs": [], "source": [ "!kubectl create namespace seldon-system" ] @@ -264,22 +152,9 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "NAME: seldon-core\r\n", - "LAST DEPLOYED: Fri Dec 6 11:33:00 2019\r\n", - "NAMESPACE: seldon-system\r\n", - "STATUS: deployed\r\n", - "REVISION: 1\r\n", - "TEST SUITE: None\r\n" - ] - } - ], + "outputs": [], "source": [ "!helm install seldon-core seldon-core-operator --repo https://storage.googleapis.com/seldon-charts --set ambassador.enabled=true --set usageMetrics.enabled=true --namespace seldon-system" ] @@ -309,17 +184,9 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "deployment \"seldon-controller-manager\" successfully rolled out\r\n" - ] - } - ], + "outputs": [], "source": [ "!kubectl rollout status deploy/seldon-controller-manager -n seldon-system" ] @@ -348,7 +215,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.4" + "version": "3.6.8" } }, "nbformat": 4, diff --git a/operator/config/webhook/kustomization.yaml b/operator/config/webhook/kustomization.yaml index c7bab78eb0..3432cc0658 100644 --- a/operator/config/webhook/kustomization.yaml +++ b/operator/config/webhook/kustomization.yaml @@ -5,5 +5,6 @@ resources: configurations: - kustomizeconfig.yaml +# Comment this if you have a k8s cluster < 1.15 and want to use namespaced or labelled operators patchesStrategicMerge: - patch_object_selector.yaml diff --git a/operator/helm/split_resources.py b/operator/helm/split_resources.py index bca218e198..c501a11e4c 100644 --- a/operator/helm/split_resources.py +++ b/operator/helm/split_resources.py @@ -19,6 +19,7 @@ HELM_SA_IF_START = '{{- if .Values.serviceAccount.create -}}\n' 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.Version }}\n' #HELM_SECRET_IF_START = '{{- if .Values.webhook.secretProvided -}}\n' HELM_IF_END = '{{- end }}\n' @@ -198,8 +199,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_NOT_SINGLE_NAMESPACE_IF_START+r"\1"+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_NOT_CONTROLLERID_IF_START+r"\1"+HELM_IF_END+HELM_CONTROLLERID_IF_START+objectSelector+HELM_IF_END,webhookData, re.M) + 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) + 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" with open(filename, 'w') as outfile: