File tree 3 files changed +113
-5
lines changed
3 files changed +113
-5
lines changed Original file line number Diff line number Diff line change 1
- FROM golang:1.24.0 as builder
1
+ FROM --platform=$BUILDPLATFORM golang:1.24.0 as builder
2
2
3
- WORKDIR /workspace
3
+ WORKDIR /app
4
4
ENV GOPROXY=https://goproxy.cn,direct
5
5
6
+ COPY go.mod go.sum ./
7
+ RUN go mod download
8
+
6
9
COPY . .
7
10
8
- # ### Build
9
- RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build .
10
11
11
- CMD ["/workspace/kube-node-metrics" ]
12
+ ARG TARGETARCH
13
+ RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -o kube-node-metrics .
14
+
15
+ FROM scratch
16
+ WORKDIR /
17
+ COPY --from=builder /app/kube-node-metrics .
18
+
19
+ EXPOSE 19191
20
+
21
+ CMD ["/kube-node-metrics" ]
Original file line number Diff line number Diff line change
1
+ .PHONY :
2
+ build :
3
+ go fmt ./...
4
+ go mod tidy
5
+ go vet ./...
6
+ go build .
7
+
8
+ .PHONY :
9
+ build-docker :
10
+ docker buildx build --platform linux/amd64,linux/arm64 \
11
+ -t xiaozongyang/kube-node-metrics:latest \
12
+ --push .
13
+
14
+ .PHONY :
15
+ clean :
16
+ rm kube-node-metrics
Original file line number Diff line number Diff line change
1
+ apiVersion : v1
2
+ kind : ServiceAccount
3
+ metadata :
4
+ name : kube-node-metrics
5
+ namespace : default
6
+
7
+ ---
8
+ apiVersion : rbac.authorization.k8s.io/v1
9
+ kind : ClusterRole
10
+ metadata :
11
+ name : kube-node-metrics
12
+ rules :
13
+ - apiGroups : [""]
14
+ resources : ["nodes"]
15
+ verbs : ["list", "watch"]
16
+ - apiGroups : [""]
17
+ resources : ["pods"]
18
+ verbs : ["list", "watch"]
19
+ ---
20
+ apiVersion : rbac.authorization.k8s.io/v1
21
+ kind : ClusterRoleBinding
22
+ metadata :
23
+ name : kube-node-metrics
24
+ roleRef :
25
+ apiGroup : rbac.authorization.k8s.io
26
+ kind : ClusterRole
27
+ name : kube-node-metrics
28
+ subjects :
29
+ - kind : ServiceAccount
30
+ name : kube-node-metrics
31
+ namespace : default
32
+
33
+ ---
34
+ apiVersion : apps/v1
35
+ kind : Deployment
36
+ metadata :
37
+ name : kube-node-metrics
38
+ namespace : default
39
+ spec :
40
+ replicas : 1
41
+ selector :
42
+ matchLabels :
43
+ app : kube-node-metrics
44
+ template :
45
+ metadata :
46
+ labels :
47
+ app : kube-node-metrics
48
+ spec :
49
+ serviceAccountName : kube-node-metrics
50
+ containers :
51
+ - name : kubep-node-metrics
52
+ image : docker.io/xiaozongyang/kube-node-metrics:latest
53
+ env :
54
+ - name : FULL_SYNC_INTERVAL
55
+ value : " 2m"
56
+ ports :
57
+ - containerPort : 19191
58
+ name : metrics
59
+ resources :
60
+ limits :
61
+ memory : " 2Gi"
62
+ cpu : " 2000m"
63
+ requests :
64
+ memory : " 64Mi"
65
+ cpu : " 50m"
66
+ tolerations :
67
+ - operator : Exists
68
+ ---
69
+ apiVersion : v1
70
+ kind : Service
71
+ metadata :
72
+ name : kube-node-metrics
73
+ namespace : default
74
+ labels :
75
+ app : kube-node-metrics
76
+ spec :
77
+ selector :
78
+ app : kube-node-metrics
79
+ ports :
80
+ - port : 19191
81
+ targetPort : 19191
82
+ name : metrics
You can’t perform that action at this time.
0 commit comments