Skip to content

Commit

Permalink
K8s: Config clusterIP, externalName to svc of Hub, Router, EventBus
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Dec 25, 2024
1 parent 08a9ea1 commit dddbebb
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 4 deletions.
9 changes: 9 additions & 0 deletions charts/selenium-grid/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| components.router.resources | object | `{}` | Resources for router container |
| components.router.securityContext | object | `{}` | SecurityContext for router container |
| components.router.serviceType | string | `"ClusterIP"` | Kubernetes service type (see https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types) |
| components.router.clusterIP | string | `""` | Set specific clusterIP when serviceType is ClusterIP (see https://kubernetes.io/docs/concepts/services-networking/service/#type-clusterip) |
| components.router.externalName | string | `""` | Set specific externalName when serviceType is ExternalName (see https://kubernetes.io/docs/concepts/services-networking/service/#type-externalname) |
| components.router.loadBalancerIP | string | `""` | Set specific loadBalancerIP when serviceType is LoadBalancer (see https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer) |
| components.router.serviceAnnotations | object | `{}` | Custom annotations for router service |
| components.router.tolerations | list | `[]` | Tolerations for router pods |
Expand Down Expand Up @@ -228,6 +230,9 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| components.eventBus.resources | object | `{}` | Resources for event-bus container |
| components.eventBus.securityContext | object | `{}` | SecurityContext for event-bus container |
| components.eventBus.serviceType | string | `"ClusterIP"` | Kubernetes service type (see https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types) |
| components.eventBus.clusterIP | string | `""` | Set specific clusterIP when serviceType is ClusterIP (see https://kubernetes.io/docs/concepts/services-networking/service/#type-clusterip) |
| components.eventBus.externalName | string | `""` | Set specific externalName when serviceType is ExternalName (see https://kubernetes.io/docs/concepts/services-networking/service/#type-externalname) |
| components.eventBus.loadBalancerIP | string | `""` | Set specific loadBalancerIP when serviceType is LoadBalancer (see https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer) |
| components.eventBus.serviceAnnotations | object | `{}` | Custom annotations for Event Bus service |
| components.eventBus.tolerations | list | `[]` | Tolerations for Event Bus pods |
| components.eventBus.nodeSelector | object | `{}` | Node selector for Event Bus pods |
Expand Down Expand Up @@ -300,6 +305,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| hub.resources | object | `{}` | Resources for selenium-hub container |
| hub.securityContext | object | `{}` | SecurityContext for selenium-hub container |
| hub.serviceType | string | `"ClusterIP"` | Kubernetes service type (see https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types) |
| hub.clusterIP | string | `""` | Set specific clusterIP when serviceType is ClusterIP (see https://kubernetes.io/docs/concepts/services-networking/service/#type-clusterip) |
| hub.externalName | string | `""` | Set specific externalName when serviceType is ExternalName (see https://kubernetes.io/docs/concepts/services-networking/service/#type-externalname) |
| hub.loadBalancerIP | string | `""` | Set specific loadBalancerIP when serviceType is LoadBalancer (see https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer) |
| hub.serviceAnnotations | object | `{}` | Custom annotations for Selenium Hub service |
| hub.tolerations | list | `[]` | Tolerations for selenium-hub pods |
Expand All @@ -324,6 +331,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| monitoring.exporter.port | int | `9199` | |
| monitoring.exporter.service.enabled | bool | `true` | Create a service for exporter |
| monitoring.exporter.service.type | string | `"ClusterIP"` | Service type |
| monitoring.exporter.service.clusterIP | string | `""` | Set specific clusterIP when serviceType is ClusterIP (see https://kubernetes.io/docs/concepts/services-networking/service/#type-clusterip) |
| monitoring.exporter.service.externalName | string | `""` | Set specific externalName when serviceType is ExternalName (see https://kubernetes.io/docs/concepts/services-networking/service/#type-externalname) |
| monitoring.exporter.service.loadBalancerIP | string | `""` | Set specific loadBalancerIP when serviceType is LoadBalancer (see https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer) |
| monitoring.exporter.service.nodePort | int | `30199` | Node port for service |
| monitoring.exporter.service.annotations | object | `{}` | Annotations for exporter service |
Expand Down
8 changes: 4 additions & 4 deletions charts/selenium-grid/configs/node/nodePreStop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ probe_name="lifecycle.${1:-"preStop"}"
SE_NODE_PORT=${SE_NODE_PORT:-"5555"}
ts_format=${SE_LOG_TIMESTAMP_FORMAT:-"%Y-%m-%d %H:%M:%S,%3N"}
NODE_CONFIG_DIRECTORY=${NODE_CONFIG_DIRECTORY:-"/opt/bin"}
PRESTOP_WAIT_STRATEGY=${SE_NODE_PRESTOP_WAIT_STRATEGY:-"local"}
PRESTOP_WAIT_STRATEGY=${SE_NODE_PRESTOP_WAIT_STRATEGY:-"deployment"}

max_time=3
retry_time=5

if [ "${PRESTOP_WAIT_STRATEGY}" = "local" ]; then
echo "$(date -u +"${ts_format}") [${probe_name}] - Using pre-stop strategy local to wait for current sessions to be finished"
if [ "${PRESTOP_WAIT_STRATEGY,,}" = "job" ]; then
echo "$(date -u +"${ts_format}") [${probe_name}] - Using pre-stop strategy Job to wait for current sessions to be finished"
while pgrep -f 'java.*selenium' | grep -v $$; do sleep 5; done
exit 0
fi

echo "$(date -u +"${ts_format}") [${probe_name}] - Using pre-stop strategy remote to wait for current sessions to be finished"
echo "$(date -u +"${ts_format}") [${probe_name}] - Using pre-stop strategy Deployment to wait for current sessions to be finished"

ID=$(echo $RANDOM)
tmp_node_file="/tmp/nodeProbe${ID}"
Expand Down
9 changes: 9 additions & 0 deletions charts/selenium-grid/templates/event-bus-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ spec:
app: {{ template "seleniumGrid.eventBus.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
type: {{ .Values.components.eventBus.serviceType }}
{{- if and (eq .Values.components.eventBus.serviceType "ClusterIP") ( .Values.components.eventBus.clusterIP ) }}
clusterIP: {{ .Values.components.eventBus.clusterIP }}
{{- end }}
{{- if and (eq .Values.components.eventBus.serviceType "ExternalName") ( .Values.components.eventBus.externalName ) }}
externalName: {{ .Values.components.eventBus.externalName }}
{{- end }}
{{- if and (eq .Values.components.eventBus.serviceType "LoadBalancer") ( .Values.components.eventBus.loadBalancerIP ) }}
loadBalancerIP: {{ .Values.components.eventBus.loadBalancerIP }}
{{- end }}
ports:
- name: http-evtbus
protocol: TCP
Expand Down
6 changes: 6 additions & 0 deletions charts/selenium-grid/templates/hub-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ spec:
app: {{ template "seleniumGrid.hub.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
type: {{ .Values.hub.serviceType }}
{{- if and (eq .Values.hub.serviceType "ClusterIP") ( .Values.hub.clusterIP ) }}
clusterIP: {{ .Values.hub.clusterIP }}
{{- end }}
{{- if and (eq .Values.hub.serviceType "ExternalName") ( .Values.hub.externalName ) }}
externalName: {{ .Values.hub.externalName }}
{{- end }}
{{- if and (eq .Values.hub.serviceType "LoadBalancer") ( .Values.hub.loadBalancerIP ) }}
loadBalancerIP: {{ .Values.hub.loadBalancerIP }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ spec:
app: {{ template "seleniumGrid.monitoring.exporter.fullname" $ }}
app.kubernetes.io/name: {{ template "seleniumGrid.monitoring.exporter.fullname" $ }}
type: {{ .Values.monitoring.exporter.service.type }}
{{- if and (eq .Values.monitoring.exporter.service.type "ClusterIP") ( .Values.monitoring.exporter.service.clusterIP ) }}
clusterIP: {{ .Values.monitoring.exporter.service.clusterIP }}
{{- end }}
{{- if and (eq .Values.monitoring.exporter.service.type "ExternalName") ( .Values.monitoring.exporter.service.externalName ) }}
externalName: {{ .Values.monitoring.exporter.service.externalName }}
{{- end }}
{{- if and (eq .Values.monitoring.exporter.service.type "LoadBalancer") ( .Values.monitoring.exporter.service.loadBalancerIP ) }}
loadBalancerIP: {{ .Values.monitoring.exporter.service.loadBalancerIP }}
{{- end }}
Expand Down
6 changes: 6 additions & 0 deletions charts/selenium-grid/templates/router-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ spec:
app: {{ template "seleniumGrid.router.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
type: {{ .Values.components.router.serviceType }}
{{- if and (eq .Values.components.router.serviceType "ClusterIP") ( .Values.components.router.clusterIP ) }}
clusterIP: {{ .Values.components.router.clusterIP }}
{{- end }}
{{- if and (eq .Values.components.router.serviceType "ExternalName") ( .Values.components.router.externalName ) }}
externalName: {{ .Values.components.router.externalName }}
{{- end }}
{{- if and (eq .Values.components.router.serviceType "LoadBalancer") (.Values.components.router.loadBalancerIP) }}
loadBalancerIP: {{ .Values.components.router.loadBalancerIP }}
{{- end }}
Expand Down
18 changes: 18 additions & 0 deletions charts/selenium-grid/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ components:
securityContext: {}
# -- Kubernetes service type (see https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types)
serviceType: ClusterIP
# -- Set specific clusterIP when serviceType is ClusterIP (see https://kubernetes.io/docs/concepts/services-networking/service/#type-clusterip)
clusterIP: ""
# -- Set specific externalName when serviceType is ExternalName (see https://kubernetes.io/docs/concepts/services-networking/service/#type-externalname)
externalName: ""
# -- Set specific loadBalancerIP when serviceType is LoadBalancer (see https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer)
loadBalancerIP: ""
# -- Custom annotations for router service
Expand Down Expand Up @@ -559,6 +563,12 @@ components:
securityContext: {}
# -- Kubernetes service type (see https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types)
serviceType: ClusterIP
# -- Set specific clusterIP when serviceType is ClusterIP (see https://kubernetes.io/docs/concepts/services-networking/service/#type-clusterip)
clusterIP: ""
# -- Set specific externalName when serviceType is ExternalName (see https://kubernetes.io/docs/concepts/services-networking/service/#type-externalname)
externalName: ""
# -- Set specific loadBalancerIP when serviceType is LoadBalancer (see https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer)
loadBalancerIP: ""
# -- Custom annotations for Event Bus service
serviceAnnotations: {}
# -- Tolerations for Event Bus pods
Expand Down Expand Up @@ -780,6 +790,10 @@ hub:
securityContext: {}
# -- Kubernetes service type (see https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types)
serviceType: ClusterIP
# -- Set specific clusterIP when serviceType is ClusterIP (see https://kubernetes.io/docs/concepts/services-networking/service/#type-clusterip)
clusterIP: ""
# -- Set specific externalName when serviceType is ExternalName (see https://kubernetes.io/docs/concepts/services-networking/service/#type-externalname)
externalName: ""
# -- Set specific loadBalancerIP when serviceType is LoadBalancer (see https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer)
loadBalancerIP: ""
# -- Custom annotations for Selenium Hub service
Expand Down Expand Up @@ -834,6 +848,10 @@ monitoring:
enabled: true
# -- Service type
type: ClusterIP
# -- Set specific clusterIP when serviceType is ClusterIP (see https://kubernetes.io/docs/concepts/services-networking/service/#type-clusterip)
clusterIP: ""
# -- Set specific externalName when serviceType is ExternalName (see https://kubernetes.io/docs/concepts/services-networking/service/#type-externalname)
externalName: ""
# -- Set specific loadBalancerIP when serviceType is LoadBalancer (see https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer)
loadBalancerIP: ""
# -- Node port for service
Expand Down

0 comments on commit dddbebb

Please sign in to comment.