Documentation
¶
Overview ¶
Package app defines the Kubernetes application model and Pulumi resource creation helpers.
It is used by the `area/apps` Pulumi program to:
- load application configuration (HJSON decoded into protobuf messages),
- convert protobuf messages into internal Go types, and
- create Kubernetes resources (Deployment, Service, Ingress, etc.) for each application.
The functions in this package are intended to be deterministic given the same input configuration and are safe to use with Pulumi mocks in unit tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrVersionMismatch = errors.New("version mismatch")
ErrVersionMismatch indicates that an application's deployed version does not match the configured version.
Note: this error is defined for callers to use as a sentinel; it is not necessarily produced by functions in this file.
Functions ¶
func CreateApplication ¶
CreateApplication creates all Kubernetes resources required for app in the target cluster.
Resources are created in a fixed order to ensure dependencies exist (for example, ServiceAccount before Deployment). Any error aborts the creation flow and is returned.
func ReadConfiguration ¶
func ReadConfiguration(path string) (*v2.Kubernetes, error)
ReadConfiguration reads the Kubernetes applications configuration from path.
The file is expected to be HJSON matching the v2.Kubernetes protobuf schema.
func WriteConfiguration ¶ added in v2.264.0
func WriteConfiguration(path string, configuration *v2.Kubernetes) error
WriteConfiguration writes configuration to path in the repository's canonical HJSON form.
The underlying writer preserves the destination file mode and appends a trailing newline.
Types ¶
type App ¶
type App struct {
// Resources are optional resource requests/limits to apply to the pod.
Resources *Resources
// ID is an optional identifier from configuration.
ID string
// Name is the Kubernetes application name (used for resource naming).
Name string
// Kind determines how the application is deployed (for example "internal" vs "external").
Kind string
// Namespace is the Kubernetes namespace to deploy into.
Namespace string
// Domain is the external hostname associated with the application.
Domain string
// Version is the application version string used for deployment (for example as an image tag).
Version string
// Secrets is a list of secret names referenced by this application.
Secrets []string
// EnvVars are environment variables to be injected into the application container.
EnvVars []*EnvVar
}
App describes an application that will be deployed to Kubernetes.
It is derived from v2.Application and is used as the input to resource constructors within this package.
func ConvertApplication ¶
func ConvertApplication(a *v2.Application) *App
ConvertApplication converts a protobuf v2.Application into the internal App model.
This conversion normalizes optional fields (for example env vars) into Go-friendly structures that are later used to create Kubernetes resources.
func (*App) HasResources ¶
HasResources reports whether a has resource requirements configured.
func (*App) IsExternal ¶
IsExternal reports whether this application is not built/published by this repository.
func (*App) IsInternal ¶
IsInternal reports whether this application uses the repository's opinionated deployment model.
Internal applications are typically built/published by this repository and deployed using a conventional container image naming scheme.
type EnvVar ¶ added in v2.190.0
EnvVar represents an environment variable to inject into the application container.
type ResourcesMap ¶ added in v2.160.0
ResourcesMap got app.
func (ResourcesMap) Resources ¶ added in v2.160.0
func (r ResourcesMap) Resources(name string) *Resources
Resources by name if found, otherwise small.