kubernetes-环境变量不适用于整数 [英] kubernetes - environment variables not works with integers
问题描述
我在 docker中运行了一个.netcore Web App。因此开始将它与kubernetes集群在一起。在appsettings.json上有四个配置,这些配置将由环境变量转换(都在 $ {}之间):
I have one .netcore Web App running in "docker". So started to cluster it with kubernetes. Has four configs on the appsettings.json that will be converted by environment variables(all between "${}"):
{
"ConnectionSettings": [
{
"id": "${connectionSettings.connectionString.idMongoDb}",
"databaseName": "${connectionSettings.connectionString.databaseName}",
"connectionString": "${connectionSettings.connectionString.mongoDB}"
}
],
{
"Key": "Token.Issuer",
"Value": "${configuration.token.issuer}",
"Description": "",
"ModifiedDate": "2018-05-05 00:00:00.0000000",
"ModifiedBy": "system",
"AllowedProfiles": 1
}
}
这是我的 .yaml 文件的一部分:
It's a bit of my .yaml file:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-dev-api-dep
labels:
app: myapp-dev-api-dep
tier: app
version: v1
spec:
selector:
matchLabels:
app: myapp-dev-api
tier: app
version: v1
replicas: 1
template:
metadata:
labels:
app: myapp-dev-api
tier: app
version: v1
spec:
containers:
- name: myapp-dev-api
image: 'myappapi_tstkube:latest'
env:
- name: connectionSettings.connectionString.mongoDB
value: mongodb://192.168.20.99:27017
- name: configuration.token.issuer
value: '86400'
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
initialDelaySeconds: 30
periodSeconds: 3600
httpGet:
path: /swagger/index.html
port: 80
resources:
requests:
cpu: 25m
memory: 200Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
restartPolicy: Always
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 25%
maxSurge: 25%
看看我的配置:
变量 connectionSettings.connectionString.mongoDB 有效。但是变量 configuration.token.issuer 不能替代应用设置。
The variable "connectionSettings.connectionString.mongoDB" works. But the variable "configuration.token.issuer" can't substituted on the appsetting.
进行了一些测试。我只是用数字变量才发现问题。
Made some tests. I found the problem only with variables of numbers.
有人有想法或您有问题吗?
Has somebody an idea or have you had the problem?
vlw
推荐答案
问题出在yamls识别码中。 yaml文件中的错误空间可能有很多问题。
The problem was in the yamls identification code. You may have many problems with the error space in the yaml file.
https://github.com/helm/helm/blob/master/docs/chart_template_guide/yaml_techniques.md
关于数字。两个答案都是正确的。您可以使用单引号'86400'和ACII \ x38 \ x36 \ x34 \ x30 \ x30。
About the number. Both answers are right. You can use single quotation marks '86400' and ACII "\ x38 \ x36 \ x34 \ x30 \ x30".
谢谢大家
这篇关于kubernetes-环境变量不适用于整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!