Skip to content

Commit

Permalink
Create 'Storybook' Helm chart (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdstone authored Sep 1, 2021
1 parent 14c6cd0 commit 76e7edb
Show file tree
Hide file tree
Showing 9 changed files with 516 additions and 0 deletions.
21 changes: 21 additions & 0 deletions charts/storybook/.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
20 changes: 20 additions & 0 deletions charts/storybook/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v2
name: storybook
version: 0.1.0
description: A Helm chart for Storybook
type: application
keywords:
- storybook
home: https://github.com/indiegogo/ops_tools/tree/main/docker/storybook
sources:
- https://github.com/indiegogo/ops_tools/tree/main/docker/storybook
dependencies:
- name: common
version: "0.1.2"
repository: https://charts.indiegogo.com/
tags:
- indiegogo-common
maintainers:
- name: DevOps
email: [email protected]
appVersion: "b0d7aa9"
136 changes: 136 additions & 0 deletions charts/storybook/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Storybook Chart packaged by Indiegogo

## TL;DR

```bash
$ helm repo add indiegogo https://charts.indiegogo.com
$ helm install my-release indiegogo/storybook
```

## Introduction

This chart bootstraps a Storybook deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.12+
- Helm 3.6.2

## Getting started with default values

To get you started with modifying the default values to your liking/needs, use the below command to grab the latest `values.yaml` file:

```bash
$ helm show values indiegogo/storybook > values.yaml
```

## Installing the Chart

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

```bash
$ helm install my-release indiegogo/storybook
```

The command deploys Storybook on the Kubernetes cluster in the default configuration. The [Parameters](#parameters) 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:

```bash
$ helm uninstall my-release
```

> NOTE: If you used `-n namespace` when you installed the chart, be sure to use it again when you uninstall the chart, otherwise the associated dependency Kubernetes resources will not be deleted:
```bash
$ helm uninstall -n namespace my-release
```

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

## Parameters


### Common parameters

| Name | Type | Description | Default |
| ------------------ | ------ | ---------------------------------------------------------------- | ------- |
| `kubeVersion` | string | Override Kubernetes version | `nil` |
| `nameOverride` | string | Partially override names.fullname | `nil` |
| `fullnameOverride` | string | Fully override names.fullname | `nil` |
| `commonLabels` | object | Labels to add to all deployed objects | `{}` |
| `networkPort` | int | Deployment container, Deployment livenessProbe, and Service port | `80` |


### Deployment parameters

| Name | Type | Description | Default |
| ------------------------ | ------- | -------------------------------------------------- | ------------------------------- |
| `image.registry` | string | The Docker image registry | `"gcr.io"` |
| `image.repository` | string | The Docker image repository | `"indiegogo-staging/storybook"` |
| `image.tag` | string | The Docker image tag | `'latest'` |
| `image.pullPolicy` | string | The Docker image pull policy | `"IfNotPresent"` |
| `environment` | object | Custom/extra environment variables | `{}` |
| `containerPort` | int | Storybook container port (overrides `networkPort`) | `nil` |
| `replicaCount` | int | Number of Storybook replicas to deploy | `1` |
| `strategy.type` | string | Deployment strategy type | `"RollingUpdate"` |
| `strategy.rollingUpdate` | object | Rolling update deployment strategy options | `{}` |
| `resources.requests` | object | CPU/memory resource requests | `{}` |
| `resources.limits` | object | CPU/memory resource limits | `{}` |
| `livenessProbeEnabled` | boolean | Enable the custom livenessProbe | `true` |
| `livenessProbe` | object | Write your custom liveness probe here | `{}` |
| `readinessProbeEnabled` | boolean | Enable the custom readinessProbe | `false` |
| `readinessProbe` | object | Write your custom readiness probe here | `{}` |
| `usePacificTime` | boolean | Use Pacific time instead of UTC in container | `false` |


### Service parameters

| Name | Type | Description | Default |
| ---------------| ------ | ------------------------------------------------ | ------------ |
| `service.port` | int | Storybook Service port (overrides `networkPort`) | `nil` |
| `service.type` | string | Storybook Service Type | `"NodePort"` |


### Ingress parameters

| Name | Type | Description | Default |
| --------------------------- | ------- | -------------------------- | ----------------- |
| `ingress.enabled` | boolean | Enable/Disable Ingress | `true` |
| `ingress.tls.enabled` | boolean | Enable/Disable Ingress TLS | `false` |
| `ingress.tls.hosts` | list | Ingress TLS host(s) | see `values.yaml` |
| `ingress.tls.secretName` | string | Ingress TLS Secret name | `nil` |
| `ingress.rules.hosts` | list | Ingress rules host(s) | see `values.yaml` |
| `ingress.customAnnotations` | object | Ingress custom annotations | `{}` |


### Storage parameters

| Name | Type | Description | Default |
| ---------------------------------------- | ------- | ------------------------------------------------- | ------------ |
| `storage.requestedSize` | string | Size of Persistent Volume Claim/Persistent Volume | `"10Gi"` |
| `storage.className` | string | Type of storage (standard/ssd) | `"standard"` |
| `storage.persistentVolume.enabled` | boolean | Enable to use an existing persistent disk | `false` |
| `storage.persistentVolume.pdName` | string | Name of the existing persistent disk | `nil` |
| `storage.persistentVolume.reclaimPolicy` | string | Reclamation of the persistent disk resources | `"Retain"` |


Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

```bash
$ helm install my-release \
--set replicaCount=1 \
indiegogo/storybook
```

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

```bash
$ helm install my-release -f values.yaml indiegogo/storybook
```

> **Tip**: You can use the default [values.yaml](values.yaml)
82 changes: 82 additions & 0 deletions charts/storybook/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
kind: Deployment
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
metadata:
name: {{ include "common.names.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplValues.render" ( dict "value" .Values.commonLabels "scope" $ ) | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ include "common.names.fullname" . }}
replicas: {{ .Values.replicaCount }}
{{- if .Values.strategy }}
strategy: {{- toYaml .Values.strategy | nindent 4 }}
{{- end }}
template:
metadata:
labels:
app: {{ include "common.names.fullname" . }}
spec:
volumes:
{{- if .Values.usePacificTime }}
- name: tz-config
hostPath:
path: /usr/share/zoneinfo/America/Los_Angeles
{{- end }}
- name: {{ include "common.names.fullname" . }}
persistentVolumeClaim:
claimName: {{ include "common.names.fullname" . }}
initContainers:
- name: setup
{{- with .Values.image }}
image: "{{- if contains ":" .repository -}}{{ .repository }}{{- else -}}{{- if .registry -}}{{ .registry }}/{{- end -}}{{ .repository }}:{{ default $.Chart.AppVersion .tag }}{{- end -}}"
{{- end }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
command: ["/bin/bash"]
args:
- "-c"
- "chown -R nginx:nginx /var/www/upload"
volumeMounts:
- name: {{ include "common.names.fullname" . }}
mountPath: /var/www/upload
securityContext:
runAsUser: 0
containers:
- name: {{ include "common.names.fullname" . }}
{{- with .Values.image }}
image: "{{- if contains ":" .repository -}}{{ .repository }}{{- else -}}{{- if .registry -}}{{ .registry }}/{{- end -}}{{ .repository }}:{{ default $.Chart.AppVersion .tag }}{{- end -}}"
{{- end }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
{{- if .Values.environment }}
env:
{{- range $key, $value := .Values.environment }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
ports:
- containerPort: {{ default .Values.networkPort .Values.containerPort }}
{{- if .Values.resources }}
resources: {{- toYaml .Values.resources | nindent 12 }}
{{- end }}
command: ["/usr/sbin/nginx"]
args:
- "-g"
- "daemon off;"
{{- if .Values.livenessProbeEnabled }}
livenessProbe: {{- toYaml .Values.livenessProbe | nindent 12 }}
{{- end }}
{{- if .Values.readinessProbeEnabled }}
readinessProbe: {{- toYaml .Values.readinessProbe | nindent 12 }}
{{- end }}
volumeMounts:
{{- if .Values.usePacificTime }}
- name: tz-config
mountPath: /etc/localtime
readOnly: true
{{- end }}
- name: {{ include "common.names.fullname" . }}
mountPath: /var/www/upload
38 changes: 38 additions & 0 deletions charts/storybook/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- if .Values.ingress.enabled }}
kind: Ingress
apiVersion: {{ include "common.capabilities.ingress.apiVersion" . }}
metadata:
name: {{ include "common.names.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplValues.render" ( dict "value" .Values.commonLabels "scope" $ ) | nindent 4 }}
{{- end }}
{{- if .Values.ingress.customAnnotations }}
annotations: {{- toYaml .Values.ingress.customAnnotations | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls.enabled }}
tls:
- hosts:
{{- range .Values.ingress.tls.hosts }}
- {{ . }}
{{- end }}
secretName: {{ printf "%s-tls" (default (index (required "You must add a host in the 'ingress.tls.hosts' list in values.yaml" .Values.ingress.tls.hosts) 0) .Values.ingress.tls.secretName) | replace "." "-" }}
{{- end }}
rules:
{{- range .Values.ingress.rules.hosts }}
- host: {{ .host }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ .service.name }}
port:
number: {{ .service.port.number }}
{{- end }}
{{- end }}
{{- end }}
19 changes: 19 additions & 0 deletions charts/storybook/templates/persistentvolume.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- if .Values.storage.persistentVolume.enabled }}
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ include "common.names.fullname" . }}
spec:
capacity:
storage: {{ .Values.storage.requestedSize }}
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: {{ .Values.storage.persistentVolume.reclaimPolicy }}
gcePersistentDisk:
pdName: {{ required "To use an existing persistent disk, please set a persistent disk name in values.yaml (storage.persistentVolume.pdName)" .Values.storage.persistentVolume.pdName }}
fsType: ext4
storageClassName: {{ .Values.storage.className }}
claimRef:
name: {{ include "common.names.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/storybook/templates/persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "common.names.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
spec:
storageClassName: {{ .Values.storage.className }}
resources:
requests:
storage: {{ .Values.storage.requestedSize }}
accessModes:
- ReadWriteOnce
{{- if .Values.storage.persistentVolume.enabled }}
volumeName: {{ include "common.names.fullname" . }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/storybook/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
kind: Service
apiVersion: v1
metadata:
name: {{ include "common.names.fullname" . }}
namespace: {{ .Release.Namespace | quote }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplValues.render" ( dict "value" .Values.commonLabels "scope" $ ) | nindent 4 }}
{{- end }}
spec:
ports:
- name: {{ include "common.names.fullname" . }}
port: {{ default .Values.networkPort .Values.service.port }}
protocol: TCP
selector:
app: {{ include "common.names.fullname" . }}
type: {{ .Values.service.type }}
Loading

0 comments on commit 76e7edb

Please sign in to comment.