应用交付提供插件模板功能,帮助增强 OAM 应用在运行过程中的扩展能力。本文为您介绍系统预置的插件模板。
系统预置的空白插件模板。适用于有明确需求,希望自行编写插件内容的场景。
为 Kubernetes 资源增加对于系统或者用户有意义的标识性属性,方便对 Kubernetes 资源进行分组管理。例如:组织和选择对象的子集。
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
cp.volces.com/label: "true"
{{ .Values.labelKey }}: {{ .Values.labelVal }}
为 Kubernetes 资源增加任意的非标识性元数据,用来记录资源的一些属性,以便客户端程序(例如工具和库)能够获取这些元数据信息。
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
cp.volces.com/annotation: "true"
annotations:
{{ .Values.annotationKey }}: {{ .Values.annotationVal }}
设置容器的 CPU/内存资源的请求量和上限。一方面保证当前服务拥有足够的资源供给,另一方面控制当前服务的资源使用量,避免资源挤兑。
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
cp.volces.com/resource-limit: "true"
spec:
template:
spec:
containers:
- name: {{ .AppDeliver.componentName }}
resources:
limits:
cpu: {{ .Values.cpuLimit }}
memory: {{ .Values.memoryLimit }}
requests:
cpu: {{ .Values.cpuRequest }}
memory: {{ .Values.memoryRequest }}
K8s 持续探测 TCP 服务的探针,用于指示容器是否正在运行。当探测失败时会根据 restartPolicy 策略重启容器。
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
cp.volces.com/liveness-probe-tcp: "true"
spec:
template:
spec:
containers:
- name: {{ .AppDeliver.componentName }}
livenessProbe:
tcpSocket:
port: {{ .Values.livenessTCPPort }}
initialDelaySeconds: {{ .Values.initDeploySeconds }}
{{- if .Values.periodSeconds }}
periodSeconds: {{ .Values.periodSeconds }}
{{- end}}
{{- if .Values.failureThreshold}}
failureThreshold: {{ .Values.failureThreshold }}
{{- end}}
K8s 持续探测 HTTP 服务的探针,用于指示容器是否正在运行。当探测失败时会根据 restartPolicy 策略重启容器。
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
cp.volces.com/liveness-probe-http: "true"
spec:
template:
spec:
containers:
- name: {{ .AppDeliver.componentName }}
livenessProbe:
httpGet:
path: {{ .Values.livenessHttpPath }}
port: {{ .Values.livenessHttpPort }}
httpHeaders:
- name: {{ .Values.livenessHttpHeaderName }}
value: {{ .Values.livenessHttpHeaderVal }}
initialDelaySeconds: {{ .Values.initDeploySeconds }}
{{- if .Values.periodSeconds }}
periodSeconds: {{ .Values.periodSeconds }}
{{- end}}
{{- if .Values.failureThreshold}}
failureThreshold: {{ .Values.failureThreshold }}
{{- end}}
用于指示容器是否准备好为请求提供 HTTP 服务。当 Pod 下所有容器都就绪时,才会接收来自 K8s Service 的流量,否则 Pod 是 unready 状态。
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
cp.volces.com/readiness-probe: "true"
spec:
template:
spec:
containers:
- name: {{ .AppDeliver.componentName }}
startupProbe:
httpGet:
path: {{ .Values.readinessHttpPath }}
port: {{ .Values.readinessHttpPort }}
httpHeaders:
- name: {{ .Values.readinessHttpHeaderName }}
value: {{ .Values.readinessHttpHeaderVal }}
initialDelaySeconds: {{ .Values.initDeploySeconds }}
{{- if .Values.periodSeconds }}
periodSeconds: {{ .Values.periodSeconds }}
{{- end}}
{{- if .Values.failureThreshold}}
failureThreshold: {{ .Values.failureThreshold }}
{{- end}}