metahelm: github.com/dollarshaveclub/metahelm/pkg/metahelm Index | Files

package metahelm

import "github.com/dollarshaveclub/metahelm/pkg/metahelm"

Index

Package Files

error.go metahelm.go models.go yamlhelper.go

Constants

const DefaultDeploymentTimeout = 10 * time.Minute

DefaultDeploymentTimeout indicates the default time to wait for a deployment to be healthy

const DefaultK8sNamespace = "default"

DefaultK8sNamespace is the k8s namespace to install a chart graph into if not specified

Variables

var ChartWaitPollInterval = 10 * time.Second

ChartWaitPollInterval is the amount of time spent between polling attempts when checking if a deployment is healthy

var MaxPodLogLines = uint(500)

MaxPodLogLines is the maximum number of failed pod log lines to return in the event of chart install/upgrade failure

func ReleaseName Uses

func ReleaseName(input string) string

releaseName returns a release name of not more than 53 characters. If the input is truncated, a random number is added to ensure uniqueness.

func ValidateCharts Uses

func ValidateCharts(charts []Chart) error

ValidateCharts verifies that a set of charts is constructed properly, particularly with respect to dependencies. It does not check to see if the referenced charts exist in the local filesystem.

type Chart Uses

type Chart struct {
    Title                      string           // unique name for this chart (must not collide with any dependencies)
    Location                   string           // local filesystem location
    ValueOverrides             []byte           // value overrides as raw YAML stream
    WaitUntilHelmSaysItsReady  bool             // wait until Helm thinks the chart is ready. This overrides WaitUntilDeployment and DeploymentHealthIndication.
    WaitUntilDeployment        string           // Deployment name that, when healthy, indicates chart install has succeeded
    WaitTimeout                time.Duration    // how long to wait for the deployment to become healthy. If unset, DefaultDeploymentTimeout is used
    DeploymentHealthIndication HealthIndication // How to determine if a deployment is healthy
    DependencyList             []string
}

Chart models a single installable Helm chart

func (*Chart) Dependencies Uses

func (c *Chart) Dependencies() []string

func (*Chart) Name Uses

func (c *Chart) Name() string

func (*Chart) String Uses

func (c *Chart) String() string

func (*Chart) ToYAMLStream Uses

func (c *Chart) ToYAMLStream(overrides ValueOverridesMap) error

ToYAMLStream takes overrides and serializes into a raw YAML stream that is assigned to c.ValueOverrides

type ChartError Uses

type ChartError struct {
    // HelmError is the original error returned by Helm
    HelmError error
    // Level is the chart level (zero-indexed) at which the error occurred
    Level uint
    // FailedDaemonSets is map of DaemonSet name to failed pods
    FailedDaemonSets map[string][]FailedPod
    // FailedDeployments is map of Deployment name to failed pods
    FailedDeployments map[string][]FailedPod
    // FailedJobs is map of Job name to failed pods
    FailedJobs map[string][]FailedPod
}

ChartError is a chart install/upgrade error due to failing Kubernetes resources. It contains all Deployment, Job or DaemonSet-related pods that appear to be in a failed state, including up to MaxPodLogLines of log data for each.

func NewChartError Uses

func NewChartError(err error) ChartError

NewChartError returns an initialized empty ChartError

func (ChartError) Error Uses

func (ce ChartError) Error() string

Error satisfies the error interface

func (ChartError) PopulateFromDeployment Uses

func (ce ChartError) PopulateFromDeployment(namespace, deploymentName string, kc K8sClient, maxloglines uint) error

PopulateFromDeployment finds the failed pods for a deployment and fills ChartError with names and logs of the failed pods

func (ChartError) PopulateFromRelease Uses

func (ce ChartError) PopulateFromRelease(rls *release.Release, kc K8sClient, maxloglines uint) error

PopulateFromRelease finds the failed Jobs and Pods for a given release and fills ChartError with names and logs of the failed resources

type FailedPod Uses

type FailedPod struct {
    Name, Phase, Message, Reason string
    Conditions                   []corev1.PodCondition
    ContainerStatuses            []corev1.ContainerStatus
    // Logs is a map of container name to raw log (stdout/stderr) output
    Logs map[string][]byte
}

FailedPod models a single failed pod with metadata and logs

type HealthIndication Uses

type HealthIndication int

HealthIndication describes how to decide if a deployment is successful

