Skip to content

Commit

Permalink
add Ghost chart (helm#177)
Browse files Browse the repository at this point in the history
* add ghost chart

* update version and remove unnecessary label

* update ghost NOTES with link to admin and fix probes

* ghost: update values.yaml
  • Loading branch information
prydonius authored and Vic Iglesias committed Nov 16, 2016
1 parent 107a34b commit 7e97163
Show file tree
Hide file tree
Showing 12 changed files with 467 additions and 0 deletions.
1 change: 1 addition & 0 deletions stable/ghost/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git
18 changes: 18 additions & 0 deletions stable/ghost/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: ghost
version: 0.4.0
description: A simple, powerful publishing platform that allows you to share your stories with the world
keywords:
- ghost
- blog
- http
- web
- application
- nodejs
- javascript
home: http://www.ghost.org/
sources:
- https://github.com/bitnami/bitnami-docker-ghost
maintainers:
- name: Bitnami
email: containers@bitnami.com
engine: gotpl
106 changes: 106 additions & 0 deletions stable/ghost/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Ghost

[Ghost](https://ghost.org/) is one of the most versatile open source content management systems on the market.

## TL;DR;

```console
$ helm install stable/ghost
```

## Introduction

This chart bootstraps a [Ghost](https://github.com/bitnami/bitnami-docker-ghost) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

It also packages the [Bitnami MariaDB chart](https://github.com/kubernetes/charts/tree/master/stable/mariadb) which is required for bootstrapping a MariaDB deployment for the database requirements of the Ghost application.

## Prerequisites

- Kubernetes 1.4+ with Beta APIs enabled
- PV provisioner support in the underlying infrastructure

## Installing the Chart

To install the chart with the release name `my-release`:

```console
$ helm install --name my-release stable/ghost
```

The command deploys Ghost on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.

> **Tip**: List all releases using `helm list`
## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```console
$ helm delete my-release
```

The command removes all the Kubernetes components associated with the chart and deletes the release.

## Configuration

The following tables lists the configurable parameters of the Ghost chart and their default values.

| Parameter | Description | Default |
| --------------------------------- | ----------------------------------------------------- | --------------------------------------------------------- |
| `image` | Ghost image | `bitnami/ghost:{VERSION}` |
| `imagePullPolicy` | Image pull policy | `Always` if `image` tag is `latest`, else `IfNotPresent` |
| `ghostHost` | Ghost host to create application URLs | `nil` |
| `ghostPort` | Ghost port to create application URLs along with host | `80` |
| `ghostLoadBalancerIP` | `loadBalancerIP` for the Ghost Service | `nil` |
| `ghostUsername` | User of the application | `user` |
| `ghostPassword` | Application password | Randomly generated |
| `ghostEmail` | Admin email | `user@example.com` |
| `ghostBlogTitle` | Ghost Blog name | `User's Blog` |
| `mariadb.mariadbRootPassword` | MariaDB admin password | `nil` |
| `serviceType` | Kubernetes Service type | `LoadBalancer` |
| `persistence.enabled` | Enable persistence using PVC | `true` |
| `persistence.storageClass` | PVC Storage Class for Ghost volume | `generic` |
| `persistence.accessMode` | PVC Access Mode for Ghost volume | `ReadWriteOnce` |
| `persistence.size` | PVC Storage Request for Ghost volume | `8Gi` |
| `resources` | CPU/Memory resource requests/limits | Memory: `512Mi`, CPU: `300m` |

The above parameters map to the env variables defined in [bitnami/ghost](http://github.com/bitnami/bitnami-docker-ghost). For more information please refer to the [bitnami/ghost](http://github.com/bitnami/bitnami-docker-ghost) image documentation.

> **Note**:
>
> For the Ghost application function correctly, you should specify the `ghostHost` parameter to specify the FQDN (recommended) or the public IP address of the Ghost service.
>
> Optionally, you can specify the `ghostLoadBalancerIP` parameter to assign a reserved IP address to the Ghost service of the chart. However please note that this feature is only available on a few cloud providers (f.e. GKE).
>
> To reserve a public IP address on GKE:
>
> ```bash
> $ gcloud compute addresses create ghost-public-ip
> ```
>
> The reserved IP address can be associated to the Ghost service by specifying it as the value of the `ghostLoadBalancerIP` parameter while installing the chart.
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
```console
$ helm install --name my-release \
--set ghostUsername=admin,ghostPassword=password,mariadb.mariadbRootPassword=secretpassword \
stable/ghost
```
The above command sets the Ghost administrator account username and password to `admin` and `password` respectively. Additionally it sets the MariaDB `root` user password to `secretpassword`.
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,
```console
$ helm install --name my-release -f values.yaml stable/ghost
```
> **Tip**: You can use the default [values.yaml](values.yaml)
## Persistence
The [Bitnami Ghost](https://github.com/bitnami/bitnami-docker-ghost) image stores the Ghost data and configurations at the `/bitnami/ghost` and `/bitnami/apache` paths of the container.
Persistent Volume Claims are used to keep the data across deployments. This is known to work in GCE, AWS, and minikube.
See the [Configuration](#configuration) section to configure the PVC or to disable persistence.
6 changes: 6 additions & 0 deletions stable/ghost/requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: mariadb
repository: http://storage.googleapis.com/kubernetes-charts
version: 0.5.2
digest: sha256:400ac77ff2337dce024b0225bbfed9f509d77eb6ff6ee10000d59c5f6a367d51
generated: 2016-10-20T17:55:13.834613554-07:00
4 changes: 4 additions & 0 deletions stable/ghost/requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies:
- name: mariadb
version: 0.5.2
repository: http://storage.googleapis.com/kubernetes-charts
47 changes: 47 additions & 0 deletions stable/ghost/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{{- if empty (include "host" .) -}}
###############################################################################
### ERROR: You did not provide an external host in your 'helm install' call ###
###############################################################################

This deployment will be incomplete until you configure Ghost with a resolvable
host. To configure Ghost with the URL of your service:

1. Get the Ghost URL by running:

{{- if contains "NodePort" .Values.serviceType }}

export APP_PORT=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath="{.spec.ports[0].nodePort}")
export APP_HOST=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")

{{- else if contains "LoadBalancer" .Values.serviceType }}

NOTE: It may take a few minutes for the LoadBalancer IP to be available.
Watch the status with: 'kubectl get svc -w {{ template "fullname" . }}'

export APP_HOST=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
{{- end }}

2. Complete your Ghost deployment by running:

helm upgrade {{ .Release.Name }} \
--set ghostHost=$APP_HOST,ghostPort=$APP_PORT stable/ghost
{{- else -}}
1. Get the Ghost URL by running:

{{- if eq .Values.serviceType "ClusterIP" }}

export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "fullname" . }}" -o jsonpath="{.items[0].metadata.name}")
echo Blog URL : http://127.0.0.1:2368/
echo Admin URL : http://127.0.0.1:2368/ghost
kubectl port-forward $POD_NAME 2368:2368
{{- else }}

echo Blog URL : http://{{ include "host" . }}{{ if .Values.ghostPort }}:{{ .Values.ghostPort }}{{ end }}/
echo Admin URL : http://{{ include "host" . }}{{ if .Values.ghostPort }}:{{ .Values.ghostPort }}{{ end }}/ghost
{{- end }}

2. Get your Ghost login credentials by running:

echo Email: {{ .Values.ghostEmail }}
echo Password: $(printf $(printf '\%o' `kubectl get secret --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath="{.data.ghost-password[*]}"`))
{{- end }}
45 changes: 45 additions & 0 deletions stable/ghost/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 24 -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 24 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 24 -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "mariadb.fullname" -}}
{{- printf "%s-%s" .Release.Name "mariadb" | trunc 24 -}}
{{- end -}}

{{/*
Get the user defined LoadBalancerIP for this release.
Note, returns 127.0.0.1 if using ClusterIP.
*/}}
{{- define "serviceIP" -}}
{{- if eq .Values.serviceType "ClusterIP" -}}
127.0.0.1
{{- else -}}
{{- index .Values (printf "%sLoadBalancerIP" .Chart.Name) | default "" -}}
{{- end -}}
{{- end -}}

{{/*
Gets the host to be used for this application.
If not using ClusterIP, or if a host or LoadBalancerIP is not defined, the value will be empty.
*/}}
{{- define "host" -}}
{{- $host := index .Values (printf "%sHost" .Chart.Name) | default "" -}}
{{- default (include "serviceIP" .) $host -}}
{{- end -}}
94 changes: 94 additions & 0 deletions stable/ghost/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{{- if include "host" . -}}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
replicas: 1
template:
metadata:
labels:
app: {{ template "fullname" . }}
spec:
containers:
- name: {{ template "fullname" . }}
image: "{{ .Values.image }}"
imagePullPolicy: {{ default "" .Values.imagePullPolicy | quote }}
env:
- name: MARIADB_HOST
value: {{ template "mariadb.fullname" . }}
- name: MARIADB_PORT
value: "3306"
- name: MARIADB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "mariadb.fullname" . }}
key: mariadb-root-password
- name: GHOST_HOST
value: {{ include "host" . | quote }}
- name: GHOST_PORT
{{- if eq .Values.serviceType "ClusterIP" }}
value: "2368"
{{- else }}
value: {{ default "" .Values.ghostPort | quote }}
{{- end }}
- name: GHOST_USERNAME
value: {{ default "" .Values.ghostUsername | quote }}
- name: GHOST_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "fullname" . }}
key: ghost-password
- name: GHOST_EMAIL
value: {{ default "" .Values.ghostEmail | quote }}
- name: BLOG_TITLE
value: {{ default "" .Values.ghostBlogTitle | quote }}
- name: SMTP_HOST
value: {{ default "" .Values.smtpHost | quote }}
- name: SMTP_PORT
value: {{ default "" .Values.smtpPort | quote }}
- name: SMTP_USER
value: {{ default "" .Values.smtpUser | quote }}
- name: SMTP_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "fullname" . }}
key: smtp-password
- name: SMTP_SERVICE
value: {{ default "" .Values.smtpService | quote }}
ports:
- name: http
containerPort: 2368
livenessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: 120
timeoutSeconds: 5
readinessProbe:
exec:
command:
- sh
- -c
- nami status ghost | grep "ghost is running"
initialDelaySeconds: 5
timeoutSeconds: 1
resources:
{{ toYaml .Values.resources | indent 10 }}
volumeMounts:
- name: ghost-data
mountPath: /bitnami/ghost
volumes:
- name: ghost-data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ template "fullname" . }}
{{- else }}
emptyDir: {}
{{- end }}
{{- end -}}
14 changes: 14 additions & 0 deletions stable/ghost/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .Values.persistence.enabled -}}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "fullname" . }}
annotations:
volume.alpha.kubernetes.io/storage-class: {{ .Values.persistence.storageClass | quote }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- end -}}
17 changes: 17 additions & 0 deletions stable/ghost/templates/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
type: Opaque
data:
{{ if .Values.ghostPassword }}
ghost-password: {{ .Values.ghostPassword | b64enc | quote }}
{{ else }}
ghost-password: {{ randAlphaNum 10 | b64enc | quote }}
{{ end }}
smtp-password: {{ default "" .Values.smtpPassword | b64enc | quote }}
20 changes: 20 additions & 0 deletions stable/ghost/templates/svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
type: {{ .Values.serviceType }}
{{- if eq .Values.serviceType "LoadBalancer" }}
loadBalancerIP: {{ default "" .Values.ghostLoadBalancerIP }}
{{- end }}
ports:
- name: http
port: 80
targetPort: http
selector:
app: {{ template "fullname" . }}
Loading

0 comments on commit 7e97163

Please sign in to comment.