-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:add vlogs server. #5343
base: main
Are you sure you want to change the base?
feat:add vlogs server. #5343
Changes from 7 commits
10c785e
18f5f84
d3ff113
695c592
afbadf2
7c073e2
1f9161d
426c2f6
01b3478
160ae72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ use ( | |
./exceptionmonitor | ||
./launchpad | ||
./pay | ||
./vlogs | ||
) | ||
|
||
replace ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# FROM scratch | ||
FROM gcr.io/distroless/static:nonroot | ||
# FROM gengweifeng/gcr-io-distroless-static-nonroot | ||
ARG TARGETARCH | ||
COPY bin/service-launchpad-$TARGETARCH /manager | ||
EXPOSE 9090 | ||
USER 65532:65532 | ||
|
||
ENTRYPOINT ["/manager"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
IMG ?= ghcr.io/labring/sealos-launchpad-service:latest | ||
|
||
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) | ||
ifeq (,$(shell go env GOBIN)) | ||
GOBIN=$(shell go env GOPATH)/bin | ||
else | ||
GOBIN=$(shell go env GOBIN) | ||
endif | ||
|
||
# only support linux, non cgo | ||
PLATFORMS ?= linux_arm64 linux_amd64 | ||
GOOS=linux | ||
CGO_ENABLED=0 | ||
GOARCH=$(shell go env GOARCH) | ||
|
||
GO_BUILD_FLAGS=-trimpath -ldflags "-s -w" | ||
|
||
.PHONY: all | ||
all: build | ||
|
||
##@ General | ||
|
||
# The help target prints out all targets with their descriptions organized | ||
# beneath their categories. The categories are represented by '##@' and the | ||
# target descriptions by '##'. The awk commands is responsible for reading the | ||
# entire set of makefiles included in this invocation, looking for lines of the | ||
# file as xyz: ## something, and then pretty-format the target and help. Then, | ||
# if there's a line with ##@ something, that gets pretty-printed as a category. | ||
# More info on the usage of ANSI control characters for terminal formatting: | ||
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters | ||
# More info on the awk command: | ||
# http://linuxcommand.org/lc3_adv_awk.php | ||
|
||
.PHONY: help | ||
help: ## Display this help. | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
||
##@ Build | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f $(SERVICE_NAME) | ||
|
||
.PHONY: build | ||
build: clean ## Build service-hub binary. | ||
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) go build $(GO_BUILD_FLAGS) -o bin/manager main.go | ||
|
||
.PHONY: docker-build | ||
docker-build: build | ||
mv bin/manager bin/service-launchpad-${TARGETARCH} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change binary name |
||
docker build -t $(IMG) . | ||
|
||
.PHONY: docker-push | ||
docker-push: | ||
docker push $(IMG) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# RESTServer | ||
|
||
## Description | ||
|
||
restserver for victoria logs | ||
|
||
## Getting Started | ||
|
||
### Running on the cluster | ||
|
||
1. Build and push your image to the location specified by `IMG`: | ||
|
||
```sh | ||
make docker-build docker-push IMG=<some-registry>/sealos-cloud-database-monitor:tag | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change name |
||
``` | ||
|
||
2. Deploy the restserver: | ||
|
||
```sh | ||
kubectl apply -f deploy/manifests/ | ||
``` | ||
|
||
### How it works | ||
|
||
To enable the database frontend application to retrieve monitoring data, you need to modify the environment variable `MONITOR_URL` of the frontend deployment to the corresponding address of the restserver. | ||
|
||
Additionally, to configure the data source, you need to set the environment variable `VM_SERVICE_HOST` of the restserver deployment to the correct address. | ||
|
||
``` | ||
e.g. | ||
http://prometheus.sealos.svc.cluster.local | ||
``` | ||
|
||
## License | ||
|
||
Copyright 2023. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
||
you may not use this file except in compliance with the License. | ||
|
||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
|
||
distributed under the License is distributed on an "AS IS" BASIS, | ||
|
||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
|
||
See the License for the specific language governing permissions and | ||
|
||
limitations under the License. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
server: | ||
addr: ":8428" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM scratch | ||
COPY registry registry | ||
COPY manifests manifests | ||
|
||
CMD ["kubectl apply -f manifests/deploy.yaml"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
### docker image build and deploy | ||
```bash | ||
make docker-build IMG=$(YourImageName) | ||
# edit deploy/manifests/depoly.yaml and deploy | ||
kubectl apply -f deploy/manifests/depoly.yaml | ||
``` | ||
|
||
### cluster image build and deploy | ||
```bash | ||
``` | ||
|
||
### Victoria Metrics | ||
|
||
In order to prevent performance degradation or abnormal behavior caused by excessive data size in Prometheus, VictoriaMetrics is utilized for data collection. | ||
|
||
> By default, we use kb-prometheus-server for the data collection service. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app: launchpad-vlogs | ||
name: launchpad-vlogs-config | ||
namespace: sealos | ||
|
||
data: | ||
config.yml: | | ||
server: | ||
addr: ":8428" | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: launchpad-vlogs | ||
name: launchpad-vlogs-deployment | ||
namespace: sealos | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: launchpad-vlogs | ||
strategy: | ||
type: Recreate | ||
template: | ||
metadata: | ||
labels: | ||
app: launchpad-vlogs | ||
spec: | ||
containers: | ||
- args: | ||
- /config/config.yml | ||
command: | ||
- /manager | ||
env: | ||
- name: VM_SERVICE_HOST | ||
value: http://vmsingle-victoria-metrics-k8s-stack.vm.svc:8429 | ||
image: ghcr.io/labring/sealos-launchpad-service:latest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change name |
||
imagePullPolicy: Always | ||
name: launchpad-monitor | ||
ports: | ||
- containerPort: 8428 | ||
protocol: TCP | ||
resources: | ||
limits: | ||
cpu: 500m | ||
memory: 1Gi | ||
requests: | ||
cpu: 5m | ||
memory: 64Mi | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
runAsNonRoot: true | ||
terminationMessagePath: /dev/termination-log | ||
terminationMessagePolicy: File | ||
volumeMounts: | ||
- mountPath: /config | ||
name: config-vol | ||
dnsPolicy: ClusterFirst | ||
restartPolicy: Always | ||
volumes: | ||
- configMap: | ||
defaultMode: 420 | ||
name: launchpad-monitor-config | ||
name: config-vol | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: launchpad-vlogs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. name |
||
name: launchpad-vlogs | ||
namespace: sealos | ||
spec: | ||
ports: | ||
- name: http | ||
port: 8428 | ||
protocol: TCP | ||
targetPort: 8428 | ||
selector: | ||
app: launchpad-vlogs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module github.com/labring/sealos/service/vlogs | ||
|
||
go 1.22 | ||
|
||
require ( | ||
github.com/labring/sealos/service v0.0.0-00010101000000-000000000000 | ||
gopkg.in/yaml.v2 v2.4.0 | ||
) | ||
|
||
replace github.com/labring/sealos/service => ../../service |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"log" | ||
"net" | ||
"net/http" | ||
"os" | ||
|
||
vlogsServer "github.com/labring/sealos/service/vlogs/server" | ||
) | ||
|
||
type RestartableServer struct { | ||
configFile string | ||
} | ||
|
||
func (rs *RestartableServer) Serve(c *vlogsServer.Config) { | ||
var vs, err = vlogsServer.NewVLogsServer(c) | ||
if err != nil { | ||
fmt.Printf("Failed to create auth server: %s\n", err) | ||
return | ||
} | ||
|
||
hs := &http.Server{ | ||
Addr: c.Server.ListenAddress, | ||
Handler: vs, | ||
} | ||
|
||
var listener net.Listener | ||
listener, err = net.Listen("tcp", c.Server.ListenAddress) | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
fmt.Printf("Serve on %s\n", c.Server.ListenAddress) | ||
|
||
if err := hs.Serve(listener); err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
} | ||
|
||
func main() { | ||
log.SetOutput(os.Stdout) | ||
log.SetFlags(log.LstdFlags | log.Lshortfile) | ||
flag.Parse() | ||
|
||
cf := flag.Arg(0) | ||
if cf == "" { | ||
fmt.Println("Config file not sepcified") | ||
return | ||
} | ||
|
||
config, err := vlogsServer.InitConfig(cf) | ||
if err != nil { | ||
fmt.Println(err) | ||
return | ||
} | ||
rs := RestartableServer{ | ||
configFile: cf, | ||
} | ||
rs.Serve(config) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change image name