const (
    // IgnorePodHealth indicates that we don't care about pod health
    IgnorePodHealth HealthIndication = iota
    // AllPodsHealthy indeicates that all pods are OK
    AllPodsHealthy
    // AtLeastOnePodHealthy indicates >= 1 pods are OK
    AtLeastOnePodHealthy
)

type HelmClient Uses

type HelmClient interface {
    InstallReleaseWithContext(ctx context.Context, chstr, ns string, opts ...helm.InstallOption) (*rls.InstallReleaseResponse, error)
    UpdateReleaseWithContext(ctx context.Context, rlsName string, chstr string, opts ...helm.UpdateOption) (*rls.UpdateReleaseResponse, error)
    ListReleases(opts ...helm.ReleaseListOption) (*rls.ListReleasesResponse, error)
    ReleaseContent(rlsName string, opts ...helm.ContentOption) (*rls.GetReleaseContentResponse, error)
}

HelmClient describes an object that functions as a Helm client

type InstallCallback Uses

type InstallCallback func(Chart) InstallCallbackAction

InstallCallback is a function that decides whether to proceed with an individual chart installation This will be called concurrently from multiple goroutines, so make sure everything is threadsafe

type InstallCallbackAction Uses

type InstallCallbackAction int

CallbackAction indicates the decision made by the callback

const (
    // Continue indicates the installation should proceed immediately
    Continue InstallCallbackAction = iota
    // Wait means the install should not happen right now but should be retried at some point in the future. The callback will be invoked again on the retry.
    Wait
    // Abort means the installation should not be attempted
    Abort
)

type InstallOption Uses

type InstallOption func(*options)

func WithInstallCallback Uses

func WithInstallCallback(cb InstallCallback) InstallOption

WithInstallCallback specifies a callback function that will be invoked immediately prior to each chart installation

func WithK8sNamespace Uses

func WithK8sNamespace(ns string) InstallOption

WithK8sNamespace specifies the kubernetes namespace to install a chart graph into. DefaultK8sNamespace is used otherwise.

func WithReleaseNamePrefix Uses

func WithReleaseNamePrefix(pfx string) InstallOption

WithReleaseNamePrefix specifies a prefix to use in Helm release names (useful for when multiple instances of a chart graph are installed into the same namespace)

func WithTillerNamespace Uses

func WithTillerNamespace(tns string) InstallOption

WithTillerNamespace specifies the namespace where the Tiller service can be found

func WithTimeout Uses

func WithTimeout(timeout time.Duration) InstallOption

WithTimeout sets a timeout for all chart installations/upgrades to complete. If the timeout is reached, chart operations are aborted and an error is returned.

type K8sClient Uses

type K8sClient interface {
    AppsV1() appsv1.AppsV1Interface
    // ExtensionsV1beta1() v1beta1.ExtensionsV1beta1Interface
    CoreV1() corev1.CoreV1Interface
    BatchV1() batchv1.BatchV1Interface
}

K8sClient describes an object that functions as a Kubernetes client

type LogFunc Uses

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

LogFunc is a function that logs a formatted string somewhere

type Manager Uses

type Manager struct {
    K8c  K8sClient
    HC   HelmClient
    LogF LogFunc
}

Manager is an object that manages installation of chart graphs

func (*Manager) Install Uses

func (m *Manager) Install(ctx context.Context, charts []Chart, opts ...InstallOption) (ReleaseMap, error)

Install installs charts in order according to dependencies and returns the names of the releases, or error. In the event of an error, the client can check if the error returned is of type ChartError, which then provides information on the kubernetes objects that caused failure, if this can be determined. A helm error unrelated to pod failure may return either a non-ChartError error value or an empty ChartError.

func (*Manager) Upgrade Uses

func (m *Manager) Upgrade(ctx context.Context, rmap ReleaseMap, charts []Chart, opts ...InstallOption) error

Upgrade upgrades charts in order according to dependencies, using the release names in rmap. ValueOverrides will be used in the upgrade. In the event of an error, the client can check if the error returned is of type ChartError, which then provides information on the kubernetes objects that caused failure, if this can be determined. A helm error unrelated to pod failure may return either a non-ChartError error value or an empty ChartError.

type ReleaseMap Uses

type ReleaseMap map[string]string

ReleaseMap is a map of chart title to installed release name

type ValueOverridesMap Uses

type ValueOverridesMap map[string]string

ValueOverridesMap represents a set of chart YAML overrides, a map of YAML path to value, in the same format as accepted by the helm CLI: "foo.bar=value" except in a map.

Package metahelm imports 23 packages (graph) and is imported by 4 packages. Updated 2019-01-10. Refresh now. Tools for package owners.