diff --git a/incubator/webpagetest-agent/.helmignore b/incubator/webpagetest-agent/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/incubator/webpagetest-agent/.helmignore @@ -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 diff --git a/incubator/webpagetest-agent/Chart.yaml b/incubator/webpagetest-agent/Chart.yaml new file mode 100644 index 0000000000..5abb3a83fa --- /dev/null +++ b/incubator/webpagetest-agent/Chart.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +description: A Helm chart for Kubernetes +name: webpagetest-agent +version: 0.1.0 +home: https://www.webpagetest.org/ +icon: https://www.webpagetest.org/images/logo_wpt.png +sources: + - https://github.com/WPO-Foundation/webpagetest +maintainers: + - name: timothyclarke + email: ghtimothy@timothy.fromnz.net + - name: pmeenan + email: pmeenan@webpagetest.org diff --git a/incubator/webpagetest-agent/README.md b/incubator/webpagetest-agent/README.md new file mode 100644 index 0000000000..4dd78e186a --- /dev/null +++ b/incubator/webpagetest-agent/README.md @@ -0,0 +1,107 @@ +# WebPageTest Agent + +[WebPageTest](https://webpagetest.org/) is a website testing tool + +## TL;DR; + +```console +$ helm install incubator/webpagetest-agent +``` + +## Introduction + +This chart deploys [WebPageTest Private Instance Containers](https://github.com/WPO-Foundation/webpagetest-docs/blob/master/user/Private%20Instances/README.md) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +Depending on your configuration you can then use Official WPT agent instances to test your websites + +## Prerequisites + +- Kubernetes 1.4+ with Beta APIs enabled + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +$ helm install --name my-release incubator/webpagetest-agent +``` + +The command deploys a WebPageTest agent on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. +Please note the default install probably won't do much without some configuration of the values.yaml file + + +> **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 WordPress chart and their default values. + +| Parameter | Description | Default | +| ------------------------------- | ------------------------------- | ---------------------------------------------------------- | +| `image` | WebPageTest server image | `webpagetest/server:{VERSION}` | +| `imagePullPolicy` | Image pull policy | `IfNotPresent` | +| `agent.key` | API Key for agent to auth the the master | `nil` | +| `agent.server` | Hostname of the WPT server (see below) | `agent-web-page-test.local` | +| `agent.location` | WPT location tag | `Test` | +| `agent.shaper` | Traffic shaping method the agent uses | `none` | +| `nodeSelector` | Node labels for pod assignment | `{}` | + + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```console +$ helm install --name my-release \ + --set agent.key=SecretKey \ + incubator/webpagetest-agent +``` + +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 incubator/webpagetest-agent +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) + + +## Ingress +There are none. This is a worker node. the standard operation is for it to poll the +WebPageTest Server for work. + +## WebPageTest Server Config +At time of writing this chart the server has two means of config +* Log onto the server and use vim or similar +* Use the AWS/EC2 init scripts to configure some values, the login and use vim ir similar to configure the rest +As such these charts will get an environment up and working, but if you want more than defaults you will need to write your own config maps or update the WebPageTest Source for either the [server](https://github.com/WPO-Foundation/webpagetest) or the [agent](https://github.com/WPO-Foundation/wptagent) + +### Defaults +A default install of the server will have a location of 'Test' with a blank key. +This config makes use of that. To use different values you will probably need to update +settings/locations.ini and or settings/keys.ini on the WebPageTest server + +### agent.server +**You'll probably want to update this one.** +This is the host header that the agent will use to speak to the master. + +### agent.shaper +This is the method that the agent will use to throttle bandwidth or add latency. Some methods require root access. +The default method did not work when this chart was being created so a value of 'none' was selected to disable this feature + +### agent.key +The API key is used by the agent to authenticate itself to the WebPageTest server. + +### agent.location +This is the WebPageTest location to use. This needs to match something in settings/locations.ini + +## Future +* Integrate with webpagetest-server and embed along with correct creation of keys diff --git a/incubator/webpagetest-agent/templates/NOTES.txt b/incubator/webpagetest-agent/templates/NOTES.txt new file mode 100644 index 0000000000..83b11a895f --- /dev/null +++ b/incubator/webpagetest-agent/templates/NOTES.txt @@ -0,0 +1,2 @@ +1. Each agent has not obvious frontend. If you need to debug, + look at both the pod logs and the webserver logs on your webpagetest server diff --git a/incubator/webpagetest-agent/templates/_helpers.tpl b/incubator/webpagetest-agent/templates/_helpers.tpl new file mode 100644 index 0000000000..721a0bf322 --- /dev/null +++ b/incubator/webpagetest-agent/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "webpagetest.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 "webpagetest.fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/incubator/webpagetest-agent/templates/deployment.yaml b/incubator/webpagetest-agent/templates/deployment.yaml new file mode 100644 index 0000000000..e84402c4b3 --- /dev/null +++ b/incubator/webpagetest-agent/templates/deployment.yaml @@ -0,0 +1,43 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "webpagetest.fullname" . }} + labels: + app: {{ template "webpagetest.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "webpagetest.name" . }} + template: + metadata: + labels: + app: {{ template "webpagetest.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: SERVER_URL + value: "http://{{- .Values.agent.server -}}/work/" + - name: LOCATION + value: {{ .Values.agent.location }} + {{- if .Values.agent.shaper }} + - name: SHAPER + value: {{ .Values.agent.shaper }} + {{- end }} + {{- if .Values.agent.key }} + - name: KEY + value: {{ .Values.agent.key }} + {{- end }} + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} diff --git a/incubator/webpagetest-agent/values.yaml b/incubator/webpagetest-agent/values.yaml new file mode 100644 index 0000000000..2bc735530c --- /dev/null +++ b/incubator/webpagetest-agent/values.yaml @@ -0,0 +1,26 @@ +# Default values for webpagetest-agent. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 +image: + repository: timothyclarke/wptagent + tag: 2018-01-08 + pullPolicy: IfNotPresent + +agent: + key: SecretKey + server: agent-web-page-test.local + location: Test + shaper: none + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi