Use the expressivity of ECMAScript, the world's largest software ecosystem and the speed of v8 to build, organize and maintain configuration.
jk
generates all your JSON, YAML and
arbitrary text configuration files. With a little luck, you
will not have to touch a YAML file again. Ever.
// Alice is a developer.
const alice = {
name: 'Alice',
beverage: 'Club-Mate',
monitors: 2,
languages: [
'python',
'haskell',
'c++',
'68k assembly', // Alice is cool like that!
],
};
// Instruct to write the alice object as a YAML file.
export default [
{ value: alice, file: `developers/${alice.name.toLowerCase()}.yaml` },
];
beverage: Club-Mate
languages:
- python
- haskell
- c++
- 68k assembly
monitors: 2
name: Alice
import { MicroService } from './micro-service';
const billing = {
name: 'billing',
description: 'Provides the /api/billing endpoints for frontend.',
maintainer: 'damien@weave.works',
namespace: 'billing',
port: 80,
image: 'quay.io/acmecorp/billing:master-fd986f62',
ingress: {
path: '/api/billing',
},
dashboards: [
'service.RPS.HTTP',
],
alerts: [
'service.RPS.HTTP.HighErrorRate',
],
};
export default MicroService(billing);
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: billing
maintainer: damien@weave.works
name: billing
namespace: billing
spec:
revisionHistoryLimit: 2
selector:
matchLabels:
app: billing
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: billing
maintainer: damien@weave.works
spec:
containers:
- image: quay.io/acmecorp/billing:master-fd986f62
name: billing
ports:
- containerPort: 80
apiVersion: v1
kind: Service
metadata:
labels:
app: billing
maintainer: damien@weave.works
name: billing
namespace: billing
spec:
ports:
- port: 80
selector:
app: billing
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
labels:
app: billing
maintainer: damien@weave.works
name: billing
namespace: billing
spec:
rules:
- http:
paths:
- backend:
serviceName: billing
servicePort: 80
path: /api/billing
apiVersion: v1
data:
dashboard: '[{"annotations":{"list":[]},"editable":false,"gnetId":null,"graphTooltip":0,"hideControls":false,"id":null,"links":[],"panels":[{"aliasColors":{},"bars":false,"dashLength":10,"dashes":false,"dataSource":"$PROMETHEUS_DS","datasource":null,"fill":1,"gridPos":{"h":7,"w":12,"x":0,"y":0},"id":2,"legend":{"alignAsTable":false,"avg":false,"current":false,"max":false,"min":false,"rightSide":false,"show":true,"total":false,"values":false},"lines":true,"linewidth":1,"links":[],"nullPointMode":"null","percentage":false,"pointradius":5,"points":false,"renderer":"flot","repeat":null,"seriesOverrides":[],"spaceLength":10,"stack":false,"steppedLine":false,"targets":[{"expr":"sum
by (code)(sum(irate(http_requests_total{job=''billing''}[2m])))","format":"time_series","intervalFactor":2,"legendFormat":"{{code}}","refId":"A"}],"thresholds":[],"title":"billing
RPS","tooltip":{"shared":true,"sort":0,"value_type":"individual"},"type":"graph","xaxis":{"buckets":null,"mode":"time","name":null,"show":true},"yaxis":[{"format":"short","label":null,"logBase":1,"max":null,"min":null,"show":true},{"format":"short","label":null,"logBase":1,"max":null,"min":null,"show":true}]},{"aliasColors":{},"bars":false,"dashLength":10,"dashes":false,"dataSource":"$PROMETHEUS_DS","datasource":null,"fill":1,"gridPos":{"h":7,"w":12,"x":12,"y":0},"id":3,"legend":{"alignAsTable":false,"avg":false,"current":false,"max":false,"min":false,"rightSide":false,"show":true,"total":false,"values":false},"lines":true,"linewidth":1,"links":[],"nullPointMode":"null","percentage":false,"pointradius":5,"points":false,"renderer":"flot","repeat":null,"seriesOverrides":[],"spaceLength":10,"stack":false,"steppedLine":false,"targets":[{"expr":"histogram_quantile(0.99,
sum(rate(http_request_duration_seconds_bucket{job=''billing''}[2m])) by (route)
* 1e3","format":"time_series","intervalFactor":2,"legendFormat":"99th percentile","refId":"A"},{"expr":"histogram_quantile(0.50,
sum(rate(http_request_duration_seconds_bucket{job=''billing''}[2m])) by (route)
* 1e3","format":"time_series","intervalFactor":2,"legendFormat":"median","refId":"B"},{"expr":"sum(rate(http_request_total{job=''billing''}[2m]))
/ sum(rate(http_request_duration_seconds_count{job=''billing''}[2m])) * 1e3","format":"time_series","intervalFactor":2,"legendFormat":"mean","refId":"C"}],"thresholds":[],"title":"billing
Latency","tooltip":{"shared":true,"sort":0,"value_type":"individual"},"type":"graph","xaxis":{"buckets":null,"mode":"time","name":null,"show":true},"yAxis":[{"format":"ms","label":null,"logBase":1,"max":null,"min":null,"show":true},{"format":"short","label":null,"logBase":1,"max":null,"min":null,"show":true}],"yaxis":[{"format":"short","label":null,"logBase":1,"max":null,"min":null,"show":true},{"format":"short","label":null,"logBase":1,"max":null,"min":null,"show":true}]}],"refresh":"","schemaVersion":16,"style":"dark","tags":[],"templating":{"list":[]},"time":{"from":"now-6h","to":"now"},"timepicker":{"refresh_intervals":["5s","10s","30s","1m","5m","15m","30m","1h","2h","1d"],"time_options":["5m","15m","1h","6h","12h","24h","2d","7d","30d"]},"timezone":"browser","title":"Service
> billing","uid":"","version":0}]'
kind: ConfigMap
metadata:
labels:
app: billing
maintainer: damien@weave.works
name: billing-dashboards
namespace: billing
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
labels:
app: billing
maintainer: damien@weave.works
prometheus: global
role: alert-rules
name: billing
spec:
groups:
- name: billing-alerts.rules
rules:
- alert: HighErrorRate
annotations:
description: More than 10% of requests to the billing service are failing
with 5xx errors
details: '{{$value | printf "%.1f"}}% errors for more than 5m'
service: billing
expr: |-
rate(http_request_total{job=billing,code=~"5.."}[2m])
/ rate(http_request_duration_seconds_count{job=billing}[2m]) * 100 > 10
for: 5m
labels:
severity: critical
apiVersion: v1
kind: Namespace
metadata:
name: billing