Invalid env value with Quarkus RestClient property when create kubernetes deployment

Emerson Luiz :

Following the Quarkus Rest Client tutorial I need to add something similar to this to the application.properties file:

country-api/mp-rest/url=https://restcountries.eu/rest

With Docker it works and I can pass the property value by parameter:

docker run -it --privileged --rm --env country-api/mp-rest/url="https://restcountries.eu/rest" mydockerhost/my-project:SNAPSHOT

The YAML file for Kubernetes looks like this:

apiVersion: "apps/v1"
kind: "Deployment"
metadata:
  labels:
    app.kubernetes.io/name: "my-project"
    app.kubernetes.io/version: "SNAPSHOT"
  name: "my-project-deployment"
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: "my-project"
      app.kubernetes.io/version: "SNAPSHOT"
  template:
    metadata:
      labels:
        app.kubernetes.io/name: "my-project"
        app.kubernetes.io/version: "SNAPSHOT"
    spec:
      containers:
      - env:
        - name: "country-api/mp-rest/url"
          value: "https://restcountries.eu/rest"

However the following error is occurring when executing the command kubectl apply -f my-projetc.yaml

The Deployment "my-project-deployment" is invalid: * spec.template.spec.containers[0].env[1].name: Invalid value: "country-api/mp-rest/url": a valid environment variable name must consist of alphabetic characters, digits, '_', '-', or '.', and must not start with a digit (e.g. 'my.env-name', or 'MY_ENV.NAME', or 'MyEnvName1', regex used for validation is '[-._a-zA-Z][-._a-zA-Z0-9]*')

Quarkus version: 1.3.1.Final

Guillaume Smet :

You can use environment variables in application.properties so you could do something like:

country-api/mp-rest/url=${MY_SERVICE_URL}

and define MY_SERVICE_URL in your Yaml file.

Also, MicroProfile Config has a way to work around your issue. Using COUNTRY_API_MP_REST_URL as an environment variable should work (uppercase everything, replace anything non alphanumeric with _).

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=398069&siteId=1