Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Commit 641a443

Browse files
committed
feat: Add Helm and Skaffold configuration for dhcpdd, fix statik configuration
1 parent a590b40 commit 641a443

File tree

14 files changed

+265
-16
lines changed

14 files changed

+265
-16
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
**/.bin
2+
**/.idea
3+
**/charts/*/charts
4+
**/dhcp/
5+
**/statik*

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
pkg/svc/dhcp
2-
pkg/svc/statik
1+
**/.bin
2+
**/.idea
3+
**/charts/*/charts
4+
**/dhcp/
5+
**/statik*

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Connect to server",
6+
"type": "go",
7+
"request": "attach",
8+
"mode": "remote",
9+
"remotePath": "/app",
10+
"port": 31441,
11+
"host": "127.0.0.1"
12+
}
13+
]
14+
}
File renamed without changes.

charts/dhcpdd/Chart.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
name: dhcpdd
3+
version: 0.0.1
4+
description: An ISC DHCP server management daemon.
5+
type: application
6+
home: https://pojntfx.github.io/go-isc-dhcp/
7+
sources:
8+
- [email protected]:pojntfx/go-isc-dhcp.git
9+
maintainers:
10+
- name: Felix Pojtinger
11+
12+
url: https://felix.pojtinger.com
13+
appVersion: 0.0.1

charts/dhcpdd/templates/stack.yaml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: dhcpd-{{ .Release.Name }}{{ if .Values.meta.dev }}-dev{{ end }}
5+
data:
6+
DIBS_TARGET: "{{ .Values.meta.target }}"
7+
TARGETPLATFORM: "{{ .Values.meta.platform }}"
8+
{{ if and .Values.meta.dev .Values.meta.debug }}
9+
DIBS_DEBUG: "true"
10+
{{end}}
11+
12+
---
13+
apiVersion: apps/v1
14+
kind: Deployment
15+
metadata:
16+
name: dhcpdd-{{ .Release.Name }}{{ if .Values.meta.dev }}-dev{{ end }}
17+
spec:
18+
selector:
19+
matchLabels:
20+
app: dhcpdd-{{ .Release.Name }}{{ if .Values.meta.dev }}-dev{{ end }}
21+
template:
22+
metadata:
23+
labels:
24+
app: dhcpdd-{{ .Release.Name }}{{ if .Values.meta.dev }}-dev{{ end }}
25+
spec:
26+
containers:
27+
- name: dhcpdd{{ if .Values.meta.dev }}-dev{{ end }}
28+
image: {{ .Values.meta.image }}
29+
envFrom:
30+
- configMapRef:
31+
name: dhcpd-{{ .Release.Name }}{{ if .Values.meta.dev }}-dev{{ end }}
32+
{{ if not .Values.meta.dev }}
33+
resources:
34+
limits:
35+
memory: {{ .Values.resources.memory }}
36+
cpu: {{ .Values.resources.cpu }}
37+
{{ end }}
38+
ports:
39+
- containerPort: 1240
40+
{{ if and .Values.meta.dev .Values.meta.debug }}
41+
- containerPort: {{ .Values.meta.debugPort }}
42+
{{end}}
43+
{{ if .Values.meta.dev }}
44+
45+
---
46+
apiVersion: v1
47+
kind: Service
48+
metadata:
49+
name: dhcpdd-{{ .Release.Name }}-dev
50+
spec:
51+
selector:
52+
app: dhcpdd-{{ .Release.Name }}-dev
53+
type: NodePort
54+
ports:
55+
- name: grpc
56+
port: 1240
57+
targetPort: 1240
58+
nodePort: {{ .Values.ingress.nodePort }}
59+
- name: debug
60+
port: {{ .Values.meta.debugNodePort }}
61+
targetPort: {{ .Values.meta.debugPort }}
62+
nodePort: {{ .Values.meta.debugNodePort }}
63+
{{ else }}
64+
65+
---
66+
apiVersion: autoscaling/v2beta1
67+
kind: HorizontalPodAutoscaler
68+
metadata:
69+
name: dhcpdd-{{ .Release.Name }}
70+
spec:
71+
maxReplicas: {{ .Values.resources.maxReplicas }}
72+
minReplicas: 1
73+
scaleTargetRef:
74+
apiVersion: apps/v1
75+
kind: Deployment
76+
name: dhcpdd-{{ .Release.Name }}
77+
metrics:
78+
- type: Resource
79+
resource:
80+
name: cpu
81+
targetAverageUtilization: 60
82+
83+
---
84+
apiVersion: v1
85+
kind: Service
86+
metadata:
87+
name: dhcpdd-{{ .Release.Name }}
88+
spec:
89+
selector:
90+
app: dhcpdd-{{ .Release.Name }}
91+
ports:
92+
- name: grpc
93+
port: 1240
94+
targetPort: 1240
95+
96+
---
97+
apiVersion: networking.k8s.io/v1beta1
98+
kind: Ingress
99+
metadata:
100+
name: dhcpdd-{{ .Release.Name }}
101+
annotations:
102+
ingress.kubernetes.io/protocol: h2c
103+
spec:
104+
rules:
105+
- host: {{ .Values.ingress.domain }}
106+
http:
107+
paths:
108+
- path: {{ .Values.ingress.path }}
109+
backend:
110+
serviceName: dhcpdd-{{ .Release.Name }}
111+
servicePort: grpc
112+
{{ end }}

