The company recently switched its monitoring system from Zabbix to Open-Falcon and needed to deploy Open-Falcon on a private Kubernetes cluster. The Open-Falcon team did not update maintenance recently, and the submitted PR did not respond, so log the deployment method here.
Apr. 15, 2019 update: PR has been accepted by the Open Falcon project team, and the project official is given a 👍, all yamL file links to adjust to the official project.
Kubernetes environment
The deployment environment is Kubernetes 1.14, see kubectl version:
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:53:57Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:45:25Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
Copy the code
Preparing the mysql service
If you already have mysql services, you can skip creating mysql services. Create mysql server as follows:
kubectl apply -f mysql.yaml
Copy the code
Then, initialize the mysql library that Open-Falcon needs to use:
sh init_mysql_data.sh
Copy the code
The script is as follows:
#! /bin/sh
mysql_pod=$(kubectl get pods | grep mysql | awk '{print $1}')
cd /tmp && \
git clone --depth=1 https://github.com/open-falcon/falcon-plus && \
cd /tmp/falcon-plus/ && \
for x in `ls ./scripts/mysql/db_schema/*.sql`; do
echo init mysql table $x. ; kubectlexec -it $mysql_pod -- mysql -uroot -p123456 < $x;
done
rm -rf /tmp/falcon-plus/
Copy the code
This script does the following:
- Obtain the POD ID of the mysql service in the cluster.
- Download the data initialization script from the Github repo of Open-Falcon.
- Execute the data initialization script to initialize the database of Open-Falcon.
- Clean temporary files and directories
Note: Change the mysql password in mysql.yaml as needed, as well as in OpenFalcon-plus and Dashboard.
Prepare the Redis service
If you already have a Redis service, you can skip this step. Create the Redis service as follows:
kubectl apply -f redis.yaml
Copy the code
Launch the Open-Falcon back-end service bucket
kubectl apply -f openfalcon-plus.yaml
Copy the code
The main point is to configure entryPoint. sh using ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
name: openfalcon-configmap
data:
entrypoint.sh: |-
#! /bin/bash
/bin/sh -c 'sleep 10 && sh ctrl.sh start graph hbs judge transfer nodata aggregator gateway api alarm' & /usr/bin/supervisord -c /etc/supervisord.conf
Copy the code
This allows you to adjust the modules that OpenFalcon starts by adjusting ConfigMap without changing the image and Deployment. Of course, in a formal environment, it is better to recompile the image from the source code. Supervisord supervises the process in a different manner than Docker.
/bin/sh -c ‘sleep 10 && sh ctrl.sh start graph hbs judge transfer nodata aggregator gateway api alarm’ & The /usr/bin/supervisor. conf command is designed to run on the supervisord. it is designed to run on the /usr/bin/supervisor. conf command, and it is designed to run on the /usr/bin/supervisor.
An open – falcon – dashboard
kubectl apply -f openfalcon-dashboard.yaml
Copy the code
The dashboard deployment focuses on the API_ADDR environment variable, which refers to the Open Falcon service in the Kubernetes cluster. I have been lazy here and defined directly in Deployment, the logical way would be to use ConfigMap.
Containers: -name: open-falcon-dashboard image: openfalcon/falcon-dashboard:v0.2.1command: ["sh"."-c"."cd /open-falcon/dashboard && ./control startfg"]
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8081
env:
- name: API_ADDR
value: http://open-falcon:8080/api/v1
- name: PORTAL_DB_HOST
value: mysql
- name: PORTAL_DB_PORT
value: "3306".Copy the code
Access to the open – falcon – dashboard
Kubectl get SVC:
NAME TYPE cluster-ip external-ip PORT(S) AGE mysql NodePort 10.110.20.201 < None > 3306:30535/TCP 25m open-falcon NodePort 10.97.12.125 < none > / TCP, 8433-31952, 8080-31957 / TCP 53 s open - falcon - dashboard NodePort 10.96.119.231 < none > 8081:30191/TCP 3s Redis ClusterIP 10.98.212.126 < None > 6379/TCP 32mCopy the code
Get the open – falcon – dashboard service exposed local port 30191, then the browser to http://192.168.10.21:30191.
All YAML files