Skip to content

Commit

Permalink
@ teracyhq#2 | Create zalenium helm-chart
Browse files Browse the repository at this point in the history
  • Loading branch information
hieptranquoc committed Sep 7, 2018
1 parent b28b7da commit 6772f8f
Show file tree
Hide file tree
Showing 16 changed files with 675 additions and 0 deletions.
6 changes: 6 additions & 0 deletions incubator/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store
.idea

!.gitkeep

.vscode
24 changes: 24 additions & 0 deletions incubator/zalenium/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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

# OWNERS file for Kubernetes
OWNERS
11 changes: 11 additions & 0 deletions incubator/zalenium/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: zalenium
apiVersion: v1
appVersion: 3.14.0
version: 0.1.0
description: zalenium helm chart for selenium grid
home: https://opensource.zalando.com/zalenium
sources:
- https://github.com/teracyhq/helm-charts
maintainers:
- name: hieptq
email: [email protected]
5 changes: 5 additions & 0 deletions incubator/zalenium/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
approvers:
- hieptq
reviewers:
- hoatle
- teracy
92 changes: 92 additions & 0 deletions incubator/zalenium/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# ZALENIUM-HELM-CHART
======================================================

## Introduction

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

## Prerequisites

- Kubernetes 1.9+.

## Installing the Chart

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

```console
$ helm install --name example-name teracy-incubator/zalenium
```

The command deploys Zalenium 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 `example-name` deployment:

```console
$ helm delete example-name --purge
```

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 Selenium chart and their default values.

| Parameter | Description | Default |
| --------- | ----------- | ------- |
| `rbac.create` | If your cluster has RBAC enabled, set rbac.create to true | false |
| `rbac.clusterWideAccess` | Set true to use ClusterRole and ClusterRoleBinding instead of Role and RoleBinding | true |
| `serviceAccount.create` | Set serviceAccount.create to true if you want to create an service account for zalenium | true |
| `serviceAccount.name` | Set serviceAccount.name | zalenium |
| `hub.image.repository` | The zalenium hub image | `dosel/zalenium` |
| `hub.image.tag` | The zalenium hub image tag | `3` |
| `hub.image.pullPolicy` | The pull policy for the hub image | `IfNotPresent` |
| `hub.port` | The port the hub listens on | `4444` |
| `hub.livenessProbe.enabled` | Set hub.livenessProbe.enabled to true if you want to use livenessProbe | true |
| `hub.readinessProbe.enabled` | Set hub.readinessProbe.enabled to true if you want to use readinessProbe | true |
| `hub.javaOpts` | The java options for the selenium hub JVM, default sets the maximum heap size to 400 mb | `-Xmx400m -XX:+UseSerialGC` |
| `hub.localVolumesRoot` | The root directory to store HostPath volumes (e.g. if running in minikube) | `/tmp` |
| `hub.resources` | The resources for the hub container, defaults to minimum half a cpu and maximum 512 mb RAM | `{"limits":{"cpu":".5", "memory":"512Mi"}}` |
| `hub.desiredContainers` | How many pods to launch at start | 2 |
| `hub.maxDockerSeleniumContainers` | Maximum number of Selenium containers to run simultaneously | 10 |
| `hub.sauceLabsEnabled` | Enable SauceLabs | false |
| `hub.browserStackEnabled` | Enable BrowserStack | false |
| `hub.testingBotEnabled` | Enable TestingBot | false |
| `hub.videoRecordingEnabled` | Enable video recording | true |
| `hub.cpuRequest` | CPU requested for browser pods. The hub passes this value to the k8s API | 200m |
| `hub.cpuLimit` | CPU limit for browser pods. The hub passes this value to the k8s API | 400m |
| `hub.memRequest` | Memory requested for browser pods. The hub passes this value to the k8s API | 200Mi |
| `hub.screenWidth` | Screen resolution to use | 1440 |
| `hub.screenHeight` | Screen resolution to use | 900 |
| `hub.timeZone` | Time zone | UTC |
| `hub.seleniumImageName` | The Selenium grid image | `elgalu/selenium` |
| `hub.maxTestSessions` | The number of tests to run on each grid container before killing it and starting a new one | 1 |
| `hub.debugEnabled` | Enables LogLevel.FINE | false |
| `hub.keepOnlyFailedTests` | Keeps only failed tests on the dashboard (you need to send a cookie with the test result) | false |
| `hub.sendAnonymousUsageInfo` | Allows sending anonymous usage info | true |
| `hub.sauceUserName` | Username to log into saucelabs. Use if hub.sauceLabsEnabled set to true | blank |
| `hub.sauceAccessKey` | Access key to log into saucelabs. Use if hub.sauceLabsEnabled set to true | blank |
| `hub.browserStackUser` | Credentials for browserstack. Use if hub.browserStackEnabled set to true | blank |
| `hub.browserStackKey` | Credentials for browserstack. Use if hub.browserStackEnabled set to true | blank |
| `hub.testingBotKey` | Credentials for testingbot. Use if hub.testingBotEnabled set to true | blank |
| `hub.testingBotSecret` | Credentials for testingbot. Use if hub.testingBotEnabled set to true | blank |
| `ingress.enabled` | Set ingress.enabled to true if you want to create an ingress entry for zalenium | false |
| `ingress.hostname` | Set ingress.hostname to which host you want | `#` |
| `services.type` | Set services.type | `ClusterIP` |
| `mountStorage.videos.enabled` | Whether to use a videos mount volume. Set mountStorage.videos.enabled to true | true |
| `mountStorage.data.enabled` | Whether to use a data mount volume. Set mountStorage.data.enabled to true | true |
| `mountStorage.videos.pvcs.enabled` | Whether to use a persistent volume claim for storage. Set mountStorage.videos.pvcs.enabled to true | false |
| `mountStorage.data.pvcs.enabled` | Whether to use a persistent volume claim for storage. Set mountStorage.data.pvcs.enabled to true | false |

