Skip to content
This repository has been archived by the owner on Apr 13, 2020. It is now read-only.

Chart to install beatpulse-ui on k8s using helm #41

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ docker pull xabarilcoding/beatpulseui
docker run --name ui -p 5000:80 -e 'BeatPulse-UI:Liveness:0:Name=httpBasic' -e 'BeatPulse-UI:Liveness:0:Uri=http://the-livenes-server-path' -d beatpulseui:latest
```

> **Note**: Beatpulse-ui is available as a helm chart, for easy installation on a Kubernetes cluster. For more information please read how [install beatpulse-ui on Kubernetes](./doc/install-beatpulse-ui-k8s.md)

### Configuration

The liveness to be used on BeatPulse-UI are configured using the **BeatPulse-UI** settings.
Expand Down
21 changes: 21 additions & 0 deletions build/helm/beatpulse-ui/.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
5 changes: 5 additions & 0 deletions build/helm/beatpulse-ui/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
appVersion: "1.0"
description: Chart to install Beatpulse UI as a ClusterIP Service in Kubernetes
name: beatpulse-ui
version: 0.1.0
19 changes: 19 additions & 0 deletions build/helm/beatpulse-ui/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "beatpulse-ui.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 "beatpulse-ui.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "beatpulse-ui.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "beatpulse-ui.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
{{- end }}
32 changes: 32 additions & 0 deletions build/helm/beatpulse-ui/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "beatpulse-ui.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).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "beatpulse-ui.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "beatpulse-ui.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
61 changes: 61 additions & 0 deletions build/helm/beatpulse-ui/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ template "beatpulse-ui.fullname" . }}
namespace: {{ .Values.namespace.name }}
labels:
app: {{ template "beatpulse-ui.name" . }}
chart: {{ template "beatpulse-ui.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "beatpulse-ui.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "beatpulse-ui.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.healthchecks}}
env:
{{- range $index, $hc :=.Values.healthchecks}}
- name: BeatPulse-UI__Liveness__{{$index}}__Name
value: {{ $hc.name}}
- name: BeatPulse-UI__Liveness__{{$index}}__Uri
value: {{ $hc.uri}}
{{- end}}
{{- end}}
ports:
- name: http
containerPort: 80
protocol: TCP
# livenessProbe:
# httpGet:
# path: /
# port: http
# readinessProbe:
# httpGet:
# path: /
# port: http
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
38 changes: 38 additions & 0 deletions build/helm/beatpulse-ui/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "beatpulse-ui.fullname" . -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
app: {{ template "beatpulse-ui.name" . }}
chart: {{ template "beatpulse-ui.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . }}
http:
paths:
- path: {{ $ingressPath }}
backend:
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}
4 changes: 4 additions & 0 deletions build/helm/beatpulse-ui/templates/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: {{.Values.namespace.name}}
20 changes: 20 additions & 0 deletions build/helm/beatpulse-ui/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "beatpulse-ui.fullname" . }}
namespace: {{ .Values.namespace.name}}
labels:
app: {{ template "beatpulse-ui.name" . }}
chart: {{ template "beatpulse-ui.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app: {{ template "beatpulse-ui.name" . }}
release: {{ .Release.Name }}
38 changes: 38 additions & 0 deletions build/helm/beatpulse-ui/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Default values for beatpulse-ui.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

namespace:
name: beatpulse-ui

image:
repository: xabarilcoding/beatpulseui
tag: 1.4.0
pullPolicy: IfNotPresent

service:
type: ClusterIP
port: 80

ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
path: /
hosts:
- chart-example.local
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local

resources: {}

nodeSelector: {}

tolerations: []

affinity: {}
32 changes: 32 additions & 0 deletions build/helm/sample.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: helloworld
spec:
template:
metadata:
labels:
app: helloworld
spec:
containers:
- name: helloworld
image: crccheck/hello-world
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8000
---
apiVersion: v1
kind: Service
metadata:
labels:
app: helloworld
name: helloworld
spec:
type: NodePort
ports:
- name: http
protocol: TCP
port: 80
targetPort: 8000
selector:
app: helloworld
7 changes: 7 additions & 0 deletions build/helm/values-sample.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Edit this file to enter your healthchecks

healthchecks:
- name: helloworld
uri: http://helloworld.default
service:
type: NodePort
Binary file added doc/beatpulse-ui-ok.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 93 additions & 0 deletions doc/install-beatpulse-ui-k8s.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Install Beatpulse-ui on Kubernetes using Helm

We provide a _helm chart_ for easy installation of beatpulse-ui on a Kubernetes cluster. Currently _chart_ is provided as source code only, it will be published soon.

>**Note** This is a _preview_ feature and can be some changes in the future. Any feedback is very valuable.

## Download and install Helm

You need [Helm](https://helm.sh/) installed in your system. Browse to [https://github.com/kubernetes/helm] and follow the instructions in the _Install_ section.

Once _helm_ is installed in your system, you need to init _Tiller_ on your cluster, by simply typing (from a terminal):

```
helm init --wait
```

You can check what version of _helm_ do you have on both clien and server (cluster) running `helm version`. Output should be something like:

```
Client: &version.Version{SemVer:"v2.9.0", GitCommit:"f6025bb9ee7daf9fee0026541c90a6f557a3e0bc", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.9.0", GitCommit:"f6025bb9ee7daf9fee0026541c90a6f557a3e0bc", GitTreeState:"clean"}
```

## Install the beatpulse-ui package

The folder `/build/helm/beatpulse-ui` contains the chart source code. If you are not interested about how the chart is developed, you don't need to care about its contents.

To configure your installation you have to supply a YAML file containing all the URLs you want to check using beatpulse-ui. The format of file should be like:

```
healthchecks:
- name: helloworld
uri: http://helloworld.default
```

You can enter as many elements (name, uri) you need. The `uri` is the uri to check. It is internal to k8s server, so you can use any service name. Can use the `values-sample.yml` file provided as a starting point.

To install the chart just type (from the terminal window located in `/build/helm`):

```
helm install .\beatpulse-ui\ --values <your-YAML-file>
```

The chart installs following elements on your cluster:

1. One namespace called `beatpulse-ui`
2. One deployment named `<release-name>-beatpulse-ui` on this namespace
3. One service named `<release-name>-beatpulse-ui` on this namespace

(`<relase-name>` is the name of the Helm release, and it is generated by Helm)

> **Note**: Using this chart, beatpulse-ui is installed under `beatpulse-ui` namespace. If you are testing k8s services running under other namespace need to append `.<namespace>` as a suffix at the end of the service name. For instance if testing a k8s service named my-service running in default namespace you have to use `http://my-service.default` as a DNS for the service. Look the sample file `values-sample.yml` for details.

## Hello world sample

We include two files:

* `sample.yaml`
* `values-sample.yaml`

First file deploys a simple helloworld running as a `NodePort` service. The second file is a YAML configuration for the chart to check this service. This sample is ready **to run using MiniKube**.

To run it:

1. Apply `sample.yaml` using `kubectl apply -f sample.yaml`
2. Install beatpulse-ui typing `helm install .\beatpulse-ui\ --values .\values-sample.yml`

Once installed check that `helloworld` service is running:

```
λ kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
helloworld NodePort 10.102.171.147 <none> 80:31511/TCP 14h
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 33d
```

Check also that beatpulse-ui is running (note that your service name could be different):

```
λ kubectl get svc -n beatpulse-ui
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
exacerbated-vulture-beatpulse-ui NodePort 10.101.22.155 <none> 80:30850/TCP 18m
```

Now launch beatpulse-ui typing:

```
minikube service <your-beatpulse-ui-service-name> -n beatpulse-ui
```

>**Note**: You must add `/beatpulse-ui` to the URI. This will be solved in following versions. And you should see beatpulse-ui testing helloworld pod:

![./beatpulse-ui testing helloworld](./beatpulse-ui-ok.png)