自定义应用是一种基于原生 Kubernetes 资源(如 Deployment、Service、ConfigMap)构建的应用范式,严格遵循 Kubernetes 声明式 API 设计原则。用户可以通过标准的 YAML 文件或直接调用 Kubernetes API 来定义和部署应用,实现对应用生命周期的细粒度控制。由镜像、代码和 YAML 等来源创建的应用均归类为 Alauda Container Platform 中的自定义应用。其设计核心在于平衡灵活性与标准化,适用于需要深度定制管理的场景。
屏蔽底层资源细节(如 Pod 副本状态),开发者可直接通过 Application 资源监控整体应用健康状况(如就绪端点比例、版本一致性)。
支持跨组件依赖声明(如数据库服务必须先于应用服务启动),确保资源初始化顺序和协调。
版本控制:跟踪历史配置,实现一键回滚至任意稳定状态。
依赖解析:自动识别并管理组件间版本兼容性(如 Service API 版本与 Ingress 控制器匹配)。
维度 | 价值主张 |
---|---|
复杂度管理 | 将分散的资源(如 Deployment、Service)封装为单一逻辑实体,降低认知和运维负担。 |
标准化 | 通过 Application CRD 统一应用描述标准,消除 YAML 碎片化带来的管理混乱。 |
生态兼容性 | 无缝集成原生工具链(如 kubectl、Kubernetes Dashboard),支持 Helm Chart 扩展。 |
DevOps 效率 | 通过 GitOps 流水线(如 Argo CD)实现声明式交付,加速 CI/CD 自动化。 |
自定义应用模块定义了两个核心 CRD 资源,构成应用管理的原子抽象单元:
维度 | 价值主张 |
---|---|
Application | 描述逻辑应用单元的元数据和组件拓扑,将 Deployment/Service 等资源聚合为单一实体。 |
ApplicationHistory | 记录所有应用生命周期操作(创建/更新/回滚/删除)为版本化快照,与 Application CRD 紧密耦合,实现端到端变更可追溯。 |
Application CRD 使用 spec.componentKinds
字段声明 Kubernetes 资源类型(如 Deployment、Service),支持跨资源生命周期管理。
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: applications.app.k8s.io
spec:
group: app.k8s.io
names:
kind: Application
listKind: ApplicationList
plural: applications
singular: application
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
description: 'Metadata is a object value representing the metadata of the kubernetes resource.
More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata'
type: object
spec:
properties:
assemblyPhase:
description: |
The installer can set this field to indicate that the application's components
are still being deployed ("Pending") or all are deployed already ("Succeeded"). When the
application cannot be successfully assembled, the installer can set this field to "Failed".'
type: string
componentKinds:
description: |
This array of GroupKinds is used to indicate the types of resources that the
application is composed of. As an example an Application that has a service and a deployment
would set this field to [{"group":"core","kind": "Service"},{"group":"apps","kind":"Deployment"}]
items:
description: 'The item of the GroupKinds, with a structure like \"{"group":"core","kind": "Service"}\"'
type: object
type: array
descriptor:
properties:
description:
description: 'A short, human readable textual description of the Application.'
type: string
icons:
description: 'A list of icons for an application. Icon information includes the source, size, and mime type.'
items:
properties:
size:
description: 'The size of the icon.'
type: string
src:
description: 'The source of the icon.'
type: string
type:
description: 'The mime type of the icon.'
type: string
required:
- src
type: object
type: array
keywords:
description: 'A list of keywords that identify the application.'
items:
type: string
type: array
links:
description: 'Links are a list of descriptive URLs intended to be used to surface additional documentation, dashboards, etc.'
items:
properties:
description:
description: 'The description of the link.'
type: string
url:
description: 'The url of the link.'
type: string
type: object
type: array
maintainers:
description: 'A list of the maintainers of the Application. Each maintainer has a
name, email, and URL. This field is meant for the distributors of the Application
to indicate their identity and contact information.'
items:
properties:
email:
description: 'The email of the maintainer.'
type: string
name:
description: 'The name of the maintainer.'
type: string
url:
description: 'The url to contact the maintainer.'
type: string
type: object
type: array
notes:
description: 'Notes contain human readable snippets intended as a quick start
for the users of the Application. They may be plain text or CommonMark markdown.'
type: string
owners:
items:
properties:
email:
description: 'The email of the owner.'
type: string
name:
description: 'The name of the owner.'
type: string
url:
description: 'The url to contact the owner.'
type: string
type: object
type: array
type:
description: 'The type of the application (e.g. WordPress, MySQL, Cassandra).
You can have many applications of different names in the same namespace.
They type field is used to indicate that they are all the same type of application.'
type: string
version:
description: 'A version indicator for the application (e.g. 5.7 for MySQL version 5.7).'
type: string
type: object
info:
description: 'Info contains human readable key-value pairs for the Application.'
items:
properties:
name:
description: 'The name of the information.'
type: string
type:
description: 'The type of the information.'
type: string
value:
description: 'The value of the information.'
type: string
valueFrom:
description: 'The value reference from other resource.'
properties:
configMapKeyRef:
description: 'The config map key reference.'
properties:
key:
type: string
type: object
ingressRef:
description: 'The ingress reference.'
properties:
host:
description: 'The host of the ingress reference.'
type: string
path:
description: 'The path of the ingress reference.'
type: string
type: object
secretKeyRef:
description: 'The secret key reference.'
properties:
key:
type: string
type: object
serviceRef:
description: 'The service reference.'
properties:
path:
description: 'The path of the service reference.'
type: string
port:
description: 'The port of the service reference.'
format: int32
type: integer
type: object
type:
type: string
type: object
type: object
type: array
selector:
description: 'The selector is used to match resources that belong to the Application.
All of the applications resources should have labels such that they match this selector.
Users should use the app.kubernetes.io/name label on all components of the Application
and set the selector to match this label. For instance,
{"matchLabels": [{"app.kubernetes.io/name": "my-cool-app"}]} should be used as the selector
for an Application named "my-cool-app", and each component should contain a label that matches.'
type: object
type: object
status:
description: 'The status summarizes the current state of the object.'
properties:
observedGeneration:
description: 'The observedGeneration is the generation most recently observed by the component
responsible for acting upon changes to the desired state of the resource.'
format: int64
type: integer
type: object
version: v1beta1
versions:
- name: v1beta1
served: true
storage: true
ApplicationHistory CRD 捕获所有生命周期操作(如创建、更新、回滚)为版本控制快照,并与 Application CRD 紧密集成,实现端到端审计追踪。
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: applicationhistories.app.k8s.io
spec:
group: app.k8s.io
names:
kind: ApplicationHistory
listKind: ApplicationHistoryList
plural: applicationhistories
singular: applicationhistory
scope: Namespaced
validation:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
description: 'Metadata is a object value representing the metadata of the kubernetes resource.
More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata'
type: object
spec:
properties:
changeCause:
description: 'The change cause of the application to generate the ApplicationHistory.'
type: string
creationTimestamp:
description: 'The creation timestamp of the application history.'
format: date-time
type: string
resourceDiffs:
description: 'The resource differences between the current and last version of application. It contains 3 types of diff: `create`,
`delete` and `update`. The item of the diff compose of the kind and name of the diff resource object.'
properties:
create:
items:
properties:
kind:
description: 'The kind of the created resource.'
type: string
name:
description: 'The name of the created resource.'
type: string
type: object
type: array
delete:
items:
properties:
kind:
description: 'The kind of the deleted resource.'
type: string
name:
description: 'The name of the deleted resource.'
type: string
type: object
type: array
update:
items:
properties:
kind:
description: 'The kind of the updated resource.'
type: string
name:
description: 'The name of the updated resource.'
type: string
type: object
type: array
type: object
revision:
description: |
The revision number of the application history. It's an integer that will be incremented on
every change of the application.'
type: integer
user:
description: 'The user name who triggered the change of the application.'
type: string
yaml:
description: |
The YAML string of the snapshot of the application and it's components.
type: string
type: object
status:
description: 'The status summarizes the current state of the object.'
properties:
observedGeneration:
description: 'The observedGeneration is the generation most recently observed by the component
responsible for acting upon changes to the desired state of the resource.'
format: int64
type: integer
type: object
type: object
version: v1beta1
versions:
- name: v1beta1
served: true
storage: true