KubeVela Application Delivery Platform

repository·master·Indexed 11 days ago

https://github.com/kubevela/kubevela

An application delivery platform based on the Open Application Model (OAM) for deploying and managing applications across hybrid and multi-cloud environments. It features a core controller, a CLI (vela), and support for CUE-based ComponentDefinitions, TraitDefinitions, and WorkflowStepDefinitions. The platform supports multi-cluster capabilities, custom resource management, and a structured enhancement process via KubeVela Enhancement Proposals (KEPs). Compatible with Kubernetes versions >= v1.19 and < v1.22.

Tokens
325.1K
Snippets
707
Records
1K
Agent score
80%

What's inside KubeVela

  1. Overview of KubeVela application delivery

    master

    KubeVela is a modern application delivery platform designed to simplify deploying and operating applications across hybrid and multi-cloud environments. It follows a "render, orchestrate, deploy" workflow and is built upon the Open Application Model (OAM).

    Key capabilities include:

    • Deployment as Code: Declare deployment plans as workflows that can be integrated with CI/CD or GitOps systems. Workflows can be extended using CUE.
    • Multi-cloud/Hybrid Support: Native support for progressive rollouts (canary, blue-green), continuous verification, and placement strategies across different clusters and clouds.
    • Built-in Governance: Out-of-the-box support for multi-tenancy, LDAP integration, fine-grained RBAC, and automated observability dashboards.
    • Extensibility: A lightweight architecture that uses reusable modules (addons) to orchestrate infrastructure capabilities.
  2. Features of the KubeVela Go SDK

    master

    The KubeVela Go SDK provides two main functional areas for interacting with KubeVela applications:

    Application Manipulation

    • Add Components, Traits, Workflow Steps, and Policies.
    • Set Workflow Mode.
    • Convert to and from Kubernetes Application Objects.
    • Convert applications to YAML or JSON formats.
    • Retrieve Components, Traits, Workflow Steps, and Policies from an existing application.
    • Recursively validate required application parameters.

    Application Client

    • Perform CRUD operations on Applications: Create, Delete, Patch, and Update.
    • List and Get Applications.
  3. Author KubeVela X-Definitions using the defkit Go SDK

    master

    The Definition Kit (defkit) is a Go SDK that allows platform engineers to author KubeVela X-Definitions (ComponentDefinition, TraitDefinition, PolicyDefinition, and WorkflowStepDefinition) using native Go code instead of CUE.

    Key benefits include:

    • Full IDE support: Autocomplete, type checking, and inline documentation.
    • Testability: Use standard Go testing frameworks (go test) to unit test definitions.
    • Compile-time safety: Catch invalid field names and type mismatches before deployment.
    • Standard Distribution: Share definitions as versioned Go modules via go get.
    • Transparent Compilation: The SDK compiles Go to CUE automatically; the KubeVela controller remains compatible without needing to execute Go code at runtime.
    package myplatform
    
    import (
        "github.com/oam-dev/kubevela/pkg/definition/defkit"
    )
    
    func init() {
        defkit.Register(WebserviceComponent())
    }
  4. Understand the Cluster Infrastructure Abstraction implementation plan

    master

    The Cluster Infrastructure Abstraction is a multi-phase architectural design for KubeVela to manage cluster lifecycles, including provisioning, adoption, and connection. The implementation is divided into several key functional areas:

    • Core CRDs & Controllers: Management of Cluster, ClusterPlane, ClusterBlueprint, and ClusterProviderDefinition.
    • Cluster Lifecycle: Workflows for provisioning (via Crossplane/Terraform), adopting existing clusters, and connecting to remote clusters via kubeconfig.
    • Definition System: Introduction of a definition.oam.dev/scope annotation to distinguish between application and cluster scoped definitions.
    • Rollout Engine: Managing cluster updates via ClusterRolloutStrategy using waves, maintenance windows, and approval gates.
    • Health & Observability: Hierarchical health aggregation (Cluster → Plane → Component → Resource) using providers like Prometheus or Datadog.
    • Drift Detection: Comparing cluster state against blueprints and providing remediation via vela cluster remediate.
  5. Overview of the defkit Go SDK

    master

    The defkit (Definition Kit) is a Go SDK designed for authoring KubeVela X-Definitions. It allows platform engineers to write definitions (Components, Traits, Policies, and Workflow Steps) using Go's type safety and standard tooling instead of raw CUE.

    Key Characteristics:

    • Compile-time execution: Go code runs on the CLI during vela def apply or vela addon enable to generate static CUE. It does not execute at application deployment time.
    • Coexistence: CUE definitions remain fully supported; defkit is an alternative path.
    • Security: Leverages standard Go security tools (gosec, staticcheck) and Go module checksums for dependency integrity.
  6. What is a ClusterPlane and how is it used

    master

    A ClusterPlane represents a composable infrastructure layer, typically owned by a specific team (e.g., networking, security, observability).

    Important Distinction: A ClusterPlane is a template, not a self-reconciling resource. Creating a ClusterPlane CRD does not automatically create infrastructure resources. It serves as a definition that can be used within a blueprint to drive the reconciliation of specific infrastructure components.

  7. Implement API Line Versioning for stable contracts

    master

    To prevent breaking changes when updating definitions (like a database schema), KubeVela uses API Line Versioning.

    Instead of referencing a bare type name or a fragile DefinitionRevision, users reference a stable API line. This line acts as a contract: the platform engineer promises that the parameter schema for that line will remain compatible.

    Usage Pattern:

    • Bare name (Old): type: database (Breaks if the schema changes).
    • Revision pinning (Fragile): type: database@v1.2.3 (Hard to manage in GitOps).
    • API Line (Recommended): type: postgres/v1/database (The v1 indicates a stable parameter contract. The underlying addon can be updated freely as long as it respects the v1 schema).
    # The type reference carries the stability contract.
    components:
      - name: my-db
        type: postgres/v1/database   # "I bind to the v1 parameter contract."
  8. Configure container-ports for multiple containers

    master

    To manage ports for multiple containers within a single Pod using the container-ports trait, use the containers property. Each item in the containers list must include a containerName to identify which container the ports apply to.

          traits:
            - type: container-ports
              properties:
                containers:
                  - containerName: container-a
                    ports:
                      - containerPort: 80
                        protocol: TCP
                        hostPort: 8080
                  - containerName: container-b
                    ports:
                      - containerPort: 9000
                        protocol: TCP
                        hostPort: 9001
  9. How nested component definitions work in KubeVela

    master

    KubeVela supports a hierarchical composition model where one ComponentDefinition can delegate to another using the def.#RenderComponent function. This allows developers to create layers of abstraction:

    1. Base Components (Level 1): Low-level definitions that map directly to Kubernetes resources (e.g., a webservice defining a Deployment).
    2. Abstraction Layers (Level 2): Intermediate definitions that wrap base components to simplify configuration (e.g., a myorg-service that maps a size parameter like s, m, or l to specific CPU/Memory/Replica values).
    3. Minimal Interfaces (Level 3): High-level, user-facing definitions that expose only the most essential parameters (e.g., a myorg-simple-service that only asks for an image).

    When a user deploys a high-level component, KubeVela recursively calls def.#RenderComponent down the chain, compiling and evaluating CUE templates at each step until final Kubernetes manifests are generated.

    graph TD
        subgraph "Level 3: Simple Interface"
            A[myorg-simple-service<br/>Parameters: image]
        end
        
        subgraph "Level 2: Size-Based"
            B[myorg-service<br/>Parameters: image, size]
        end
        
        subgraph "Level 1: Full Featured"
            C[webservice<br/>Parameters: image, replicas,<br/>resources, env, ports, etc.]
        end
        
        A -->|def.#RenderComponent| B
        B -->|def.#RenderComponent| C
        C --> D[Kubernetes Deployment]
  10. Understand the Deprecation Lifecycle for Addon Modules

    master

    When an addon module is updated, API lines (versions) follow a specific deprecation lifecycle managed via AddonModuleStatus:

    1. Active: The line is available and used by applications.
    2. Deprecated: A line enters this state if enabled evaluates to false (via _version.cue) or if the line is removed from the current addon version.
      • Behavior: Deprecated lines remain on the cluster indefinitely and are not automatically removed. However, the admission webhook blocks new Applications from referencing them.
      • Reversibility: If the deprecation was caused by a context-based disable (disabled-by-context), it is reversible if the context becomes enabled again. If the line was physically removed from the source (line-removed), it is a one-way transition.
    3. Removal: Removal of a line is an explicit action (e.g., upgrading the addon or KubeVela controller).