From: Taewan Kim Date: Tue, 28 Nov 2023 08:38:08 +0000 (+0900) Subject: Deploy Kserve Adapter through Helm X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=4b15ab19813814ba9ac195dbcec46095fb43fd90;p=aiml-fw%2Faimlfw-dep.git Deploy Kserve Adapter through Helm Issue-ID: AIMLFW-61 Change-Id: Iae37ef52b00c2d9c7b52d43028d39ba79e3b015e Signed-off-by: Taewan Kim --- diff --git a/RECIPE_EXAMPLE/example_recipe_local_images_oran_i_release.yaml b/RECIPE_EXAMPLE/example_recipe_local_images_oran_i_release.yaml new file mode 100644 index 0000000..f6c3d20 --- /dev/null +++ b/RECIPE_EXAMPLE/example_recipe_local_images_oran_i_release.yaml @@ -0,0 +1,87 @@ +# ================================================================================== +# +# Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== + +#------------------------------------------------------------------------- +# Global common setting +#------------------------------------------------------------------------- + +traininghost: + ip_address: +tm: + image: + repository: tm + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +leofs: + image: + repository: leofs + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +dataextraction: + image: + repository: data-extraction + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +datalake: + influxdb: + host: + port: + orgname: + bucket: + token: + +kfadapter: + image: + repository: kfadapter + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +aimldashboard: + image: + repository: aiml-dashboard + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + host: + tm_host: "localhost" + notebook_host: "localhost" + debug: "\"false\"" + +aimlnotebook: + image: + repository: aiml-notebook + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +kserveadapter: + image: + repository: kserve-adapter + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "1.0.0" + ric_dms: + ip: + port: 8000 diff --git a/aimlfw-common/Common-Template/helm/aimlfw-common/templates/_kserve-adapter.tpl b/aimlfw-common/Common-Template/helm/aimlfw-common/templates/_kserve-adapter.tpl new file mode 100644 index 0000000..605ca2b --- /dev/null +++ b/aimlfw-common/Common-Template/helm/aimlfw-common/templates/_kserve-adapter.tpl @@ -0,0 +1,84 @@ +# ================================================================================== +# +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== + +{{/* +Expand the name of the chart. +*/}} +{{- define "kserve-adapter.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "kserve-adapter.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "kserve-adapter.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "kserve-adapter.labels" -}} +helm.sh/chart: {{ include "kserve-adapter.chart" . }} +{{ include "kserve-adapter.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "kserve-adapter.selectorLabels" -}} +app.kubernetes.io/name: {{ include "kserve-adapter.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "kserve-adapter.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "kserve-adapter.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{- define "common.serviceport.kserve-adapter.http" -}}10000{{- end -}} +{{- define "common.serviceport.kserve-adapter.targetport" -}}10000{{- end -}} +{{- define "common.serviceport.kserve-adapter.external" -}}31000{{- end -}} diff --git a/aimlfw-common/Common-Template/helm/aimlfw-common/templates/_namespace.tpl b/aimlfw-common/Common-Template/helm/aimlfw-common/templates/_namespace.tpl index 5ac915e..8eebaf5 100644 --- a/aimlfw-common/Common-Template/helm/aimlfw-common/templates/_namespace.tpl +++ b/aimlfw-common/Common-Template/helm/aimlfw-common/templates/_namespace.tpl @@ -18,3 +18,4 @@ {{- define "common.namespace.platform" -}}traininghost{{- end -}} {{- define "common.namespace.kubeflow" -}}kubeflow{{- end -}} +{{- define "common.namespace.kserve" -}}ricips{{- end -}} diff --git a/bin/docker_image_build_local.sh b/bin/docker_image_build_local.sh index 9ffe017..2c003f3 100755 --- a/bin/docker_image_build_local.sh +++ b/bin/docker_image_build_local.sh @@ -22,12 +22,14 @@ git clone "https://gerrit.o-ran-sc.org/r/aiml-fw/awmf/tm" git clone "https://gerrit.o-ran-sc.org/r/aiml-fw/athp/data-extraction" git clone "https://gerrit.o-ran-sc.org/r/aiml-fw/athp/tps/kubeflow-adapter" git clone "https://gerrit.o-ran-sc.org/r/portal/aiml-dashboard" +git clone "https://gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter" docker build -f tm/Dockerfile -t tm tm/. docker build -f data-extraction/Dockerfile -t data-extraction data-extraction/. docker build -f kubeflow-adapter/Dockerfile -t kfadapter kubeflow-adapter/. docker build -f aiml-dashboard/Dockerfile -t aiml-dashboard aiml-dashboard/. docker build -f aiml-dashboard/kf-pipelines/Dockerfile -t aiml-notebook aiml-dashboard/kf-pipelines/. +docker build -f kserve-adapter/Dockerfile -t kserve-adapter:1.0.0 kserve-adapter/. cd - rm -Rf /tmp/gerrit_code diff --git a/bin/docker_images_delete_local.sh b/bin/docker_images_delete_local.sh index 5b41fa5..145bcc1 100755 --- a/bin/docker_images_delete_local.sh +++ b/bin/docker_images_delete_local.sh @@ -20,3 +20,4 @@ docker rmi data-extraction docker rmi kfadapter docker rmi aiml-dashboard docker rmi aiml-notebook +docker rmi kserve-adapter:1.0.0 diff --git a/bin/install.sh b/bin/install.sh index d00133a..e711063 100755 --- a/bin/install.sh +++ b/bin/install.sh @@ -73,8 +73,6 @@ fi COMPONENTS="tm data-extraction kfadapter aiml-dashboard aiml-notebook" - - for component in $COMPONENTS; do helm dep up helm/$component echo "Installing $component" diff --git a/bin/install_kserve_inference.sh b/bin/install_kserve_inference.sh new file mode 100755 index 0000000..447ad3a --- /dev/null +++ b/bin/install_kserve_inference.sh @@ -0,0 +1,80 @@ +# ================================================================================== +# +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== +#!/bin/bash + +IS_HELM3=$(helm version --short|grep -e "^v3") + +while [ -n "$1" ]; do # while loop starts + + case "$1" in + + -f) OVERRIDEYAML=$2 + shift + ;; + -c) LIST_OF_COMPONENTS=$2 + shift + ;; + -o) KERNEL_OPTIMIZATION=true + ;; + *) echo "Option $1 not recognized" ;; # In case you typed a different option other than a,b,c + + esac + + shift + +done + +if [ -z "$OVERRIDEYAML" ];then + echo "****************************************************************************************************************" + echo " ERROR " + echo "****************************************************************************************************************" + echo "Kserve deployment without deployment recipe is currently disabled. Please specify an recipe with the -f option." + echo "****************************************************************************************************************" + exit 1 +fi + +if [ -z $IS_HELM3 ] +then + echo "****************************************************************************************************************" + echo " ERROR " + echo "****************************************************************************************************************" + echo "Kserve deployment expects helm 3 installed" + echo "****************************************************************************************************************" + exit 1 +else + HAS_COMMON_PACKAGE=$(helm search repo local/aimlfw-common | grep aimlfw-common) +fi + +if [ -z "$HAS_COMMON_PACKAGE" ];then + bin/install_common_templates_to_helm.sh + if [ -z $(helm search repo local/aimlfw-common | grep aimlfw-common) ];then + echo "****************************************************************************************************************" + echo " ERROR " + echo "****************************************************************************************************************" + echo "Can't locate the aimlfw-common helm package in the local repo. Please make sure that it is properly installed." + echo "****************************************************************************************************************" + exit 1 + fi +fi + +kubectl create namespace ricips +bin/install_kserve.sh + +helm dep up helm/kserve-adapter +echo "Installing kserve-adapter" +helm install kserve-adapter helm/kserve-adapter -f $OVERRIDEYAML diff --git a/bin/uninstall_kserve_inference.sh b/bin/uninstall_kserve_inference.sh new file mode 100755 index 0000000..b769d76 --- /dev/null +++ b/bin/uninstall_kserve_inference.sh @@ -0,0 +1,21 @@ +# ================================================================================== +# +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== +echo "Uninstalling kserve-adapter" +helm uninstall kserve-adapter +bin/uninstall_kserve.sh +kubectl delete namespace ricips diff --git a/bin/uninstall_traininghost.sh b/bin/uninstall_traininghost.sh index 00a4ff1..5471605 100755 --- a/bin/uninstall_traininghost.sh +++ b/bin/uninstall_traininghost.sh @@ -27,4 +27,4 @@ bin/uninstall_rolebindings.sh kubectl delete namespace traininghost tools/nfs/delete_nfs_subdir_external_provisioner.sh -tools/kubernetes/uninstall_k8s.sh \ No newline at end of file +tools/kubernetes/uninstall_k8s.sh diff --git a/helm/kserve-adapter/Chart.yaml b/helm/kserve-adapter/Chart.yaml new file mode 100644 index 0000000..3547281 --- /dev/null +++ b/helm/kserve-adapter/Chart.yaml @@ -0,0 +1,23 @@ +# ================================================================================== +# +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== +apiVersion: v1 +name: kserve-adapter +description: Helm chart for Kserve Adapter +type: application +version: 1.0.0 +appVersion: "1.0.0" diff --git a/helm/kserve-adapter/requirements.yaml b/helm/kserve-adapter/requirements.yaml new file mode 100644 index 0000000..ca1af17 --- /dev/null +++ b/helm/kserve-adapter/requirements.yaml @@ -0,0 +1,21 @@ +# ================================================================================== +# +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== +dependencies: + - name: aimlfw-common + version: 1.0.0 + repository: "@local" diff --git a/helm/kserve-adapter/templates/cluster-role.yaml b/helm/kserve-adapter/templates/cluster-role.yaml new file mode 100644 index 0000000..e84e99d --- /dev/null +++ b/helm/kserve-adapter/templates/cluster-role.yaml @@ -0,0 +1,48 @@ +# ================================================================================== +# +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: kserver-adapter-role +rules: +- apiGroups: + - "serving.kserve.io" + resources: + - inferenceservices + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: kserver-adapter-rolebinding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: kserver-adapter-role +subjects: + - kind: ServiceAccount + name: default + namespace: {{ include "common.namespace.kserve" . }} diff --git a/helm/kserve-adapter/templates/configmap.yaml b/helm/kserve-adapter/templates/configmap.yaml new file mode 100644 index 0000000..3b7a9d3 --- /dev/null +++ b/helm/kserve-adapter/templates/configmap.yaml @@ -0,0 +1,26 @@ +# ================================================================================== +# +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== +kind: ConfigMap +apiVersion: v1 +metadata: + name: kserve-adapter-configmap + namespace: {{ include "common.namespace.kserve" . }} +data: + # Configuration values can be set as key-value properties + RIC_DMS_IP: "{{ .Values.kserveadapter.ric_dms.ip }}" + RIC_DMS_PORT: "{{ .Values.kserveadapter.ric_dms.port }}" diff --git a/helm/kserve-adapter/templates/deployment.yaml b/helm/kserve-adapter/templates/deployment.yaml new file mode 100644 index 0000000..c4f8032 --- /dev/null +++ b/helm/kserve-adapter/templates/deployment.yaml @@ -0,0 +1,55 @@ +# ================================================================================== +# +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "kserve-adapter.fullname" . }} + namespace: {{ include "common.namespace.kserve" . }} + labels: + {{- include "kserve-adapter.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "kserve-adapter.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "kserve-adapter.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.kserveadapter.image.repository }}:{{ .Values.kserveadapter.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.kserveadapter.image.pullPolicy }} + ports: + - name: serviceport + containerPort: {{ include "common.serviceport.kserve-adapter.http" . }} + protocol: TCP + command: ["/root/kserve-adapter"] + envFrom: + - configMapRef: + name: kserve-adapter-configmap diff --git a/helm/kserve-adapter/templates/service.yaml b/helm/kserve-adapter/templates/service.yaml new file mode 100644 index 0000000..8f50ef3 --- /dev/null +++ b/helm/kserve-adapter/templates/service.yaml @@ -0,0 +1,34 @@ +# ================================================================================== +# +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== +apiVersion: v1 +kind: Service +metadata: + name: {{ include "kserve-adapter.fullname" . }} + namespace: {{ include "common.namespace.kserve" . }} + labels: + {{- include "kserve-adapter.labels" . | nindent 4 }} +spec: + type: NodePort + ports: + - port: {{ include "common.serviceport.kserve-adapter.http" . }} + targetPort: {{ include "common.serviceport.kserve-adapter.targetport" . }} + nodePort: {{ include "common.serviceport.kserve-adapter.external" . }} + protocol: TCP + name: serviceport + selector: + {{- include "kserve-adapter.selectorLabels" . | nindent 4 }} diff --git a/helm/kserve-adapter/values.yaml b/helm/kserve-adapter/values.yaml new file mode 100644 index 0000000..04a83d5 --- /dev/null +++ b/helm/kserve-adapter/values.yaml @@ -0,0 +1,24 @@ +# ================================================================================== +# +# Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== +# Default values for kserve-adapter component. + +image: + repository: kserve-adapter + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "1.0.0"