Skip to content

Commit

Permalink
Issue #3968: Allow hostNetwork=true for seldon operator (#3971)
Browse files Browse the repository at this point in the history
* Issue #3968: Allow hostNetwork=true for seldon operator

* Issue #3968: Allow hostNetwork=true for seldon operator

update helm template generators

* Issue #3968: Allow hostNetwork=true for seldon operator

remove duplicated code

* Issue #3968: Allow hostNetwork=true for seldon operator

Remove quotes from hostNetwork when generating helm chart

* Issue #3968: Allow hostNetwork=true for seldon operator

Remove quotes from hostNetwork when generating helm chart

Co-authored-by: Mariano Billinghurst <mariano.billinghurst@pmi.com>
  • Loading branch information
marianobilli and Mariano Billinghurst authored Mar 17, 2022
1 parent 845e809 commit c515a00
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 16 deletions.
2 changes: 2 additions & 0 deletions helm-charts/seldon-core-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,5 @@ helm install seldon-core-operator seldonio/seldon-core-operator --namespace seld
| storageInitializer.memoryRequest | string | `"100Mi"` | |
| usageMetrics.enabled | bool | `false` | |
| webhook.port | int | `4443` | |
| metrics.port | int | `8080` | |
| hostNetwork | bool | `false` | |
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
{{- with .Values.manager.annotations }}
{{- toYaml . | nindent 8}}
{{- end }}
prometheus.io/port: '{{ .Values.metrics.port }}'
prometheus.io/scrape: 'true'
sidecar.istio.io/inject: 'false'
labels:
Expand Down Expand Up @@ -140,7 +141,7 @@ spec:
- containerPort: {{ .Values.webhook.port }}
name: webhook-server
protocol: TCP
- containerPort: 8080
- containerPort: {{ .Values.metrics.port }}
name: metrics
protocol: TCP
resources:
Expand All @@ -156,6 +157,7 @@ spec:
name: cert
readOnly: true
{{- end }}
hostNetwork: {{ .Values.hostNetwork }}
securityContext:
runAsUser: {{ .Values.managerUserID }}
serviceAccountName: '{{ .Values.serviceAccount.name }}'
Expand Down
14 changes: 10 additions & 4 deletions helm-charts/seldon-core-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Below are the default values when installing Seldon Core

# Defaults to .Release.Namespace
namespaceOverride: ""
namespaceOverride: ""

# ## Ingress Options
# You are able to choose between Istio and Ambassador
Expand Down Expand Up @@ -69,6 +69,7 @@ executor:
workQueueSize: 10000
writeTimeoutMs: 2000


# ## Seldon Core Controller Manager Options
image:
pullPolicy: IfNotPresent
Expand Down Expand Up @@ -101,13 +102,18 @@ storageInitializer:
memoryRequest: 100Mi
usageMetrics:
enabled: false
# In scenarios like EKS with non-standard CNI plugin like calico, the control plane cannot reach the webhook
# hence it is needed to set hostNetwork: true
hostNetwork: false
webhook:
port: 4443
port: 4443 # If 'hostNetwork: true' you might need to change this port if it is already used by the node
metrics: # these are the metrics exposed by the controller pod
port: 8080 # If 'hostNetwork: true' you might need to change this port if it is already used by the node

# ## Predictive Unit Values
predictiveUnit:
httpPort: 9000
grpcPort: 9500
grpcPort: 9500
metricsPortName: metrics
# If you would like to add extra environment variables to the init container to make available
# secrets such as cloud credentials, you can provide a default secret name that will be loaded
Expand Down Expand Up @@ -135,7 +141,7 @@ predictor_servers:
seldon:
defaultImageVersion: "1.14.0-dev"
image: seldonio/tfserving-proxy
tensorflow:
tensorflow:
defaultImageVersion: 2.1.0
image: tensorflow/serving
XGBOOST_SERVER:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ spec:
metadata:
annotations:
prometheus.io/scrape: 'true'
prometheus.io/port: '8080'
spec:
containers:
# Expose the prometheus metrics on default port
Expand Down
23 changes: 12 additions & 11 deletions operator/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
labels:
control-plane: seldon-controller-manager
spec:
hostNetwork: false
serviceAccountName: manager
securityContext:
runAsUser: 8888
Expand All @@ -38,30 +39,30 @@ spec:
- --leader-election-id=$(MANAGER_LEADER_ELECTION_ID)
env:
- name: MANAGER_LEADER_ELECTION_ID
value: "a33bd623.machinelearning.seldon.io"
value: "a33bd623.machinelearning.seldon.io"
- name: MANAGER_LOG_LEVEL
value: "INFO"
- name: WATCH_NAMESPACE
value: ""
- name: RELATED_IMAGE_EXECUTOR
value: ""
- name: RELATED_IMAGE_STORAGE_INITIALIZER
value: ""
value: ""
- name: RELATED_IMAGE_SKLEARNSERVER
value: ""
value: ""
- name: RELATED_IMAGE_XGBOOSTSERVER
value: ""
value: ""
- name: RELATED_IMAGE_MLFLOWSERVER
value: ""
value: ""
- name: RELATED_IMAGE_TFPROXY
value: ""
value: ""
- name: RELATED_IMAGE_TENSORFLOW
value: ""
value: ""
- name: RELATED_IMAGE_EXPLAINER
value: ""
value: ""
- name: RELATED_IMAGE_MOCK_CLASSIFIER
value: ""
- name: MANAGER_CREATE_RESOURCES
value: ""
- name: MANAGER_CREATE_RESOURCES
value: "false"
- name: POD_NAMESPACE
valueFrom:
Expand Down Expand Up @@ -100,7 +101,7 @@ spec:
- name: EXECUTOR_SERVER_PORT
value: "8000"
- name: EXECUTOR_CONTAINER_USER
value: "8888"
value: "8888"
- name: EXECUTOR_CONTAINER_SERVICE_ACCOUNT_NAME
value: default
- name: EXECUTOR_SERVER_METRICS_PORT_NAME
Expand Down
19 changes: 19 additions & 0 deletions operator/helm/split_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,17 @@ def helm_namespace_override():
'{{- if .Values.singleNamespace }}--namespace={{ include "seldon.namespace" . }}{{- end }}'
)

# Update metrics port
res["spec"]["template"]["metadata"]["annotations"]["prometheus.io/port"] = helm_value('metrics.port')
for portSpec in res["spec"]["template"]["spec"]["containers"][0][
"ports"
]:
if portSpec["name"] == "metrics":
portSpec["containerPort"] = helm_value("metrics.port")

# Networking
res["spec"]["template"]["spec"]["hostNetwork"] = helm_value("hostNetwork")

if kind == "configmap" and name == "seldon-config":
res["data"]["credentials"] = helm_value_json("credentials")
res["data"]["predictor_servers"] = helm_value_json(
Expand Down Expand Up @@ -454,6 +465,14 @@ def helm_namespace_override():
re.M,
)

# make sure hostNetwork is not quoted as its a bool
fdata = fdata.replace(
"'{{ .Values.hostNetwork }}'", "{{ .Values.hostNetwork }}"
)
# make sure metrics.port is not quoted as its an int
fdata = fdata.replace(
"containerPort: '{{ .Values.metrics.port }}'", "containerPort: {{ .Values.metrics.port }}"
)
# make sure webhook is not quoted as its an int
fdata = fdata.replace(
"'{{ .Values.webhook.port }}'", "{{ .Values.webhook.port }}"
Expand Down

0 comments on commit c515a00

Please sign in to comment.