Răsfoiți Sursa

support user defined config files and spring profiles

Jason Song 4 ani în urmă
părinte
comite
0173304a46

+ 30 - 0
scripts/helm/README.md

@@ -80,6 +80,7 @@ The following table lists the configurable parameters of the apollo-service char
 | `configService.liveness.periodSeconds` | The period seconds of liveness probe | `10` |
 | `configService.readiness.initialDelaySeconds` | The initial delay seconds of readiness probe | `30` |
 | `configService.readiness.periodSeconds` | The period seconds of readiness probe | `5` |
+| `configService.config.profiles` | specify the spring profiles to activate | `github,kubernetes` |
 | `configService.config.configServiceUrlOverride` | Override `apollo.config-service.url`: config service url to be accessed by apollo-client | `nil` |
 | `configService.config.adminServiceUrlOverride` | Override `apollo.admin-service.url`: admin service url to be accessed by apollo-portal | `nil` |
 | `configService.env` | Environment variables passed to the container, e.g. <br />`JAVA_OPTS: -Xss256k` | `{}` |
@@ -102,6 +103,7 @@ The following table lists the configurable parameters of the apollo-service char
 | `adminService.liveness.periodSeconds` | The period seconds of liveness probe | `10` |
 | `adminService.readiness.initialDelaySeconds` | The initial delay seconds of readiness probe | `30` |
 | `adminService.readiness.periodSeconds` | The period seconds of readiness probe | `5` |
+| `adminService.config.profiles` | specify the spring profiles to activate | `github,kubernetes` |
 | `adminService.env` | Environment variables passed to the container, e.g. <br />`JAVA_OPTS: -Xss256k` | `{}` |
 | `adminService.strategy` | The deployment strategy of apollo-adminservice | `{}` |
 | `adminService.resources` | The resources definition of apollo-adminservice | `{}` |
@@ -213,9 +215,11 @@ The following table lists the configurable parameters of the apollo-portal chart
 | `nodeSelector` | The node selector definition of apollo-portal | `{}` |
 | `tolerations` | The tolerations definition of apollo-portal | `[]` |
 | `affinity` | The affinity definition of apollo-portal | `{}` |
+| `config.profiles` | specify the spring profiles to activate | `github,auth` |
 | `config.envs` | specify the env names, e.g. dev,pro | `nil` |
 | `config.contextPath` | specify the context path, e.g. `/apollo`, then users could access portal via `http://{portal_address}/apollo` | `nil` |
 | `config.metaServers` | specify the meta servers, e.g.<br />`dev: http://apollo-configservice-dev:8080`<br />`pro: http://apollo-configservice-pro:8080` | `{}` |
+| `config.files` | specify the extra config files for apollo-portal, e.g. application-ldap.yml | `{}` |
 | `portaldb.host` | The host for apollo portal db | `nil`                              |
 | `portaldb.port` | The port for apollo portal db | `3306` |
 | `portaldb.dbName` | The database name for apollo portal db | `ApolloPortalDB`                                     |
@@ -325,4 +329,30 @@ ingress:
     - host: xxx.somedomain.com # host is required to make session affinity work
       paths:
         - /
