Skip to content

Commit 2424934

Browse files
committed
feat(k8s/magiclove): spegel
1 parent ff5cca4 commit 2424934

File tree

7 files changed

+308
-0
lines changed

7 files changed

+308
-0
lines changed

k8s/magiclove/list.cue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
"github.com/uhthomas/automata/k8s/magiclove/snapscheduler"
4444
"github.com/uhthomas/automata/k8s/magiclove/snapshot_controller"
4545
"github.com/uhthomas/automata/k8s/magiclove/speedtest_exporter"
46+
"github.com/uhthomas/automata/k8s/magiclove/spegel"
4647
"github.com/uhthomas/automata/k8s/magiclove/thomas"
4748
// "github.com/uhthomas/automata/k8s/magiclove/trivy_system"
4849
// "github.com/uhthomas/automata/k8s/magiclove/vector"
@@ -124,6 +125,7 @@ _items: [
124125
snapscheduler.#List.items,
125126
snapshot_controller.#List.items,
126127
speedtest_exporter.#List.items,
128+
spegel.#List.items,
127129
thomas.#List.items,
128130
// trivy_system.#List.items,
129131
// vector.#List.items,

k8s/magiclove/spegel/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Spegel
2+
3+
[https://spegel.dev](https://spegel.dev)
4+
5+
[https://github.com/spegel-org/spegel](https://github.com/spegel-org/spegel)
6+
7+
## Talos
8+
9+
[https://spegel.dev/docs/getting-started/#talos](https://spegel.dev/docs/getting-started/#talos)
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
package spegel
2+
3+
import (
4+
appsv1 "k8s.io/api/apps/v1"
5+
"k8s.io/api/core/v1"
6+
)
7+
8+
#DaemonSetList: appsv1.#DaemonSetList & {
9+
apiVersion: "apps/v1"
10+
kind: "DaemonSetList"
11+
items: [...{
12+
apiVersion: "apps/v1"
13+
kind: "DaemonSet"
14+
}]
15+
}
16+
17+
#DaemonSetList: items: [{
18+
spec: {
19+
selector: matchLabels: "app.kubernetes.io/name": #Name
20+
template: {
21+
metadata: labels: "app.kubernetes.io/name": #Name
22+
spec: {
23+
volumes: [{
24+
name: "containerd-sock"
25+
hostPath: {
26+
path: "/run/containerd/containerd.sock"
27+
type: v1.#HostPathSocket
28+
}
29+
}, {
30+
name: "containerd-content"
31+
hostPath: {
32+
path: "/var/lib/containerd/io.containerd.content.v1.content"
33+
type: v1.#HostPathDirectory
34+
}
35+
}, {
36+
name: "containerd-config"
37+
hostPath: {
38+
path: "/etc/cri/conf.d/hosts"
39+
type: v1.#HostPathDirectoryOrCreate
40+
}
41+
}]
42+
initContainers: [{
43+
name: "config"
44+
image: _image.reference
45+
args: [
46+
"configuration",
47+
"--log-level=INFO",
48+
"--containerd-registry-config-path=/etc/cri/conf.d/hosts",
49+
"--mirror-targets",
50+
"http://$(NODE_IP):30020",
51+
"--resolve-tags=true",
52+
"--prepend-existing=false",
53+
]
54+
env: [{
55+
name: "NODE_IP"
56+
valueFrom: fieldRef: fieldPath: "status.hostIP"
57+
}]
58+
resources: limits: {
59+
cpu: "100m"
60+
memory: "128Mi"
61+
}
62+
volumeMounts: [{
63+
name: "containerd-config"
64+
mountPath: "/etc/cri/conf.d/hosts"
65+
}]
66+
imagePullPolicy: v1.#PullIfNotPresent
67+
securityContext: {
68+
capabilities: drop: ["ALL"]
69+
readOnlyRootFilesystem: true
70+
allowPrivilegeEscalation: false
71+
}
72+
}]
73+
containers: [{
74+
name: "spegel"
75+
image: _image.reference
76+
args: [
77+
"registry",
78+
"--log-level=INFO",
79+
"--mirror-resolve-retries=3",
80+
"--mirror-resolve-timeout=20ms",
81+
"--registry-addr=:5000",
82+
"--router-addr=:5001",
83+
"--metrics-addr=:9090",
84+
"--containerd-sock=/run/containerd/containerd.sock",
85+
"--containerd-namespace=k8s.io",
86+
"--containerd-registry-config-path=/etc/cri/conf.d/hosts",
87+
"--bootstrap-kind=dns",
88+
"--dns-bootstrap-domain=\(#Name)-bootstrap.\(#Namespace).svc.cluster.local.",
89+
"--resolve-latest-tag=true",
90+
"--containerd-content-path=/var/lib/containerd/io.containerd.content.v1.content",
91+
"--debug-web-enabled=true",
92+
]
93+
env: [{
94+
name: "DATA_DIR"
95+
value: ""
96+
}, {
97+
name: "NODE_IP"
98+
valueFrom: fieldRef: fieldPath: "status.hostIP"
99+
}, {
100+
name: "GOMEMLIMIT"
101+
valueFrom: resourceFieldRef: {
102+
resource: "limits.memory"
103+
divisor: 1
104+
}
105+
}]
106+
ports: [{
107+
name: "registry"
108+
containerPort: 5000
109+
}, {
110+
name: "router"
111+
containerPort: 5001
112+
}, {
113+
name: "metrics"
114+
containerPort: 9090
115+
}]
116+
resources: limits: {
117+
(v1.#ResourceCPU): "300m"
118+
(v1.#ResourceMemory): "128Mi"
119+
}
120+
volumeMounts: [{
121+
name: "containerd-sock"
122+
mountPath: "/run/containerd/containerd.sock"
123+
}, {
124+
name: "containerd-content"
125+
mountPath: "/var/lib/containerd/io.containerd.content.v1.content"
126+
readOnly: true
127+
}]
128+
129+
let probe = {
130+
httpGet: {
131+
path: "/readyz"
132+
port: "registry"
133+
}
134+
}
135+
136+
livenessProbe: probe
137+
readinessProbe: probe
138+
startupProbe: probe & {
139+
periodSeconds: 3
140+
failureThreshold: 60
141+
}
142+
143+
imagePullPolicy: v1.#PullIfNotPresent
144+
// securityContext: {
145+
// capabilities: drop: ["ALL"]
146+
// readOnlyRootFilesystem: true
147+
// allowPrivilegeEscalation: false
148+
// }
149+
securityContext: readOnlyRootFilesystem: true
150+
}]
151+
// securityContext: {
152+
// runAsUser: 1000
153+
// runAsGroup: 3000
154+
// runAsNonRoot: true
155+
// fsGroup: 2000
156+
// seccompProfile: type: v1.#SeccompProfileTypeRuntimeDefault
157+
// }
158+
tolerations: [{
159+
key: "CriticalAddonsOnly"
160+
operator: v1.#TolerationOpExists
161+
}, {
162+
operator: v1.#TolerationOpExists
163+
effect: v1.#TaintEffectNoExecute
164+
}, {
165+
operator: v1.#TolerationOpExists
166+
effect: v1.#TaintEffectNoSchedule
167+
}]
168+
}
169+
}
170+
}
171+
}]

k8s/magiclove/spegel/list.cue

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package spegel
2+
3+
import (
4+
"list"
5+
6+
"k8s.io/api/core/v1"
7+
8+
"github.com/uhthomas/automata/tools"
9+
)
10+
11+
#Name: "spegel"
12+
#Namespace: #Name
13+
14+
// renovate: datasource=github-releases depName=spegel-org/spegel extractVersion=^v(?<version>.*)$
15+
#Version: "0.4.0"
16+
17+
_image: tools.#Image & {
18+
name: "ghcr.io/spegel-org/spegel"
19+
tag: #Version
20+
digest: "sha256:a86089ae74c4f9c98ec86c366d196f7a03044c38af09e6582b0661d42a324226"
21+
}
22+
23+
#List: v1.#List & {
24+
apiVersion: "v1"
25+
kind: "List"
26+
items: [...{
27+
metadata: {
28+
name: string | *#Name
29+
namespace: #Namespace
30+
labels: {
31+
"app.kubernetes.io/name": #Name
32+
"app.kubernetes.io/version": #Version
33+
}
34+
}
35+
}]
36+
}
37+
38+
#List: items: list.Concat(_items)
39+
40+
_items: [
41+
#DaemonSetList.items,
42+
#NamespaceList.items,
43+
#ServiceList.items,
44+
#VMServiceScrapeList.items,
45+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package spegel
2+
3+
import "k8s.io/api/core/v1"
4+
5+
#NamespaceList: v1.#NamespaceList & {
6+
apiVersion: "v1"
7+
kind: "NamespaceList"
8+
items: [...{
9+
apiVersion: "v1"
10+
kind: "Namespace"
11+
}]
12+
}
13+
14+
#NamespaceList: items: [{metadata: labels: "pod-security.kubernetes.io/enforce": "privileged"}]
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package spegel
2+
3+
import "k8s.io/api/core/v1"
4+
5+
#ServiceList: v1.#ServiceList & {
6+
apiVersion: "v1"
7+
kind: "ServiceList"
8+
items: [...{
9+
apiVersion: "v1"
10+
kind: "Service"
11+
}]
12+
}
13+
14+
#ServiceList: items: [{
15+
spec: {
16+
ports: [{
17+
name: "http-metrics"
18+
port: 9090
19+
targetPort: "metrics"
20+
}]
21+
selector: "app.kubernetes.io/name": #Name
22+
}
23+
}, {
24+
metadata: name: "\(#Name)-bootstrap"
25+
spec: {
26+
ports: [{
27+
name: "router"
28+
port: 5001
29+
targetPort: "router"
30+
}]
31+
selector: "app.kubernetes.io/name": #Name
32+
clusterIP: v1.#ClusterIPNone
33+
publishNotReadyAddresses: true
34+
}
35+
}, {
36+
metadata: name: "\(#Name)-registry"
37+
spec: {
38+
ports: [{
39+
name: "registry"
40+
port: 5000
41+
targetPort: "registry"
42+
nodePort: 30020
43+
}]
44+
selector: "app.kubernetes.io/name": #Name
45+
type: v1.#ServiceTypeNodePort
46+
trafficDistribution: "PreferSameNode"
47+
}
48+
}]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package spegel
2+
3+
import operatorv1beta1 "github.com/VictoriaMetrics/operator/api/operator/v1beta1"
4+
5+
#VMServiceScrapeList: operatorv1beta1.#VMServiceScrapeList & {
6+
apiVersion: "operator.victoriametrics.com/v1beta1"
7+
kind: "VMServiceScrapeList"
8+
items: [...{
9+
apiVersion: "operator.victoriametrics.com/v1beta1"
10+
kind: "VMServiceScrape"
11+
}]
12+
}
13+
14+
#VMServiceScrapeList: items: [{
15+
spec: {
16+
endpoints: [{port: "http-metrics"}]
17+
selector: matchLabels: "app.kubernetes.io/name": #Name
18+
}
19+
}]

0 commit comments

Comments
 (0)