Documentation
¶
Overview ¶
Package release allows to manage Helm 3 releases.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Kubeconfig is content of kubeconfig file in YAML format, which will be used to authenticate
// to the cluster and create a release.
Kubeconfig string `json:"kubeconfig,omitempty"`
// Namespace is a namespace, where helm release will be created and all it's resources.
Namespace string `json:"namespace,omitempty"`
// Name is a name of the release used to identify it.
Name string `json:"name,omitempty"`
// Chart is a location of the chart. It may be local path or remote chart in user repository.
Chart string `json:"chart,omitempty"`
// Values is a chart values in YAML format.
Values string `json:"values,omitempty"`
// Version is a requested version of the chart.
Version string `json:"version,omitempty"`
// CreateNamespace controls, if the namespace for the release should be created before installing
// the release.
CreateNamespace bool `json:"createNamespace,omitempty"`
// Wait controls if client should wait until managed chart converges.
Wait bool `json:"wait,omitempty"`
}
Config represents user-configured Helm release.
func (*Config) New ¶
New validates release configuration and builds installable version of it.
Example ¶
Creating helm release.
package main
import (
"context"
"fmt"
"os"
"github.com/flexkube/libflexkube/pkg/helm/release"
)
func main() {
config := &release.Config{
// Put content of your kubeconfig file here.
Kubeconfig: "",
// The namespace must be created upfront.
Namespace: "kube-system",
// Name of helm release.
Name: "coredns",
// Repositories must be added upfront as well.
Chart: "stable/coredns",
// Values passed to the release in YAML format.
Values: `replicas: 1
labels:
foo: bar
`,
// Version of the chart to use.
Version: "1.12.0",
}
exampleRelease, err := config.New()
if err != nil {
fmt.Fprintf(os.Stderr, "Creating release object failed: %v\n", err)
return
}
if err := exampleRelease.Install(context.TODO()); err != nil {
fmt.Fprintf(os.Stderr, "Installing release failed: %v\n", err)
return
}
}
type Release ¶
type Release interface {
// ValidateChart validates configured chart.
ValidateChart() error
// Install installs configured release. If release already exists, error will be returned.
Install(context.Context) error
// Upgrade upgrades configured release. If release does not exist, error will be returned.
Upgrade(context.Context) error
// InstallOrUpgrade either installs or upgrades the release, depends whether it exists or not.
InstallOrUpgrade(context.Context) error
// Exists checks, if release exists. If cluster is not reachable, error is returned.
Exists() (bool, error)
// Uninstall removes the release.
Uninstall() error
}
Release is an interface representing helm release.
Click to show internal directories.
Click to hide internal directories.