+```
+
+9. Enable LDAP support
+
+```yaml
+config:
+  ...
+  profiles: github,ldap
+  ...
+  files:
+    application-ldap.yml: |
+      spring:
+        ldap:
+          base: "dc=example,dc=org"
+          username: "cn=admin,dc=example,dc=org"
+          password: "password"
+          searchFilter: "(uid={0})"
+          urls:
+          - "ldap://xxx.somedomain.com:389"
+
+      ldap:
+        mapping:
+          objectClass: "inetOrgPerson"
+          loginId: "uid"
+          userDisplayName: "cn"
+          email: "mail"
 ```

+ 16 - 3
scripts/helm/apollo-portal/templates/deployment-portal.yaml

@@ -20,6 +20,10 @@ data:
     {{- range $env, $address := .Values.config.metaServers }}
     {{ $env }}.meta = {{ $address }}
     {{- end }}
+{{- range $fileName, $content := .Values.config.files }}
+{{ $fileName | indent 2 }}: |
+{{ $content | indent 4 }}
+{{- end }}
 
 ---
 kind: Deployment
@@ -55,6 +59,10 @@ spec:
                 path: application-github.properties
               - key: apollo-env.properties
                 path: apollo-env.properties
+            {{- range $fileName, $content := .Values.config.files }}
+              - key: {{ $fileName }}
+                path: {{ $fileName }}
+            {{- end }}
             defaultMode: 420
       containers:
         - name: {{ .Values.name }}
@@ -64,13 +72,13 @@ spec:
             - name: http
               containerPort: {{ .Values.containerPort }}
               protocol: TCP
-          {{- with .Values.env }}
           env:
-          {{- range $key, $value := . }}
+            - name: SPRING_PROFILES_ACTIVE
+              value: {{ .Values.config.profiles | quote }}
+          {{- range $key, $value := .Values.env }}
             - name: {{ $key }}
               value: {{ $value }}
           {{- end }}
-          {{- end }}
           volumeMounts:
             - name: configmap-{{ $portalFullName }}
               mountPath: /apollo-portal/config/application-github.properties
@@ -78,6 +86,11 @@ spec:
             - name: configmap-{{ $portalFullName }}
               mountPath: /apollo-portal/config/apollo-env.properties
               subPath: apollo-env.properties
+          {{- range $fileName, $content := .Values.config.files }}
+            - name: configmap-{{ $portalFullName }}
+              mountPath: /apollo-portal/config/{{ $fileName }}
+              subPath: {{ $fileName }}
+          {{- end }}
           livenessProbe:
             tcpSocket:
               port: {{ .Values.containerPort }}

+ 4 - 0
scripts/helm/apollo-portal/values.yaml

@@ -34,6 +34,8 @@ tolerations: []
 affinity: {}
 
 config:
+  # spring profiles to activate
+  profiles: "github,auth"
   # specify the env names, e.g. dev,pro
   envs: ""
   # specify the meta servers, e.g.
@@ -42,6 +44,8 @@ config:
   metaServers: {}
   # specify the context path, e.g. /apollo
   contextPath: ""
+  # extra config files for apollo-portal, e.g. application-ldap.yml
+  files: {}
 
 portaldb:
   name: apollo-portaldb

+ 1 - 1
scripts/helm/apollo-service/templates/deployment-adminservice.yaml

@@ -54,7 +54,7 @@ spec:
               protocol: TCP
           env:
             - name: SPRING_PROFILES_ACTIVE
-              value: 'github,kubernetes'
+              value: {{ .Values.adminService.config.profiles | quote }}
           {{- range $key, $value := .Values.adminService.env }}
             - name: {{ $key }}
               value: {{ $value }}

+ 1 - 1
scripts/helm/apollo-service/templates/deployment-configservice.yaml

@@ -56,7 +56,7 @@ spec:
               protocol: TCP
           env:
             - name: SPRING_PROFILES_ACTIVE
-              value: 'github,kubernetes'
+              value: {{ .Values.configService.config.profiles | quote }}
           {{- range $key, $value := .Values.configService.env }}
             - name: {{ $key }}
               value: {{ $value }}

+ 5 - 0
scripts/helm/apollo-service/values.yaml

@@ -37,6 +37,8 @@ configService:
     initialDelaySeconds: 30
     periodSeconds: 5
   config:
+    # spring profiles to activate
+    profiles: "github,kubernetes"
     # override apollo.config-service.url: config service url to be accessed by apollo-client 
     configServiceUrlOverride: ""
     # override apollo.admin-service.url: admin service url to be accessed by apollo-portal 
@@ -69,6 +71,9 @@ adminService:
   readiness:
     initialDelaySeconds: 30
     periodSeconds: 5
+  config:
+    # spring profiles to activate
+    profiles: "github,kubernetes"
   # environment variables passed to the container, e.g. JAVA_OPTS
   env: {}
   strategy: {}