Skip to content

Commit

Permalink
feat: allow setting ISTIO_HOST in notebook/tensorboard controller f…
Browse files Browse the repository at this point in the history
…or Istio VirtualServices (#6902)

* Added ISTIO_HOSTS env variables for tensorboard and notebook controllers

* ISTIO_HOSTS -> ISTIO_HOST rename

* istioHosts -> istioHost rename
  • Loading branch information
punkerpunker authored May 24, 2024
1 parent d42682a commit e17ddbd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions components/notebook-controller/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ spec:
configMapKeyRef:
name: config
key: ISTIO_GATEWAY
- name: ISTIO_HOST
valueFrom:
configMapKeyRef:
name: config
key: ISTIO_HOST
- name: CLUSTER_DOMAIN
valueFrom:
configMapKeyRef:
Expand Down
3 changes: 2 additions & 1 deletion components/notebook-controller/config/manager/params.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
USE_ISTIO=true
ISTIO_GATEWAY=kubeflow/kubeflow-gateway
ISTIO_HOST=*
CLUSTER_DOMAIN=cluster.local
ENABLE_CULLING=false
CULL_IDLE_TIME=1440
IDLENESS_CHECK_PERIOD=1
IDLENESS_CHECK_PERIOD=1
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,14 @@ func generateVirtualService(instance *v1beta1.Notebook) (*unstructured.Unstructu
vsvc.SetKind("VirtualService")
vsvc.SetName(virtualServiceName(name, namespace))
vsvc.SetNamespace(namespace)
if err := unstructured.SetNestedStringSlice(vsvc.Object, []string{"*"}, "spec", "hosts"); err != nil {
return nil, fmt.Errorf("set .spec.hosts error: %v", err)

istioHost := os.Getenv("ISTIO_HOST")
if len(istioHost) == 0 {
istioHost = "*"
}
if err := unstructured.SetNestedStringSlice(vsvc.Object, []string{istioHost}, "spec", "hosts"); err != nil {
return nil, fmt.Errorf("Set .spec.hosts error: %v", err)

}

istioGateway := os.Getenv("ISTIO_GATEWAY")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ configMapGenerator:
- RWO_PVC_SCHEDULING="True"
- TENSORBOARD_IMAGE=tensorflow/tensorflow:2.5.1
- ISTIO_GATEWAY=kubeflow/kubeflow-gateway
- ISTIO_HOST=*
patchesStrategicMerge:
- patches/add_controller_config.yaml
images:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,17 @@ func generateVirtualService(tb *tensorboardv1alpha1.Tensorboard) (*unstructured.
return nil, err
}

istioHost, err := getEnvVariable("ISTIO_HOST")
if err != nil {
return nil, err
}

vsvc := &unstructured.Unstructured{}
vsvc.SetAPIVersion("networking.istio.io/v1alpha3")
vsvc.SetKind("VirtualService")
vsvc.SetName(tb.Name)
vsvc.SetNamespace(tb.Namespace)
if err := unstructured.SetNestedStringSlice(vsvc.Object, []string{"*"}, "spec", "hosts"); err != nil {
if err := unstructured.SetNestedStringSlice(vsvc.Object, []string{istioHost}, "spec", "hosts"); err != nil {
return nil, fmt.Errorf("Set .spec.hosts error: %v", err)
}
if err := unstructured.SetNestedStringSlice(vsvc.Object, []string{istioGateway},
Expand Down

0 comments on commit e17ddbd

Please sign in to comment.