metahelm

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHelmDriver       = "secrets"
	MaxPodContainerLogLines = 1000
	DefaultRestConfigQPS    = 100000
	DefaultRestConfigBurst  = 100000
)

Defaults configuration options, if not specified otherwise

Variables

This section is empty.

Functions

func NewInClusterHelmConfiguration added in v0.9.2

func NewInClusterHelmConfiguration(ctx context.Context, kc kubernetes.Interface, hccfg config.HelmClientConfig, namespace string) (*metahelmlib.Manager, error)

NewInClusterHelmConfiguration is a HelmClientConfigurationFunc that returns a Helm v3 client configured for use within the k8s cluster

func NewInClusterK8sClientset

func NewInClusterK8sClientset(k8sJWTPath string, enableK8sTracing bool) (*kubernetes.Clientset, *rest.Config, error)

func NewKubecfgContextK8sClientset

func NewKubecfgContextK8sClientset(kubecfgpath, kubectx string) (*kubernetes.Clientset, *rest.Config, error)

Types

type ChartInstaller

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

ChartInstaller is an object that manages namespaces and install/upgrades/deletes metahelm chart graphs

func NewChartInstaller

func NewChartInstaller(ib images.Builder, dl persistence.DataLayer, fs billy.Filesystem, mc metrics.Collector, k8sGroupBindings map[string]string, k8sRepoWhitelist []string, k8sSecretInjs map[string]config.K8sSecret, k8sJWTPath string, enableK8sTracing bool, hccfg config.HelmClientConfig) (*ChartInstaller, error)

NewChartInstaller returns a ChartInstaller configured with an in-cluster K8s clientset

func NewChartInstallerWithClientsetFromContext

func NewChartInstallerWithClientsetFromContext(ib images.Builder, dl persistence.DataLayer, fs billy.Filesystem, mc metrics.Collector, k8sGroupBindings map[string]string, k8sRepoWhitelist []string, k8sSecretInjs map[string]config.K8sSecret, kubeconfigpath string, hccfg config.HelmClientConfig) (*ChartInstaller, error)

NewChartInstallerWithClientsetFromContext returns a ChartInstaller configured with a K8s clientset from the current kubeconfig context

func (ChartInstaller) BuildAndInstallCharts

func (ci ChartInstaller) BuildAndInstallCharts(ctx context.Context, newenv *EnvInfo, cl ChartLocations) (err error)

BuildAndInstallCharts builds images for the environment while simultaneously installing the associated helm charts, returning the k8s namespace or error

func (ChartInstaller) BuildAndInstallChartsIntoExisting

func (ci ChartInstaller) BuildAndInstallChartsIntoExisting(ctx context.Context, env *EnvInfo, k8senv *models.KubernetesEnvironment, cl ChartLocations) error

func (ChartInstaller) BuildAndUpgradeCharts

func (ci ChartInstaller) BuildAndUpgradeCharts(ctx context.Context, env *EnvInfo, k8senv *models.KubernetesEnvironment, cl ChartLocations) error

func (ChartInstaller) Cleanup

func (ci ChartInstaller) Cleanup(ctx context.Context, objMaxAge time.Duration)

Cleanup runs various processes to clean up. For example, it removes orphaned k8s resources older than objMaxAge. It is intended to be run periodically via a cronjob.

func (ChartInstaller) DeleteNamespace

func (ci ChartInstaller) DeleteNamespace(ctx context.Context, k8senv *models.KubernetesEnvironment) error

DeleteNamespace deletes the kubernetes namespace and removes k8senv from the database if they exist

func (ChartInstaller) GenerateCharts

func (ci ChartInstaller) GenerateCharts(ctx context.Context, ns string, newenv *EnvInfo, cloc ChartLocations) (out []metahelmlib.Chart, err error)

GenerateCharts processes the fetched charts, adds and merges overrides and returns metahelm Charts ready to be installed/upgraded

func (ChartInstaller) GetPodContainers added in v0.8.0

func (ci ChartInstaller) GetPodContainers(ctx context.Context, ns, podname string) (out K8sPodContainers, err error)

GetK8sEnvPodContainers returns all container names for the specified pod

func (ChartInstaller) GetPodList added in v0.8.0

func (ci ChartInstaller) GetPodList(ctx context.Context, ns string) (out []K8sPod, err error)

GetK8sEnvPodList returns a kubernetes environment pod list for the namespace provided

func (ChartInstaller) GetPodLogs added in v0.8.0

func (ci ChartInstaller) GetPodLogs(ctx context.Context, ns, podname, container string, lines uint) (out io.ReadCloser, err error)

GetK8sEnvPodLogs returns

type ChartLocation

type ChartLocation struct {
	ChartPath, VarFilePath string
}

ChartLocation models the local filesystem path for the chart and the associated vars file

