-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
674 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 |
---|---|---|
|
@@ -6,3 +6,4 @@ out/ | |
docs/_site | ||
.idea | ||
open-falcon | ||
build |
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 alpine:3.7 | ||
LABEL maintainer [email protected] | ||
USER root | ||
|
||
ENV FALCON_DIR=/open-falcon | ||
# agent | ||
RUN apk add --no-cache ca-certificates git curl | ||
# alarm | ||
ADD https://github.com/golang/go/raw/master/lib/time/zoneinfo.zip /usr/local/go/lib/time/zoneinfo.zip | ||
|
||
COPY build/%%MODULE_NAME%% ${FALCON_DIR}/%%MODULE_NAME%% | ||
WORKDIR ${FALCON_DIR} | ||
|
||
CMD ["/open-falcon/%%MODULE_NAME%%/bin/falcon-%%MODULE_NAME%%", "-c", "/open-falcon/%%MODULE_NAME%%/config/cfg.json"] |
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,23 @@ | ||
## 分布式部署 open-falcon 到 k8s 集群 | ||
|
||
### 构建 | ||
|
||
克隆源码: | ||
|
||
```shell | ||
git clone https://github.com/open-falcon/falcon-plus.git && cd falcon-plus | ||
``` | ||
|
||
编译源码并构建 Docker 镜像 | ||
|
||
```shell | ||
./docker/k8s-cluster/build.sh | ||
``` | ||
|
||
### 部署 | ||
|
||
注意点: | ||
|
||
1. graph 为有状态组件,部署方式为每个节点一个 Deployment,同时 replica 设置为 1 | ||
2. 所有配置文件使用挂载目录的方式持久化,可以改为 ConfigMap 管理配置 | ||
3. 镜像可以使用构建脚本自己构建后推送到自己的私仓使用(推荐),或者直接使用我构建好的,仓库地址在 docker/k8s-cluster/build.sh 查看或修改 |
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,47 @@ | ||
#!/bin/bash | ||
MODULES=( | ||
'agent' | ||
'aggregator' | ||
'alarm' | ||
'api' | ||
'gateway' | ||
'graph' | ||
'hbs' | ||
'judge' | ||
'nodata' | ||
'transfer' | ||
) | ||
DOCKER_REGISTRY=registry.cn-hangzhou.aliyuncs.com/open-falcon | ||
VERSION=v0.3 | ||
|
||
clean() { | ||
echo "clean..." | ||
if [ -d "build" ]; then | ||
rm -rf build/ | ||
fi | ||
mkdir build | ||
} | ||
|
||
build() { | ||
echo "build source..." | ||
docker run -it --rm \ | ||
--name build \ | ||
-v "$(pwd)":"/go/src/github.com/open-falcon/falcon-plus" \ | ||
-w "/go/src/github.com/open-falcon/falcon-plus" \ | ||
openfalcon/makegcc-golang:1.10-alpine \ | ||
docker/k8s-cluster/init.sh | ||
} | ||
|
||
buildDockerImages() { | ||
echo "build docker images..." | ||
for i in "${MODULES[@]}"; do | ||
echo "build $i" | ||
awk -v module="$i" '{ gsub(/%%MODULE_NAME%%/, module); print $0 }' docker/k8s-cluster/Dockerfile.tpl > docker/k8s-cluster/Dockerfile | ||
docker build -f docker/k8s-cluster/Dockerfile -t $DOCKER_REGISTRY/$i:$VERSION . | ||
rm docker/k8s-cluster/Dockerfile | ||
done | ||
} | ||
|
||
clean | ||
build | ||
buildDockerImages |
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,7 @@ | ||
#!/bin/sh | ||
|
||
apk add --no-cache ca-certificates git bash \ | ||
&& make all \ | ||
&& make pack4docker \ | ||
&& tar -zxf open-falcon-v*.tar.gz -C build \ | ||
&& rm open-falcon-v*.tar.gz |
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,54 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
namespace: open-falcon | ||
name: falcon-agent | ||
labels: | ||
app: open-falcon | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- name: http | ||
port: 1988 | ||
selector: | ||
name: falcon-agent | ||
--- | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
namespace: open-falcon | ||
name: falcon-agent | ||
labels: | ||
app: open-falcon | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
name: falcon-agent | ||
spec: | ||
containers: | ||
- name: falcon-agent | ||
image: registry.cn-hangzhou.aliyuncs.com/open-falcon/agent:v0.3 | ||
imagePullPolicy: IfNotPresent | ||
ports: | ||
- containerPort: 1988 | ||
name: http | ||
protocol: TCP | ||
volumeMounts: | ||
- mountPath: /open-falcon/agent/config | ||
name: falcon-agent-config | ||
- mountPath: /etc/localtime | ||
name: tz-config | ||
volumes: | ||
- flexVolume: | ||
driver: alicloud/nas | ||
options: | ||
path: /open-falcon/falcon-agent/config | ||
server: xxx.cn-hangzhou.nas.aliyuncs.com | ||
vers: "4.0" | ||
name: falcon-agent-config | ||
- hostPath: | ||
path: /etc/localtime | ||
type: '' | ||
name: tz-config |
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,54 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
namespace: open-falcon | ||
name: falcon-aggregator | ||
labels: | ||
app: open-falcon | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- name: http | ||
port: 6055 | ||
selector: | ||
name: falcon-aggregator | ||
--- | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
namespace: open-falcon | ||
name: falcon-aggregator | ||
labels: | ||
app: open-falcon | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
name: falcon-aggregator | ||
spec: | ||
containers: | ||
- name: falcon-aggregator | ||
image: registry.cn-hangzhou.aliyuncs.com/open-falcon/aggregator:v0.3 | ||
imagePullPolicy: IfNotPresent | ||
ports: | ||
- containerPort: 6055 | ||
name: http | ||
protocol: TCP | ||
volumeMounts: | ||
- mountPath: /open-falcon/aggregator/config | ||
name: falcon-aggregator-config | ||
- mountPath: /etc/localtime | ||
name: tz-config | ||
volumes: | ||
- flexVolume: | ||
driver: alicloud/nas | ||
options: | ||
path: /open-falcon/falcon-aggregator/config | ||
server: xxx.cn-hangzhou.nas.aliyuncs.com | ||
vers: "4.0" | ||
name: falcon-aggregator-config | ||
- hostPath: | ||
path: /etc/localtime | ||
type: '' | ||
name: tz-config |
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,54 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
namespace: open-falcon | ||
name: falcon-alarm | ||
labels: | ||
app: open-falcon | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- name: http | ||
port: 9912 | ||
selector: | ||
name: falcon-alarm | ||
--- | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
namespace: open-falcon | ||
name: falcon-alarm | ||
labels: | ||
app: open-falcon | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
name: falcon-alarm | ||
spec: | ||
containers: | ||
- name: falcon-alarm | ||
image: registry.cn-hangzhou.aliyuncs.com/open-falcon/alarm:v0.3 | ||
imagePullPolicy: IfNotPresent | ||
ports: | ||
- containerPort: 9912 | ||
name: http | ||
protocol: TCP | ||
volumeMounts: | ||
- mountPath: /open-falcon/alarm/config | ||
name: falcon-alarm-config | ||
- mountPath: /etc/localtime | ||
name: tz-config | ||
volumes: | ||
- flexVolume: | ||
driver: alicloud/nas | ||
options: | ||
path: /open-falcon/falcon-alarm/config | ||
server: xxx.cn-hangzhou.nas.aliyuncs.com | ||
vers: "4.0" | ||
name: falcon-alarm-config | ||
- hostPath: | ||
path: /etc/localtime | ||
type: '' | ||
name: tz-config |
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,54 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
namespace: open-falcon | ||
name: falcon-api | ||
labels: | ||
app: open-falcon | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- name: http | ||
port: 8080 | ||
selector: | ||
name: falcon-api | ||
--- | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
namespace: open-falcon | ||
name: falcon-api | ||
labels: | ||
app: open-falcon | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
name: falcon-api | ||
spec: | ||
containers: | ||
- name: falcon-api | ||
image: registry.cn-hangzhou.aliyuncs.com/open-falcon/api:v0.3 | ||
imagePullPolicy: IfNotPresent | ||
ports: | ||
- containerPort: 8080 | ||
name: http | ||
protocol: TCP | ||
volumeMounts: | ||
- mountPath: /open-falcon/api/config | ||
name: falcon-api-config | ||
- mountPath: /etc/localtime | ||
name: tz-config | ||
volumes: | ||
- flexVolume: | ||
driver: alicloud/nas | ||
options: | ||
path: /open-falcon/falcon-api/config | ||
server: xxx.cn-hangzhou.nas.aliyuncs.com | ||
vers: "4.0" | ||
name: falcon-api-config | ||
- hostPath: | ||
path: /etc/localtime | ||
type: '' | ||
name: tz-config |
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,67 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
namespace: open-falcon | ||
name: falcon-dashboard | ||
labels: | ||
app: open-falcon | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- name: http | ||
port: 8081 | ||
selector: | ||
name: falcon-dashboard | ||
--- | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
namespace: open-falcon | ||
name: falcon-dashboard | ||
labels: | ||
app: open-falcon | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
name: falcon-dashboard | ||
spec: | ||
containers: | ||
- name: falcon-dashboard | ||
image: openfalcon/falcon-dashboard:v0.2.1 | ||
command: ["sh","-c","cd /open-falcon/dashboard && ./control startfg"] | ||
imagePullPolicy: IfNotPresent | ||
ports: | ||
- containerPort: 8081 | ||
env: | ||
- name: API_ADDR | ||
value: http://falcon-api:8080/api/v1 | ||
- name: PORTAL_DB_HOST | ||
value: 127.0.0.1 | ||
- name: PORTAL_DB_PORT | ||
value: "3306" | ||
- name: PORTAL_DB_USER | ||
value: root | ||
- name: PORTAL_DB_PASS | ||
value: xxx | ||
- name: PORTAL_DB_NAME | ||
value: falcon_portal | ||
- name: ALARM_DB_HOST | ||
value: 127.0.0.1 | ||
- name: ALARM_DB_PORT | ||
value: "3306" | ||
- name: ALARM_DB_USER | ||
value: root | ||
- name: ALARM_DB_PASS | ||
value: root | ||
- name: ALARM_DB_NAME | ||
value: alarms | ||
volumeMounts: | ||
- mountPath: /etc/localtime | ||
name: tz-config | ||
volumes: | ||
- hostPath: | ||
path: /etc/localtime | ||
type: '' | ||
name: tz-config |
Oops, something went wrong.