Add Hoverfly to incubator (#11365)

* Initial commit for hoverfly chart

Signed-off-by: Tommy Situ <tommy.situ@specto.io>

* Update version and owners

Signed-off-by: Tommy Situ <tommy.situ@specto.io>

* Add README template

Signed-off-by: Tommy Situ <tommy.situ@specto.io>

* Pass Hoverfly flags via args, update readme and notes

Signed-off-by: Tommy Situ <tommy.situ@specto.io>

* Add missing appVersion, update Chart.yaml

Signed-off-by: Tommy Situ <tommy.situ@specto.io>

* Fix linting error in values.yaml

Signed-off-by: Tommy Situ <tommy.situ@specto.io>

* Update Hoverfly version

Signed-off-by: Tommy Situ <tommy.situ@specto.io>

* Address review comments

Signed-off-by: Tommy Situ <tommy.situ@specto.io>

* Fix linting error

Signed-off-by: Tommy Situ <tommy.situ@specto.io>

* Add missing spec.selector field

Signed-off-by: Tommy Situ <tommy.situ@specto.io>
This commit is contained in:
Tommy Situ
2019-02-26 07:10:11 -08:00
committed by Kubernetes Prow Robot
parent d51d65999e
commit 7f76e9695c
9 changed files with 230 additions and 0 deletions
+23
View File
@@ -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
+17
View File
@@ -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
+4
View File
@@ -0,0 +1,4 @@
approvers:
- tommysitu
reviewers:
- tommysitu
+72
View File
@@ -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)
+17
View File
@@ -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 }}
+16
View File
@@ -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 -}}
@@ -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 }}
+19
View File
@@ -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" . }}
+22
View File
@@ -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