部署轻量私有化服务监控UptimeKuma
本文最后更新于 645 天前, 如有失效请评论区留言.
Uptime Kuma 是一个开源的、简单易用的、自托管的监控工具,功能类似于 Uptime Robot。它可以帮助你监控你的网站或者任何暴露在互联网上的服务,如 HTTP、TCP、Ping、DNS 等,并且提供实时的状态和通知功能。本文将介绍如何安装、配置和使用 Uptime Kuma。
安装
Uptime Kuma 支持多种安装方式. 这里我们以compose和k8s为例,介绍如何安装 Uptime Kuma。
Docker方式
默认已经安装好docker啦, 如果没有参考docker安装
# docker-compose.yaml
version: "3"
services:
uptime-kuma:
image: louislam/uptime-kuma:1
container_name: uptime-kuma
restart: always
ports:
- 3001:3001
volumes:
- uptime:/app/data
volumes:
uptime:
driver: local
运行以下命令来启动 Uptime Kuma:
# 老版本或者直接使用二进制方式
docker-compose up -d
# 新版本docker plugin插件方式
docker compose up -d
k8s方式
其实服务比较简单, 在k8s跑起来也比较简单
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
k8s.ysicing.me/name: uptime
name: uptime
spec:
# storageClassName: tkecfs
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
k8s.ysicing.me/name: uptime
name: uptime
spec:
replicas: 1
selector:
matchLabels:
k8s.ysicing.me/name: uptime
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 0%
type: RollingUpdate
template:
metadata:
labels:
k8s.ysicing.me/name: uptime
spec:
containers:
- image: louislam/uptime-kuma:1
imagePullPolicy: Always
name: uptime
resources:
limits:
cpu: 150m
memory: 256Mi
requests:
cpu: 50m
memory: 128Mi
volumeMounts:
- mountPath: /app/data
name: uptime
restartPolicy: Always
volumes:
- name: uptime
persistentVolumeClaim:
claimName: uptime
---
apiVersion: v1
kind: Service
metadata:
labels:
k8s.ysicing.me/name: uptime
name: uptime
spec:
ports:
- name: http
port: 3001
protocol: TCP
targetPort: 3001
selector:
k8s.ysicing.me/name: uptime
type: ClusterIP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
labels:
k8s.ysicing.me/name: uptime
name: uptime
spec:
rules:
- host: uptime.i.ysicing.net
http:
paths:
- backend:
service:
name: uptime
port:
name: http
path: /
pathType: ImplementationSpecific
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
labels:
k8s.ysicing.me/name: uptime
annotations:
nginx.ingress.kubernetes.io/configuration-snippet: |
rewrite ^/dashboard$ https://uptime.i.ysicing.net/dashboard redirect;
name: uptime-status
spec:
rules:
- host: status.ysicing.net
http:
paths:
- backend:
service:
name: uptime
port:
name: http
path: /
pathType: ImplementationSpecific
将上述文件保存为kuma.yaml并apply到集群
kubectl apply -f kuma.yaml
配置kuma
这里以k8s为例。
在启动 Uptime Kuma 后,你可以通过浏览器访问 uptime.i.ysicing.net 来进入 Uptime Kuma 的界面。如果你是第一次访问,你需要先创建一个管理员账号和密码。然后,你就可以登录并开始配置 Uptime Kuma。
添加监控项比较简单,这里提下Bark告警推送遇到的坑哈, bark群组不能为中文
配置监控页
也比较简单, 安装步骤一步一步来就可以咯
配置自定义域名
通常我们都会默认用status.ysicing.net
来展示服务状态哈