Skip to content
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

Launchpad #4645

Merged
merged 32 commits into from Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1291be1
update kafka monitor
wallyxjh Nov 29, 2023
824f877
Merge branch 'labring:main' into main
wallyxjh Nov 30, 2023
38c5794
Merge branch 'labring:main' into main
wallyxjh Dec 6, 2023
6af10b6
Merge branch 'labring:main' into main
wallyxjh Dec 6, 2023
265b427
Merge branch 'labring:main' into main
wallyxjh Dec 7, 2023
e29bd00
Merge branch 'labring:main' into main
wallyxjh Dec 14, 2023
395910a
Merge branch 'labring:main' into main
wallyxjh Dec 20, 2023
165ac80
Merge branch 'labring:main' into main
wallyxjh Dec 25, 2023
e20b558
Merge branch 'labring:main' into main
wallyxjh Dec 26, 2023
9507314
Merge branch 'labring:main' into main
wallyxjh Jan 5, 2024
c9d0caa
Merge branch 'labring:main' into main
wallyxjh Jan 29, 2024
ac859f5
Merge branch 'labring:main' into main
wallyxjh Mar 18, 2024
604164e
launchpad monitor
wallyxjh Mar 29, 2024
c92f2c2
launchpad monitor
wallyxjh Mar 29, 2024
7881e7d
launchpad monitor
wallyxjh Mar 29, 2024
589bc7e
launchpad monitor
wallyxjh Mar 29, 2024
2f54c21
launchpad monitor
wallyxjh Apr 1, 2024
0cb3872
launchpad monitor
wallyxjh Apr 1, 2024
3d205dd
launchpad monitor
wallyxjh Apr 1, 2024
2fd405b
launchpad monitor
wallyxjh Apr 1, 2024
3218af9
launchpad monitor
wallyxjh Apr 1, 2024
d84b6c7
launchpad monitor
wallyxjh Apr 1, 2024
3ab016a
launchpad monitor
wallyxjh Apr 1, 2024
657e8c3
Merge branch 'main' into launchpad
lingdie Apr 1, 2024
f05c01d
launchpad monitor
wallyxjh Apr 1, 2024
cd772b5
Merge remote-tracking branch 'origin/launchpad' into launchpad
wallyxjh Apr 1, 2024
b279bed
launchpad monitor
wallyxjh Apr 1, 2024
15000dd
launchpad monitor
wallyxjh Apr 1, 2024
e2a2a99
launchpad monitor
wallyxjh Apr 1, 2024
cf1041e
launchpad monitor
wallyxjh Apr 1, 2024
0513f95
launchpad monitor
wallyxjh Apr 1, 2024
9203045
fix build error.
lingdie Apr 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/services.yml
Expand Up @@ -87,7 +87,7 @@ jobs:
strategy:
matrix:
## TODO: add more modules
module: [database, pay, account, minio]
module: [database, pay, account, minio, launchpad]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -182,7 +182,7 @@ jobs:
strategy:
matrix:
## TODO: add more modules
module: [database, pay, account, minio]
module: [database, pay, account, minio, launchpad]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions frontend/providers/applaunchpad/deploy/Kubefile
Expand Up @@ -10,5 +10,6 @@ ENV cloudPort=""

ENV certSecretName="wildcard-cert"
ENV ingressSecret="wildcard-cert"
ENv monitorUrl="http://database-monitor.sealos.svc.cluster.local:9090"

CMD ["kubectl apply -f manifests"]
Expand Up @@ -45,6 +45,8 @@ spec:
- env:
- name: SEALOS_DOMAIN
value: {{ .cloudDomain }}
- name: MONITOR_URL
value {{ .monitorUrl }}
- name: DOMAIN_PORT
value: "{{ if .cloudPort }}:{{ .cloudPort }}{{ end }}"
- name: INGRESS_SECRET
Expand Down
5 changes: 3 additions & 2 deletions scripts/cloud/install.sh
Expand Up @@ -26,6 +26,7 @@ cilium_version=${cilium_version:-"1.12.14"}
cert_manager_version=${cert_manager_version:-"1.13.3"}
helm_version=${helm_version:-"3.12.0"}
openebs_version=${openebs_version:-"3.4.0"}
victoria_metrics_k8s_stack_version=${victoria-metrics-k8s-stack_version:-"1.96.0"}
lingdie marked this conversation as resolved.
Show resolved Hide resolved
ingress_nginx_version=${ingress_nginx_version:-"1.5.1"}
kubeblocks_version=${kubeblocks_version:-"0.6.4"}
metrics_server_version=${metrics_server_version:-"0.6.4"}
Expand Down Expand Up @@ -252,7 +253,7 @@ init() {
pull_image "ingress-nginx" "v${ingress_nginx_version#v:-1.5.1}"
pull_image "kubeblocks" "v${kubeblocks_version#v:-0.6.4}"
pull_image "metrics-server" "v${metrics_server_version#v:-0.6.4}"
pull_image "kube-prometheus-stack" "v${kube_prometheus_stack_version#v:-0.63.0}"
pull_image "victoria-metrics-k8s-stack" "v${victoria_metrics_k8s_stack_version#v:-1.96.0}"
pull_image "sealos-cloud" "${cloud_version}"
}

