Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOSIP-35226] Enabled config-server to pull configurations from local… #736

Merged
merged 3 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion charts/config-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,15 @@ $ helm install my-release mosip/config-server
secretKeyRef:
name: {{ .Values.overrides.secrets.secretName }}
key: <key-name>
```
```

### Enable config-server to pull configurations from local git repo.

Set the below configuration values as mentioned in the values.yaml file in-order to pull the configurations from local git repository
* Set `localRepo` enabled to `true`.
* Update the `spring.profiles.active` to `native` under localRepo.
* Update the `spring.cloud.config.server.native.search-locations` to `file:///var/lib/config_repo` as this is the mountDir where your local configurations are cloned/maintained.
* Update the `spring.cloud.config.server.accept-empty` to `true`. # Server would return a HTTP 404 status, if the application is not found.By default, this flag is set to true.
* Update the `spring.cloud.config.server.git.force-pull` to `false`. # Spring Cloud Config Server makes a clone of the remote git repository and if somehow the local copy gets dirty (e.g. folder content changes by OS process) so Spring Cloud Config Server cannot update the local copy from remote repository but as our configurations are maintained locally we are setting this to `false`.
* Update the `spring.cloud.config.server.git.refreshRate` to `0`. # Setting up refresh rate to 5 seconds so that config server will check for updates in Git repo after every one minute, can be lowered down for production.
* Update the `spring.cloud.config.server.git.cloneOnStart` to `false`. # Adding provision to clone on start of server instead of first request but our configurations are stored in local so no need to clone the repository on start of server so setting it to `false`.
19 changes: 19 additions & 0 deletions charts/config-server/templates/config-pv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if .Values.localRepo.enabled }}
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ .Values.volume.name }}
labels:
name: {{ .Values.volume.name }}
spec:
storageClassName: {{ .Values.volume.storageClass }}
capacity:
storage: {{ .Values.volume.size }}
accessModes:
{{- range .Values.volume.accessModes }}
- {{ . }}
{{- end }}
nfs:
server: {{ .Values.volume.nfs.server }}
path: {{ .Values.volume.nfs.path }}
{{- end }}
19 changes: 19 additions & 0 deletions charts/config-server/templates/config-pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if .Values.localRepo.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.volume.name }}
namespace: {{ .Release.Namespace | quote }}
spec:
storageClassName: {{ .Values.volume.storageClass }}
accessModes:
{{- range .Values.volume.accessModes }}
- {{ . }}
{{- end }}
resources:
requests:
storage: {{ .Values.volume.size }}
selector:
matchLabels:
name: {{ .Values.volume.name }}
{{- end }}
6 changes: 5 additions & 1 deletion charts/config-server/templates/configmap-env-vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ metadata:
namespace: {{ .Release.Namespace }}
data:
SPRING_CLOUD_CONFIG_SERVER_GIT_SEARCHPATHS: {{ .Values.gitRepo.searchFolders | quote }}
{{- if .Values.localRepo.enabled }}
SPRING_CLOUD_CONFIG_SERVER_GIT_URI: {{ .Values.volume.mountDir | quote }}
{{- else }}
SPRING_CLOUD_CONFIG_SERVER_GIT_URI: {{ .Values.gitRepo.uri | quote }}
SPRING_CLOUD_CONFIG_SERVER_GIT_USERNAME: {{ .Values.gitRepo.username | quote }}
{{- end }}
SPRING_CLOUD_CONFIG_SERVER_GIT_USERNAME: {{ .Values.gitRepo.username | quote }}
25 changes: 23 additions & 2 deletions charts/config-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,25 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- if .Values.localRepo.enabled }}
- name: spring_profiles_active
value: {{ .Values.localRepo.spring_profiles_active | quote }}
- name: spring_cloud_config_server_native_search-locations
value: {{ .Values.localRepo.spring_cloud_config_server_native_search_locations | quote }}
- name: spring_cloud_config_server_accept-empty
value: {{ .Values.localRepo.spring_cloud_config_server_accept_empty | quote }}
- name: spring_cloud_config_server_git_force-pull
value: {{ .Values.localRepo.spring_cloud_config_server_git_force_pull | quote }}
- name: spring_cloud_config_server_git_refreshRate
value: {{ .Values.localRepo.spring_cloud_config_server_git_refreshRate | quote }}
- name: spring_cloud_config_server_git_cloneOnStart
value: {{ .Values.localRepo.spring_cloud_config_server_git_cloneOnStart | quote }}
{{- end }}
- name: SPRING_CLOUD_CONFIG_SERVER_GIT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "config-server.fullname" . }}
key: github-token

