Skip to content

Commit

Permalink
enhance hardcode namespace in SDK sample (kubeflow#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinchihe authored and k8s-ci-robot committed Oct 19, 2019
1 parent a376b5d commit dc9eca5
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions docs/samples/client/kfserving_sdk_sample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"\n",
"from kfserving import KFServingClient\n",
"from kfserving import constants\n",
"from kfserving import utils\n",
"from kfserving import V1alpha2EndpointSpec\n",
"from kfserving import V1alpha2PredictorSpec\n",
"from kfserving import V1alpha2TensorflowSpec\n",
Expand All @@ -34,6 +35,22 @@
"from kubernetes.client import V1ResourceRequirements"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Define namespace where InferenceService needs to be deployed to. If not specified, below function defines namespace to the current one where SDK is running in the cluster, otherwise it will deploy to default namespace."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"namespace = utils.get_default_target_namespace()"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -66,7 +83,7 @@
"isvc = V1alpha2InferenceService(api_version=api_version,\n",
" kind=constants.KFSERVING_KIND,\n",
" metadata=client.V1ObjectMeta(\n",
" name='flower-sample', namespace='kubeflow'),\n",
" name='flower-sample', namespace=namespace),\n",
" spec=V1alpha2InferenceServiceSpec(default=default_endpoint_spec))"
]
},
Expand Down Expand Up @@ -107,7 +124,7 @@
"metadata": {},
"outputs": [],
"source": [
"KFServing.get('flower-sample', namespace='kubeflow', watch=True, timeout_seconds=120)"
"KFServing.get('flower-sample', namespace=namespace, watch=True, timeout_seconds=120)"
]
},
{
Expand Down Expand Up @@ -139,7 +156,7 @@
" limits={'cpu':'100m', 'memory':'1Gi'}))))\n",
"\n",
"KFServing.rollout_canary('flower-sample', canary=canary_endpoint_spec, percent=10,\n",
" namespace='kubeflow', watch=True, timeout_seconds=120)"
" namespace=namespace, watch=True, timeout_seconds=120)"
]
},
{
Expand All @@ -162,7 +179,7 @@
"metadata": {},
"outputs": [],
"source": [
"KFServing.rollout_canary('flower-sample', percent=50, namespace='kubeflow',\n",
"KFServing.rollout_canary('flower-sample', percent=50, namespace=namespace,\n",
" watch=True, timeout_seconds=120)"
]
},
Expand All @@ -179,7 +196,7 @@
"metadata": {},
"outputs": [],
"source": [
"KFServing.promote('flower-sample', namespace='kubeflow', watch=True, timeout_seconds=120)"
"KFServing.promote('flower-sample', namespace=namespace, watch=True, timeout_seconds=120)"
]
},
{
Expand All @@ -195,7 +212,7 @@
"metadata": {},
"outputs": [],
"source": [
"KFServing.delete('flower-sample', namespace='kubeflow')"
"KFServing.delete('flower-sample', namespace=namespace)"
]
}
],
Expand Down

0 comments on commit dc9eca5

Please sign in to comment.