Skip to content

Commit

Permalink
support user defined config files and spring profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
nobodyiam committed Aug 1, 2020
1 parent fd74317 commit 0173304
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 5 deletions.
30 changes: 30 additions & 0 deletions scripts/helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` | `{}` |
Expand All @@ -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 | `{}` |
Expand Down Expand Up @@ -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` |
Expand Down Expand Up @@ -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"
```
19 changes: 16 additions & 3 deletions scripts/helm/apollo-portal/templates/deployment-portal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand All @@ -64,20 +72,25 @@ 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
subPath: application-github.properties
- 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 }}
Expand Down
4 changes: 4 additions & 0 deletions scripts/helm/apollo-portal/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
5 changes: 5 additions & 0 deletions scripts/helm/apollo-service/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: {}
Expand Down

0 comments on commit 0173304

Please sign in to comment.