Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
[PIO-198] add helm chart (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
marevol authored and haginot committed Apr 7, 2019
1 parent 7f0cda5 commit 794d5ef
Show file tree
Hide file tree
Showing 20 changed files with 936 additions and 0 deletions.
59 changes: 59 additions & 0 deletions docker/charts/README.md
@@ -0,0 +1,59 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

Helm Charts for Apache PredictionIO
============================

## Overview

Helm Charts are packages of pre-configured Kubernetes resources.
Using charts, you can install and manage PredictionIO in the Kubernetes.

## Usage

### Install PredictionIO with PostgreSQL

To install PostgreSQL and PredictionIO, run `helm install` command:

```
helm install --name my-postgresql stable/postgresql -f postgresql.yaml
helm install --name my-pio ./predictionio -f predictionio_postgresql.yaml
```

`postgresql.yaml` and `predictionio_postgresql.yaml` are configuration files for charts.
To access Jupyter for PredictionIO, run `kubectl port-forward` and then open `http://localhost:8888/`.

```
export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/name=predictionio,app.kubernetes.io/instance=my-pio" -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward $POD_NAME 8888:8888
```


### Install Spark Cluster

To install Spark cluster, run the following command:

```
helm install --name my-spark ./spark
```

To train a model, run `pio train` as below:

```
pio train -- --master spark://my-spark-master:7077
```

23 changes: 23 additions & 0 deletions docker/charts/postgresql.yaml
@@ -0,0 +1,23 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
postgresqlUsername: pio
postgresqlPassword: pio
postgresqlDatabase: pio

# for testing
persistence:
enabled: false
38 changes: 38 additions & 0 deletions docker/charts/predictionio/.helmignore
@@ -0,0 +1,38 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# 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
27 changes: 27 additions & 0 deletions docker/charts/predictionio/Chart.yaml
@@ -0,0 +1,27 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: predictionio
version: 0.1.0
appVersion: 0.13.0
description: Machine learning server
home: http://predictionio.apache.org
icon: http://predictionio.apache.org/images/logos/logo-ee2b9bb3.png
sources:
- https://github.com/apache/predictionio
maintainers:
- name: Shinsuke Sugaya
email: shinsuke@apache.org
31 changes: 31 additions & 0 deletions docker/charts/predictionio/templates/NOTES.txt
@@ -0,0 +1,31 @@
{{/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/}}
1. Get the application URL by running these commands:
{{- if contains "NodePort" .Values.pio.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "predictionio.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.pio.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ include "predictionio.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "predictionio.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.pio.service.port }}
{{- else if contains "ClusterIP" .Values.pio.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "predictionio.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8888 to use your application"
kubectl port-forward $POD_NAME 8888:8888
{{- end }}
36 changes: 36 additions & 0 deletions docker/charts/predictionio/templates/_helpers.tpl
@@ -0,0 +1,36 @@
{{/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/}}
{{- define "predictionio.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "predictionio.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 -}}

{{- define "predictionio.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
75 changes: 75 additions & 0 deletions docker/charts/predictionio/templates/pio-deployment.yaml
@@ -0,0 +1,75 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ include "predictionio.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "predictionio.name" . }}
helm.sh/chart: {{ include "predictionio.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
replicas: {{ .Values.pio.replicas }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "predictionio.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "predictionio.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.pio.image.repository }}:{{ .Values.pio.image.tag }}"
imagePullPolicy: {{ .Values.pio.image.pullPolicy }}
env:
{{ toYaml .Values.pio.env | indent 12 }}
ports:
- name: event
containerPort: 7070
protocol: TCP
- name: predict
containerPort: 8000
protocol: TCP
- name: jupyter
containerPort: 8888
protocol: TCP
livenessProbe:
httpGet:
path: /
port: 7070
readinessProbe:
httpGet:
path: /
port: 7070
resources:
{{ toYaml .Values.pio.resources | indent 12 }}
{{- with .Values.pio.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.pio.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.pio.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
35 changes: 35 additions & 0 deletions docker/charts/predictionio/templates/pio-service.yaml
@@ -0,0 +1,35 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
apiVersion: v1
kind: Service
metadata:
name: {{ include "predictionio.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "predictionio.name" . }}
helm.sh/chart: {{ include "predictionio.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
type: {{ .Values.pio.service.type }}
ports:
- port: {{ .Values.pio.service.port }}
targetPort: 8888
protocol: TCP
name: jupyter
selector:
app.kubernetes.io/name: {{ include "predictionio.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
53 changes: 53 additions & 0 deletions docker/charts/predictionio/values.yaml
@@ -0,0 +1,53 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
pio:
replicas: 1
image:
repository: predictionio/pio-jupyter
tag: latest
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 8888
env:
- name: PIO_STORAGE_SOURCES_PGSQL_TYPE
value: jdbc
- name: PIO_STORAGE_SOURCES_PGSQL_URL
value: "jdbc:postgresql://postgresql/pio"
- name: PIO_STORAGE_SOURCES_PGSQL_USERNAME
value: pio
- name: PIO_STORAGE_SOURCES_PGSQL_PASSWORD
value: pio
- name: PIO_STORAGE_REPOSITORIES_MODELDATA_NAME
value: pio_model
- name: PIO_STORAGE_REPOSITORIES_MODELDATA_SOURCE
value: PGSQL
- name: PIO_STORAGE_REPOSITORIES_METADATA_NAME
value: pio_meta
- name: PIO_STORAGE_REPOSITORIES_METADATA_SOURCE
value: PGSQL
- name: PIO_STORAGE_REPOSITORIES_EVENTDATA_NAME
value: pio_event
- name: PIO_STORAGE_REPOSITORIES_EVENTDATA_SOURCE
value: PGSQL
- name: PYSPARK_DRIVER_PYTHON_OPTS
value: "notebook --NotebookApp.token=''"
resources: {}
nodeSelector: {}
tolerations: []
affinity: {}

0 comments on commit 794d5ef

Please sign in to comment.