From dddbebbf74243ea3c96e59165c06d4877fc03a7f Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Wed, 25 Dec 2024 16:48:57 +0700 Subject: [PATCH] K8s: Config clusterIP, externalName to svc of Hub, Router, EventBus Signed-off-by: Viet Nguyen Duc --- charts/selenium-grid/CONFIGURATION.md | 9 +++++++++ .../selenium-grid/configs/node/nodePreStop.sh | 8 ++++---- .../templates/event-bus-service.yaml | 9 +++++++++ .../selenium-grid/templates/hub-service.yaml | 6 ++++++ .../templates/monitoring-exporter-service.yaml | 6 ++++++ .../templates/router-service.yaml | 6 ++++++ charts/selenium-grid/values.yaml | 18 ++++++++++++++++++ 7 files changed, 58 insertions(+), 4 deletions(-) diff --git a/charts/selenium-grid/CONFIGURATION.md b/charts/selenium-grid/CONFIGURATION.md index d68d69b2c9..fb9e8c8fdd 100644 --- a/charts/selenium-grid/CONFIGURATION.md +++ b/charts/selenium-grid/CONFIGURATION.md @@ -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 | @@ -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 | @@ -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 | @@ -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 | diff --git a/charts/selenium-grid/configs/node/nodePreStop.sh b/charts/selenium-grid/configs/node/nodePreStop.sh index 6b8285e957..e3dfaead4e 100644 --- a/charts/selenium-grid/configs/node/nodePreStop.sh +++ b/charts/selenium-grid/configs/node/nodePreStop.sh @@ -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}" diff --git a/charts/selenium-grid/templates/event-bus-service.yaml b/charts/selenium-grid/templates/event-bus-service.yaml index c5c5b9052f..04fb56436d 100644 --- a/charts/selenium-grid/templates/event-bus-service.yaml +++ b/charts/selenium-grid/templates/event-bus-service.yaml @@ -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 diff --git a/charts/selenium-grid/templates/hub-service.yaml b/charts/selenium-grid/templates/hub-service.yaml index 0f394a6ebf..0e887808ca 100644 --- a/charts/selenium-grid/templates/hub-service.yaml +++ b/charts/selenium-grid/templates/hub-service.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/monitoring-exporter-service.yaml b/charts/selenium-grid/templates/monitoring-exporter-service.yaml index 670cceedb3..8adf531bad 100644 --- a/charts/selenium-grid/templates/monitoring-exporter-service.yaml +++ b/charts/selenium-grid/templates/monitoring-exporter-service.yaml @@ -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 }} diff --git a/charts/selenium-grid/templates/router-service.yaml b/charts/selenium-grid/templates/router-service.yaml index c93d04c119..268557237e 100644 --- a/charts/selenium-grid/templates/router-service.yaml +++ b/charts/selenium-grid/templates/router-service.yaml @@ -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 }} diff --git a/charts/selenium-grid/values.yaml b/charts/selenium-grid/values.yaml index 41f52204ee..ecbaaede52 100644 --- a/charts/selenium-grid/values.yaml +++ b/charts/selenium-grid/values.yaml @@ -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 @@ -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 @@ -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 @@ -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