2 years ago

#44004

test-img

Javier

kubernetes configmap with spring cloud with dictionaries and sincronization: best practice

I am reviewing the following code of a java application in kubernetes that uses springcloud for the management of configmap's and I would like to know if this is the best implementation for a list of pairs (code ,value) thinking about the following issues:

  • best nomeclature for the configmap yaml.
  • Maintenance and synchronization of values ​​between the application properties file and the values ​​in the yaml of the configmap.
  • performance in loading keys and values ​​in kubernetes and better way of use by the application deplyment(such as mounted volume, enviroments variables)
  • type of object mapping iimplemented in the app.

boostrap.yaml in source code:

%YAML 1.2
---
spring:
    application:
        name: ms-service-app
    cloud:
        kubernetes:
            reload:
                enabled: true
                mode: polling
                period: 100000
                monitoring-config-maps: true
            config:
                enabled: true
                sources:
                - name: bankslist

bankslist.properties in source code. List with no order of value pairs of code and name:

## Banks List       
ms.service.banks.001=BankA_Name 
ms.service.banks.009=BankC_Name
ms.service.banks.020=BankO_Name
ms.service.banks.042=BankP_Name

kubernetes configmap definition , perhaps with more values than the properties ( ... means many items, is not part of the yaml): bankslist.yaml:

kind: ConfigMap
apiVersion: v1
metadata:
  name: bankslist
data:
  bankslist.properties: |-

    ## Banks List.
    ms.service.banks.001=BankA_Name
    ms.service.banks.009=BankC_Name
    ms.service.banks.020=BankO_Name
    ms.service.banks.042=BankP_Name
    ...
    ms.service.banks.100=BankT_Name
    ms.service.banks.102=BankU_Name

kubernetes

properties

yaml

spring-cloud-config

configmap

0 Answers

Your Answer

Accepted video resources