Added xray exporter
This commit is contained in:
@@ -232,6 +232,10 @@ spec:
|
||||
port: 62050
|
||||
protocol: TCP
|
||||
targetPort: 62050
|
||||
- name: metrics
|
||||
port: 9550
|
||||
protocol: TCP
|
||||
targetPort: 9550
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Endpoints
|
||||
@@ -249,6 +253,9 @@ spec:
|
||||
- name: api
|
||||
port: 62050
|
||||
protocol: TCP
|
||||
- name: metrics
|
||||
port: 9550
|
||||
protocol: TCP
|
||||
EOF
|
||||
|
||||
echo "Service created: ${SERVICE_NAME}.${NAMESPACE}.svc.cluster.local -> ${NODE_IP}:62050"
|
||||
@@ -256,6 +263,75 @@ spec:
|
||||
- name: shared-data
|
||||
mountPath: /shared
|
||||
containers:
|
||||
- name: xray-exporter
|
||||
image: alpine:3.18
|
||||
imagePullPolicy: IfNotPresent
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- |
|
||||
# Install required tools
|
||||
apk add --no-cache wget curl ss bash
|
||||
|
||||
# Download v2ray-exporter
|
||||
echo "Downloading v2ray-exporter..."
|
||||
wget -O /tmp/v2ray-exporter https://github.com/wi1dcard/v2ray-exporter/releases/latest/download/v2ray-exporter_linux_amd64
|
||||
mv /tmp/v2ray-exporter /usr/local/bin/v2ray-exporter
|
||||
chmod +x /usr/local/bin/v2ray-exporter
|
||||
|
||||
# Wait for xray to start
|
||||
echo "Waiting for xray process to start..."
|
||||
sleep 10
|
||||
|
||||
# Find xray API port
|
||||
while true; do
|
||||
echo "Looking for xray API port..."
|
||||
API_PORT=$(ss -tlpn | grep xray | grep 127.0.0.1 | awk '{print $4}' | cut -d: -f2 | head -1)
|
||||
|
||||
if [ -n "$API_PORT" ]; then
|
||||
echo "Found potential API port: $API_PORT"
|
||||
|
||||
# Verify it's the correct port
|
||||
if curl -s -o /dev/null -w "%{http_code}" "127.0.0.1:$API_PORT" 2>&1 | grep -q "Received HTTP/0.9"; then
|
||||
echo "Verified API port: $API_PORT"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "API port not found or not verified, retrying in 5 seconds..."
|
||||
sleep 5
|
||||
done
|
||||
|
||||
# Start exporter
|
||||
echo "Starting v2ray-exporter with endpoint 127.0.0.1:$API_PORT"
|
||||
exec /usr/local/bin/v2ray-exporter --v2ray-endpoint "127.0.0.1:$API_PORT" --listen ":9550"
|
||||
ports:
|
||||
- name: metrics
|
||||
containerPort: 9550
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /scrape
|
||||
port: metrics
|
||||
initialDelaySeconds: 60
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 10
|
||||
failureThreshold: 3
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /scrape
|
||||
port: metrics
|
||||
initialDelaySeconds: 45
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
resources:
|
||||
requests:
|
||||
memory: "64Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "128Mi"
|
||||
cpu: "100m"
|
||||
- name: pasarguard-node
|
||||
image: 'pasarguard/node:v0.1.1'
|
||||
imagePullPolicy: Always
|
||||
|
||||
Reference in New Issue
Block a user