Adding in examples for readme

This commit is contained in:
Justin Nauman 2017-10-03 17:35:46 -05:00
parent 2e914c652a
commit e386cd0343
18 changed files with 223 additions and 2 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
dist/
.idea/

58
PATHS.md Normal file
View File

@ -0,0 +1,58 @@
# Paths Overivew
Using manifest files in conjunction with command line argument can be a bit confusing.
A few rules to clear up this ambiguity:
- Absolute paths are always resolved as absolute paths
- Relative paths referenced *in* the helmfile manifest itself are relative to that manifest
- Relative paths referenced on the command line are relative to the current working directory the user is in
### Examples
There are several examples that we can go through in the `/examples` folder which demonstrate this.
**Local Execution**
This is an example of a Helmfile manifest referencing a local value directly.
Indirect:
```
helmfile -f examples/deployments/local/charts.yaml sync
```
Direct:
```
cd examples/deployments/local/
helmfile sync
```
**Relative Paths in Helmfile**
This is an example of a Helmfile manifest using relative paths for values.
Indirect:
```
helmfile -f examples/deployments/dev/charts.yaml sync
```
Direct:
```
cd examples/deployments/dev/
helmfile sync
```
**Relative Paths in Helmfile w/ --values overrides**
This is an example of a Helmfile manifest using relative paths for values including an additional `--values` from the command line.
NOTE: The `--values` is resolved relative to the CWD of the terminal *not* the Helmfile manifest. You can see this with the `replicas` being adjusted to 3 now for the deployment.
Indirect:
```
helmfile -f examples/deployments/dev/charts.yaml sync --values values/replica-values.yaml
```
Direct:
```
cd examples/deployments/dev/
helmfile sync --values ../../values/replica-values.yaml
```

View File

@ -22,9 +22,10 @@ repositories:
url: http://roboll.io/charts
charts:
# Published chart example
- name: vault # helm deployment name
namespace: vault # target namespace
chart: roboll/vault-secret-manager # chart reference
chart: roboll/vault-secret-manager # chart reference (repository)
values: [ vault.yaml ] # value files (--values)
set: # values (--set)
- name: address
@ -33,6 +34,13 @@ charts:
- name: db.password
value: DB_PASSWORD # $DB_PASSOWRD needs to be set in the calling environment ex: export DB_PASSWORD='password1'
# Local chart example
- name: grafana # helm deployment name
namespace: another # target namespace
chart: ../my-charts/grafana # chart reference (relative path to manifest)
values:
- ../../my-values/grafana/values.yaml # Values file (relative path to manifest)
```
## install
@ -72,3 +80,15 @@ the charts/releases defined in the manifest.
Under the covers Helmfile is simply using the `helm diff` plugin, so that needs to be installed prior. For Helm 2.3+
you should be able to simply execute `helm plugin install https://github.com/databus23/helm-diff`. For more details
please look at their [documentation](https://github.com/databus23/helm-diff#helm-diff-plugin).
## Paths Overview
Using manifest files in conjunction with command line argument can be a bit confusing.
A few rules to clear up this ambiguity:
- Absolute paths are always resolved as absolute paths
- Relative paths referenced *in* the helmfile manifest itself are relative to that manifest
- Relative paths referenced on the command line are relative to the current working directory the user is in
For additional context, take a look at [paths examples](PATHS.md)

View File

@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj

View File

@ -0,0 +1,4 @@
apiVersion: v1
description: demonstration of local file path references in Helmfile
name: paths-example
version: 0.1.0

View File

@ -0,0 +1,16 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

View File

@ -0,0 +1,37 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
template:
metadata:
labels:
app: {{ template "name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: {{ .Values.service.internalPort }}
livenessProbe:
httpGet:
path: /
port: {{ .Values.service.internalPort }}
readinessProbe:
httpGet:
path: /
port: {{ .Values.service.internalPort }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}

View File

@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
protocol: TCP
name: {{ .Values.service.name }}
selector:
app: {{ template "name" . }}
release: {{ .Release.Name }}

View File

@ -0,0 +1,13 @@
# Default values for paths-example.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: nginx
tag: stable
pullPolicy: IfNotPresent
service:
name: nginx
type: ClusterIP
externalPort: 80
internalPort: 80

View File

@ -0,0 +1,6 @@
charts:
- name: dev-paths-example
namespace: dev
chart: ../../charts/paths-example/
values:
- ../../values/dev/paths-example/values.yaml # Values file (relative path to manifest)

View File

@ -0,0 +1,6 @@
charts:
- name: local-paths-example
namespace: local
chart: ../../charts/paths-example/
values:
- values.yaml # Values file (relative path to manifest)

View File

@ -0,0 +1,2 @@
# Dev specific overrides
nameOverride: local-nginx

View File

@ -0,0 +1,6 @@
charts:
- name: prod-paths-example
namespace: prod
chart: ../../charts/paths-example/
values:
- ../../values/prod/paths-example/values.yaml # Values file (relative path to manifest)

View File

@ -0,0 +1,5 @@
charts:
# Published chart example
- name: grafana # helm deployment name
namespace: grafana # target namespace
chart: stable/grafana # chart reference (repository)

View File

@ -0,0 +1,2 @@
# Dev specific overrides
nameOverride: dev-nginx

View File

@ -0,0 +1,2 @@
# Prod specific overrides
nameOverride: prod-nginx

View File

@ -0,0 +1,2 @@
# Example used to override value explicitly via CLI
replicaCount: 3

View File

@ -51,7 +51,8 @@ func ReadFromFile(file string) (*HelmState, error) {
}
var state HelmState
state.BaseChartPath = path.Dir(file)
state.BaseChartPath, _ = filepath.Abs(path.Dir(file))
if err := yaml.Unmarshal(content, &state); err != nil {
return nil, err
}