Documentation
¶
Index ¶
- Constants
- type AWSProvider
- type Accessory
- type AlicloudProvider
- type AppConfiguration
- type AzureEnvironmentType
- type AzureKVProvider
- type BackendConfig
- type BackendConfigs
- type BackendLocalConfig
- type BackendMysqlConfig
- type BackendOssConfig
- type BackendS3Config
- type BuilderType
- type Config
- type ExternalSecretRef
- type FakeProvider
- type FakeProviderData
- type GeneratorConfig
- type GenericBackendObjectStorageConfig
- type GenericConfig
- type Intent
- type KubernetesConfig
- type ModuleConfig
- type ModuleConfigs
- type ModulePatcherConfig
- type ModulePatcherConfigs
- type Patcher
- type Project
- type ProviderConfig
- type ProviderSpec
- type Resource
- type Resources
- type RuntimeConfigs
- type SecretStoreSpec
- type Stack
- type State
- type TerraformConfig
- type Type
- type VaultKVStoreVersion
- type VaultProvider
- type Workspace
Constants ¶
const ( DefaultBackendName = "default" BackendCurrent = "current" BackendType = "type" BackendConfigItems = "configs" BackendLocalPath = "path" BackendMysqlDBName = "dbName" BackendMysqlUser = "user" BackendMysqlPassword = "password" BackendMysqlHost = "host" BackendMysqlPort = "port" BackendGenericOssEndpoint = "endpoint" BackendGenericOssAK = "accessKeyID" BackendGenericOssSK = "accessKeySecret" BackendGenericOssBucket = "bucket" BackendGenericOssPrefix = "prefix" BackendS3Region = "region" BackendTypeLocal = "local" BackendTypeMysql = "mysql" BackendTypeOss = "oss" BackendTypeS3 = "s3" EnvBackendMysqlPassword = "KUSION_BACKEND_MYSQL_PASSWORD" EnvOssAccessKeyID = "OSS_ACCESS_KEY_ID" EnvOssAccessKeySecret = "OSS_ACCESS_KEY_SECRET" EnvAwsAccessKeyID = "AWS_ACCESS_KEY_ID" EnvAwsSecretAccessKey = "AWS_SECRET_ACCESS_KEY" EnvAwsDefaultRegion = "AWS_DEFAULT_REGION" EnvAwsRegion = "AWS_REGION" DefaultMysqlPort = 3306 )
const ( // ResourceExtensionGVK is the key for resource extension, which is used to // store the GVK of the resource. ResourceExtensionGVK = "GVK" // ResourceExtensionKubeConfig is the key for resource extension, which is used // to indicate the path of kubeConfig for Kubernetes type resource. ResourceExtensionKubeConfig = "kubeConfig" )
const ( DefaultBlock = "default" ProjectSelectorField = "projectSelector" )
const ConfigBackends = "backends"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AWSProvider ¶
type AWSProvider struct { // AWS Region to be used to interact with AWS Secrets Manager. // Examples are us-east-1, us-west-2, etc. Region string `yaml:"region" json:"region"` // The profile to be used to interact with AWS Secrets Manager. // If not set, the default profile created with `aws configure` will be used. Profile string `yaml:"profile,omitempty" json:"profile,omitempty"` }
AWSProvider configures a store to retrieve secrets from AWS Secrets Manager.
type AlicloudProvider ¶
type AlicloudProvider struct { // Alicloud Region to be used to interact with Alicloud Secrets Manager. // Examples are cn-beijing, cn-shanghai, etc. Region string `yaml:"region" json:"region"` }
AlicloudProvider configures a store to retrieve secrets from Alicloud Secrets Manager.
type AppConfiguration ¶ added in v0.11.0
type AppConfiguration struct { // Name of the target App. Name string `json:"name,omitempty" yaml:"name,omitempty"` // Workload defines how to run your application code. Workload *workload.Workload `json:"workload" yaml:"workload"` // Accessories defines a collection of accessories that will be attached to the workload. Accessories map[string]Accessory `json:"accessories,omitempty" yaml:"accessories,omitempty"` // Labels and Annotations can be used to attach arbitrary metadata as key-value pairs to resources. Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` Annotations map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty"` }
AppConfiguration is a developer-centric definition that describes how to run an App. The application model is built on a decade of experience from AntGroup in operating a large-scale internal developer platform and combines the best ideas and practices from the community.
Note: AppConfiguration per se is not a Kusion ModulePath
Example: import kam.v1 as ac import kam.v1.workload as wl import kam.v1.workload.container as c import kam.v1.workload.container.probe as p import kam.v1.monitoring as m import kam.v1.database as d
helloWorld: ac.AppConfiguration { # Built-in module workload: wl.Service { containers: { "main": c.Container { image: "ghcr.io/kusion-stack/samples/helloworld:latest" # Configure a HTTP readiness probe readinessProbe: p.Probe { probeHandler: p.Http { url: "http://localhost:80" } } } } } # a collection of accessories that will be attached to the workload accessories: { # Built-in module "my-database" : d.MySQL { type: "cloud" version: "8.0" } # Built-in module "my-prometheus" : m.Prometheus { path: "/metrics" } # Customized module "my-customize": customizedModule { ... } } }
type AzureEnvironmentType ¶
type AzureEnvironmentType string
AzureEnvironmentType specifies the Azure cloud environment endpoints to use for connecting and authenticating with Azure.
const ( AzureEnvironmentPublicCloud AzureEnvironmentType = "PublicCloud" AzureEnvironmentUSGovernmentCloud AzureEnvironmentType = "USGovernmentCloud" AzureEnvironmentChinaCloud AzureEnvironmentType = "ChinaCloud" AzureEnvironmentGermanCloud AzureEnvironmentType = "GermanCloud" )
type AzureKVProvider ¶
type AzureKVProvider struct { // Vault Url from which the secrets to be fetched from. VaultURL *string `yaml:"vaultUrl" json:"vaultUrl"` // TenantID configures the Azure Tenant to send requests to. TenantID *string `yaml:"tenantId" json:"tenantId"` // EnvironmentType specifies the Azure cloud environment endpoints to use for connecting and authenticating with Azure. // By-default it points to the public cloud AAD endpoint, and the following endpoints are available: // PublicCloud, USGovernmentCloud, ChinaCloud, GermanCloud // Ref: https://github.com/Azure/go-autorest/blob/main/autorest/azure/environments.go#L152 EnvironmentType AzureEnvironmentType `yaml:"environmentType,omitempty" json:"environmentType,omitempty"` }
AzureKVProvider configures a store to retrieve secrets from Azure KeyVault
type BackendConfig ¶ added in v0.11.0
type BackendConfig struct { // Type is the backend type, supports BackendTypeLocal, BackendTypeMysql, BackendTypeOss, BackendTypeS3. Type string `yaml:"type,omitempty" json:"type,omitempty"` // Configs contains config items of the backend, whose keys differ from different backend types. Configs map[string]any `yaml:"configs,omitempty" json:"configs,omitempty"` }
BackendConfig contains the type and configs of a backend, which is used to store Spec, State and Workspace.
func (*BackendConfig) ToLocalBackend ¶ added in v0.11.0
func (b *BackendConfig) ToLocalBackend() *BackendLocalConfig
ToLocalBackend converts BackendConfig to structured BackendLocalConfig, works only when the Type is BackendTypeLocal, and the Configs are with correct type, or return nil.
func (*BackendConfig) ToMysqlBackend ¶ added in v0.11.0
func (b *BackendConfig) ToMysqlBackend() *BackendMysqlConfig
ToMysqlBackend converts BackendConfig to structured BackendMysqlConfig, works only when the Type is BackendTypeMysql, and the Configs are with correct type, or return nil.
func (*BackendConfig) ToOssBackend ¶ added in v0.11.0
func (b *BackendConfig) ToOssBackend() *BackendOssConfig
ToOssBackend converts BackendConfig to structured BackendOssConfig, works only when the Type is BackendTypeOss, and the Configs are with correct type, or return nil.
func (*BackendConfig) ToS3Backend ¶ added in v0.11.0
func (b *BackendConfig) ToS3Backend() *BackendS3Config
ToS3Backend converts BackendConfig to structured BackendS3Config, works only when the Type is BackendTypeS3, and the Configs are with correct type, or return nil.
type BackendConfigs ¶
type BackendConfigs struct { // Current is the name of the current used backend. Current string `yaml:"current,omitempty" json:"current,omitempty"` // Backends contains the types and configs of multiple backends, whose key is the backend name. Backends map[string]*BackendConfig `yaml:",omitempty,inline" json:",omitempty,inline"` }
BackendConfigs contains the configuration of multiple backends and the current backend.
type BackendLocalConfig ¶ added in v0.11.0
type BackendLocalConfig struct { // Path of the directory to store the files. Path string `yaml:"path,omitempty" json:"path,omitempty"` }
BackendLocalConfig contains the config of using local file system as backend, which can be converted from BackendConfig if Type is BackendTypeLocal.
type BackendMysqlConfig ¶ added in v0.11.0
type BackendMysqlConfig struct { // DBName is the database name. DBName string `yaml:"dbName" json:"dbName"` // User of the database. User string `yaml:"user" json:"user"` // Password of the database. Password string `yaml:"password,omitempty" json:"password,omitempty"` // Host of the database. Host string `yaml:"host" json:"host"` // Port of the database. If not set, then it will be set to DeprecatedDefaultMysqlPort. Port int `yaml:"port,omitempty" json:"port,omitempty"` }
BackendMysqlConfig contains the config of using mysql database as backend, which can be converted from BackendConfig if Type is BackendMysqlConfig.
type BackendOssConfig ¶ added in v0.11.0
type BackendOssConfig struct {
*GenericBackendObjectStorageConfig `yaml:",inline" json:",inline"` // OSS asks for non-empty endpoint
}
BackendOssConfig contains the config of using OSS as backend, which can be converted from BackendConfig if Type is BackendOssConfig.
type BackendS3Config ¶ added in v0.11.0
type BackendS3Config struct { *GenericBackendObjectStorageConfig `yaml:",inline" json:",inline"` // Region of S3. Region string `yaml:"region,omitempty" json:"region,omitempty"` }
BackendS3Config contains the config of using S3 as backend, which can be converted from BackendConfig if Type is BackendS3Config.
type BuilderType ¶
type BuilderType string
const ( KCLBuilder BuilderType = "KCL" AppConfigurationBuilder BuilderType = "AppConfiguration" )
type Config ¶ added in v0.11.0
type Config struct { // Backends contains the configurations for multiple backends. Backends *BackendConfigs `yaml:"backends,omitempty" json:"backends,omitempty"` }
Config contains configurations for kusion cli, which stores in ${KUSION_HOME}/config.yaml.
type ExternalSecretRef ¶
type ExternalSecretRef struct { // Specifies the name of the secret in Provider to read, mandatory. Name string `yaml:"name" json:"name"` // Specifies the version of the secret to return, if supported. Version string `yaml:"version,omitempty" json:"version,omitempty"` // Used to select a specific property of the secret data (if a map), if supported. Property string `yaml:"property,omitempty" json:"property,omitempty"` }
ExternalSecretRef contains information that points to the secret store data location.
type FakeProvider ¶
type FakeProvider struct {
Data []FakeProviderData `json:"data"`
}
FakeProvider configures a fake provider that returns static values.
type FakeProviderData ¶
type GeneratorConfig ¶
type GeneratorConfig struct { // Type specifies the type of Generator. can be either "KCL" or "AppConfiguration". Type BuilderType `json:"type" yaml:"type"` // Configs contains extra configurations used by the Generator. Configs map[string]interface{} `json:"configs,omitempty" yaml:"configs,omitempty"` }
GeneratorConfig holds the intent generation configurations defined in Project resource.
type GenericBackendObjectStorageConfig ¶ added in v0.11.0
type GenericBackendObjectStorageConfig struct { // Endpoint of the object storage service. Endpoint string `yaml:"endpoint,omitempty" json:"endpoint,omitempty"` // AccessKeyID of the object storage service. AccessKeyID string `yaml:"accessKeyID,omitempty" json:"accessKeyID,omitempty"` // AccessKeySecret of the object storage service. AccessKeySecret string `yaml:"accessKeySecret,omitempty" json:"accessKeySecret,omitempty"` // Bucket of the object storage service. Bucket string `yaml:"bucket" json:"bucket"` // Prefix of the key to store the files. Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty"` }
GenericBackendObjectStorageConfig contains generic configs which can be reused by BackendOssConfig and BackendS3Config.
type GenericConfig ¶
GenericConfig is a generic model to describe config which shields the difference among multiple concrete models. GenericConfig is designed for extensibility, used for module, terraform runtime config, etc.
type Intent ¶
type Intent struct { // Resources is the list of Resource this Intent contains. Resources Resources `json:"resources" yaml:"resources"` }
Intent describes the desired state how the infrastructure should look like: which workload to run, the load-balancer setup, the location of the database schema, and so on. Based on that information, the Kusion engine takes care of updating the production state to match the Intent.
type KubernetesConfig ¶
type KubernetesConfig struct { // KubeConfig is the path of the kubeconfig file. KubeConfig string `yaml:"kubeConfig" json:"kubeConfig"` }
KubernetesConfig contains config to access a kubernetes cluster.
type ModuleConfig ¶
type ModuleConfig struct { // Default is default block of the module config. Default GenericConfig `yaml:"default" json:"default"` // ModulePatcherConfigs are the patcher blocks of the module config. ModulePatcherConfigs `yaml:",inline,omitempty" json:",inline,omitempty"` }
ModuleConfig is the config of a module, which contains a default and several patcher blocks.
The default block's key is "default", and value is the module inputs. The patcher blocks' keys are the patcher names, which are just block identifiers without specific meaning, but must not be "default". Besides module inputs, patcher block's value also contains a field named "projectSelector", whose value is a slice containing the project names that use the patcher configs. A project can only be assigned in a patcher's "projectSelector" field, the assignment in multiple patchers is not allowed. For a project, if not specified in the patcher block's "projectSelector" field, the default config will be used.
Take the ModuleConfig of "database" for an example, which is shown as below:
config := ModuleConfig { "default": { "type": "aws", "version": "5.7", "instanceType": "db.t3.micro", }, "smallClass": { "instanceType": "db.t3.small", "projectSelector": []string{"foo", "bar"}, }, }
type ModuleConfigs ¶
type ModuleConfigs map[string]*ModuleConfig
ModuleConfigs is a set of multiple ModuleConfig, whose key is the module name.
type ModulePatcherConfig ¶
type ModulePatcherConfig struct { // GenericConfig contains the module configs. GenericConfig `yaml:",inline" json:",inline"` // ProjectSelector contains the selected projects. ProjectSelector []string `yaml:"projectSelector" json:"projectSelector"` }
ModulePatcherConfig is a patcher block of the module config.
type ModulePatcherConfigs ¶
type ModulePatcherConfigs map[string]*ModulePatcherConfig
ModulePatcherConfigs is a group of ModulePatcherConfig.
type Patcher ¶ added in v0.11.0
type Patcher struct { // Environments represent the environment variables patched to all containers in the workload. Environments []v1.EnvVar `json:"environments" yaml:"environments"` // Labels represent the labels patched to both the workload and pod. Labels map[string]string `json:"labels" yaml:"labels"` // Annotations represent the annotations patched to both the workload and pod. Annotations map[string]string `json:"annotations" yaml:"annotations"` }
Patcher contains fields should be patched into the workload corresponding fields
type Project ¶
type Project struct { // Name is a required fully qualified name. Name string `json:"name" yaml:"name"` // Description is an optional informational description. Description *string `json:"description,omitempty" yaml:"description,omitempty"` // Labels is the list of labels that are assigned to this project. Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` // Path is a directory path within the Git repository. Path string `json:"path,omitempty" yaml:"path,omitempty"` // Generator controls how to generate the Intent. Generator *GeneratorConfig `json:"generator,omitempty" yaml:"generator,omitempty"` // The set of stacks that are known about this project. Stacks []*Stack `json:"stacks,omitempty" yaml:"stacks,omitempty"` }
Project is a definition of Kusion Project resource. A project is composed of one or more applications and is linked to a Git repository, which contains the project's desired manifests.
type ProviderConfig ¶
type ProviderConfig struct { // Source of the provider. Source string `yaml:"source" json:"source"` // Version of the provider. Version string `yaml:"version" json:"version"` // GenericConfig is used to describe the config of a specified terraform provider. GenericConfig `yaml:",inline,omitempty" json:",inline,omitempty"` }
ProviderConfig contains the full configurations of a specified provider. It is the combination of the specified provider's config in blocks "terraform/required_providers" and "providers" in terraform hcl file, where the former is described by fields Source and Version, and the latter is described by GenericConfig cause different provider has different config.
type ProviderSpec ¶
type ProviderSpec struct { // Alicloud configures a store to retrieve secrets from Alicloud Secrets Manager. Alicloud *AlicloudProvider `yaml:"alicloud,omitempty" json:"alicloud,omitempty"` // AWS configures a store to retrieve secrets from AWS Secrets Manager. AWS *AWSProvider `yaml:"aws,omitempty" json:"aws,omitempty"` // Vault configures a store to retrieve secrets from HashiCorp Vault. Vault *VaultProvider `yaml:"vault,omitempty" json:"vault,omitempty"` // Azure configures a store to retrieve secrets from Azure KeyVault. Azure *AzureKVProvider `yaml:"azure,omitempty" json:"azure,omitempty"` // Fake configures a store with static key/value pairs Fake *FakeProvider `yaml:"fake,omitempty" json:"fake,omitempty"` }
ProviderSpec contains provider-specific configuration.
type Resource ¶
type Resource struct { // ID is the unique key of this resource in the whole State. // ApiVersion:Kind:Namespace:Name is an idiomatic way for Kubernetes resources. // providerNamespace:providerName:resourceType:resourceName for Terraform resources ID string `json:"id" yaml:"id"` // Type represents all Runtimes we supported like Kubernetes and Terraform Type Type `json:"type" yaml:"type"` // Attributes represents all specified attributes of this resource Attributes map[string]interface{} `json:"attributes" yaml:"attributes"` // DependsOn contains all resources this resource depends on DependsOn []string `json:"dependsOn,omitempty" yaml:"dependsOn,omitempty"` // Extensions specifies arbitrary metadata of this resource Extensions map[string]interface{} `json:"extensions,omitempty" yaml:"extensions,omitempty"` }
Resource is the representation of a resource in the state.
func (*Resource) ResourceKey ¶
type Resources ¶
type Resources []Resource
type RuntimeConfigs ¶
type RuntimeConfigs struct { // Kubernetes contains the config to access a kubernetes cluster. Kubernetes *KubernetesConfig `yaml:"kubernetes,omitempty" json:"kubernetes,omitempty"` // Terraform contains the config of multiple terraform providers. Terraform TerraformConfig `yaml:"terraform,omitempty" json:"terraform,omitempty"` }
RuntimeConfigs contains a set of runtime config.
type SecretStoreSpec ¶
type SecretStoreSpec struct {
Provider *ProviderSpec `yaml:"provider" json:"provider"`
}
SecretStoreSpec contains configuration to describe target secret store.
type Stack ¶
type Stack struct { // Name is a required fully qualified name. Name string `json:"name" yaml:"name"` // Description is an optional informational description. Description *string `json:"description,omitempty" yaml:"description,omitempty"` // Labels is the list of labels that are assigned to this stack. Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` // Path is a directory path within the Git repository. Path string `json:"path,omitempty" yaml:"path,omitempty"` }
Stack is a definition of Kusion Stack resource.
Stack provides a mechanism to isolate multiple deploys of same application, it's the target workspace that an application will be deployed to, also the smallest operation unit that can be configured and deployed independently.
type State ¶ added in v0.11.0
type State struct { // State ID ID int64 `json:"id" yaml:"id"` // Project name Project string `json:"project" yaml:"project"` // Stack name Stack string `json:"stack" yaml:"stack"` // Workspace name Workspace string `json:"workspace" yaml:"workspace"` // State version Version int `json:"version" yaml:"version"` // KusionVersion represents the Kusion's version when this State is created KusionVersion string `json:"kusionVersion" yaml:"kusionVersion"` // Serial is an auto-increase number that represents how many times this State is modified Serial uint64 `json:"serial" yaml:"serial"` // Operator represents the person who triggered this operation Operator string `json:"operator,omitempty" yaml:"operator,omitempty"` // Resources records all resources in this operation Resources Resources `json:"resources" yaml:"resources"` // CreateTime is the time State is created CreateTime time.Time `json:"createTime" yaml:"createTime"` // ModifiedTime is the time State is modified each time ModifiedTime time.Time `json:"modifiedTime,omitempty" yaml:"modifiedTime,omitempty"` }
State is a record of an operation's result. It is a mapping between resources in KCL and the actual infra resource and often used as a datasource for 3-way merge/diff in operations like Apply or Preview.
type TerraformConfig ¶
type TerraformConfig map[string]*ProviderConfig
TerraformConfig contains the config of multiple terraform provider config, whose key is the provider name.
type VaultKVStoreVersion ¶
type VaultKVStoreVersion string
const ( VaultKVStoreV1 VaultKVStoreVersion = "v1" VaultKVStoreV2 VaultKVStoreVersion = "v2" )
type VaultProvider ¶
type VaultProvider struct { // Server is the target Vault server address to connect, e.g: "https://vault.example.com:8200". Server string `yaml:"server" json:"server"` // Path is the mount path of the Vault KV backend endpoint, e.g: "secret". Path *string `yaml:"path,omitempty" json:"path,omitempty"` // Version is the Vault KV secret engine version. Version can be either "v1" or // "v2", defaults to "v2". Version VaultKVStoreVersion `yaml:"version" json:"version"` }
VaultProvider configures a store to retrieve secrets from HashiCorp Vault.
type Workspace ¶
type Workspace struct { // Name identifies a Workspace uniquely. Name string `yaml:"-" json:"-"` // Modules are the configs of a set of modules. Modules ModuleConfigs `yaml:"modules,omitempty" json:"modules,omitempty"` // Runtimes are the configs of a set of runtimes. Runtimes *RuntimeConfigs `yaml:"runtimes,omitempty" json:"runtimes,omitempty"` // SecretStore represents a secure external location for storing secrets. SecretStore *SecretStoreSpec `yaml:"secretStore,omitempty" json:"secretStore,omitempty"` }
Workspace is a logical concept representing a target that stacks will be deployed to.
Workspace is managed by platform engineers, which contains a set of configurations that application developers do not want or should not concern, and is reused by multiple stacks belonging to different projects.