{{- range .Values.envVariables }}
{{- if .enabled }}
- name: {{ .name }}
Expand All @@ -61,7 +74,6 @@ spec:
{{- if .Values.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }}
{{- end }}

envFrom:
- configMapRef:
name: {{ printf "%s-env-vars" (include "config-server.fullname" .) }}
Expand All @@ -86,6 +98,15 @@ spec:
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if .Values.localRepo.enabled }}
volumeMounts:
- name: {{ .Values.volume.name }}
mountPath: {{ .Values.volume.mountDir }}
volumes:
- name: {{ .Values.volume.name }}
persistentVolumeClaim:
claimName: {{ .Values.volume.name }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
75 changes: 71 additions & 4 deletions charts/config-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ springServicePort: 51000
startupProbe:
enabled: true
httpGet:
path: "/config/*/*"
path: "/config/application/default"
port: 51000
initialDelaySeconds: 0
periodSeconds: 10
Expand All @@ -43,7 +43,7 @@ startupProbe:
livenessProbe:
enabled: true
httpGet:
path: "/config/*/*"
path: "/config/application/default"
port: 51000
initialDelaySeconds: 20
periodSeconds: 10
Expand All @@ -54,7 +54,7 @@ livenessProbe:
readinessProbe:
enabled: true
httpGet:
path: "/config/*/*"
path: "/config/application/default"
port: 51000
initialDelaySeconds: 0
periodSeconds: 10
Expand Down Expand Up @@ -127,14 +127,81 @@ affinity: {}
## version: branch/tag of the repo to be used
gitRepo:
uri: https://github.com/mosip/mosip-config
version: 1.2.0_v3
version: develop
## Folders within the base repo where properties may be found.
searchFolders: ""
private: false
## User name of user who has access to the private repo. Ignore for public repo
username: ""
token: ""

localRepo:
enabled: false
spring_profiles_active: "native"
spring_cloud_config_server_native_search_locations: "file:///var/lib/config_repo"
spring_cloud_config_server_accept_empty: true
spring_cloud_config_server_git_force_pull: false
spring_cloud_config_server_git_refreshRate: 0
spring_cloud_config_server_git_cloneOnStart: false

volume:
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack).
##
# storageClass: "-"
##
## If you want to reuse an existing claim, you can pass the name of the PVC using
## the existingClaim variable
# existingClaim: your-claim
## ReadWriteMany not supported by AWS gp2
name: config-server
storageClass: nfs-client
accessModes:
- ReadWriteMany
size: 10Mi
existingClaim:
# Dir where config and keys are written inside container
mountDir: '/var/lib/config_repo'
nfs:
path: '' # Dir within the nfs server where config repo is cloned/maintained locally.
server: '' # Ip address of nfs server.

## Init containers parameters:
## volumePermissions: Change the owner and group of the persistent volume mountpoint to runAsUser:fsGroup values from the securityContext section.
##
volumePermissions:
enabled: true
image:
registry: docker.io
repository: bitnami/bitnami-shell
tag: "10"
pullPolicy: Always
## Optionally specify an array of imagePullSecrets.
## Secrets must be manually created in the namespace.
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
##
pullSecrets: []
## - myRegistryKeySecretName
## Init containers' resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
##
resources:
## We usually recommend not to specify default resources and to leave this as a conscious
## choice for the user. This also increases chances charts run on environments with little
## resources, such as Minikube. If you do want to specify resources, uncomment the following
## lines, adjust them as necessary, and remove the curly braces after 'resources:'.
##
limits: {}
## cpu: 100m
## memory: 128Mi
##
requests: {}
## cpu: 100m
## memory: 128Mi
##

# All env variables that are accessed from mosip config properties
envVariables:
Expand Down
Loading