Переопределение переменных и настроек приложений в Kubernetes
В случае, если есть необходимость переопределить переменные или настройки для компонентов Test IT (например, уровень логирования), а также есть требование не хранить чувствительные данные в переменных окружения,
- Отредактируйте соответствующее поле в
values.yaml
илиvalues-override.yaml
:webapi: configJson: webapi-appsettings-json: appsettings.json: # Name of the file in the configmap # JSON contents: AWS_ACCESS_KEY: "myAWSAccessKey" AWS_SECRET_KEY: "myAWSSecretKey" # Other variables you want to put in a file # --- Serilog: System: MinimumLevel: "Information" # Verbose, Debug, Information, Warning, Error # If you need the app to write to file SystemAll: MinimumLevel: "Information" # Verbose, Debug, Information, Warning, Error WriteTo: - Args: path: "/app/log/system.log" # SystemAll path logs rollingInterval: "Day" # Rolling interval retainedFileCountLimit: "7" # Retention period UserAction: MinimumLevel: "Information" # Verbose, Debug, Information, Warning, Error UserActionAll: MinimumLevel: "Information" # Verbose, Debug, Information, Warning, Error WriteTo: - Args: path: "/app/log/user_actions.log" # AdminAll path logs rollingInterval: "Day" # Rolling interval retainedFileCountLimit: "7" # Retention period
Данный файл будет располагаться в директории приложений:
# values.yaml или values-override.yaml
webapi:
volumes:
appsettings-json:
fromConfigMap: webapi-appsettings-json
mounts:
webapi:
mountPath: /app/customs/appsettings.json
subPath: appsettings.json
general:
config:
APPLICATION__CONFIGURATION__CUSTOMFILEPATH: "/app/customs/appsettings.json"
При переопределении учитывайте:
- Дополнительный appsettings.json имеет приоритет выше, чем переменные окружения и основной appsettings.json.
- Дополнительный appsettings.json не является заменой основного файла, а действует как дополняющий или переопределяющий файл.
- Перечень переменных для компонентов Test IT расположен по пути
values.yaml:service-name.config
иvalues.yaml:general.config
.
Переменные, название которых включает два "_" подряд, в файле .json структурно разделяются:
## пример для Hangfire__DbConnectionString
webapi:
configJson:
webapi-appsettings-json:
appsettings.json:
Handfire:
DbConnectionString: "Host=postgres;Port=5432;Database=backgrounddb;Username=backgrounddbowner;Password=password;Pooling=true;Maximum Pool Size=130;Command Timeout=30"