This commit is contained in:
parent
a351b391be
commit
4dfb6322f7
|
@ -56,7 +56,9 @@
|
||||||
packages.x86_64-linux = {
|
packages.x86_64-linux = {
|
||||||
kubernetes = (kubenix.evalModules.x86_64-linux {
|
kubernetes = (kubenix.evalModules.x86_64-linux {
|
||||||
module = { kubenix, ... }: {
|
module = { kubenix, ... }: {
|
||||||
imports = [ kubenix.modules.k8s ./homelab/kubernetes.nix ];
|
imports = [
|
||||||
|
kubenix.modules.k8s ./homelab/kubernetes.nix
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}).config.kubernetes.result;
|
}).config.kubernetes.result;
|
||||||
};
|
};
|
||||||
|
|
17
homelab/custom.nix
Normal file
17
homelab/custom.nix
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{ lib, ... }: {
|
||||||
|
kubernetes.customTypes = [
|
||||||
|
{
|
||||||
|
name = "servicemonitors";
|
||||||
|
attrName = "servicemonitor";
|
||||||
|
group = "monitoring.coreos.com";
|
||||||
|
kind = "ServiceMonitor";
|
||||||
|
version = "v1";
|
||||||
|
module = {
|
||||||
|
options.endpoints = lib.mkOption {
|
||||||
|
description = "Endpoints";
|
||||||
|
type = lib.types.list;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
{ config, kubenix, ... }: {
|
{ lib, config, kubenix, ... }: {
|
||||||
imports = [ kubenix.modules.k8s
|
imports = [ kubenix.modules.k8s
|
||||||
|
(import ./custom.nix)
|
||||||
(import ./tclip.nix) ];
|
(import ./tclip.nix) ];
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,26 @@ let
|
||||||
tclipImage = "git.gmem.ca/arch/tclip:arm";
|
tclipImage = "git.gmem.ca/arch/tclip:arm";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
kubernetes.resources."monitoring.coreos.com"."v1".ServiceMonitor.tclip = {
|
||||||
|
spec = {
|
||||||
|
selector.matchLabels.app = appName;
|
||||||
|
endpoints = [ { port = "metrics"; interval = "30s"; } ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
kubernetes.resources.services.tclip = {
|
||||||
|
metadata.annotations = {
|
||||||
|
"prometheus.io/port" = "9090";
|
||||||
|
"prometheus.io/scrape" = "true";
|
||||||
|
"prometheus.io/path" = "/metrics";
|
||||||
|
};
|
||||||
|
spec = {
|
||||||
|
selector.app = appName;
|
||||||
|
ports.metrics = {
|
||||||
|
port = 9090;
|
||||||
|
targetPort = 9090;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
kubernetes.resources.statefulSets.tclip.spec = {
|
kubernetes.resources.statefulSets.tclip.spec = {
|
||||||
selector.matchLabels.app = appName;
|
selector.matchLabels.app = appName;
|
||||||
serviceName = appName;
|
serviceName = appName;
|
||||||
|
|
|
@ -1,119 +0,0 @@
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: StatefulSet
|
|
||||||
metadata:
|
|
||||||
name: tclip
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: tclip
|
|
||||||
serviceName: tclip
|
|
||||||
replicas: 1
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: tclip
|
|
||||||
spec:
|
|
||||||
volumes:
|
|
||||||
- name: litestream
|
|
||||||
configMap:
|
|
||||||
name: tclip-litestream
|
|
||||||
- name: config
|
|
||||||
configMap:
|
|
||||||
name: tclip
|
|
||||||
initContainers:
|
|
||||||
- name: init-litestream
|
|
||||||
image: litestream/litestream:sha-749bc0d
|
|
||||||
args: ['restore', '-if-db-not-exists', '-if-replica-exists', '-v', '/data/data.db']
|
|
||||||
volumeMounts:
|
|
||||||
- name: data
|
|
||||||
mountPath: /data
|
|
||||||
- name: litestream
|
|
||||||
mountPath: /etc/litestream.yml
|
|
||||||
subPath: tclip.yml
|
|
||||||
envFrom:
|
|
||||||
- secretRef:
|
|
||||||
name: tclip-litestream-s3
|
|
||||||
|
|
||||||
containers:
|
|
||||||
- name: tclip
|
|
||||||
image: git.gmem.ca/arch/tclip:arm
|
|
||||||
imagePullPolicy: Always
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
memory: "128Mi"
|
|
||||||
cpu: "500m"
|
|
||||||
requests:
|
|
||||||
memory: "64Mi"
|
|
||||||
cpu: "100m"
|
|
||||||
envFrom:
|
|
||||||
- secretRef:
|
|
||||||
name: tclip
|
|
||||||
volumeMounts:
|
|
||||||
- name: data
|
|
||||||
mountPath: /data
|
|
||||||
env:
|
|
||||||
- name: DATA_DIR
|
|
||||||
value: /data
|
|
||||||
- name: USE_FUNNEL
|
|
||||||
value: "true"
|
|
||||||
|
|
||||||
- name: litestream
|
|
||||||
image: litestream/litestream:sha-749bc0d
|
|
||||||
args: ['replicate']
|
|
||||||
volumeMounts:
|
|
||||||
- name: data
|
|
||||||
mountPath: /data
|
|
||||||
- name: litestream
|
|
||||||
mountPath: /etc/litestream.yml
|
|
||||||
subPath: tclip.yml
|
|
||||||
envFrom:
|
|
||||||
- secretRef:
|
|
||||||
name: tclip-litestream-s3
|
|
||||||
ports:
|
|
||||||
- name: metrics
|
|
||||||
containerPort: 9090
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
memory: "128Mi"
|
|
||||||
cpu: "300m"
|
|
||||||
requests:
|
|
||||||
memory: "64Mi"
|
|
||||||
cpu: "100m"
|
|
||||||
|
|
||||||
volumeClaimTemplates:
|
|
||||||
- metadata:
|
|
||||||
name: data
|
|
||||||
spec:
|
|
||||||
storageClassName: nfs-client
|
|
||||||
accessModes: [ "ReadWriteOnce" ]
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 1Gi
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: tclip-metrics
|
|
||||||
annotations:
|
|
||||||
prometheus.io/port: "9090"
|
|
||||||
prometheus.io/scrape: "true"
|
|
||||||
prometheus.io/path: "/metrics"
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: tclip
|
|
||||||
ports:
|
|
||||||
- port: 9090
|
|
||||||
targetPort: 9090
|
|
||||||
name: litestream-metrics
|
|
||||||
---
|
|
||||||
apiVersion: monitoring.coreos.com/v1
|
|
||||||
kind: ServiceMonitor
|
|
||||||
metadata:
|
|
||||||
name: tclip
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: tclip
|
|
||||||
endpoints:
|
|
||||||
- port: metrics
|
|
||||||
interval: 30s
|
|
Loading…
Reference in a new issue