ไลบรารีสคีมาและไลบรารีการแมปที่ใช้ร่วมกัน: Component MariaDB
หน้า
aggrega draft --example mariadb-adminerจาก
cd mariadb-admineraggrega pull --release release-compose.yamlaggrega build --release release-compose.yamlเอนทิตีmy-org รูป
ไลบรารีสคีมาเก็บรูปทรง
SchemaLibrary ประกาศ
apiVersion: aggrega.ai/v1beta1kind: SchemaLibrarymetadata: name: Datastores version: 1.0.0spec: schemas: PodResources: requests: cpu: { type: string, pattern: "^[0-9]+(m|\\.[0-9]+)?$", default: "250m" } memory: { type: string, pattern: "^[1-9][0-9]*(Mi|Gi)$", default: "512Mi" } NodePool: replicaCount: { type: integer, min: 1, max: 9, default: 1 } resources: { $ref: "Datastores#/schemas/PodResources" } MariaDBPayload: architecture: { type: string, enum: [standalone, replication], default: standalone } image: tag: { type: string, validate: '{{ ne . "latest" }}', validateMessage: "image.tag must name a version: latest moves with every chart release" } primary: { $ref: "Datastores#/schemas/NodePool", required: true } secondary: when: '{{ eq $.architecture "replication" }}' required: true properties: replicaCount: { type: integer, min: 2, max: 8, default: 2 }การmetadata.name — Datastores#/schemas/<entry> — ไม่validate: และ validateMessage: เพิ่มwhen: ทำให้replication $ref: ข้ามproperties, required และ description ไว้NodePool
Component อ้างอิงไลบรารีสคีมา
apiVersion: aggrega.ai/v1beta1kind: Componentmetadata: name: my-org/datastore/mariadb version: 1.0.0 labels: component.aggrega.ai/type: stateful-server component.aggrega.ai/category: datastorespec: schema: values: $ref: Datastores#/schemas/MariaDBPayload infra: cpu_arch: { type: string, enum: [amd64, arm64], default: amd64 } provides: host: { type: string, format: hostname } port: { type: integer, min: 1024, max: 65535 } featuresSchema: root_credentials: required: true inject: [] replication_credentials: required: false inject: [] assertions: replication-needs-credentials: | {{- if eq .values.architecture "replication" -}} {{- if not (hasKey .features "replication_credentials") -}} {{- fail "architecture=replication requires replication_credentials secret to be supplied" -}} {{- end -}} {{- end -}}เสาvalues คือ$ref: เดียว ส่วน infra และ provides ที่
ไลบรารีการแมปเก็บการแปล
MappingLibrary เก็บdefine ที่template สำหรับ
apiVersion: aggrega.ai/v1beta1kind: MappingLibrarymetadata: name: BitnamiHelpers version: 1.0.0spec: mappings: MariaDBBitnamiCore: | {{- define "BitnamiNodePool" }} resources: requests: cpu: {{ .pool.resources.requests.cpu | quote }} memory: {{ .pool.resources.requests.memory | quote }} {{- end }} {{- with .values -}} fullnameOverride: {{ $.context.rendered_name | quote }} architecture: {{ .architecture }} primary: name: primary {{- template "BitnamiNodePool" (dict "pool" .primary) }} {{- end }}ประกาศoptional ของ Aggrega สำหรับinclude ของ Helm ไม่template เขียน
Recipe นำเข้าไลบรารีการแมป
apiVersion: aggrega.ai/v1beta1kind: Recipemetadata: name: mariadb-bitnami version: 1.0.0spec: capability: helm implements: my-org/datastore/mariadb:^1.0.0 source: kind: helm-oci-chart url: oci://registry-1.docker.io/bitnamicharts/mariadb version: "25.0.8" valuesMapping: $import: BitnamiHelpers#/mappings/MariaDBBitnamiCore provides: host: "{{ .context.rendered_name }}{{ if eq .values.architecture `replication` }}-primary{{ end }}" port: "3306"Recipe มีfullnameOverride ของ chart ไว้.context.rendered_name Recipe จึง
สิ่งที่ไลบรารีให้
เมื่อtype: object, properties: และrequired: ส่วน when: และ validate: ไม่มี$jsonschema: ประโยชน์values ของ Component ที่$ref: เดียว
เอกสาร$ref: ข้าม