Documentation ¶
Overview ¶
Package application collects the structures and functions that deal with application workloads on k8s
Index ¶
- Constants
- func AddActualApplicationRoutes(auxiliary map[ConfigurationKey]AppData, ctx context.Context, ...) (map[ConfigurationKey]AppData, error)
- func AddApplicationPods(auxiliary map[ConfigurationKey]AppData, ctx context.Context, ...) (map[ConfigurationKey]AppData, error)
- func AppChart(app *unstructured.Unstructured) (string, error)
- func BoundApps(ctx context.Context, cluster *kubernetes.Cluster, namespace string) (map[string]models.AppList, error)
- func BoundAppsNames(ctx context.Context, cluster *kubernetes.Cluster, namespace string) (map[ConfigurationKey][]string, error)
- func BoundAppsNamesFor(ctx context.Context, cluster *kubernetes.Cluster, ...) ([]string, error)
- func BoundConfigurationNames(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef) ([]string, error)
- func BoundConfigurationNamesFromSecret(configSecret *v1.Secret) []string
- func BoundConfigurationsSet(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, ...) error
- func BoundConfigurationsUnset(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, ...) error
- func BoundServicesSet(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, ...) error
- func BoundServicesUnset(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, ...) error
- func BuilderURL(app *unstructured.Unstructured) (string, error)
- func Create(ctx context.Context, cluster *kubernetes.Cluster, app models.AppRef, ...) error
- func DecodeConfigurationKey(key ConfigurationKey) (string, string)
- func DecodeServiceKey(key string) (string, string)
- func Delete(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef) error
- func DesiredRoutes(appCR *unstructured.Unstructured) ([]string, error)
- func Environment(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef) (models.EnvVariableMap, error)
- func EnvironmentFromSecret(evSecret *v1.Secret) models.EnvVariableMap
- func EnvironmentNames(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef) ([]string, error)
- func EnvironmentSet(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, ...) error
- func EnvironmentUnset(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, ...) error
- func Exists(ctx context.Context, cluster *kubernetes.Cluster, app models.AppRef) (bool, error)
- func Get(ctx context.Context, cluster *kubernetes.Cluster, app models.AppRef) (*unstructured.Unstructured, error)
- func GetPodMetrics(ctx context.Context, cluster *kubernetes.Cluster, namespace string) (map[string]metricsv1beta1.PodMetrics, error)
- func ImageURL(app *unstructured.Unstructured) (string, error)
- func IsCurrentlyStaging(ctx context.Context, cluster JobLister, namespace, appName string) (bool, error)
- func List(ctx context.Context, cluster *kubernetes.Cluster, namespace string) (models.AppList, error)
- func ListAppRefs(ctx context.Context, cluster *kubernetes.Cluster, namespace string) ([]models.AppRef, error)
- func ListRoutes(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef) ([]string, error)
- func Logs(ctx context.Context, logChan chan tailer.ContainerLogLine, wg *sync.WaitGroup, ...) error
- func Lookup(ctx context.Context, cluster *kubernetes.Cluster, namespace, appName string) (*models.App, error)
- func Origin(app *unstructured.Unstructured) (models.ApplicationOrigin, error)
- func Scaling(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef) (int32, error)
- func ScalingFromSecret(scaleSecret *v1.Secret) (int32, error)
- func ScalingSet(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, ...) error
- func ServiceKey(name, namespace string) string
- func ServicesBoundApps(ctx context.Context, cluster *kubernetes.Cluster, namespace string) (map[string]models.AppList, error)
- func ServicesBoundAppsNames(ctx context.Context, cluster *kubernetes.Cluster, namespace string) (map[string][]string, error)
- func ServicesBoundAppsNamesFor(ctx context.Context, cluster *kubernetes.Cluster, ...) ([]string, error)
- func SetOrigin(ctx context.Context, cluster *kubernetes.Cluster, app models.AppRef, ...) error
- func Settings(app *unstructured.Unstructured) (models.ChartValueSettings, error)
- func StageID(app *unstructured.Unstructured) (string, error)
- func StagingStatuses(ctx context.Context, cluster JobLister, namespace string) (map[ConfigurationKey]models.ApplicationStagingStatus, error)
- func Unstage(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, ...) error
- func ValidateCV(cv models.ChartValueSettings, decl map[string]models.ChartSetting) []error
- type AppConfigurationBind
- type AppConfigurationBindList
- type AppData
- type ConfigurationKey
- type JobLister
- type NameSet
- type PatchOperation
- type Workload
- func (a *Workload) AssembleFromParts(ctx context.Context, podList []corev1.Pod, ...) (*models.AppDeployment, error)
- func (a *Workload) Get(ctx context.Context) (*models.AppDeployment, error)
- func (a *Workload) PodNames(ctx context.Context) ([]string, error)
- func (a *Workload) Pods(ctx context.Context) ([]corev1.Pod, error)
Constants ¶
const EpinioApplicationAreaLabel = "epinio.io/area"
Variables ¶
This section is empty.
Functions ¶
func AddActualApplicationRoutes ¶ added in v1.7.1
func AddActualApplicationRoutes(auxiliary map[ConfigurationKey]AppData, ctx context.Context, cluster *kubernetes.Cluster, namespace string) (map[ConfigurationKey]AppData, error)
AddActualApplicationRoutes is a helper for List. It loads all the epinio controlled ingresses in the namespace into memory, indexes their routes by namespace and application, and returns the resulting map of route lists. ATTENTION: Using an empty string for the namespace loads the information from all namespaces.
func AddApplicationPods ¶ added in v1.7.1
func AddApplicationPods(auxiliary map[ConfigurationKey]AppData, ctx context.Context, cluster *kubernetes.Cluster, namespace string) (map[ConfigurationKey]AppData, error)
AddApplicationPods is a helper for List. It loads all the epinio controlled pods in the namespace into memory, indexes them by namespace and application, and returns the resulting map of pod lists. ATTENTION: Using an empty string for the namespace loads the information from all namespaces.
func AppChart ¶ added in v0.8.0
func AppChart(app *unstructured.Unstructured) (string, error)
AppChart returns the app chart (to be) used for application deployment, if one exists. It returns an empty string otherwise. The information is pulled out of the app resource itself, saved there by the deploy endpoint.
func BoundApps ¶ added in v0.3.0
func BoundApps(ctx context.Context, cluster *kubernetes.Cluster, namespace string) (map[string]models.AppList, error)
BoundApps is an extension of BoundAppsNames after it, to retrieve a map of configurations to the full data of the applications bound to them. It uses BoundAppsNames internally to quickly determine the applications to fetch.
func BoundAppsNames ¶ added in v0.3.0
func BoundAppsNames(ctx context.Context, cluster *kubernetes.Cluster, namespace string) (map[ConfigurationKey][]string, error)
BoundAppsNames returns a map from the names of configurations in the specified namespace, to the names of the applications they are bound to. The keys of the map are always a combination of namespace name and configuration name, to distinguish same-named configurations in different namespaces (See `ConfigurationKey` below). The application names never contain namespace information, as they are always in the same namespace as the configuration referencing them.
func BoundAppsNamesFor ¶ added in v0.3.0
func BoundAppsNamesFor(ctx context.Context, cluster *kubernetes.Cluster, namespace, configurationName string) ([]string, error)
BoundAppsNamesFor is a specialization of BoundAppsNames after it, to retrieve the names of the applications bound to a single configuration, specified by name.
func BoundConfigurationNames ¶ added in v0.6.0
func BoundConfigurationNames(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef) ([]string, error)
BoundConfigurationNames returns the configuration names for the configurations bound to the application by a user, as a slice. Ordered by name.
func BoundConfigurationNamesFromSecret ¶ added in v1.7.1
BoundConfigurationNamesFromSecret is the core of BoundConfigurationNames, extracting the set of configuration names from the secret containing them.
func BoundConfigurationsSet ¶ added in v0.6.0
func BoundConfigurationsSet(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, configurationNames []string, replace bool) error
BoundConfigurationsSet replaces or adds the specified configuration names to the named application. When the function returns the configuration set will be extended. Adding a known configuration is a no-op.
func BoundConfigurationsUnset ¶ added in v0.6.0
func BoundConfigurationsUnset(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, configurationNames []string) error
BoundConfigurationsUnset removes the specified configuration name from the named application. When the function returns the configuration set will be shrunk. Removing an unknown configuration is a no-op.
func BoundServicesSet ¶ added in v0.1.2
func BoundServicesSet(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, serviceNames []string, replace bool) error
BoundServicesSet replaces or adds the specified service names to the named application. When the function returns the service set will be extended. Adding a known service is a no-op.
func BoundServicesUnset ¶ added in v0.1.2
func BoundServicesUnset(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, serviceName string) error
BoundServicesUnset removes the specified service name from the named application. When the function returns the service set will be shrunk. Removing an unknown service is a no-op.
func BuilderURL ¶ added in v1.8.1
func BuilderURL(app *unstructured.Unstructured) (string, error)
BuilderURL returns the builder url of the currently running build, if one exists. It returns an empty string otherwise. The information is pulled out of the app resource itself, saved there by the deploy endpoint.
func Create ¶ added in v0.0.18
func Create(ctx context.Context, cluster *kubernetes.Cluster, app models.AppRef, username string, routes []string, chart string, settings models.ChartValueSettings) error
Create generates a new kube app resource in the namespace of the namespace. Note that this is the passive resource holding the app's configuration. It is not the active workload
func DecodeConfigurationKey ¶ added in v0.6.0
func DecodeConfigurationKey(key ConfigurationKey) (string, string)
DecodeConfigurationKey splits the given key back into name and namespace. The name is the first result, the namespace the second.
func DecodeServiceKey ¶ added in v0.3.0
DecodeServiceKey splits the given key back into name and namespace. The name is the first result, the namespace the second.
func Delete ¶ added in v0.0.13
Delete removes the named application, its workload (if active), bindings (if any), the stored application sources, and any staging jobs from when the application was staged (if active). Waits for the application's deployment's pods to disappear (if active).
func DesiredRoutes ¶ added in v0.1.5
func DesiredRoutes(appCR *unstructured.Unstructured) ([]string, error)
DesiredRoutes lists all desired routes for the given application The list is constructed from the stored information on the Application Custom Resource.
func Environment ¶ added in v0.0.19
func Environment(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef) (models.EnvVariableMap, error)
Environment returns the environment variables and their values which are set on the named application by users
func EnvironmentFromSecret ¶ added in v1.7.1
func EnvironmentFromSecret(evSecret *v1.Secret) models.EnvVariableMap
EnvironmentFromSecret is the core of Environment, extracting the set of environment variable assignments from the secret containing them.
func EnvironmentNames ¶ added in v0.1.2
func EnvironmentNames(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef) ([]string, error)
EnvironmentNames returns the names of all environment variables which are set on the named application by users. It does not return values.
func EnvironmentSet ¶ added in v0.0.19
func EnvironmentSet(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, assignments models.EnvVariableMap, replace bool) error
EnvironmentSet adds or modifies the specified environment variable for the named application. When the function returns the variable will have the specified value. If the application is active the workload is restarted to update it to the new settings. The function will __not__ wait on this to complete.
func EnvironmentUnset ¶ added in v0.0.19
func EnvironmentUnset(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, varName string) error
EnvironmentUnset removes the specified environment variable from the named application. When the function returns the variable will be gone. If the application is active the workload is restarted to update it to the new settings. The function will __not__ wait on this to complete.
func Exists ¶ added in v0.0.18
Exists checks if the named application exists or not, and returns an appropriate boolean flag
func Get ¶ added in v0.0.18
func Get(ctx context.Context, cluster *kubernetes.Cluster, app models.AppRef) (*unstructured.Unstructured, error)
Get returns the application resource from the cluster. This should be changed to return a typed application struct, like epinioappv1.App if needed in the future.
func GetPodMetrics ¶ added in v1.7.1
func GetPodMetrics(ctx context.Context, cluster *kubernetes.Cluster, namespace string) (map[string]metricsv1beta1.PodMetrics, error)
GetPodMetrics is a helper for List. It loads all the pot metrics for epinio controlled pods in the namespace into memory, indexes them by pod name, and returns the resulting map of metrics lists. The user, List, selects the metrics it needs for an application based on the application's pods. ATTENTION: Using an empty string for the namespace loads the information from all namespaces.
func ImageURL ¶ added in v0.6.0
func ImageURL(app *unstructured.Unstructured) (string, error)
ImageURL returns the image url of the currently running build, if one exists. It returns an empty string otherwise. The information is pulled out of the app resource itself, saved there by the deploy endpoint.
func IsCurrentlyStaging ¶ added in v1.7.1
func IsCurrentlyStaging(ctx context.Context, cluster JobLister, namespace, appName string) (bool, error)
IsCurrentlyStaging returns true if the named application is staging (there is an active Job for this application). If this information is needed for more than one application use StagingStatuses instead.
func List ¶
func List(ctx context.Context, cluster *kubernetes.Cluster, namespace string) (models.AppList, error)
List returns a list of all available apps in the specified namespace. If no namespace is specified (empty string) then apps across all namespaces are returned.
func ListAppRefs ¶ added in v0.0.18
func ListAppRefs(ctx context.Context, cluster *kubernetes.Cluster, namespace string) ([]models.AppRef, error)
ListAppRefs returns an app reference for every application resource in the specified namespace. If no namespace is specified (empty string) then apps across all namespaces are returned.
func ListRoutes ¶ added in v0.1.5
func ListRoutes(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef) ([]string, error)
ListRoutes lists all (currently active) routes for the given application The list is constructed from the actual Ingresses and not from the stored information on the Application Custom Resource.
func Logs ¶ added in v0.0.17
func Logs(ctx context.Context, logChan chan tailer.ContainerLogLine, wg *sync.WaitGroup, cluster *kubernetes.Cluster, follow bool, app, stageID, namespace string) error
Logs method writes log lines to the specified logChan. The caller can stop the logging with the ctx cancelFunc. It's also the callers responsibility to close the logChan when done. When stageID is an empty string, no staging logs are returned. If it is set, then only logs from that staging process are returned.
func Lookup ¶
func Lookup(ctx context.Context, cluster *kubernetes.Cluster, namespace, appName string) (*models.App, error)
Lookup locates the named application (and namespace).
func Origin ¶ added in v0.2.1
func Origin(app *unstructured.Unstructured) (models.ApplicationOrigin, error)
Origin returns the origin of the specified application. The data is constructed from the stored information on the Application Custom Resource.
func Scaling ¶ added in v0.1.2
Scaling returns the number of desired instances set by a user for the application
func ScalingFromSecret ¶ added in v1.7.1
ScalingFromSecret is the core of Scaling, extracting the desired number of instances from the secret containing them.
func ScalingSet ¶ added in v0.1.2
func ScalingSet(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, instances int32) error
ScalingSet sets the desired number of instances for the named application. When the function returns the number is saved.
func ServiceKey ¶ added in v0.3.0
ServiceKey constructs a single key string from service and namespace names, for the `servicesToApps` map, when used for services and apps across all namespaces. It uses ASCII NUL (\000) as the separator character. NUL is forbidden to occur in the names themselves. This should make it impossible to construct two different pairs of service/namespace names which map to the same key.
func ServicesBoundApps ¶ added in v0.9.0
func ServicesBoundApps(ctx context.Context, cluster *kubernetes.Cluster, namespace string) (map[string]models.AppList, error)
ServicesBoundApps is an extension of ServicesBoundAppsNames after it, to retrieve a map from services to the full data of the applications bound to them. It uses ServicesBoundAppsNames internally to quickly determine the applications to fetch.
func ServicesBoundAppsNames ¶ added in v0.9.0
func ServicesBoundAppsNames(ctx context.Context, cluster *kubernetes.Cluster, namespace string) (map[string][]string, error)
ServicesBoundAppsNames returns a map from the names of services in the specified namespace, to the names of the applications they are bound to. The keys of the map are always a combination of namespace name and service name, to distinguish same-named services in different namespaces (See `ServiceKey` below). The application names never contain namespace information, as they are always in the same namespace as the service referencing them.
func ServicesBoundAppsNamesFor ¶ added in v0.9.0
func SetOrigin ¶ added in v0.2.1
func SetOrigin(ctx context.Context, cluster *kubernetes.Cluster, app models.AppRef, origin models.ApplicationOrigin) error
SetOrigin patches the new origin information into the specified application.
func Settings ¶ added in v1.2.0
func Settings(app *unstructured.Unstructured) (models.ChartValueSettings, error)
Settings returns the app chart customization settings used for application deployment. It returns an empty slice otherwise. The information is pulled out of the app resource itself, saved there by the deploy endpoint.
func StageID ¶ added in v0.3.0
func StageID(app *unstructured.Unstructured) (string, error)
StageID returns the stage ID of the last attempt at staging, if one exists. It returns an empty string otherwise. The information is pulled out of the app resource itself, saved there by the staging endpoint. Note that success/failure of staging is immaterial to this.
func StagingStatuses ¶ added in v1.8.0
func StagingStatuses(ctx context.Context, cluster JobLister, namespace string) (map[ConfigurationKey]models.ApplicationStagingStatus, error)
StagingStatuses returns a map of applications and their staging statuses
func Unstage ¶ added in v0.0.15
func Unstage(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef, stageIDCurrent string) error
Unstage removes staging resources. It deletes either all Jobs of the named application, or all but stageIDCurrent. It also deletes the staged objects from the S3 storage except for the current one.
func ValidateCV ¶ added in v1.2.0
func ValidateCV(cv models.ChartValueSettings, decl map[string]models.ChartSetting) []error
ValidateCV checks the custom values against the declarations. It reports as many issues as it can find.
Types ¶
type AppConfigurationBind ¶ added in v0.6.0
type AppConfigurationBind struct {
// contains filtered or unexported fields
}
type AppConfigurationBindList ¶ added in v0.6.0
type AppConfigurationBindList []AppConfigurationBind
func ToBinds ¶ added in v0.1.2
func ToBinds(ctx context.Context, configurations configurations.ConfigurationList, appName string, userName string) (AppConfigurationBindList, error)
func (AppConfigurationBindList) ToMountsArray ¶ added in v0.6.0
func (b AppConfigurationBindList) ToMountsArray() []corev1.VolumeMount
func (AppConfigurationBindList) ToNames ¶ added in v0.6.0
func (b AppConfigurationBindList) ToNames() []string
func (AppConfigurationBindList) ToVolumesArray ¶ added in v0.6.0
func (b AppConfigurationBindList) ToVolumesArray() []corev1.Volume
type ConfigurationKey ¶ added in v0.6.0
type ConfigurationKey string
ConfigurationKey is a type used to create a unique key for an app/namespace
func EncodeConfigurationKey ¶ added in v1.7.1
func EncodeConfigurationKey(name, namespace string) ConfigurationKey
EncodeConfigurationKey constructs a single key string from configuration and namespace names, for the `configurationsToApps` map, when used for configurations and apps across all namespaces. It uses ASCII NUL (\000) as the separator character. NUL is forbidden to occur in the names themselves. This should make it impossible to construct two different pairs of configuration/namespace names which map to the same key.
type NameSet ¶ added in v0.1.2
type NameSet map[string]struct{}
func BoundConfigurationNameSet ¶ added in v0.6.0
func BoundConfigurationNameSet(ctx context.Context, cluster *kubernetes.Cluster, appRef models.AppRef) (NameSet, error)
BoundConfigurationNameSet returns the configuration names for the configurations bound to the application by a user, as a map/set.
type PatchOperation ¶ added in v0.3.6
type PatchOperation struct { Op string `json:"op"` Path string `json:"path"` Value models.ApplicationOrigin `json:"value"` }
type Workload ¶ added in v0.0.18
type Workload struct {
// contains filtered or unexported fields
}
Workload manages applications that are deployed. It provides workload (deployments) specific actions for the application model.
func NewWorkload ¶ added in v0.0.18
NewWorkload constructs and returns a workload representation from an application reference.
func (*Workload) AssembleFromParts ¶ added in v1.7.1
func (a *Workload) AssembleFromParts( ctx context.Context, podList []corev1.Pod, podMetrics []metricsv1beta1.PodMetrics, routes []string, ) (*models.AppDeployment, error)
AssembleFromParts is the core of Get constructing the deployment structure from the pods and auxiliary information explicitly given to it.
func (*Workload) Get ¶ added in v0.1.2
Get returns the state of the app deployment encoded in the workload.