Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
How to edit configmap configuration in spring boot kubernetes application during runtime

We have application with huge configuration (this is just a part):

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-app
data:
  application.yaml: |-
    config:
      app: MY-APP
      my-custom-map:
        KEY1: value1
        KEY2: value2
        KEY3: value3
        KEY4: value4
      something1: true
      something2: 123
      something3: string123
      something4: null
      subclass:
        anotherMap:
          "[AAA:0.0.1,BBB:CCC]": "DDD:EEEE"
      subclass2:
        something4: AAAA
        anotherMap2:
          0.0.3: 0.0.3

I follow this example to bind configmap with spring boot configuration but there is still some problem for example how to solve null in yaml which spring yaml postprocessor resolve as empty string: issue

second problem is how to handle this configmap. I know I can edit and then use apply but this can lead to some error. Is there some tool which I can use to edit this yaml and make some bash script for editing ? like: ./my-script.sh -function addMyCustomMapValue -args "KEY5:value5" . I tried to explore yq but I think there is some limitation and it is hard to use for some use-case and then kustomize which I think is good for creating configmap but not for editing existing one.

Is there already some good example for this use-case ?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Option : 1

You can Use the Lens : https://k8slens.dev/kubernetes.html

It's UI for monitoring and Managing K8s clusters. Using this you can also edit the configmap.

Option : 2

You can manage all the Key value into single YAML file and create configmap from file :

kubectl create configmap some-config \
  --from-file=some-key=some-config.yaml \
  -n some-namespace \
  -o yaml \
  --dry-run | kubectl apply -f - 

Option : 3

Use helm and values.yaml template to create and your chart and apply it further.

Configmap using YAML helm

apiVersion: v1
kind: ConfigMap
metadata:
  name: jksconfig
data:
  config.json: |-
    {{ .Files.Get "config.json" | indent 4 }}

Option : 4

If you are using the configmap as Environment or injecting it to file path you can use the Hashi corp vault also : https://www.vaultproject.io/

Option : 5

As you suggested you can create one Bash script which will export the existing running Configmap to a new YAML file one you are done with editing YAML manually. You can apply the changes to K8s cluster.

#bin/bash
kubectl get configmap <configmap-name>  -o yaml > cofig.yaml

You can also check the : https://github.com/Gallore/yaml_cli might be helpful.

over 4 years ago · Santiago Trujillo Relatório

0

apiVersion: v1
kind: ConfigMap
metadata:
  name: application-conf
data: 
  {{- if .Values.global.applicationConfiguration }}
  application.properties: | 
    {{- .Values.global.applicationConfiguration  | nindent 4 }}
   {{- end }}

This is how we can specify a config map. Add applicationConfiguration in your values.yaml if it specified then only it will write an application.properties externally. It need not have all the properties.

over 4 years ago · Santiago Trujillo Relatório

0

This is best tool to edit and make changes in kubernetes env

k9s : https://github.com/derailed/k9s

You can explore https://kubeval.instrumenta.dev/ to catch any configmap error before deploying

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda