Skip to content

Commit dab5dfa

Browse files
committed
feat: add depoy manifest
Signed-off-by: niejiangang <niejiangang@harmonycloud.cn>
1 parent de3bdce commit dab5dfa

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package main
2+
3+
import (
4+
"flag"
5+
"fmt"
6+
"log"
7+
"net/http"
8+
_ "net/http/pprof"
9+
10+
"github.com/Kindling-project/kindling/collector/pkg/metadata/kubernetes"
11+
"github.com/Kindling-project/kindling/collector/pkg/metadata/metaprovider/service"
12+
)
13+
14+
func main() {
15+
authType := flag.String("authType", "serviceAccount", "AuthType describes the type of authentication to use for the K8s API, support 'kubeConfig' or 'serviceAccount'. ")
16+
kubeConfigPath := flag.String("kubeConfig", "/root/.kube/config", "kubeConfig describe the filePath to your kubeConfig,only used when authType is 'kubeConfig'")
17+
httpPort := flag.Int("http-port", 9504, "port describe which port will be used to expose data")
18+
enableFetchReplicaset := flag.Bool("enableFetchReplicaset", false, "controls whether to fetch ReplicaSet information. The default value is false. It should be enabled if the ReplicaSet is used to control pods in the third-party CRD except for Deployment.")
19+
logInterval := flag.Int("logInterval", 120, "Interval(Second) to show how many event mp received, default 120s")
20+
21+
flag.Parse()
22+
23+
config := &service.Config{
24+
KubeAuthType: kubernetes.AuthType(*authType),
25+
KubeConfigDir: *kubeConfigPath,
26+
EnableFetchReplicaSet: *enableFetchReplicaset,
27+
LogInterval: *logInterval,
28+
}
29+
30+
if mdw, err := service.NewMetaDataWrapper(config); err != nil {
31+
log.Fatalf("create MetaData Wrapper failed, err: %v", err)
32+
} else {
33+
http.HandleFunc("/listAndWatch", mdw.ListAndWatch)
34+
log.Printf("[http] service start at port: %d", *httpPort)
35+
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *httpPort), nil))
36+
}
37+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM golang:1.20.2-bullseye AS builder
2+
WORKDIR /build
3+
4+
ENV GOPROXY https://goproxy.cn
5+
COPY go.mod go.sum ./
6+
RUN go mod download && go mod verify
7+
8+
COPY . .
9+
RUN go build -v -o metadata-provider ./cmd/metadata-provider
10+
11+
FROM debian:bullseye-slim AS runner
12+
WORKDIR /app
13+
COPY --from=builder /build/metadata-provider /app/
14+
CMD ["/app/metadata-provider"]
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
k8s-app: metadata-provider
6+
name: metadata-provider
7+
namespace: kindling
8+
spec:
9+
selector:
10+
matchLabels:
11+
k8s-app: metadata-provider
12+
template:
13+
metadata:
14+
labels:
15+
k8s-app: metadata-provider
16+
spec:
17+
serviceAccount: kindling-agent
18+
containers:
19+
- name: metadata-provider
20+
image: kindlingproject/metadata-provider:v1.0
21+
command: ["./metadata-provider"]
22+
args:
23+
- --http-port=9504
24+
- --authType=serviceAccount
25+
# - --kubeConfig=/root/.kube/config
26+
imagePullPolicy: Always
27+
securityContext:
28+
privileged: true
29+
resources:
30+
limits:
31+
memory: 1Gi
32+
requests:
33+
memory: 300Mi
34+
ports:
35+
- containerPort: 9504
36+
protocol: TCP
37+
name: http
38+
restartPolicy: Always
39+
terminationGracePeriodSeconds: 30
40+
41+
---
42+
apiVersion: v1
43+
kind: Service
44+
metadata:
45+
name: metadata-provider
46+
namespace: kindling
47+
spec:
48+
ports:
49+
- port: 9504
50+
protocol: TCP
51+
targetPort: http
52+
selector:
53+
k8s-app: metadata-provider

0 commit comments

Comments
 (0)