From 39cfd9ee36fd4b6d2cb4142d8359a9e2da9e4ced Mon Sep 17 00:00:00 2001 From: tjandy98 <3953059+tjandy98@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:57:05 +0800 Subject: [PATCH 1/9] Update example Signed-off-by: tjandy98 <3953059+tjandy98@users.noreply.github.com> --- docs/modelserving/storage/gcs/gcs.md | 43 ++++++++++++++-------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/docs/modelserving/storage/gcs/gcs.md b/docs/modelserving/storage/gcs/gcs.md index 4db6cfbc7..8fe9865a3 100644 --- a/docs/modelserving/storage/gcs/gcs.md +++ b/docs/modelserving/storage/gcs/gcs.md @@ -17,13 +17,14 @@ e.g. ```gs://kfserving-examples/models/tensorflow/flowers``` KServe supports authenticating using Google Service Account Key -### Create a Service Account Key +### Create a Google Service Account Key * To create a Service Account Key follow the steps [here](https://cloud.google.com/iam/docs/keys-create-delete#iam-service-account-keys-create-console). * Base64 encode the generated Service Account Key file -## Create Google Secret +## Create Secret and attach to Service Account¶ + ### Create secret === "yaml" @@ -33,39 +34,39 @@ kind: Secret metadata: name: storage-config type: Opaque -stringData: - gcs: | - { - "type": "gs", - "bucket": "mlpipeline", - "base64_service_account": "c2VydmljZWFjY291bnQ=" # base64 encoded value of the credential file - } +data: + gcloud-application-credentials.json: <base64 encoded value of the credential file> ``` -=== "kubectl" -```bash -kubectl apply -f create-gcs-secret.yaml +### Attach secret to a service account +=== "yaml" +```yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: sa +secrets: +- name: gcscreds ``` + ## Deploy the model on GCS with `InferenceService` Create the InferenceService with the Google service account credential === "yaml" ```yaml -apiVersion: serving.kserve.io/v1beta1 -kind: InferenceService +apiVersion: "serving.kserve.io/v1beta1" +kind: "InferenceService" metadata: - name: sklearn-gcs + name: sklearn-gcs spec: predictor: + serviceAccountName: sa model: modelFormat: - name: sklearn - storage: - key: gcs - path: models/tensorflow/flowers - parameters: # Parameters to override the default values - bucket: kfserving-examples + name: tensorflow + storageUri: "gs://kfserving-examples/models/tensorflow/flowers" + ``` Apply the `sklearn-gcs.yaml`. From 565e81bc79a30c64050ac7d9ab3550663383c9f0 Mon Sep 17 00:00:00 2001 From: tjandy98 <3953059+tjandy98@users.noreply.github.com> Date: Tue, 15 Oct 2024 22:04:54 +0800 Subject: [PATCH 2/9] remove symbol Signed-off-by: tjandy98 <3953059+tjandy98@users.noreply.github.com> --- docs/modelserving/storage/gcs/gcs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modelserving/storage/gcs/gcs.md b/docs/modelserving/storage/gcs/gcs.md index 8fe9865a3..a4e3b9d55 100644 --- a/docs/modelserving/storage/gcs/gcs.md +++ b/docs/modelserving/storage/gcs/gcs.md @@ -23,7 +23,7 @@ KServe supports authenticating using Google Service Account Key * Base64 encode the generated Service Account Key file -## Create Secret and attach to Service Account¶ +## Create Secret and attach to Service Account ### Create secret From 2d1f9265a09fe82303c3f84554dd20a3120667e8 Mon Sep 17 00:00:00 2001 From: tjandy98 <3953059+tjandy98@users.noreply.github.com> Date: Tue, 15 Oct 2024 22:06:05 +0800 Subject: [PATCH 3/9] rename secret Signed-off-by: tjandy98 <3953059+tjandy98@users.noreply.github.com> --- docs/modelserving/storage/gcs/gcs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modelserving/storage/gcs/gcs.md b/docs/modelserving/storage/gcs/gcs.md index a4e3b9d55..133db6393 100644 --- a/docs/modelserving/storage/gcs/gcs.md +++ b/docs/modelserving/storage/gcs/gcs.md @@ -32,7 +32,7 @@ KServe supports authenticating using Google Service Account Key apiVersion: v1 kind: Secret metadata: - name: storage-config + name: gcscreds type: Opaque data: gcloud-application-credentials.json: <base64 encoded value of the credential file> From c429615e6dcfbc66a794805a458b56e3c208171e Mon Sep 17 00:00:00 2001 From: tjandy98 <3953059+tjandy98@users.noreply.github.com> Date: Tue, 15 Oct 2024 22:25:11 +0800 Subject: [PATCH 4/9] Remove quotes and add command Signed-off-by: tjandy98 <3953059+tjandy98@users.noreply.github.com> --- docs/modelserving/storage/gcs/gcs.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/modelserving/storage/gcs/gcs.md b/docs/modelserving/storage/gcs/gcs.md index 133db6393..63833a75e 100644 --- a/docs/modelserving/storage/gcs/gcs.md +++ b/docs/modelserving/storage/gcs/gcs.md @@ -38,6 +38,11 @@ data: gcloud-application-credentials.json: <base64 encoded value of the credential file> ``` +=== "kubectl" +```bash +kubectl apply -f create-gcs-secret.yaml +``` + ### Attach secret to a service account === "yaml" ```yaml @@ -55,8 +60,8 @@ secrets: Create the InferenceService with the Google service account credential === "yaml" ```yaml -apiVersion: "serving.kserve.io/v1beta1" -kind: "InferenceService" +apiVersion: serving.kserve.io/v1beta1 +kind: InferenceService metadata: name: sklearn-gcs spec: From e09f36e3289aa45895ecdb1f0c6bd04b9a8ef989 Mon Sep 17 00:00:00 2001 From: tjandy98 <3953059+tjandy98@users.noreply.github.com> Date: Tue, 15 Oct 2024 22:27:01 +0800 Subject: [PATCH 5/9] change sklearn to tensorflow Signed-off-by: tjandy98 <3953059+tjandy98@users.noreply.github.com> --- docs/modelserving/storage/gcs/gcs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/modelserving/storage/gcs/gcs.md b/docs/modelserving/storage/gcs/gcs.md index 63833a75e..7a57ccc01 100644 --- a/docs/modelserving/storage/gcs/gcs.md +++ b/docs/modelserving/storage/gcs/gcs.md @@ -63,7 +63,7 @@ Create the InferenceService with the Google service account credential apiVersion: serving.kserve.io/v1beta1 kind: InferenceService metadata: - name: sklearn-gcs + name: tensorflow-gcs spec: predictor: serviceAccountName: sa @@ -74,7 +74,7 @@ spec: ``` -Apply the `sklearn-gcs.yaml`. +Apply the `tensorflow-gcs.yaml`. === "kubectl" ```bash From e5bfad65f1c7695fe95535903869e66c11cf1279 Mon Sep 17 00:00:00 2001 From: tjandy98 <3953059+tjandy98@users.noreply.github.com> Date: Tue, 15 Oct 2024 22:29:55 +0800 Subject: [PATCH 6/9] change sklearn to tensorflow Signed-off-by: tjandy98 <3953059+tjandy98@users.noreply.github.com> --- docs/modelserving/storage/gcs/gcs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modelserving/storage/gcs/gcs.md b/docs/modelserving/storage/gcs/gcs.md index 7a57ccc01..8836c51f6 100644 --- a/docs/modelserving/storage/gcs/gcs.md +++ b/docs/modelserving/storage/gcs/gcs.md @@ -78,7 +78,7 @@ Apply the `tensorflow-gcs.yaml`. === "kubectl" ```bash -kubectl apply -f sklearn-gcs.yaml +kubectl apply -f tensorflow-gcs.yaml ``` ## Run a prediction From 090d6ed32c631ef45219bc953249919ec1b5dfb4 Mon Sep 17 00:00:00 2001 From: tjandy98 <3953059+tjandy98@users.noreply.github.com> Date: Tue, 15 Oct 2024 22:30:51 +0800 Subject: [PATCH 7/9] change sklearn to tensorflow Signed-off-by: tjandy98 <3953059+tjandy98@users.noreply.github.com> --- docs/modelserving/storage/gcs/gcs.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/modelserving/storage/gcs/gcs.md b/docs/modelserving/storage/gcs/gcs.md index 8836c51f6..aaa392c61 100644 --- a/docs/modelserving/storage/gcs/gcs.md +++ b/docs/modelserving/storage/gcs/gcs.md @@ -87,9 +87,9 @@ Now, the ingress can be accessed at `${INGRESS_HOST}:${INGRESS_PORT}` or follow to find out the ingress IP and port. ```bash -SERVICE_HOSTNAME=$(kubectl get inferenceservice sklearn-gcs -o jsonpath='{.status.url}' | cut -d "/" -f 3) +SERVICE_HOSTNAME=$(kubectl get inferenceservice tensorflow-gcs -o jsonpath='{.status.url}' | cut -d "/" -f 3) -MODEL_NAME=sklearn-gcs +MODEL_NAME=tensorflow-gcs INPUT_PATH=@./input.json curl -v -H "Host: ${SERVICE_HOSTNAME}" -H "Content-Type: application/json" http://${INGRESS_HOST}:${INGRESS_PORT}/v1/models/$MODEL_NAME:predict -d $INPUT_PATH ``` @@ -100,8 +100,8 @@ curl -v -H "Host: ${SERVICE_HOSTNAME}" -H "Content-Type: application/json" http: * Trying 127.0.0.1:8080... * TCP_NODELAY set * Connected to localhost (127.0.0.1) port 8080 (#0) - > POST /v1/models/sklearn-gcs:predict HTTP/1.1 - > Host: sklearn-gcs.default.example.com + > POST /v1/models/tensorflow-gcs:predict HTTP/1.1 + > Host: tensorflow-gcs.default.example.com > User-Agent: curl/7.68.0 > Accept: */* > Content-Length: 84 From ed0564ae3ec58525b9355006ccb5529d01ea6a00 Mon Sep 17 00:00:00 2001 From: tjandy98 <3953059+tjandy98@users.noreply.github.com> Date: Wed, 16 Oct 2024 21:48:05 +0800 Subject: [PATCH 8/9] Add imperative command Signed-off-by: tjandy98 <3953059+tjandy98@users.noreply.github.com> --- docs/modelserving/storage/gcs/gcs.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/modelserving/storage/gcs/gcs.md b/docs/modelserving/storage/gcs/gcs.md index aaa392c61..f81518ee0 100644 --- a/docs/modelserving/storage/gcs/gcs.md +++ b/docs/modelserving/storage/gcs/gcs.md @@ -27,6 +27,18 @@ KServe supports authenticating using Google Service Account Key ### Create secret + +You can create a secret using either the imperative kubectl command or by declaratively defining it in a YAML file. + +#### Using Imperative Command + +=== "kubectl" +```bash +kubectl create secret generic gcs-credential --from-file=gcloud-application-credentials.json=/path/to/gcloud-application-credentials.json +``` + +#### Using Declarative YAML + === "yaml" ```yaml apiVersion: v1 From 6d91e0c1073cecdfe1064e588c0dfca5f95305cb Mon Sep 17 00:00:00 2001 From: tjandy98 <3953059+tjandy98@users.noreply.github.com> Date: Wed, 16 Oct 2024 21:58:33 +0800 Subject: [PATCH 9/9] Update Signed-off-by: tjandy98 <3953059+tjandy98@users.noreply.github.com> --- docs/modelserving/storage/gcs/gcs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/modelserving/storage/gcs/gcs.md b/docs/modelserving/storage/gcs/gcs.md index f81518ee0..4dd19cf13 100644 --- a/docs/modelserving/storage/gcs/gcs.md +++ b/docs/modelserving/storage/gcs/gcs.md @@ -34,7 +34,7 @@ You can create a secret using either the imperative kubectl command or by declar === "kubectl" ```bash -kubectl create secret generic gcs-credential --from-file=gcloud-application-credentials.json=/path/to/gcloud-application-credentials.json +kubectl create secret generic gcscreds --from-file=gcloud-application-credentials.json=/path/to/gcloud-application-credentials.json ``` #### Using Declarative YAML @@ -52,7 +52,7 @@ data: === "kubectl" ```bash -kubectl apply -f create-gcs-secret.yaml +kubectl apply -f gcs-secret.yaml ``` ### Attach secret to a service account