From 0173304a46e937d95e1694b988d50ffd61f87b42 Mon Sep 17 00:00:00 2001 From: Jason Song Date: Sun, 26 Jul 2020 13:42:10 +0800 Subject: [PATCH] support user defined config files and spring profiles --- scripts/helm/README.md | 30 +++++++++++++++++++ .../templates/deployment-portal.yaml | 19 ++++++++++-- scripts/helm/apollo-portal/values.yaml | 4 +++ .../templates/deployment-adminservice.yaml | 2 +- .../templates/deployment-configservice.yaml | 2 +- scripts/helm/apollo-service/values.yaml | 5 ++++ 6 files changed, 57 insertions(+), 5 deletions(-) diff --git a/scripts/helm/README.md b/scripts/helm/README.md index 2d7c6c7065e..36d6eb1648c 100644 --- a/scripts/helm/README.md +++ b/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.
`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.
`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.
`dev: http://apollo-configservice-dev:8080`
`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" ``` \ No newline at end of file diff --git a/scripts/helm/apollo-portal/templates/deployment-portal.yaml b/scripts/helm/apollo-portal/templates/deployment-portal.yaml index 34cc4ed2961..bf588046418 100644 --- a/scripts/helm/apollo-portal/templates/deployment-portal.yaml +++ b/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 }} diff --git a/scripts/helm/apollo-portal/values.yaml b/scripts/helm/apollo-portal/values.yaml index 99fadf222b4..991bd327430 100644 --- a/scripts/helm/apollo-portal/values.yaml +++ b/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 diff --git a/scripts/helm/apollo-service/templates/deployment-adminservice.yaml b/scripts/helm/apollo-service/templates/deployment-adminservice.yaml index 8dcc9db3f8d..547bd1c8d43 100644 --- a/scripts/helm/apollo-service/templates/deployment-adminservice.yaml +++ b/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 }} diff --git a/scripts/helm/apollo-service/templates/deployment-configservice.yaml b/scripts/helm/apollo-service/templates/deployment-configservice.yaml index faec8f7aef5..501e7dfa629 100644 --- a/scripts/helm/apollo-service/templates/deployment-configservice.yaml +++ b/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 }} diff --git a/scripts/helm/apollo-service/values.yaml b/scripts/helm/apollo-service/values.yaml index 58a5eeb4a90..9c7197a77ae 100644 --- a/scripts/helm/apollo-service/values.yaml +++ b/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: {}