-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: niejiangang <[email protected]>
- Loading branch information
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
"net/http" | ||
_ "net/http/pprof" | ||
|
||
"github.com/Kindling-project/kindling/collector/pkg/metadata/kubernetes" | ||
"github.com/Kindling-project/kindling/collector/pkg/metadata/metaprovider/service" | ||
) | ||
|
||
func main() { | ||
authType := flag.String("authType", "serviceAccount", "AuthType describes the type of authentication to use for the K8s API, support 'kubeConfig' or 'serviceAccount'. ") | ||
kubeConfigPath := flag.String("kubeConfig", "/root/.kube/config", "kubeConfig describe the filePath to your kubeConfig,only used when authType is 'kubeConfig'") | ||
httpPort := flag.Int("http-port", 9504, "port describe which port will be used to expose data") | ||
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.") | ||
logInterval := flag.Int("logInterval", 120, "Interval(Second) to show how many event mp received, default 120s") | ||
|
||
flag.Parse() | ||
|
||
config := &service.Config{ | ||
KubeAuthType: kubernetes.AuthType(*authType), | ||
KubeConfigDir: *kubeConfigPath, | ||
EnableFetchReplicaSet: *enableFetchReplicaset, | ||
LogInterval: *logInterval, | ||
} | ||
|
||
if mdw, err := service.NewMetaDataWrapper(config); err != nil { | ||
log.Fatalf("create MetaData Wrapper failed, err: %v", err) | ||
} else { | ||
http.HandleFunc("/listAndWatch", mdw.ListAndWatch) | ||
log.Printf("[http] service start at port: %d", *httpPort) | ||
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *httpPort), nil)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM golang:1.20.2-bullseye AS builder | ||
WORKDIR /build | ||
|
||
ENV GOPROXY https://goproxy.cn | ||
COPY go.mod go.sum ./ | ||
RUN go mod download && go mod verify | ||
|
||
COPY . . | ||
RUN go build -v -o metadata-provider ./cmd/metadata-provider | ||
|
||
FROM debian:bullseye-slim AS runner | ||
WORKDIR /app | ||
COPY --from=builder /build/metadata-provider /app/ | ||
CMD ["/app/metadata-provider"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
k8s-app: metadata-provider | ||
name: metadata-provider | ||
namespace: kindling | ||
spec: | ||
selector: | ||
matchLabels: | ||
k8s-app: metadata-provider | ||
template: | ||
metadata: | ||
labels: | ||
k8s-app: metadata-provider | ||
spec: | ||
serviceAccount: kindling-agent | ||
containers: | ||
- name: metadata-provider | ||
image: kindlingproject/metadata-provider:v1.0 | ||
command: ["./metadata-provider"] | ||
args: | ||
- --http-port=9504 | ||
- --authType=serviceAccount | ||
# - --kubeConfig=/root/.kube/config | ||
imagePullPolicy: Always | ||
securityContext: | ||
privileged: true | ||
resources: | ||
limits: | ||
memory: 1Gi | ||
requests: | ||
memory: 300Mi | ||
ports: | ||
- containerPort: 9504 | ||
protocol: TCP | ||
name: http | ||
restartPolicy: Always | ||
terminationGracePeriodSeconds: 30 | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: metadata-provider | ||
namespace: kindling | ||
spec: | ||
ports: | ||
- port: 9504 | ||
protocol: TCP | ||
targetPort: http | ||
selector: | ||
k8s-app: metadata-provider |