6 Commits

Author SHA1 Message Date
Iain Sproat 09b5fae3d6 feat(tests): adds tests to helm chart (#7) 2023-02-08 22:48:24 +00:00
Iain Sproat 23150f1b94 Mount emptydir to /tmp (#6)
* Mount empty directory to /tmp
2023-02-08 22:05:38 +00:00
Iain Sproat 6e18864dd6 Update readme (#5)
* docs(README): adds an example values, and uses helm chart repository

* docs(README): add comments to helm chart values
2023-02-08 20:35:23 +00:00
Iain Sproat 30c610c817 docs(README): adds an example values, and uses helm chart repository (#4) 2023-02-08 19:55:44 +00:00
Iain Sproat 375f748670 fix(circleci): include get_version.sh (#3) 2023-02-08 19:40:07 +00:00
Iain Sproat 4d831e56bb Initial helm chart and fix CircleCI (#2)
* Initial helm chart
* fix(circleci): adds ssh key finger print
2023-02-08 19:36:53 +00:00
15 changed files with 429 additions and 11 deletions
+4 -1
View File
@@ -18,6 +18,9 @@ workflows:
branches: &filter-only-main
only:
- main
requires:
- get-version
- pre-commit
jobs:
get-version:
@@ -88,7 +91,7 @@ jobs:
- checkout
- add_ssh_keys:
fingerprints:
- 'TODO: add fingerprint here'
- '99:72:8a:c8:d2:8d:f5:b8:66:c0:01:12:ee:24:2b:16'
- attach_workspace:
at: /tmp/workspace
- run:
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash
set -eo pipefail
if [[ "${CIRCLE_TAG}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "${CIRCLE_TAG}"
exit 0
fi
# shellcheck disable=SC2068,SC2046
LAST_RELEASE="$(git describe --always --tags $(git rev-list --tags) | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)"
NEXT_RELEASE="$(echo "${LAST_RELEASE}" | awk -F. -v OFS=. '{$NF += 1 ; print}')"
if [[ "${CIRCLE_BRANCH}" == "main" ]]; then
echo "${NEXT_RELEASE}-alpha.${CIRCLE_BUILD_NUM}"
exit 0
fi
# docker has a 128 character tag limit, so ensuring the branch name will be short enough
# helm uses semver 2, only valid characters are a-zA-Z0-9 and hyphen '-'
# shellcheck disable=SC2034
BRANCH_NAME_TRUNCATED="$(echo "${CIRCLE_BRANCH}" | cut -c -50 | sed 's/[^a-zA-Z0-9.-]/-/g')"
echo "${NEXT_RELEASE}-branch.${BRANCH_NAME_TRUNCATED}.${CIRCLE_BUILD_NUM}"
exit 0
+2 -2
View File
@@ -8,7 +8,7 @@ repos:
rev: 'v4.4.0'
hooks:
- id: check-yaml
exclude: 'deploy/helm'
exclude: 'charts'
- id: check-merge-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
@@ -16,7 +16,7 @@ repos:
- id: check-vcs-permalinks
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: 'deploy/helm/README.md'
exclude: 'charts/seq-input-gelf/README.md'
- repo: https://github.com/syntaqx/git-hooks
rev: 'v0.0.17'
+25 -8
View File
@@ -1,4 +1,4 @@
# Speckle Repo Management Templates
# Seq Input GELF - Helm Chart
[![Twitter Follow](https://img.shields.io/twitter/follow/SpeckleSystems?style=social)](https://twitter.com/SpeckleSystems) [![Community forum users](https://img.shields.io/discourse/users?server=https%3A%2F%2Fdiscourse.speckle.works&style=flat-square&logo=discourse&logoColor=white)](https://discourse.speckle.works) [![website](https://img.shields.io/badge/https://-speckle.systems-royalblue?style=flat-square)](https://speckle.systems) [![docs](https://img.shields.io/badge/docs-speckle.guide-orange?style=flat-square&logo=read-the-docs&logoColor=white)](https://speckle.guide/dev/)
@@ -12,29 +12,42 @@ You may wish to deploy `seq-input-gelf` if you are exporting logs in Graylog Ext
You may wish to deploy `seq-input-gelf` independently of `seq` if you have a multiple Kubernetes clusters, and wish to transfer log data from a source cluster to a target cluster, running `seq`. Alternatively, you may have `seq` deployed on a non-Kubernetes environment, and wish to export logs messages from Kubernetes to that external seq instance.
## Documentation
This project or repository is in no way affiliated with DataLust or Seq.
Comprehensive developer and user documentation can be found in our:
## Documentation
### Usage
1. You will require [Helm](https://helm.sh/docs/intro/install/) and access to a [Kubernetes](https://kubernetes.io/) cluster to which you have appropriate permissions to deploy resources.
1. Clone this repository and in a shell terminal, `cd` in to the root directory of the cloned repository.
1. Create a namespace to deploy into:
```shell
kubectl create namespace seq-input-gelf
```
1. Run the following command to create a secret containing your deployment key, replacing `YOURAPIKEY` with an [API key generated by your Seq instance](https://docs.datalust.co/docs/api-keys):
```shell
kubectl create secret generic seq-api-key --from-value=api-key=YOURAPIKEY --namespace seq-input-gelf
kubectl create secret generic seq-api-key --from-literal=api-key=YOURAPIKEY --namespace seq-input-gelf
```
1. Add the helm repository for this Helm Chart
```shell
helm repo add seq-input-gelf https://specklesystems.github.io/seq-input-gelf/stable
```
1. Update the value of `seq.url` in `./examples/values.yaml` file to match the url of your seq instance. The default example assumes seq is hosted within the same Kubernetes cluster with a Service named `seq` within a namespace named `seq`. Please adjust this as required.
1. Run the following command to install the helm chart in your kubernetes cluster. Note that this will create a new namespace named `seq-input-gelf`:
```shell
helm upgrade seq-input-gelf \
./charts/seq-input-gelf \
--create-namespace \
seq-input-gelf \
--namespace seq-input-gelf \
--install \
--values ./example/values.yaml
--values ./examples/values.yaml
```
1. Verify that the deployment has successfully [rolled out](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#deployment-status):
@@ -45,7 +58,11 @@ Comprehensive developer and user documentation can be found in our:
### Developing & Debugging
This doesn't make sense here, but in general, we should try to provide a small "how to" guide on local development and debugging, as it lowers the barrier to contributions.
1. Ensure the Helm chart can be templated:
```shell
helm template seq-input-gelf ./charts/seq-input-gelf
```
### Contributing
+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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
+13
View File
@@ -0,0 +1,13 @@
apiVersion: v2
appVersion: "3.0.441-x64"
description: A Helm chart for deploying seq-input-gelf to Kubernetes
home: 'https://speckle.systems/'
icon: 'https://speckle.xyz/logo.svg'
maintainers:
- name: Speckle Systems
url: 'https://speckle.systems/'
name: seq-input-gelf
sources:
- 'https://github.com/specklesystems/speckle-server'
type: application
version: 0.1.0
+46
View File
@@ -0,0 +1,46 @@
# seq-input-gelf
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 3.0.441-x64](https://img.shields.io/badge/AppVersion-3.0.441--x64-informational?style=flat-square)
A Helm chart for deploying seq-input-gelf to Kubernetes
**Homepage:** <https://speckle.systems/>
## Maintainers
| Name | Email | Url |
| ---- | ------ | --- |
| Speckle Systems | | <https://speckle.systems/> |
## Source Code
* <https://github.com/specklesystems/speckle-server>
## Values
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | |
| fullnameOverride | string | `""` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"datalust/seq-input-gelf"` | |
| image.tag | string | `""` | |
| imagePullSecrets | list | `[]` | |
| nameOverride | string | `""` | |
| nodeSelector | object | `{}` | |
| podAnnotations | object | `{}` | |
| replicaCount | int | `1` | The number of instances of seq-input-gelf to deploy |
| resources | object | `{}` | |
| seq.apiKey.secretKey | string | `"api-key"` | The key in the Kubernetes secret containing the Seq API key |
| seq.apiKey.secretName | string | `"seq-api-key"` | The name of the Kubernetes secret containing the Seq API key |
| seq.diagnosticLogging | bool | `true` | Whether to enable diagnostic logging |
| seq.rustBackTrace | int | `0` | Whether to enable backtrace logging (used for debugging). 0 = disabled, 1 = enabled. |
| seq.url | string | `"http://seq:5341"` | The URL of the Seq server to send events to |
| service.port | int | `12201` | The port on which seq-input-gelf will listen for GELF messages |
| service.protocol | string | `"TCP"` | The protocol (either TCP or UDP) used by seq-input-gelf to listen for GELF messages |
| service.type | string | `"ClusterIP"` | |
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created |
| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template |
| tolerations | list | `[]` | |
@@ -0,0 +1 @@
🎉 Thank you for deploying seq-input-gelf!
@@ -0,0 +1,68 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "seq-input-gelf.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 "seq-input-gelf.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 }}
{{/*
*/}}
{{- define "seq-input-gelf.testname" -}}
{{- printf "%s-test" ( include "seq-input-gelf.fullname" . ) }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "seq-input-gelf.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "seq-input-gelf.labels" -}}
helm.sh/chart: {{ include "seq-input-gelf.chart" . }}
{{ include "seq-input-gelf.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "seq-input-gelf.selectorLabels" -}}
app.kubernetes.io/name: {{ include "seq-input-gelf.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "seq-input-gelf.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "seq-input-gelf.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
@@ -0,0 +1,93 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "seq-input-gelf.fullname" . }}
labels:
{{- include "seq-input-gelf.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "seq-input-gelf.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "seq-input-gelf.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "seq-input-gelf.serviceAccountName" . }}
securityContext:
fsGroup: 2000
runAsUser: 1000
runAsGroup: 3000
runAsNonRoot: true
containers:
- name: {{ .Chart.Name }}
securityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: gelf
containerPort: {{ .Values.service.port }}
protocol: {{ .Values.service.protocol }}
# TODO: docker image does not yet support liveness and readiness probes
# livenessProbe:
# httpGet:
# path: /
# port: http
# readinessProbe:
# httpGet:
# path: /
# port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: SEQ_ADDRESS
value: {{ .Values.seq.url }}
- name: SEQ_API_KEY
valueFrom:
secretKeyRef:
name: {{ .Values.seq.apiKey.secretName }}
key: {{ .Values.seq.apiKey.secretKey }}
- name: GELF_ADDRESS
value: {{ printf "%s://0.0.0.0:%d" ( lower .Values.service.protocol ) ( .Values.service.port | int ) }}
- name: GELF_ENABLE_DIAGNOSTICS
value: {{ .Values.seq.enableDiagnostics | quote }}
# TODO support mounting of certificates from secrets
# - name: GELF_CERTIFICATE_PATH
# value: /certs/seq-input-gelf.crt
# - name: GELF_CERTIFICATE_PRIVATE_KEY_PATH
# value: /certs/seq-input-gelf.key
- name: RUST_BACKTRACE
value: {{ .Values.seq.rustBackTrace | quote }}
volumeMounts:
# mount an empty dir to /tmp to prevent errors as readOnlyRootFilesystem is true
- mountPath: /tmp
name: tmp
volumes:
- name: tmp
emptyDir: {}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "seq-input-gelf.fullname" . }}
labels:
{{- include "seq-input-gelf.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: gelf
protocol: {{ .Values.service.protocol }}
name: gelf
selector:
{{- include "seq-input-gelf.selectorLabels" . | nindent 4 }}
@@ -0,0 +1,14 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "seq-input-gelf.serviceAccountName" . }}
labels:
{{- include "seq-input-gelf.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
secrets:
- name: {{ .Values.seq.apiKey.secretName }}
{{- end }}
@@ -0,0 +1,36 @@
kind: Job
apiVersion: batch/v1
metadata:
name: {{ include "seq-input-gelf.testname" . }}
labels:
{{- include "seq-input-gelf.labels" . | nindent 4 }}
spec:
backoffLimit: 5
activeDeadlineSeconds: 60
ttlSecondsAfterFinished: 600 #automatically deleted 10 minutes after completion
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "seq-input-gelf.selectorLabels" . | nindent 8 }}
spec:
securityContext:
fsGroup: 2000
runAsUser: 1000
runAsGroup: 3000
runAsNonRoot: true
containers:
- name: tcp-connection-is-alive
image: alpine
command: ["/bin/sh"]
args: ["-c", "nc -z {{ printf "%s.%s.svc.cluster.local" ( include "seq-input-gelf.fullname" . ) .Release.Namespace }} {{ .Values.service.port }}"]
securityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
restartPolicy: Never
+56
View File
@@ -0,0 +1,56 @@
# -- The number of instances of seq-input-gelf to deploy
replicaCount: 1
seq:
apiKey:
# -- The name of the Kubernetes secret containing the Seq API key
secretName: seq-api-key
# -- The key in the Kubernetes secret containing the Seq API key
secretKey: api-key
# -- The URL of the Seq server to send events to
url: http://seq:5341
# -- Whether to enable diagnostic logging
diagnosticLogging: true
# -- Whether to enable backtrace logging (used for debugging). 0 = disabled, 1 = enabled.
rustBackTrace: 0
image:
repository: datalust/seq-input-gelf
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# -- Specifies whether a service account should be created
create: true
# -- Annotations to add to the service account
annotations: {}
# -- The name of the service account to use. If not set and create is true, a name is generated using the fullname template
name: ""
podAnnotations: {}
service:
type: ClusterIP
# -- The port on which seq-input-gelf will listen for GELF messages
port: 12201
# -- The protocol (either TCP or UDP) used by seq-input-gelf to listen for GELF messages
protocol: TCP
resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}
+10
View File
@@ -0,0 +1,10 @@
seq:
url: http://seq.seq.svc.cluster.local:5341
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi