Skip to content

Commit

Permalink
✨ update pipelines, update telegraf config, see b4mad#374
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Görn <[email protected]>
  • Loading branch information
goern committed Aug 17, 2023
1 parent 5af8e95 commit 2e26d0d
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 80 deletions.
52 changes: 20 additions & 32 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,37 @@ on:
types: [opened, reopened, synchronize]

env:
IMAGE_NAME: paddock
IMAGE_TAGS: ${{ github.sha }}
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
IMAGE_NAME: paddock
IMAGE_TAGS: ${{ github.sha }}
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}

permissions:
contents: read

# https://github.com/pre-commit/action/issues/7#issuecomment-1251300704
# run only on changed files
jobs:
lint-and-format:
name: linting and formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# requites to grab the history of the PR
fetch-depth: 0
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]
with:
extra_args: --color=always --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}
build:
name: build
runs-on: ubuntu-latest

steps:
- name: Harden Runner
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Harden Runner
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- name: Buildah Action
id: build_image
uses: redhat-actions/buildah-build@b4dc19b4ba891854660ab1f88a097d45aa158f76 # v2.12
with:
image: ${{ env.IMAGE_NAME }}
tags: ${{ env.IMAGE_TAGS }}
oci: true
context: components/paddock
containerfiles: |
./components/paddock/Containerfile
- name: Buildah Action
id: build_image
uses: redhat-actions/buildah-build@b4dc19b4ba891854660ab1f88a097d45aa158f76 # v2.12
with:
image: ${{ env.IMAGE_NAME }}
tags: ${{ env.IMAGE_TAGS }}
oci: true
context: components/paddock
containerfiles: |
./components/paddock/Containerfile
50 changes: 5 additions & 45 deletions .tekton/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,12 @@ kind: PipelineRun
metadata:
name: git-racing-git
annotations:
# The event we are targeting as seen from the webhook payload
# this can be an array too, i.e: [pull_request, push]
pipelinesascode.tekton.dev/on-event: "[pull_request, push]"

# The branch or tag we are targeting (ie: main, refs/tags/*)
pipelinesascode.tekton.dev/on-target-branch: "main"

# Fetch the git-clone task from hub, we are able to reference later on it
# with taskRef and it will automatically be embedded into our pipeline.
pipelinesascode.tekton.dev/task: "[git-clone, .tekton/tasks/e2e-telemetry-test.yaml]"

# You can add more tasks in here to reuse, browse the one you like from here
# https://hub.tekton.dev/
# example:
# pipelinesascode.tekton.dev/task-2: "[maven, buildah]"

# How many runs we want to keep attached to this event
pipelinesascode.tekton.dev/max-keep-runs: "5"
spec:
params:
# The variable with brackets are special to Pipelines as Code
# They will automatically be expanded with the events from Github.
- name: repo_url
value: "{{ repo_url }}"
- name: revision
Expand All @@ -35,16 +19,13 @@ spec:
- name: revision
workspaces:
- name: source
- name: basic-auth
tasks:
- name: fetch-repository
taskRef:
name: git-clone
workspaces:
- name: output
workspace: source
- name: basic-auth
workspace: basic-auth
params:
- name: url
value: $(params.repo_url)
Expand All @@ -54,27 +35,11 @@ spec:
- name: e2e-tests
runAfter:
- fetch-repository
taskSpec:
workspaces:
- name: source
steps:
- image: quay.io/fedora/python-310@sha256:6875e96d2b8f6897e26d578c75e5a0c8efcdbe6a492f22448ff48a98a6d7d2ae
name: run-e2e-test-in-venv
workingDir: $(workspaces.source.path)
script: |
#!/usr/bin/env bash
p=$(mktemp -d)
python3.10 -m venv $p/venv
source $p/venv/bin/activate
micropipenv install --dev
python manage.py migrate
# python manage.py load_devel_data
python manage.py test telemetry
taskRef:
name: e2e-telemetry-test
workspaces:
- name: source
workspace: source
workspaces:
- name: source
volumeClaimTemplate:
Expand All @@ -84,8 +49,3 @@ spec:
resources:
requests:
storage: 1Gi
# This workspace will inject secret to help the git-clone task to be able to
# checkout the private repositories
- name: basic-auth
secret:
secretName: "{{ git_auth_secret }}"
14 changes: 11 additions & 3 deletions .tekton/tasks/e2e-telemetry-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ metadata:
tekton.dev/pipelines.minVersion: "0.12.1"
tekton.dev/displayName: "#B4mad Racing Telemetry e2e test"
spec:
steps:
- image: quay.io/sclorg/python-311-c9s:20230531
name: run-e2e-test-in-venv
workingDir: $(workspaces.source.path)
command:
- components/paddock/e2e-test.sh
env:
- name: SECRET_KEY
value: abcd1ac34873c54e158d38e7f1283977f202abcd
workspaces:
- name: source
mountPath: /workspace/src/$(params.package)
mountPath: /workspace/src
description: >-
The workspace containing the Go source code
which needs to be released.
The workspace containing the source code which needs to be released.
11 changes: 11 additions & 0 deletions manifests/env/nostromo-stage/telegraf/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../../base/telegraf

configMapGenerator:
- name: telegraf-config
behavior: replace
files:
- telegraf.conf
114 changes: 114 additions & 0 deletions manifests/env/nostromo-stage/telegraf/telegraf.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
[agent]
collection_jitter = "0s"
debug = false
flush_interval = "2s"
flush_jitter = "0s"
hostname = "$HOSTNAME"
interval = "1s"
logfile = ""
metric_batch_size = 1000
metric_buffer_limit = 10000
omit_hostname = false
precision = ""
quiet = false
round_interval = true

[[processors.enum]]
[[processors.enum.mapping]]
dest = "status_code"
field = "status"

[processors.enum.mapping.value_mappings]
critical = 3
healthy = 1
problem = 2

# Collect statistics about itself
[[inputs.internal]]
## If true, collect telegraf memory stats.
collect_memstats = true

[[inputs.mqtt_consumer.topic_parsing]]
topic = "racing/+/+/+/+/+/+/+"
# measurement = "measurement/_"
tags = "_/user/UserId/SessionId/GameName/TrackCode/CarModel/SessionTypeName"
# fields = "_/_/_/test"

[inputs.mqtt_consumer.topic_parsing.types]
CarModel = "string"
GameName = "string"
SessionId = "string"
TrackCode = "string"
UserId = "string"
user = "string"

[[inputs.mqtt_consumer.json_v2]]
measurement_name = "laps"
# dont use the timestamp from the message, since it is not reliable
# timestamp will be set to the time the message was received
# timestamp_format = "unix_ms"
# timestamp_path = "time"
# timestamp_timezone = "UTC"

# [[inputs.mqtt_consumer.json_v2.tag]]
# path = "userId"
# type = "text"

# [[inputs.mqtt_consumer.json_v2.field]]
# path = "carState.CarCoordinates.0"
# rename = "world_x"

[[inputs.mqtt_consumer.json_v2.object]]
disable_prepend_keys = true
path = "telemetry"
# timestamp_key = "time"
# excluded_keys = ["CarCoordinates"]
# tags = ["CarModel", "CarClass"]

# CrewChief v1 configuration
[[inputs.mqtt_consumer]]
servers = ["tcp://mosquitto-tcp:1883"]
topics = [
"crewchief/#"
]
username = "$USERNAME"
password = "$PASSWORD"
data_format = "json_v2"

[[inputs.mqtt_consumer.topic_parsing]]
topic = "crewchief/+/+/+/+/+/+"
tags = "_/user/SessionId/GameName/TrackCode/CarModel/SessionTypeName"
[inputs.mqtt_consumer.topic_parsing.types]
user = "string"
SessionId = "string"
GameName = "string"
TrackCode = "string"
CarModel = "string"
SessionTypeName = "string"

[[inputs.mqtt_consumer.json_v2]]
measurement_name = "laps_cc"
# dont use the timestamp from the message, since it is not reliable
# timestamp will be set to the time the message was received
# timestamp_path = "time"
# timestamp_format = "unix_ms"
# timestamp_timezone = "UTC"

[[inputs.mqtt_consumer.json_v2.object]]
path = "telemetry"
# timestamp_key = "time"
disable_prepend_keys = true
tags = ["CurrentLap", "CarClass"]

[[outputs.influxdb_v2]]
bucket = "racing"
organization = "b4mad"
token = "$INFLUX_TOKEN"
urls = ["http://influxdb2:8086"]
namepass = ["laps*"]

# Configuration for the Prometheus client to spawn
[[outputs.prometheus_client]]
## Address to listen on.
listen = ":9090"
namepass = ["internal_*"]

0 comments on commit 2e26d0d

Please sign in to comment.