Expand Down Expand Up @@ -619,6 +620,7 @@ execute_commands() {
sealos run "${image_registry}/${image_repository}/cert-manager:v${cert_manager_version#v:-1.8.0}"
sealos run "${image_registry}/${image_repository}/openebs:v${openebs_version#v:-3.4.0}"
sealos run "${image_registry}/${image_repository}/metrics-server:v${metrics_server_version#v:-0.6.4}"
sealos run "${image_registry}/${image_repository}/victoria-metrics-k8s-stack:v${victoria_metrics_k8s_stack_version#v:-1.96.0}"
kubectl get sc openebs-backup > /dev/null 2>&1 || kubectl create -f - <<EOF
apiVersion: storage.k8s.io/v1
kind: StorageClass
Expand All @@ -637,7 +639,6 @@ EOF
kbcli addon enable prometheus

get_prompt "installing_monitoring"
sealos run "${image_registry}/${image_repository}/kube-prometheus-stack:v${kube_prometheus_stack_version#v:-0.63.0}"

# TODO use sealos run to install cockroachdb-operator
kubectl apply -f https://raw.githubusercontent.com/cockroachdb/cockroach-operator/v2.12.0/install/crds.yaml
Expand Down
9 changes: 9 additions & 0 deletions service/launchpad/Dockerfile
@@ -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"]
55 changes: 55 additions & 0 deletions service/launchpad/Makefile
@@ -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}
docker build -t $(IMG) .

.PHONY: docker-push
docker-push:
docker push $(IMG)
54 changes: 54 additions & 0 deletions service/launchpad/README.md
@@ -0,0 +1,54 @@
# RESTServer

## Description

restserver for database monitoring

## 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
```

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.
2 changes: 2 additions & 0 deletions service/launchpad/config/config.yml
@@ -0,0 +1,2 @@
server:
addr: ":8428"
5 changes: 5 additions & 0 deletions service/launchpad/deploy/Kubefile
@@ -0,0 +1,5 @@
FROM scratch
COPY registry registry
COPY manifests manifests

CMD ["kubectl apply -f manifests/deploy.yaml"]
16 changes: 16 additions & 0 deletions service/launchpad/deploy/README.md
@@ -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.
86 changes: 86 additions & 0 deletions service/launchpad/deploy/manifests/deploy.yaml
@@ -0,0 +1,86 @@
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: launchpad-monitor
name: launchpad-monitor-config
namespace: sealos
data:
config.yml: |
server:
addr: ":8428"
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: launchpad-monitor
name: launchpad-monitor-deployment
namespace: sealos
spec:
replicas: 1
selector:
matchLabels:
app: launchpad-monitor
strategy:
type: Recreate
template:
metadata:
labels:
app: launchpad-monitor
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
imagePullPolicy: Always
name: launchpad-monitor
ports:
- containerPort: 8428
protocol: TCP
resources:
lingdie marked this conversation as resolved.
Show resolved Hide resolved
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-monitor
name: launchpad-monitor
namespace: sealos
spec:
ports:
- name: http
port: 8428
protocol: TCP
targetPort: 8428
selector:
app: launchpad-monitor
3 changes: 3 additions & 0 deletions service/launchpad/go.mod
@@ -0,0 +1,3 @@
module github.com/wally/sealos-latest-1/service/launchpad
lingdie marked this conversation as resolved.
Show resolved Hide resolved

go 1.20
64 changes: 64 additions & 0 deletions service/launchpad/main.go
@@ -0,0 +1,64 @@
package main

import (
"flag"
"fmt"
"log"
"net"
"net/http"
"os"

"github.com/labring/sealos/service/launchpad/server"
)

type RestartableServer struct {
configFile string
}

func (rs *RestartableServer) Serve(c *server.Config) {
var vs, err = server.NewVMServer(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) // 将日志输出定向到标准输出(stdout)
log.SetFlags(log.LstdFlags | log.Lshortfile)
flag.Parse()

cf := flag.Arg(0)
if cf == "" {
fmt.Println("Config file not sepcified")
return
}

config, err := server.InitConfig(cf)
if err != nil {
fmt.Println(err)
return
}
rs := RestartableServer{
configFile: cf,
}
rs.Serve(config)
}