chart

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Package chart contains types and methods to convert the App CRD to an internal representation of a helm chart and install it to a kubernetes cluster.

Index

Constants

View Source
const (
	DefaultApplicationPort     = 8888
	DefaultRoutableProcessName = "web"
)

Variables

View Source
var (
	ErrEmptyProcfile = errors.New("procfile should contain at least one process name with a command")
)
View Source
var (
	ErrPortsNotFound = errors.New("routable process should have at least one container port and one service port")
)

Functions

This section is empty.

Types

type ApplicationChart

type ApplicationChart struct {
	// contains filtered or unexported fields
}

ApplicationChart is an internal representation of a helm chart converted from the App CRD and is used to render a helm chart.

func New

func New(application *ketchv1.App, framework *ketchv1.Framework, opts ...Option) (*ApplicationChart, error)

New returns an ApplicationChart instance.

func (ApplicationChart) ExportToDirectory

func (chrt ApplicationChart) ExportToDirectory(directory string, chartConfig ChartConfig) error

ExportToDirectory saves the chart to the provided directory inside a folder with app_Name_TIMESTAMP

for example, for any app with name `hello`, it will save chart inside a folder with name `hello_11_Dec_20_12_30_IST`

func (ApplicationChart) GetName

func (a ApplicationChart) GetName() string

GetName returns the app name, satisfying TemplateValuer

func (ApplicationChart) GetTemplates

func (a ApplicationChart) GetTemplates() map[string]string

GetTemplates returns the app templates, satisfying TemplateValuer

func (ApplicationChart) GetValues

func (a ApplicationChart) GetValues() interface{}

GetValues returns the app values, satisfying TemplateValuer

type ChartConfig

type ChartConfig struct {
	Version            string
	Description        string
	AppName            string
	AppVersion         string
	DeploymentVersions []int
}

ChartConfig contains data used to render the helm chart's "Chart.yaml" file.

func NewChartConfig

func NewChartConfig(app ketchv1.App) ChartConfig

NewChartConfig returns a ChartConfig instance based on the given application.

func NewJobChartConfig

func NewJobChartConfig(job ketchv1.Job) ChartConfig

NewJobChartConfig returns a ChartConfig instance based on the given job.

type Configurator

type Configurator struct {
	// contains filtered or unexported fields
}

Configurator provides a Pod related configuration based on KetchYamlData and Procfile.

func NewConfigurator

func NewConfigurator(data *ketchv1.KetchYamlData, procfile Procfile, exposedPorts []ketchv1.ExposedPort, defaultPort int) Configurator

NewConfigurator returns a Configurator instance.

func (Configurator) ContainerPortsForProcess

func (c Configurator) ContainerPortsForProcess(process string) []apiv1.ContainerPort

func (Configurator) Lifecycle

func (c Configurator) Lifecycle() *apiv1.Lifecycle

func (Configurator) Probes

func (c Configurator) Probes(port int32) (Probes, error)

func (Configurator) ProcessPortConfigs

func (c Configurator) ProcessPortConfigs(process string) []ketchv1.KetchYamlProcessPortConfig

func (Configurator) ServicePortsForProcess

func (c Configurator) ServicePortsForProcess(process string) []apiv1.ServicePort

type HelmClient

type HelmClient struct {
	// contains filtered or unexported fields
}

HelmClient performs helm install and uninstall operations for provided application helm charts.

func (HelmClient) DeleteChart

func (c HelmClient) DeleteChart(appName string) error

DeleteChart uninstalls the app's helm release. It doesn't return an error if the release is not found.

func (HelmClient) UpdateChart

func (c HelmClient) UpdateChart(tv TemplateValuer, config ChartConfig, opts ...InstallOption) (*release.Release, error)

UpdateChart checks if the app chart is already installed and performs "helm install" or "helm update" operation.

type HelmClientFactory added in v0.6.2

type HelmClientFactory struct {
	sync.Mutex
	// contains filtered or unexported fields
}

HelmClientFactory provides "NewHelmClient()" method to get a helm client. HelmClientFactory internally maintains a cache for action.Configurations per k8s namespace decreasing the cost of creating a new helm client.

func NewHelmClientFactory added in v0.6.2

func NewHelmClientFactory() *HelmClientFactory

func (*HelmClientFactory) NewHelmClient added in v0.6.2

func (f *HelmClientFactory) NewHelmClient(namespace string, c client.Client, log logr.Logger) (*HelmClient, error)

NewHelmClient returns a HelmClient instance.

type InstallOption

type InstallOption func(install *action.Install)

InstallOption to perform additional configuration of action.Install before running a chart installation.

type Job added in v0.7.0

type Job struct {
	ketchv1.JobSpec
	Group string `json:"group"`
}

type JobChart

type JobChart struct {
	// contains filtered or unexported fields
}

JobChart is an internal representation of a helm chart converted from the Job CRD and is used to render a helm chart.

func NewJobChart

func NewJobChart(job *ketchv1.Job, opts ...Option) *JobChart

NewJobChart returns a JobChart instance from a ketchv1.Job and []Option

func (*JobChart) GetName

func (j *JobChart) GetName() string

GetName returns the job name, satisfying TemplateValuer

func (*JobChart) GetTemplates

func (j *JobChart) GetTemplates() map[string]string

GetTemplates returns the job templates, satisfying TemplateValuer

func (*JobChart) GetValues

func (j *JobChart) GetValues() interface{}

GetValues returns the job values, satisfying TemplateValuer

type Option

type Option func(opts *Options)

func WithExposedPorts

func WithExposedPorts(ports map[ketchv1.DeploymentVersion][]ketchv1.ExposedPort) Option

func WithTemplates

func WithTemplates(tpls templates.Templates) Option

type Options

type Options struct {
	// ExposedPorts are ports exposed by an image of each deployment.
	ExposedPorts map[ketchv1.DeploymentVersion][]ketchv1.ExposedPort
	Templates    templates.Templates
}

type Probes

type Probes struct {
	Liveness  *apiv1.Probe
	Readiness *apiv1.Probe
}

Probes represents a Pod's liveness and readiness probes.

type Procfile

type Procfile struct {
	Processes           map[string][]string
	RoutableProcessName string
}

Procfile represents a parsed Procfile.

func CreateProcfile

func CreateProcfile(buildMetadata string) (*Procfile, error)

CreateProcfile creates a Procfile instance from pack build metadata found under the `io.buildpacks.build.metadata` label. This function should only be called for images build using pack

func ProcfileFromProcesses

func ProcfileFromProcesses(processes []ketchv1.ProcessSpec) (*Procfile, error)

ProcfileFromProcesses construct a Procfile instance from a list of ProcessSpec and returns it.

func (*Procfile) IsRoutable

func (p *Procfile) IsRoutable(processName string) bool

func (*Procfile) SortedNames

func (p *Procfile) SortedNames() []string

type TemplateValuer

type TemplateValuer interface {
	GetValues() interface{}
	GetTemplates() map[string]string
	GetName() string
}

TemplateValuer is an interface that permits types that implement it (e.g. Application, Job) to be parameters in the UpdateChart function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL