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

Commit e0e69e5

Browse files
Add helm chart (#356)
* add example helm chart Signed-off-by: Matt Butcher <matt.butcher@microsoft.com> * update to use helloworld-python example Signed-off-by: Matt Butcher <matt.butcher@microsoft.com> * Update examples/charts/README.md Co-Authored-By: Hongchao Deng <hongchaodeng1@gmail.com> * Update examples/charts/README.md Co-Authored-By: Hongchao Deng <hongchaodeng1@gmail.com>
1 parent 5ff3b21 commit e0e69e5

File tree

8 files changed

+156
-0
lines changed

8 files changed

+156
-0
lines changed

examples/charts/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Example Charts of OAM Apps
2+
3+
This directory contains example Helm charts that install Open Application Model apps.
4+
5+
Helm is a useful tool for parameterizing AppConfig files. There are various strategies for installing ComponentSchematics:
6+
7+
- They may be bundled into the same chart that manages them, and treated like standard resources
8+
- When this chart is upgraded or deleted, components will be updated or deleted
9+
- This can be bad if multiple apps share the same components
10+
- This can be good if your app configs and components are closely related
11+
- They may be bundled into the same chart that references them, but managed with hooks
12+
- You can configure hooks to not delete components
13+
- This solves some of the problems above
14+
- They may be kept in separate Helm charts
15+
- This model is best if you want to have lots of components that can be shared among different app configs
16+
17+
18+
## Installing OAM Apps
19+
20+
These examples are built for Helm 3. They can be installed with the following command:
21+
22+
```console
23+
$ helm install my-hello hello-rudr
24+
```
25+
26+
They can be uninstalled with `helm delete my-hello`.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: hello-rudr
3+
description: Demonstration of using Helm with Rudr, using the Python example.
4+
type: application
5+
version: 0.1.0
6+
appVersion: 0.1.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This chart is an example of using Helm to install rudr applications.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "hello-rudr.name" -}}
6+
{{/* - trunc 63 .Chart.Name | trimSuffix "-" - */}}
7+
{{ .Chart.name }}
8+
{{- end -}}
9+
10+
{{/*
11+
Create a default fully qualified app name.
12+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
13+
If release name contains chart name it will be used as a full name.
14+
*/}}
15+
{{- define "hello-rudr.fullname" -}}
16+
{{- if .Values.fullnameOverride -}}
17+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
18+
{{- else -}}
19+
{{- $name := default .Chart.Name .Values.nameOverride -}}
20+
{{- if contains $name .Release.Name -}}
21+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
22+
{{- else -}}
23+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
24+
{{- end -}}
25+
{{- end -}}
26+
{{- end -}}
27+
28+
{{/*
29+
Create chart name and version as used by the chart label.
30+
*/}}
31+
{{- define "hello-rudr.chart" -}}
32+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
33+
{{- end -}}
34+
35+
{{/*
36+
Common labels
37+
*/}}
38+
{{- define "hello-rudr.labels" -}}
39+
app.kubernetes.io/name: {{ include "hello-rudr.name" . }}
40+
helm.sh/chart: {{ include "hello-rudr.chart" . }}
41+
app.kubernetes.io/instance: {{ .Release.Name }}
42+
{{- if .Chart.AppVersion }}
43+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
44+
{{- end }}
45+
app.kubernetes.io/managed-by: {{ .Release.Service }}
46+
{{- end -}}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
kind: ApplicationConfiguration
2+
apiVersion: core.oam.dev/v1alpha1
3+
metadata:
4+
name: "{{ .Release.Name }}"
5+
spec:
6+
components:
7+
- name: "{{ .Release.Name }}-{{ .Values.appVersion}}"
8+
instanceName: "{{ .Release.Name }}-{{ .Values.appVersion}}"
9+
parameterValues:
10+
- name: target
11+
value: "{{ .Values.target }}"
12+
- name: port
13+
value: "{{ .Values.port }}"
14+
traits:
15+
- name: ingress
16+
parameterValues:
17+
- name: hostname
18+
value: example.com
19+
- name: path
20+
value: /
21+
- name: service_port
22+
value: {{ .Values.port }}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
apiVersion: core.oam.dev/v1alpha1
2+
kind: ComponentSchematic
3+
metadata:
4+
name: "{{.Release.Name}}-{{.Values.appVersion}}"
5+
spec:
6+
name: helloworld-python
7+
workloadType: core.oam.dev/v1alpha1.Server
8+
containers:
9+
- name: foo
10+
image: oamdev/helloworld-python:v1
11+
env:
12+
- name: TARGET
13+
fromParam: target
14+
- name: PORT
15+
fromParam: port
16+
ports:
17+
- type: tcp
18+
containerPort: 9999
19+
name: http
20+
parameters:
21+
- name: target
22+
type: string
23+
default: World
24+
- name: port
25+
type: string
26+
default: "9999"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Default values for hello-rudr.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
5+
replicaCount: 1
6+
appVersion: v1
7+
target: Rudr
8+
port: "9999"

0 commit comments

Comments
 (0)