Cachet is a beautiful and powerful open source status page system.
要部署 Cachet status page system 使用下列原件部署在 Kubernetes。
Cachet Docker Imagecachet-monitor
[~]$ git clone https://github.com/cachethq/Docker [~]$ cd Docker/ [~]$ vim Dockerfile
增加 cachet-monitor binary 到 cachet
----
....
COPY conf/.env.docker /var/www/html/.env
RUN sudo wget https://github.com/CastawayLabs/cachet-monitor/releases/download/v3.0/cachet_monitor_linux_amd64 && \
sudo chmod +x cachet_monitor_linux_amd64
VOLUME /var/www
...
----
[~]$ docker build -t test/cachet:2.3.10 . 建立 Cachet status page [~]$ vim cachet-status-page.yaml apiVersion: extensions/v1beta1 kind: Deployment metadata: name: cachet-status-page spec: replicas: 1 template: metadata: labels: app: cachet-status-page spec: hostname: cachet # 部署到指定的 node nodeSelector: cachet: "true" # 使用本機空間來存 postgresql volumes: - name: postgresql-data hostPath: path: /opt/etc/postgresql/data containers: - name: postgres image: postgres:9.5 env: - name: POSTGRES_USER value: "postgres" - name: POSTGRES_PASSWORD value: "postgres" volumeMounts: - name: postgresql-data mountPath: /var/lib/postgresql/data - name: cachet image: test/cachet:2.3.10 env: - name: DB_DRIVER value: "pgsql" - name: DB_HOST value: "cachet" - name: DB_DATABASE value: "postgres" - name: DB_USERNAME value: "postgres" - name: DB_PASSWORD value: "postgres" --- apiVersion: v1 kind: Service metadata: name: cachet-svc labels: app: cachet-status-page spec: type: NodePort ports: - nodePort: 30000 port: 80 protocol: TCP targetPort: 80 selector: app: cachet-status-page
[~]$ kubectl create -f cachet-status-page.yaml
到 http://{node-ip}:30000/ 設定 cachet-status-page
並建立被監控的 components 和 metrics
建立 Cachet monitor
[~]$ wget https://raw.githubusercontent.com/CastawayLabs/cachet-monitor/master/example.config.yml
[~]$ cp example.config.yml cachet-monitor.yaml
[~]$ vim cachet-monitor.yaml
更新 url 和 token, 更新相對應的 component_id 和 metric_id。
----
url: http://{node-ip}:30000/api/v1
# cachet api token
token: zxcxzczxcxzcxzcxzczxc
insecure: false
...
# set to update component (either component_id or metric_id are required)
component_id: 1
# set to post lag to cachet metric (graph)
metric_id: 1
# custom templates (see readme for details) 錯誤輸出格式
template:
investigating:
subject: "{{ .Monitor.Name }} - {{ .SystemName }}"
message: "{{ .Monitor.Name }} check **failed** (server time: {{ .now }})\n\n{{ .FailReason }}"
fixed:
subject: "I HAVE BEEN FIXED"
# seconds between checks 監控間隔
interval: 1
...
----
把 monitor config 存到 k8s configmap 來使用
[~]$ kubectl create configmap cachet-monitor-config --from-file=cachet-monitor.yaml
[~]$ vim cachet-monitor.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: cachet-monitor
spec:
replicas: 1
template:
metadata:
labels:
app: cachet-monitor
spec:
# 使用本機DNS 來monitor
hostNetwork: true
nodeSelector:
cachet: "true"
volumes:
- name: cachet-monitor-yaml
configMap:
name: cachet-monitor-config
items:
- key: cachet-monitor.yaml
path: cachet-monitor.yaml
containers:
- name: cachet
image: test/cachet:2.3.10
command: ["/var/www/html/cachet_monitor_linux_amd64","-c","/var/www/html/cachet-monitor-config/cachet-monitor.yaml"]
volumeMounts:
- name: cachet-monitor-yaml
mountPath: /var/www/html/cachet-monitor-config
[~]$ kubectl create -f cachet-monitor.yaml [~]$ kubectl get pod NAME READY STATUS RESTARTS AGE cachet-monitor-2852706633-7x98h 1/1 Running 0 1d cachet-status-page-2249399379-sjhk5 2/2 Running 0 1d上述範例(cachet status page)使用本機儲存資訊,可改用其他volumes或persistent volumes/storageclasses
沒有留言:
張貼留言