charts/dhcpdd/values.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
meta:
2+
image: pojntfx/dhcpdd:latest
3+
dev: false
4+
debugPort: 31441
5+
debugNodePort: 31441
6+
target: "{{ .DIBS_TARGET }}"
7+
platform: "{{ .TARGETPLATFORM }}"
8+
debug: "{{ .DIBS_DEBUG }}"
9+
10+
resources:
11+
memory: "128Mi"
12+
cpu: "256m"
13+
maxReplicas: 10
14+
15+
ingress:
16+
loadBalancerPorts:
17+
- 67
18+
nodePort: 31240
19+
domain: dhcpdd.felix.pojtinger.com
20+
path: /

cmd/dhcpdd/main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package main
22

33
import (
4+
"net"
5+
"os"
6+
"os/signal"
7+
"path/filepath"
8+
"strings"
9+
"syscall"
10+
411
constants "github.com/pojntfx/go-isc-dhcp/cmd"
512
goISCDHCP "github.com/pojntfx/go-isc-dhcp/pkg/proto/generated"
613
"github.com/pojntfx/go-isc-dhcp/pkg/svc"
@@ -11,12 +18,6 @@ import (
1118
"gitlab.com/bloom42/libs/rz-go/log"
1219
"google.golang.org/grpc"
1320
"google.golang.org/grpc/reflection"
14-
"net"
15-
"os"
16-
"os/signal"
17-
"path/filepath"
18-
"strings"
19-
"syscall"
2021
)
2122

2223
const (

dibs.yaml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ targets:
1717
build: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -tags netgo -ldflags '-extldflags "-static"' -o .bin/binaries/dhcpdd-linux-amd64 cmd/dhcpdd/main.go
1818
unitTests: go test -v ./...
1919
integrationTests: .bin/binaries/dhcpdd-linux-amd64 --help
20-
imageTests: docker run --platform linux/amd64 -e DIBS_TARGET=linux -e TARGETPLATFORM=linux/amd64 pojntfx/dhcpdd:linux-amd64 /usr/local/bin/dhcpdd --help
20+
imageTests: docker run --platform linux/amd64 -e DIBS_TARGET=dhcpdd-linux -e TARGETPLATFORM=linux/amd64 pojntfx/dhcpdd:linux-amd64 /usr/local/bin/dhcpdd --help
2121
chartTests: helm install dhcpdd .bin/chart/dhcpdd-*.tgz && helm delete dhcpdd
2222
start: |
2323
if [ "$DIBS_DEBUG" = "true" ]; then
@@ -57,7 +57,7 @@ targets:
5757
build: GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -tags netgo -ldflags '-extldflags "-static"' -o .bin/binaries/dhcpdd-linux-arm64 cmd/dhcpdd/main.go
5858
unitTests: go test -v ./...
5959
integrationTests: .bin/binaries/dhcpdd-linux-arm64 --help
60-
imageTests: docker run --platform linux/arm64 -e DIBS_TARGET=linux -e TARGETPLATFORM=linux/arm64 pojntfx/dhcpdd:linux-arm64 /usr/local/bin/dhcpdd --help
60+
imageTests: docker run --platform linux/arm64 -e DIBS_TARGET=dhcpdd-linux -e TARGETPLATFORM=linux/arm64 pojntfx/dhcpdd:linux-arm64 /usr/local/bin/dhcpdd --help
6161
chartTests: helm install dhcpdd .bin/chart/dhcpdd-*.tgz && helm delete dhcpdd
6262
start: |
6363
if [ "$DIBS_DEBUG" = "true" ]; then
@@ -85,6 +85,27 @@ targets:
8585
file: Dockerfile.chartTests
8686
context: .
8787
tag: pojntfx/dhcpdd-chart-tests:linux-arm64
88+
- name: dhcpdd-darwin
89+
platforms:
90+
- identifier: darwin/amd64
91+
paths:
92+
watch: .
93+
include: (.*)\.go
94+
gitRepoRoot: .
95+
commands:
96+
generateSources: go generate ./...
97+
build: GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -tags netgo -ldflags '-extldflags "-static"' -o .bin/binaries/dhcpdd-linux-amd64 cmd/dhcpdd/main.go
98+
unitTests: go test -v ./...
99+
integrationTests: .bin/binaries/dhcpdd-darwin-amd64 --help
100+
start: |
101+
if [ "$DIBS_DEBUG" = "true" ]; then
102+
pkill -9 dlv || true
103+
pkill -9 dhcpdd || true
104+
.bin/binaries/dhcpdd-darwin-amd64 &
105+
dlv attach $! --headless --listen=:31441 --api-version=2 --accept-multiclient || true
106+
else
107+
.bin/binaries/dhcpdd-darwin-amd64
108+
fi
88109
- name: dhcpdctl-linux
89110
platforms:
90111
- identifier: linux/amd64

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.14
55
require (
66
github.com/fatih/color v1.9.0 // indirect
77
github.com/ghodss/yaml v1.0.0
8+
github.com/golang/protobuf v1.3.2
89
github.com/gosuri/uitable v0.0.4
910
github.com/mattn/go-runewidth v0.0.8 // indirect
1011
github.com/rakyll/statik v0.1.7

0 commit comments

Comments
 (0)