Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: experimental integration with helm-x #673

Merged
merged 1 commit into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# helmfile [![CircleCI](https://circleci.com/gh/roboll/helmfile.svg?style=svg)](https://circleci.com/gh/roboll/helmfile)
# Helmfile [![CircleCI](https://circleci.com/gh/roboll/helmfile.svg?style=svg)](https://circleci.com/gh/roboll/helmfile)

Deploy Kubernetes Helm Charts

[![Docker Repository on Quay](https://quay.io/repository/roboll/helmfile/status "Docker Repository on Quay")](https://quay.io/repository/roboll/helmfile)
[![Slack Community #helmfile](https://slack.sweetops.com/badge.svg)](https://slack.sweetops.com)

## status
## Status

Even though Helmfile is used in production environments [across multiple organizations](USERS.md), it is still in its early stage of development, hence versioned 0.x.

Helmfile complies to Semantic Versioning 2.0.0 in which v0.x means that there could be backward-incompatible changes for every release.

Note that we will try our best to document any backward incompatibility.
Note that we will try our best to document any backward incompatibility. And in reality, helmfile had no breaking change for a year or so.

## about
## About

Helmfile is a declarative spec for deploying helm charts. It lets you...

Expand All @@ -23,7 +23,17 @@ Helmfile is a declarative spec for deploying helm charts. It lets you...

To avoid upgrades for each iteration of `helm`, the `helmfile` executable delegates to `helm` - as a result, `helm` must be installed.

## configuration syntax
## Highlights

**Declarative**: Write, version-control, apply the desired state file for visibility and reproducibility.

**Modules**: Modularize common patterns of your infrastructure, distribute it via Git, S3, etc. to be reused across the entire company (See [#648](https://github.com/roboll/helmfile/pull/648))

**Versatility**: Manage your cluster consisting of charts, [kustomizations](https://github.com/kubernetes-sigs/kustomize), and directories of Kubernetes resources, turning everything to Helm releases (See [#673](https://github.com/roboll/helmfile/pull/673))

**Patch**: JSON/Strategic-Merge Patch Kubernetes resources before `helm-install`ing, without forking upstream charts (See [#673](https://github.com/roboll/helmfile/pull/673))

## Configuration

**CAUTION**: This documentation is for the development version of Helmfile. If you are looking for the documentation for any of releases, please switch to the corresponding release tag like [v0.31.0](https://github.com/roboll/helmfile/tree/v0.31.0).

Expand Down
51 changes: 51 additions & 0 deletions pkg/state/helmx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package state

type Dependency struct {
Chart string `yaml:"chart"`
Version string `yaml:"version"`
Alias string `yaml:"alias"`
}

func (st *HelmState) appendHelmXFlags(flags []string, release *ReleaseSpec) ([]string, error) {
for _, d := range release.Dependencies {
var dep string
if d.Alias != "" {
dep += d.Alias + "="
}
dep += d.Chart
if d.Version != "" {
dep += ":" + d.Version
}
flags = append(flags, "--dependency", dep)
}

jsonPatches := release.JSONPatches
if len(jsonPatches) > 0 {
generatedFiles, err := st.generateTemporaryValuesFiles(jsonPatches, release.MissingFileHandler)
if err != nil {
return nil, err
}

for _, f := range generatedFiles {
flags = append(flags, "--json-patch", f)
}

release.generatedValues = append(release.generatedValues, generatedFiles...)
}

strategicMergePatches := release.StrategicMergePatches
if len(strategicMergePatches) > 0 {
generatedFiles, err := st.generateTemporaryValuesFiles(strategicMergePatches, release.MissingFileHandler)
if err != nil {
return nil, err
}

for _, f := range generatedFiles {
flags = append(flags, "--strategic-merge-patch", f)
}

release.generatedValues = append(release.generatedValues, generatedFiles...)
}

return flags, nil
}
36 changes: 35 additions & 1 deletion pkg/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ type ReleaseSpec struct {
TLSKey string `yaml:"tlsKey"`
TLSCert string `yaml:"tlsCert"`

// These settings requires helm-x integration to work
Dependencies []Dependency `yaml:"dependencies"`
JSONPatches []interface{} `yaml:"jsonPatches"`
StrategicMergePatches []interface{} `yaml:"strategicMergePatches"`

// generatedValues are values that need cleaned up on exit
generatedValues []string
//version of the chart that has really been installed cause desired version may be fuzzy (~2.0.0)
Expand Down Expand Up @@ -1198,6 +1203,12 @@ func (st *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSp

flags = st.appendTillerFlags(flags, release)

var err error
flags, err = st.appendHelmXFlags(flags, release)
if err != nil {
return nil, err
}

common, err := st.namespaceAndValuesFlags(helm, release, workerIndex)
if err != nil {
return nil, err
Expand All @@ -1209,6 +1220,13 @@ func (st *HelmState) flagsForTemplate(helm helmexec.Interface, release *ReleaseS
flags := []string{
"--name", release.Name,
}

var err error
flags, err = st.appendHelmXFlags(flags, release)
if err != nil {
return nil, err
}

common, err := st.namespaceAndValuesFlags(helm, release, workerIndex)
if err != nil {
return nil, err
Expand All @@ -1228,6 +1246,12 @@ func (st *HelmState) flagsForDiff(helm helmexec.Interface, release *ReleaseSpec,

flags = st.appendTillerFlags(flags, release)

var err error
flags, err = st.appendHelmXFlags(flags, release)
if err != nil {
return nil, err
}

common, err := st.namespaceAndValuesFlags(helm, release, workerIndex)
if err != nil {
return nil, err
Expand All @@ -1245,7 +1269,17 @@ func (st *HelmState) isDevelopment(release *ReleaseSpec) bool {
}

func (st *HelmState) flagsForLint(helm helmexec.Interface, release *ReleaseSpec, workerIndex int) ([]string, error) {
return st.namespaceAndValuesFlags(helm, release, workerIndex)
flags, err := st.namespaceAndValuesFlags(helm, release, workerIndex)
if err != nil {
return nil, err
}

flags, err = st.appendHelmXFlags(flags, release)
if err != nil {
return nil, err
}

return flags, nil
}

func (st *HelmState) RenderValuesFileToBytes(path string) ([]byte, error) {
Expand Down