Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Add helm chart (#356)
Browse files Browse the repository at this point in the history
* add example helm chart

Signed-off-by: Matt Butcher <[email protected]>

* update to use helloworld-python example

Signed-off-by: Matt Butcher <[email protected]>

* Update examples/charts/README.md

Co-Authored-By: Hongchao Deng <[email protected]>

* Update examples/charts/README.md

Co-Authored-By: Hongchao Deng <[email protected]>
  • Loading branch information
technosophos and hongchaodeng authored Oct 15, 2019
1 parent 5ff3b21 commit e0e69e5
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 0 deletions.
26 changes: 26 additions & 0 deletions examples/charts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Example Charts of OAM Apps

This directory contains example Helm charts that install Open Application Model apps.

Helm is a useful tool for parameterizing AppConfig files. There are various strategies for installing ComponentSchematics:

- They may be bundled into the same chart that manages them, and treated like standard resources
- When this chart is upgraded or deleted, components will be updated or deleted
- This can be bad if multiple apps share the same components
- This can be good if your app configs and components are closely related
- They may be bundled into the same chart that references them, but managed with hooks
- You can configure hooks to not delete components
- This solves some of the problems above
- They may be kept in separate Helm charts
- This model is best if you want to have lots of components that can be shared among different app configs


## Installing OAM Apps

These examples are built for Helm 3. They can be installed with the following command:

```console
$ helm install my-hello hello-rudr
```

They can be uninstalled with `helm delete my-hello`.
21 changes: 21 additions & 0 deletions examples/charts/hello-rudr/.helmignore
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions examples/charts/hello-rudr/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: hello-rudr
description: Demonstration of using Helm with Rudr, using the Python example.
type: application
version: 0.1.0
appVersion: 0.1.0
1 change: 1 addition & 0 deletions examples/charts/hello-rudr/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This chart is an example of using Helm to install rudr applications.
46 changes: 46 additions & 0 deletions examples/charts/hello-rudr/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "hello-rudr.name" -}}
{{/* - trunc 63 .Chart.Name | trimSuffix "-" - */}}
{{ .Chart.name }}
{{- 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).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "hello-rudr.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "hello-rudr.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "hello-rudr.labels" -}}
app.kubernetes.io/name: {{ include "hello-rudr.name" . }}
helm.sh/chart: {{ include "hello-rudr.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
22 changes: 22 additions & 0 deletions examples/charts/hello-rudr/templates/appconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
kind: ApplicationConfiguration
apiVersion: core.oam.dev/v1alpha1
metadata:
name: "{{ .Release.Name }}"
spec:
components:
- name: "{{ .Release.Name }}-{{ .Values.appVersion}}"
instanceName: "{{ .Release.Name }}-{{ .Values.appVersion}}"
parameterValues:
- name: target
value: "{{ .Values.target }}"
- name: port
value: "{{ .Values.port }}"
traits:
- name: ingress
parameterValues:
- name: hostname
value: example.com
- name: path
value: /
- name: service_port
value: {{ .Values.port }}
26 changes: 26 additions & 0 deletions examples/charts/hello-rudr/templates/component.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: core.oam.dev/v1alpha1
kind: ComponentSchematic
metadata:
name: "{{.Release.Name}}-{{.Values.appVersion}}"
spec:
name: helloworld-python
workloadType: core.oam.dev/v1alpha1.Server
containers:
- name: foo
image: oamdev/helloworld-python:v1
env:
- name: TARGET
fromParam: target
- name: PORT
fromParam: port
ports:
- type: tcp
containerPort: 9999
name: http
parameters:
- name: target
type: string
default: World
- name: port
type: string
default: "9999"
8 changes: 8 additions & 0 deletions examples/charts/hello-rudr/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Default values for hello-rudr.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1
appVersion: v1
target: Rudr
port: "9999"

0 comments on commit e0e69e5

Please sign in to comment.