Преглед изворни кода

Merge pull request #13899 from richardkchapman/eclwatchApplication

HPCC-24250 Simplify ESP running as an application - Helm chart changes

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday пре 5 година
родитељ
комит
497531ec1f

+ 0 - 2
dockerfiles/platform-core-debug/Dockerfile

@@ -36,5 +36,3 @@ ENV HPCC_containerized=1
 ENV HPCC_DLLSERVER_PATH=/var/lib/HPCCSystems/queries
 
 USER hpcc
-# temporary workaround for ESP configuration not being implemented yet
-COPY --chown=hpcc:hpcc esp.xml /var/lib/HPCCSystems

+ 0 - 3
dockerfiles/platform-core/Dockerfile

@@ -83,6 +83,3 @@ USER hpcc
 ENV PATH="/opt/HPCCSystems/bin:${PATH}"
 ENV HPCC_containerized=1
 ENV HPCC_DLLSERVER_PATH=/var/lib/HPCCSystems/queries
-# temporary workaround for ESP configuration not being implemented yet
-COPY --chown=hpcc:hpcc esp.xml /var/lib/HPCCSystems
-

+ 5 - 12
helm/hpcc/templates/_helpers.tpl

@@ -50,18 +50,11 @@ Pass in root as .
 {{- $local := dict "defaultEsp" "" -}}
 imageVersion: {{ required "Please specify .global.image.version" .Values.global.image.version | quote }}
 singleNode: {{ .Values.global.singleNode | default false }}
-{{- if .Values.global.defaultEsp -}}
- {{- $_ := set $local "defaultEsp" .Values.global.defaultEsp -}}
-{{- else if hasPrefix "[]" (typeOf .Values.esp) -}}
- {{- range $key, $value := .Values.esp -}}
-  {{- if (not $value.disabled) -}}
-   {{- if (not $local.defaultEsp) -}}
-    {{- $_ := set $local "defaultEsp" $value.name -}}
-   {{- end -}} 
-  {{- end -}} 
- {{- end -}} 
-{{- end }} 
-defaultEsp: {{ $local.defaultEsp | quote }}
+defaultEsp: {{ .Values.global.defaultEsp | default ""}}
+{{ if hasPrefix "[]" (typeOf .Values.esp) -}}
+esp:
+{{ toYaml .Values.esp }}
+{{ end -}}
 secretTimeout: {{ .Values.secrets.timeout | default 300 }}
 storage:
   ##The following is a temporary solution to allow blob storage to be tested

+ 5 - 3
helm/hpcc/templates/esp.yaml

@@ -1,5 +1,6 @@
 {{ range $.Values.esp -}}
 {{- if not .disabled -}}
+{{- $application := .application | default "eclwatch" -}}
 apiVersion: apps/v1
 kind: Deployment
 metadata:
@@ -19,6 +20,7 @@ spec:
         workingDir: /var/lib/HPCCSystems
         command: [ esp ] 
         args: [
+                {{ printf "--application=%s" $application | quote }},
                 {{ include "hpcc.configArg" . }},
                 {{ include "hpcc.daliArg" $ }}
               ]
@@ -56,12 +58,12 @@ metadata:
   name: {{ .name | quote }}
 spec:
   ports:
-  - port: 8010
+  - port: {{ required "servicePort must be specified" .servicePort }}
     protocol: TCP
-    targetPort: 8010
+    targetPort: {{ .port | default 8880 }}
   selector:
     run: {{ .name | quote }}
-  type: LoadBalancer
+  type: {{ .public | ternary "LoadBalancer" "ClusterIP" }}
 ---
 {{- end }}
 {{- end }}

+ 30 - 4
helm/hpcc/values.yaml

@@ -13,10 +13,10 @@ global:
   logging:
     detail: 100
 
-  # Specify a defaultEsp to control which EclWatch service is returned from Std.File.GetEspURL, and other uses
-  # If not specified, the first esp component present is assumed.
+  # Specify a defaultEsp to control which eclservices service is returned from Std.File.GetEspURL, and other uses
+  # If not specified, the first esp component that exposes eclservices application is assumed.
   # Can also be overridden locally in individual components
-  ## defaultEsp: myesp
+  ## defaultEsp: eclservices
 
 ## storage:
 ##
@@ -115,8 +115,34 @@ eclccserver:
   listen: []
     
 esp:
-- name: myesp
+- name: eclwatch
+  ## Pre-configured esp applications include eclwatch, eclservices, and eclqueries
+  application: eclwatch
+  auth: none
+  tls: off
   replicas: 1
+  ## port can be used to change the local port used by the pod. If omitted, the default port (8880) is used
+  port: 8888
+  ## servicePort controls the port that this service will be exposed on, either internally to the cluster, or externally
+  servicePort: 8010
+  ## Specify public: true if you want the service available from outside the cluster. Typically, eclwatch and wsecl are published externally, while eclservices is designed for internal use.
+  public: true
+
+- name: eclservices
+  application: eclservices
+  auth: none
+  tls: off
+  replicas: 1
+  servicePort: 8010
+  public: false
+
+- name: eclqueries
+  application: eclqueries
+  auth: none
+  tls: off
+  replicas: 1
+  public: true
+  servicePort: 8002
 
 roxie:
 - name: roxie-cluster

+ 31 - 2
plugins/fileservices/fileservices.cpp

@@ -2860,6 +2860,24 @@ FILESERVICES_API char * FILESERVICES_CALL fsGetEspURL(const char *username, cons
     const char *defaultEsp = queryComponentConfig().queryProp("@defaultEsp");
     if (!defaultEsp)
         defaultEsp = queryGlobalConfig().queryProp("@defaultEsp");
+    if (!defaultEsp)
+    {
+        Owned<IPropertyTreeIterator> esps = queryGlobalConfig().getElements("esp");
+        ForEach(*esps)
+        {
+            const char *application = esps->query().queryProp("@application");
+            if (application)
+            {
+                if (streq(application, "eclservices"))
+                {
+                    defaultEsp = esps->query().queryProp("@name");
+                    break;
+                }
+                else if (!defaultEsp && streq(application, "eclwatch"))
+                    defaultEsp = esps->query().queryProp("@name");
+            }
+        }
+    }
     if (defaultEsp)
     {
         StringBuffer credentials;
@@ -2868,8 +2886,19 @@ FILESERVICES_API char * FILESERVICES_CALL fsGetEspURL(const char *username, cons
         else if (username && username[0])
             credentials.setf("%s@", username);
 
-        // MORE - do we want to make such things as port and protocol configurable?
-        VStringBuffer espURL("http://%s%s:8010", credentials.str(), defaultEsp);
+        VStringBuffer espInfo("esp[@name='%s']", defaultEsp);
+        const char *protocol = "https";
+        unsigned port = 8010;
+        const IPropertyTree *espconfig = queryGlobalConfig().queryPropTree(espInfo);
+        if (espconfig)
+        {
+            if (!espconfig->getPropBool("@tls", true))
+                protocol = "http";
+            port = espconfig->getPropInt("@servicePort", port);
+        }
+        // MORE - if not found, we could generate a warning - it implies something misconfigured!
+
+        VStringBuffer espURL("%s://%s%s:%u", protocol, credentials.str(), defaultEsp, port);
         return espURL.detach();
     }
 #else