按照 Quarkus Rest Client 教程,我需要在 application.properties 文件中添加与此类似的内容:
country-api/mp-rest/url=https://restcountries.eu/rest
使用 Docker 它可以工作,我可以通过参数传递属性值:
docker run -it --privileged --rm --env country-api/mp-rest/url="https://restcountries.eu/rest" mydockerhost/my-project:SNAPSHOT
Kubernetes 的 YAML 文件如下所示:
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"
但是执行命令时出现以下错误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 版本:1.3.1.Final