Specify each parameter using the `--set key0=value0,key1=value1,key..n=value..n` argument to `helm install`. For example,

```console
$ helm install --name example-name \
--set rbac.create=false \
teracy-incubator/zelenium
```

Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,
1 change: 1 addition & 0 deletions incubator/zalenium/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Helm chart for zalenium. Let enjoying !!!
34 changes: 34 additions & 0 deletions incubator/zalenium/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- 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).
*/}}
{{- define "fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

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

{{/*
Create the name of the service account
*/}}
{{- define "serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "name" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
139 changes: 139 additions & 0 deletions incubator/zalenium/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{{- $fullName := include "fullname" . -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $fullName }}
labels:
app: {{ $fullName }}
chart: {{ template "chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.hub.replicaCount }}
strategy:
type: {{ default "RollingUpdate" .Values.hub.strategyType }}
selector:
matchLabels:
app: {{ $fullName }}
zalenium: {{ .Values.hub.name }}
template:
metadata:
labels:
app: {{ $fullName }}
zalenium: {{ .Values.hub.name }}
{{- with .Values.hub.annotations }}
annotations:
{{ toYaml .Values.hub.annotations | indent 8 }}
{{- end }}
spec:
initContainers:
- name: zalenium-prepare
image: dosel/zalenium:latest
command: ['sh', '-c', 'sudo chown -R seluser:seluser /home/seluser/videos']
volumeMounts:
- name: {{ $fullName }}-videos
mountPath: /home/seluser/videos
serviceAccountName: {{ template "serviceAccountName" . }}
containers:
- name: {{ template "name" . }}-{{ .Values.hub.name }}
image: "{{ .Values.hub.image.repository }}:{{ .Values.hub.image.tag }}"
imagePullPolicy: {{ .Values.hub.image.pullPolicy }}
ports:
- containerPort: {{ .Values.hub.port }}
protocol: TCP
{{- if .Values.hub.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: /grid/console
port: {{ .Values.hub.port }}
initialDelaySeconds: 90
periodSeconds: 5
{{- end }}
{{- if .Values.hub.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: /grid/console
port: {{ .Values.hub.port }}
timeoutSeconds: 1
{{- end }}
resources:
{{ toYaml .Values.hub.resources | indent 12 }}
env:
- name: ZALENIUM_KUBERNETES_CPU_REQUEST
value: {{ .Values.hub.cpuRequest }}
- name: ZALENIUM_KUBERNETES_CPU_LIMIT
value: {{ .Values.hub.cpuLimit }}
- name: ZALENIUM_KUBERNETES_MEMORY_REQUEST
value: {{ .Values.hub.memRequest }}
{{- if eq true .Values.hub.sauceLabsEnabled }}
- name: SAUCE_USERNAME
value: {{ .Values.hub.sauceUserName }}
- name: SAUCE_ACCESS_KEY
value: {{ .Values.hub.sauceAccessKey }}
{{- end }}
{{- if eq true .Values.hub.browserStackEnabled }}
- name: BROWSER_STACK_USER
value: {{ .Values.hub.browserStackUser }}
- name: BROWSER_STACK_KEY
value: {{ .Values.hub.browserStackKey }}
{{- end }}
{{- if eq true .Values.hub.testingBotEnabled }}
- name: TESTINGBOT_KEY
value: {{ .Values.hub.testingBotKey }}
- name: TESTINGBOT_SECRET
value: {{ .Values.hub.testingBotSecret }}
{{- end }}
args:
- start
- '--desiredContainers'
- '{{ .Values.hub.desiredContainers }}'
- '--maxDockerSeleniumContainers'
- '{{ .Values.hub.maxDockerSeleniumContainers }}'
- '--sauceLabsEnabled'
- '{{ .Values.hub.sauceLabsEnabled }}'
- '--browserStackEnabled'
- '{{ .Values.hub.browserStackEnabled }}'
- '--testingBotEnabled'
- '{{ .Values.hub.testingBotEnabled }}'
- '--videoRecordingEnabled'
- '{{ .Values.hub.videoRecordingEnabled }}'
- '--screenWidth'
- '{{ .Values.hub.screenWidth }}'
- '--screenHeight'
- '{{ .Values.hub.screenHeight }}'
- '--timeZone'
- '{{ .Values.hub.timeZone }}'
- '--seleniumImageName'
- '{{ .Values.hub.seleniumImageName }}'
- '--maxTestSessions'
- '{{ .Values.hub.maxTestSessions }}'
- '--debugEnabled'
- '{{ .Values.hub.debugEnabled }}'
- '--sendAnonymousUsageInfo'
- '{{ .Values.hub.sendAnonymousUsageInfo }}'
- '--keepOnlyFailedTests'
- '{{ .Values.hub.keepOnlyFailedTests }}'
volumeMounts:
{{- range $key, $val := .Values.mountStorage }}
{{- if .enabled }}
- name: {{ $fullName }}-{{ $key }}
mountPath: {{ .mountPath }}
{{- end }}
{{- end }}
volumes:
{{- range $key, $val := .Values.mountStorage }}
{{- if .enabled }}
- name: {{ $fullName }}-{{ $key }}
{{- if .pvcs.enabled }}
{{- if and (.pvcs.useExisting) (not (empty .pvcs.name))}}
persistentVolumeClaim:
claimName: {{ .pvcs.name }}
{{- else }}
persistentVolumeClaim:
claimName: {{ $fullName }}-{{ $key }}
{{- end }}
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}
{{- end }}
31 changes: 31 additions & 0 deletions incubator/zalenium/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "fullname" . -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}-ingress
labels:
app: {{ template "fullname" . }}
chart: {{ template "chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml .Values.ingress.annotations | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
- hosts:
- {{ .Values.ingress.hostname | quote }}
secretName: {{ .Values.ingress.secretName }}
{{- end }}
rules:
- host: {{ .Values.ingress.hostname }}
http:
paths:
- path: {{ .path }}
backend:
serviceName: {{ template "fullname" . }}
servicePort: {{ .Values.hub.port }}
{{- end }}
28 changes: 28 additions & 0 deletions incubator/zalenium/templates/pvcs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- $fullName := include "fullname" . -}}
{{- range $key, $val := .Values.mountStorage }}
{{- if and (.enabled) (.pvcs.enabled) (not .pvcs.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ $fullName }}-{{ $key }}
labels:
app: {{ $fullName }}
chart: "{{ $.Chart.Name }}-{{ $.Chart.Version }}"
release: "{{ $.Release.Name }}"
heritage: "{{ $.Release.Service }}"
spec:
accessModes:
- {{ .pvcs.accessMode | quote }}
resources:
requests:
storage: {{ .pvcs.size | quote }}
{{- if .pvcs.storageClass }}
{{- if (eq "-" .pvcs.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .pvcs.storageClass }}"
{{- end }}
{{- end }}
---
{{- end }}
{{- end }}
Loading

0 comments on commit 6772f8f

Please sign in to comment.