配置部署资源¶
名为 Deployment ConfigMap 的 config-deployment ConfigMap 包含用于确定如何配置支持 Knative 服务的 Kubernetes Deployment 资源的设置。此 ConfigMap 位于 knative-serving 命名空间中。
您可以通过运行以下命令查看当前的 config-deployment ConfigMap
kubectl get configmap -n knative-serving config-deployment -oyaml
config-deployment ConfigMap 示例¶
apiVersion: v1
kind: ConfigMap
metadata:
name: config-deployment
namespace: knative-serving
labels:
serving.knative.dev/release: devel
annotations:
knative.dev/example-checksum: "fa67b403"
data:
# This is the Go import path for the binary that is containerized
# and substituted here.
queue-sidecar-image: ko://knative.com.cn/serving/cmd/queue
# List of repositories for which tag to digest resolving should be skipped
registries-skipping-tag-resolving: "kind.local,ko.local,dev.local"
# digest-resolution-timeout is the maximum time allowed for an image's
# digests to be resolved.
digest-resolution-timeout: "10s"
# progress-deadline is the duration we wait for the deployment to
# be ready before considering it failed.
progress-deadline: "600s"
# queue-sidecar-cpu-request is the requests.cpu to set for the queue proxy sidecar container.
# If omitted, a default value (currently "25m"), is used.
queue-sidecar-cpu-request: "25m"
# queue-sidecar-cpu-limit is the limits.cpu to set for the queue proxy sidecar container.
# If omitted, no value is specified and the system default is used.
queue-sidecar-cpu-limit: "1000m"
# queue-sidecar-memory-request is the requests.memory to set for the queue proxy container.
# If omitted, no value is specified and the system default is used.
queue-sidecar-memory-request: "400Mi"
# queue-sidecar-memory-limit is the limits.memory to set for the queue proxy container.
# If omitted, no value is specified and the system default is used.
queue-sidecar-memory-limit: "800Mi"
# queue-sidecar-ephemeral-storage-request is the requests.ephemeral-storage to
# set for the queue proxy sidecar container.
# If omitted, no value is specified and the system default is used.
queue-sidecar-ephemeral-storage-request: "512Mi"
# queue-sidecar-ephemeral-storage-limit is the limits.ephemeral-storage to set
# for the queue proxy sidecar container.
# If omitted, no value is specified and the system default is used.
queue-sidecar-ephemeral-storage-limit: "1024Mi"
配置进度截止时间¶
配置进度截止时间设置允许您指定最大时间(以秒或分钟为单位),您将等待您的 Deployment 取得进展,然后系统报告该 Deployment 未能为 Knative Revision 取得进展。
默认进度截止时间为 600 秒。该值表示为 Golang time.Duration 字符串表示形式,并且必须四舍五入到秒精度。
如果无法在此设置定义的时间限制内实现初始扩容,Knative Autoscaler 组件会将 Revision 扩容到 0,并且 Knative 服务进入终端 Failed 状态。
如果您的 Knative 部署中出现以下任何问题,您可能希望将此设置配置为更高的值
- 由于镜像大小,拉取服务镜像需要很长时间。
- 由于初始缓存状态的预热,服务需要很长时间才能变为
READY。 - 集群依赖于集群自动扩容来为新 Pod 分配资源。
有关更多信息,请参阅 Kubernetes 文档。
进度截止时间设置可以通过 ConfigMap 在全局级别配置,也可以使用注解在每个修订级别配置。
- 全局键:
progress-deadline - 每个修订的注解键:
serving.knative.dev/progress-deadline - 可能的值:
time.Duration - 默认值:
"600s"
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-deployment
namespace: knative-serving
labels:
serving.knative.dev/release: devel
annotations:
knative.dev/example-checksum: "fa67b403"
data:
progress-deadline: "10m"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld-go
spec:
template:
metadata:
annotations:
serving.knative.dev/progress-deadline: "60s"
spec:
containers:
- image: ghcr.io/knative/helloworld-go:latest
跳过标签解析¶
您可以通过修改 registries-skipping-tag-resolving ConfigMap 设置来配置 Knative Serving,以跳过 Deployment 的标签解析。
以下示例展示了如何禁用 registry.example.com 的标签解析
apiVersion: v1
kind: ConfigMap
metadata:
name: config-deployment
namespace: knative-serving
labels:
serving.knative.dev/release: devel
annotations:
knative.dev/example-checksum: "fa67b403"
data:
# List of repositories for which tag to digest resolving should be skipped
registries-skipping-tag-resolving: registry.example.com
配置可选的 RuntimeClassName¶
您可以通过修改 runtime-class-name 设置来配置 Knative Serving,以使用指定的 RuntimeClassName (Pod.Spec.RuntimeClassName) 配置部署。
此设置与 Service 标签配合使用,并将配置默认值或最匹配标签的值。
示例
apiVersion: v1
kind: ConfigMap
metadata:
name: config-deployment
namespace: knative-serving
data:
runtime-class-name: |
kata: {}
gvisor:
selector:
my-label: selector
apiVersion: operator.knative.dev/v1beta1
kind: KnativeServing
metadata:
name: knative-serving
namespace: knative-serving
spec:
config:
deployment:
runtime-class-name: |
kata: {}
gvisor:
selector:
my-label: selector
有关更多信息,请参阅 Kubernetes RuntimeClass 文档。
另外,还有一个功能标志允许手动配置 RuntimeClassName。