Added xray exporter
All checks were successful
Update Kubernetes Services Wiki / Generate and Update K8s Wiki (push) Successful in 12s
Check with kubeconform / lint (push) Successful in 15s
Auto-update README / Generate README and Create MR (push) Successful in 7s

This commit is contained in:
Ultradesu
2025-11-18 14:27:12 +02:00
parent 536be6a61f
commit c998426b44

View File

@@ -279,26 +279,24 @@ spec:
mv /tmp/v2ray-exporter /usr/local/bin/v2ray-exporter mv /tmp/v2ray-exporter /usr/local/bin/v2ray-exporter
chmod +x /usr/local/bin/v2ray-exporter chmod +x /usr/local/bin/v2ray-exporter
# Wait for xray to start # Wait for xray API port file from pasarguard-node container
echo "Waiting for xray process to start..." echo "Waiting for xray API port file..."
sleep 10
# Find xray API port
while true; do while true; do
echo "Looking for xray API port..." if [ -f /shared/xray-api-port ]; then
API_PORT=$(ss -tlpn | grep xray | grep 127.0.0.1 | awk '{print $4}' | cut -d: -f2 | head -1) API_PORT=$(cat /shared/xray-api-port)
if [ -n "$API_PORT" ]; then
if [ -n "$API_PORT" ]; then echo "Got xray API port from shared volume: $API_PORT"
echo "Found potential API port: $API_PORT"
# Verify the port is working
# Verify it's the correct port if curl -s -o /dev/null -w "%{http_code}" --max-time 2 "127.0.0.1:$API_PORT" 2>&1 | grep -q "Received HTTP/0.9"; then
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"
echo "Verified API port: $API_PORT" break
break else
echo "Port verification failed, waiting..."
fi
fi fi
fi fi
echo "Waiting for valid xray API port... retrying in 5 seconds"
echo "API port not found or not verified, retrying in 5 seconds..."
sleep 5 sleep 5
done done
@@ -332,6 +330,10 @@ spec:
limits: limits:
memory: "128Mi" memory: "128Mi"
cpu: "100m" cpu: "100m"
volumeMounts:
- name: shared-data
mountPath: /shared
readOnly: true
- name: pasarguard-node - name: pasarguard-node
image: 'pasarguard/node:v0.1.1' image: 'pasarguard/node:v0.1.1'
imagePullPolicy: Always imagePullPolicy: Always
@@ -348,7 +350,29 @@ spec:
fi fi
cd /app cd /app
exec ./main
# Start main process in background
./main &
MAIN_PID=$!
# Wait a bit for xray to start
sleep 10
# Find xray API port and save to shared volume
echo "Looking for xray API port..."
for i in {1..60}; do
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 xray API port: $API_PORT"
echo -n "$API_PORT" > /shared/xray-api-port
break
fi
echo "Waiting for xray API port... ($i/60)"
sleep 1
done
# Continue running main process
wait $MAIN_PID
ports: ports:
- name: api - name: api
containerPort: 62050 containerPort: 62050
@@ -400,7 +424,7 @@ spec:
volumeMounts: volumeMounts:
- name: shared-data - name: shared-data
mountPath: /shared mountPath: /shared
readOnly: true readOnly: false
volumes: volumes:
- name: shared-data - name: shared-data
emptyDir: {} emptyDir: {}