func (*ChartLocation) MergeVars

func (cl *ChartLocation) MergeVars(fs billy.Filesystem, overrides map[string]string) ([]byte, error)

mergeVars merges overrides with the variables defined in the file at VarFilePath and returns the merged YAML stream

type ChartLocations

type ChartLocations map[string]ChartLocation

ChartLocations is a map of repo name to ChartLocation

type EnvInfo

type EnvInfo struct {
	Env      *models.QAEnvironment
	RC       *models.RepoConfig
	Releases map[string]string // map of repo to release name
}

EnvInfo models all the data required to create a new environment or upgrade an existing one

type FakeInstaller

type FakeInstaller struct {
	// ChartInstallFunc is called for each repo in chartLocations. Return an error to abort.
	ChartInstallFunc func(repo string, location ChartLocation) error
	ChartUpgradeFunc func(repo string, k8senv *models.KubernetesEnvironment, location ChartLocation) error
	DL               persistence.DataLayer
	KC               kubernetes.Interface
	HelmReleases     []string
}

FakeInstaller satisfies the Installer interface but does nothing

func (*FakeInstaller) BuildAndInstallCharts

func (fi *FakeInstaller) BuildAndInstallCharts(ctx context.Context, newenv *EnvInfo, chartsLocation ChartLocations) error

func (FakeInstaller) BuildAndInstallChartsIntoExisting

func (fi FakeInstaller) BuildAndInstallChartsIntoExisting(ctx context.Context, newenv *EnvInfo, k8senv *models.KubernetesEnvironment, cl ChartLocations) error

func (FakeInstaller) BuildAndUpgradeCharts

func (fi FakeInstaller) BuildAndUpgradeCharts(ctx context.Context, env *EnvInfo, k8senv *models.KubernetesEnvironment, cl ChartLocations) error

func (FakeInstaller) DeleteNamespace

func (fi FakeInstaller) DeleteNamespace(ctx context.Context, k8senv *models.KubernetesEnvironment) error

type FakeKubernetesReporter added in v0.8.0

type FakeKubernetesReporter struct {
	FakePodLogFilePath string
}

FakeKubernetesReporter satisfies the kubernetes reporter interface but does nothing

func (FakeKubernetesReporter) GetPodContainers added in v0.8.0

func (fkr FakeKubernetesReporter) GetPodContainers(ctx context.Context, ns, podname string) (out K8sPodContainers, err error)

func (FakeKubernetesReporter) GetPodList added in v0.8.0

func (fkr FakeKubernetesReporter) GetPodList(ctx context.Context, ns string) (out []K8sPod, err error)

func (FakeKubernetesReporter) GetPodLogs added in v0.8.0

func (fkr FakeKubernetesReporter) GetPodLogs(ctx context.Context, ns, podname, container string, lines uint) (out io.ReadCloser, err error)

type Installer

type Installer interface {
	BuildAndInstallCharts(ctx context.Context, newenv *EnvInfo, cl ChartLocations) error
	BuildAndInstallChartsIntoExisting(ctx context.Context, newenv *EnvInfo, k8senv *models.KubernetesEnvironment, cl ChartLocations) error
	BuildAndUpgradeCharts(ctx context.Context, env *EnvInfo, k8senv *models.KubernetesEnvironment, cl ChartLocations) error
	DeleteNamespace(ctx context.Context, k8senv *models.KubernetesEnvironment) error
}

Installer describes an object that installs Helm charts and manages image builds

type K8sClientFactoryFunc

type K8sClientFactoryFunc func(kubecfgpath, kubectx string) (*kubernetes.Clientset, *rest.Config, error)

type K8sPod added in v0.8.0

type K8sPod struct {
	Name, Ready, Status string
	Restarts            int32
	Age                 time.Duration
}

K8sPod models the returned pod details

type K8sPodContainers added in v0.8.0

type K8sPodContainers struct {
	Pod        string
	Containers []string
}

type KubernetesReporter added in v0.8.0

type KubernetesReporter interface {
	GetPodList(ctx context.Context, ns string) (out []K8sPod, err error)
	GetPodContainers(ctx context.Context, ns, podname string) (out K8sPodContainers, err error)
	GetPodLogs(ctx context.Context, ns, podname, container string, lines uint) (out io.ReadCloser, err error)
}

KubernetesReporter describes an object that returns k8s environment data

type LogFunc

type LogFunc func(string, ...interface{})

LogFunc is a function that logs a formatted string somewhere

type MetahelmManagerFactoryFunc added in v0.9.2

type MetahelmManagerFactoryFunc func(ctx context.Context, kc kubernetes.Interface, hccfg config.HelmClientConfig, namespace string) (*metahelmlib.Manager, error)

Jump to

Keyboard shortcuts

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