Reputation: 13
i have a docker-composes for app dotnetcore, I'm new to k8s, my app has quite a long envvariable. "ConnectionStrings__DefaultConnection" as below
productstudio:
volumes:
- ${USERPROFILE}/.aws:/root/.aws
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ConnectionStrings__DefaultConnection=Username=someuser;Password=somepassword;Server=postgres;Port=5432;Database=somedb;Search Path=some
- EventBus__Enable=true
- EventBus__HostUri=rabbitmq://eventbus/
and i write configmap
apiVersion: v1
kind: ConfigMap
metadata:
name: be-productstudio-configmap
labels:
app: product-builder-be
tier: backend
data:
ASPNETCORE_ENVIRONMENT: Development
EventBus__Enable: true
EventBus__HostUri: rabbitmq://eventbus/
ConnectionStrings__DefaultConnection: |-
Username=someuser;
Password=somepassword;
Server=postgres;
Port=5432;
Database=somedb;
Search Path=some
But I got an error
Error from server (BadRequest): error when creating "manifect-be.yml": ConfigMap in version "v1" cannot be handled as a ConfigMap: v1.ConfigMap.Data: ReadString: expects " or n, but found t, error found in #10 byte of ...|_Enable":true,"Event|..., bigger context ...|nSearch Path=productstudio\"","EventBus__Enable":true,"EventBus__HostUri":"rabbitmq://eventbus/"},"k|...
Can anyone help me, thanks
Upvotes: 1
Views: 292
Reputation: 13898
I see two issues here:
true
for EventBus__Enable
is not quoted and it gets treated as a keyword that means a boolean true. Environment variables are strings and must be quoted in your yaml definition. You need to make it look more like this: EventBus__Enable: "true"
ConfigMap
:Search Path=productstudio
as:
Each key under the
data
or thebinaryData
field must consist of alphanumeric characters,-
,_
or.
.
You can use the official docs for a reference of a correctly configured ConfigMaps, for example:
apiVersion: v1
kind: ConfigMap
metadata:
name: game-demo
data:
# property-like keys; each key maps to a simple value
player_initial_lives: "3"
ui_properties_file_name: "user-interface.properties"
# file-like keys
game.properties: |
enemy.types=aliens,monsters
player.maximum-lives=5
user-interface.properties: |
color.good=purple
color.bad=yellow
allow.textmode=true
Upvotes: 2