配置默认值 ConfigMap¶
config-defaults
ConfigMap,称为默认值 ConfigMap,包含确定 Knative 如何为资源设置默认值的设置。
此 ConfigMap 位于 knative-serving
命名空间中。
您可以通过运行以下命令查看当前的 config-defaults
ConfigMap
kubectl get configmap -n knative-serving config-defaults -oyaml
示例 config-defaults ConfigMap¶
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
revision-timeout-seconds: "300"
max-revision-timeout-seconds: "600"
revision-response-start-timeout-seconds: "300"
revision-idle-timeout-seconds: "0" # infinite
revision-cpu-request: "400m"
revision-memory-request: "100M"
revision-ephemeral-storage-request: "500M"
revision-cpu-limit: "1000m"
revision-memory-limit: "200M"
revision-ephemeral-storage-limit: "750M"
container-name-template: "user-container"
container-concurrency: "0"
container-concurrency-max-limit: "1000"
allow-container-concurrency-zero: "true"
enable-service-links: "false"
请参阅下面对每个属性的描述。
属性¶
修订超时秒¶
修订超时值确定如果未指定,则用于修订的每个请求超时的默认秒数。
- 全局键:
revision-timeout-seconds
- 每个修订的规范键:
timeoutSeconds
- 可能的值: 整数
- 默认值:
"300"
(5 分钟)
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
revision-timeout-seconds: "300"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
namespace: default
spec:
template:
spec:
timeoutSeconds: 300
containers:
- image: ghcr.io/knative/helloworld-go:latest
最大修订超时秒¶
max-revision-timeout-seconds
值确定可用于 revision-timeout-seconds
的最大秒数。此值必须大于或等于 revision-timeout-seconds
。如果省略,则使用系统默认值(600 秒)。
如果增加此值,还应增加激活器的 terminationGracePeriodSeconds
以防止正在进行的请求被打断。
- 全局键:
max-revision-timeout-seconds
- 每个修订的注释键: N/A
- 可能的值: 整数
- 默认值:
"600"
(10 分钟)
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
max-revision-timeout-seconds: "600"
修订响应开始超时秒¶
修订响应开始超时值确定请求路由层将等待传递到容器的请求开始发送任何网络流量的最大持续时间(以秒为单位)。如果省略,则使用系统默认值(300 秒)。
- 全局键:
revision-response-start-timeout-seconds
- 每个修订的规范键:
responseStartTimeoutSeconds
- 可能的值: 整数
- 默认值:
"300"
(5 分钟)
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
revision-response-start-timeout-seconds: "300"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
namespace: default
spec:
template:
spec:
responseStartTimeoutSeconds: 300
containers:
- image: ghcr.io/knative/helloworld-go:latest
修订空闲超时秒¶
修订空闲超时值确定请求在未从用户的应用程序接收任何字节的情况下保持打开状态的最大持续时间(以秒为单位)。如果省略,则使用系统默认值(无限)。
- 全局键:
revision-idle-timeout-seconds
- 每个修订的规范键:
idleTimeoutSeconds
- 可能的值: 整数
- 默认值:
"0"
(无限)
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
revision-idle-timeout-seconds: "0"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
namespace: default
spec:
template:
spec:
idleTimeoutSeconds: 0
containers:
- image: ghcr.io/knative/helloworld-go:latest
修订 CPU 请求¶
revision-cpu-request
值确定默认分配给修订的 CPU 分配。如果省略此值,则使用系统默认值。此键默认情况下未为 Knative 启用。
- 全局键:
revision-cpu-request
- 每个修订的注释键:
cpu
- 可能的值: 整数
- 默认值:
"400m"
(0.4 个 CPU 或 400 个毫 CPU)
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
revision-cpu-request: "400m"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
namespace: default
spec:
template:
spec:
containers:
- image: ghcr.io/knative/helloworld-go:latest
resources:
requests:
cpu: "400m"
修订内存请求¶
revision-memory-request
值确定默认分配给修订的内存分配。如果省略此值,则使用系统默认值。此键默认情况下未为 Knative 启用。
- 全局键:
revision-memory-request
- 每个修订的注释键:
memory
- 可能的值: 整数
- 默认值:
"100M"
(100 兆字节内存)
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
revision-memory-request: "100M"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
namespace: default
spec:
template:
spec:
containers:
- image: ghcr.io/knative/helloworld-go:latest
resources:
requests:
memory: "100M"
修订瞬时存储请求¶
revision-ephemeral-storage-request
值确定默认分配给修订的瞬时存储分配。如果省略此值,则使用系统默认值。此键默认情况下未为 Knative 启用。
- 全局键:
revision-ephemeral-storage-request
- 每个修订的注释键:
ephemeral-storage
- 可能的值: 整数
- 默认值:
"500M"
(500 兆字节存储)
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
revision-ephemeral-storage-request: "500M"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
namespace: default
spec:
template:
spec:
containers:
- image: ghcr.io/knative/helloworld-go:latest
resources:
requests:
ephemeral-storage: "500M"
修订 CPU 限制¶
revision-cpu-limit
值确定修订的默认 CPU 分配限制。如果省略此值,则使用系统默认值。此键默认情况下未为 Knative 启用。
- 全局键:
revision-cpu-limit
- 每个修订的注释键:
cpu
- 可能的值: 整数
- 默认值:
"1000m"
(1 个 CPU 或 1000 个毫 CPU)
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
revision-cpu-limit: "1000m"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
namespace: default
spec:
template:
spec:
containers:
- image: ghcr.io/knative/helloworld-go:latest
resources:
requests:
cpu: "1000m"
修订内存限制¶
revision-memory-limit
值确定修订的默认内存分配限制。如果省略此值,则使用系统默认值。此键默认情况下未为 Knative 启用。
- 全局键:
revision-memory-limit
- 每个修订的注释键:
memory
- 可能的值: 整数
- 默认值:
"200M"
(200 兆字节内存)
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
revision-memory-limit: "200M"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
namespace: default
spec:
template:
spec:
containers:
- image: ghcr.io/knative/helloworld-go:latest
resources:
requests:
memory: "200M"
修订瞬时存储限制¶
revision-ephemeral-storage-limit
值确定分配给修订的默认瞬时存储限制。如果省略此值,则使用系统默认值。此键默认情况下未为 Knative 启用。
- 全局键:
revision-ephemeral-storage-limit
- 每个修订的注释键:
ephemeral-storage
- 可能的值: 整数
- 默认值:
"750M"
(750 兆字节存储)
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
revision-ephemeral-storage-limit: "750M"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
namespace: default
spec:
template:
spec:
containers:
- image: ghcr.io/knative/helloworld-go:latest
resources:
requests:
ephemeral-storage: "750M"
容器名称模板¶
container-name-template
值在未指定容器名称的情况下提供默认容器名称的模板。此字段支持 Go 模板,并由封闭的服务或配置的 ObjectMeta
提供,因此 {{.Name}}
等值也为有效值。
- 全局键:
container-name-template
- 每个修订的注释键:
name
- 可能的值: 字符串
- 默认值:
"user-container"
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
container-name-template: "user-container"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
namespace: default
spec:
template:
spec:
containers:
- name: user-container
image: ghcr.io/knative/helloworld-go:latest
容器并发性¶
container-concurrency
值指定容器一次可以处理的请求最大数量。超过此阈值的请求将排队。将值设置为零将禁用此节流,并让所有进入 pod 的请求通过。
- 全局键:
container-concurrency
- 每个修订的规范键:
containerConcurrency
- 可能的值: 整数
- 默认值:
"0"
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
container-concurrency: "0"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
namespace: default
spec:
template:
spec:
containerConcurrency: 0
容器并发性最大限制¶
container-concurrency-max-limit
设置会禁用单个修订的任意大并发值或自动缩放目标。container-concurrency
默认设置必须低于或等于此值。container-concurrency-max-limit
设置的值必须大于 1。
注意
即使设置了此值,用户也可以选择 containerConcurrency
值为零(无界),除非 allow-container-concurrency-zero
设置为 "false"
。
- 全局键:
container-concurrency-max-limit
- 每个修订的注释键: N/A
- 可能的值: 整数
- 默认值:
"1000"
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
container-concurrency-max-limit: "1000"
apiVersion: operator.knative.dev/v1beta1
kind: KnativeServing
metadata:
name: knative-serving
namespace: knative-serving
spec:
config:
defaults:
container-concurrency-max-limit: "1000"
允许容器并发性为零¶
allow-container-concurrency-zero
值确定用户是否可以为 containerConcurrency
指定 0
(无界)。
- 全局键:
allow-container-concurrency-zero
- 每个修订的注释键: N/A
- 可能的值: 布尔值
- 默认值:
"true"
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
allow-container-concurrency-zero: "true"
启用服务链接¶
enable-service-links
值指定在用户省略时,PodSpec
的 enableServiceLinks
字段使用的默认值。请参阅有关 enableServiceLinks
功能的 Kubernetes 文档。
这是一个三态标志,可能的值为(true|false|default)。
在具有大量服务的环境中,建议将此值设置为 false
。请参阅serving#8498。
- 全局键:
enable-service-links
- 每个修订的注释键: N/A
- 可能的值:
true|false|default
- 默认值:
"false"
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-defaults
namespace: knative-serving
data:
enable-service-links: "false"