diff --git a/incubator/hoverfly/.helmignore b/incubator/hoverfly/.helmignore new file mode 100644 index 0000000000..46fd899656 --- /dev/null +++ b/incubator/hoverfly/.helmignore @@ -0,0 +1,23 @@ +# 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 diff --git a/incubator/hoverfly/Chart.yaml b/incubator/hoverfly/Chart.yaml new file mode 100644 index 0000000000..33880e5605 --- /dev/null +++ b/incubator/hoverfly/Chart.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +appVersion: 1.0.0-rc.2 +description: Hoverfly is a lightweight, open source API simulation tool. Using Hoverfly, you can create realistic simulations of the APIs your application depends on. +name: hoverfly +version: 0.1.0 +keywords: + - hoverfly + - api-simulation + - mocking + - stubbing + - service-virtualization +home: https://hoverfly.io +sources: +- https://github.com/SpectoLabs/hoverfly +maintainers: +- name: tommysitu + email: tommy.situ@specto.io diff --git a/incubator/hoverfly/OWNERS b/incubator/hoverfly/OWNERS new file mode 100644 index 0000000000..00ba52f978 --- /dev/null +++ b/incubator/hoverfly/OWNERS @@ -0,0 +1,4 @@ +approvers: +- tommysitu +reviewers: +- tommysitu diff --git a/incubator/hoverfly/README.md b/incubator/hoverfly/README.md new file mode 100644 index 0000000000..8bd4f811a2 --- /dev/null +++ b/incubator/hoverfly/README.md @@ -0,0 +1,72 @@ +# Hoverfly + +[Hoverfly](https://hoverfly.io/) is a lightweight, open source API simulation tool. Using Hoverfly, you can create realistic simulations of the APIs your application depends on. + + +## TL;DR; + +```console +$ helm install incubator/hoverfly +``` + +## Introduction + +This chart bootstraps a [Hoverfly](https://hoverfly.io/) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +$ helm install --name my-release incubator/hoverfly +``` + +The command deploys Hoverfly 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 table lists the configurable parameters of the Hoverfly chart and their default values. + +| Parameter | Description | Default | +| --------------------------------- | ------------------------------------------ | --------------------------------------------------------- | +| `image.repository` | Hoverfly Image name | `docker.io/spectolabs/hoverfly` | +| `image.tag` | Hoverfly Image tag | `v1.0.0-rc.2` | +| `hoverflyFlags` | Flags to start Hoverfly with, eg. '-auth' | `""` | +| `healthcheckEndpoint` | Admin API path for Kubernetes healthcheck | `/api/health` | +| `service.type` | Kubernetes Service type | `ClusterIP` | +| `service.adminPort` | Container Admin port | `8888` | +| `service.proxyPort` | Container Proxy port | `8500` | +| `service.externalAdminPort` | Service Admin port | `8888` | +| `service.externalProxyPort` | Service Proxy port | `8500` | +| `resources` | CPU/Memory resource requests/limits | Memory: `200Mi`, CPU: `0.2` | + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```console +$ helm install --name my-release \ + --set hoverflyFlags='-webserver -journal-size 0' \ + incubator/hoverfly +``` + +The above command starts Hoverfly in webserver mode and disable journal. You can find all the available flags [here](https://hoverfly.readthedocs.io/en/latest/pages/reference/hoverfly/hoverflycommands.html) + +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/hoverfly +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) diff --git a/incubator/hoverfly/templates/NOTES.txt b/incubator/hoverfly/templates/NOTES.txt new file mode 100644 index 0000000000..82d521d996 --- /dev/null +++ b/incubator/hoverfly/templates/NOTES.txt @@ -0,0 +1,17 @@ +1. Get the application URL by running these commands: +{{- if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "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.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 {{ template "fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo "Hoverfly Admin URL: http://$SERVICE_IP:{{ .Values.service.externalAdminPort }}" + echo "Hoverfly Proxy URL: http://$SERVICE_IP:{{ .Values.service.externalProxyPort }}" +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "fullname" . }}" -o jsonpath="{.items[0].metadata.name}") + kubectl port-forward $POD_NAME {{ .Values.service.externalAdminPort }} {{ .Values.service.externalProxyPort }} + echo "Hoverfly Admin URL http://127.0.0.1:{{ .Values.service.externalAdminPort }}" + echo "Hoverfly Proxy URL http://127.0.0.1:{{ .Values.service.externalProxyPort }}" +{{- end }} diff --git a/incubator/hoverfly/templates/_helpers.tpl b/incubator/hoverfly/templates/_helpers.tpl new file mode 100644 index 0000000000..f0d83d2edb --- /dev/null +++ b/incubator/hoverfly/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* 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 -}} diff --git a/incubator/hoverfly/templates/deployment.yaml b/incubator/hoverfly/templates/deployment.yaml new file mode 100644 index 0000000000..2a184c5880 --- /dev/null +++ b/incubator/hoverfly/templates/deployment.yaml @@ -0,0 +1,40 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "fullname" . }} + labels: + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "fullname" . }} + template: + metadata: + labels: + app: {{ template "fullname" . }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + env: + - name: FLAGS + value: {{ .Values.hoverflyFlags }} + args: ["$(FLAGS)"] + ports: + - containerPort: {{ .Values.service.adminPort }} + - containerPort: {{ .Values.service.proxyPort }} + livenessProbe: + httpGet: + path: {{ .Values.healthcheckEndpoint }} + port: {{ .Values.service.adminPort }} + initialDelaySeconds: 5 + timeoutSeconds: 1 + readinessProbe: + httpGet: + path: {{ .Values.healthcheckEndpoint }} + port: {{ .Values.service.adminPort }} + initialDelaySeconds: 5 + timeoutSeconds: 1 + resources: +{{ toYaml .Values.resources | indent 12 }} diff --git a/incubator/hoverfly/templates/service.yaml b/incubator/hoverfly/templates/service.yaml new file mode 100644 index 0000000000..66967be511 --- /dev/null +++ b/incubator/hoverfly/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fullname" . }} + labels: + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.externalAdminPort }} + targetPort: {{ .Values.service.adminPort }} + protocol: TCP + name: admin + - port: {{ .Values.service.externalProxyPort }} + targetPort: {{ .Values.service.proxyPort }} + protocol: TCP + name: proxy + selector: + app: {{ template "fullname" . }} diff --git a/incubator/hoverfly/values.yaml b/incubator/hoverfly/values.yaml new file mode 100644 index 0000000000..7d729a2144 --- /dev/null +++ b/incubator/hoverfly/values.yaml @@ -0,0 +1,22 @@ +# Default values for hoverfly. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +image: + repository: docker.io/spectolabs/hoverfly + tag: v1.0.0-rc.2 + pullPolicy: IfNotPresent +service: + type: ClusterIP + externalAdminPort: 8888 + adminPort: 8888 + externalProxyPort: 8500 + proxyPort: 8500 +healthcheckEndpoint: /api/health +hoverflyFlags: +# resources: +# limits: +# cpu: 0.2 +# memory: 200Mi +# requests: +# cpu: 0.1 +# memory: 100Mi