mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-17 10:17:55 +00:00
Feature/upgrade obs docker (#364)
* upgrade docker config * upgrade obs.toml * modify dockerfile image from alpine to ubuntu
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
[observability]
|
[observability]
|
||||||
endpoint = "http://localhost:4317" # Default is "http://localhost:4317" if not specified
|
endpoint = "http://otel-collector:4317" # Default is "http://localhost:4317" if not specified
|
||||||
use_stdout = false # Output with stdout, true output, false no output
|
use_stdout = false # Output with stdout, true output, false no output
|
||||||
sample_ratio = 2.0
|
sample_ratio = 2.0
|
||||||
meter_interval = 30
|
meter_interval = 30
|
||||||
service_name = "rustfs"
|
service_name = "rustfs"
|
||||||
service_version = "0.1.0"
|
service_version = "0.1.0"
|
||||||
environments = "production"
|
environments = "production"
|
||||||
logger_level = "info"
|
logger_level = "debug"
|
||||||
|
|
||||||
[sinks]
|
[sinks]
|
||||||
[sinks.kafka] # Kafka sink is disabled by default
|
[sinks.kafka] # Kafka sink is disabled by default
|
||||||
|
|||||||
+6
-2
@@ -1,4 +1,4 @@
|
|||||||
FROM alpine:latest
|
FROM ubuntu:latest
|
||||||
|
|
||||||
# RUN apk add --no-cache <package-name>
|
# RUN apk add --no-cache <package-name>
|
||||||
# 如果 rustfs 有依赖,可以在这里添加,例如:
|
# 如果 rustfs 有依赖,可以在这里添加,例如:
|
||||||
@@ -7,7 +7,11 @@ FROM alpine:latest
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY ./target/x86_64-unknown-linux-musl/release/rustfs /app/rustfs
|
# 创建与 RUSTFS_VOLUMES 一致的目录
|
||||||
|
RUN mkdir -p /root/data/target/volume/test1 /root/data/target/volume/test2 /root/data/target/volume/test3 /root/data/target/volume/test4
|
||||||
|
|
||||||
|
# COPY ./target/x86_64-unknown-linux-musl/release/rustfs /app/rustfs
|
||||||
|
COPY ./target/x86_64-unknown-linux-gnu/release/rustfs /app/rustfs
|
||||||
|
|
||||||
RUN chmod +x /app/rustfs
|
RUN chmod +x /app/rustfs
|
||||||
|
|
||||||
|
|||||||
@@ -10,19 +10,21 @@ use std::env;
|
|||||||
/// Add endpoint for metric collection
|
/// Add endpoint for metric collection
|
||||||
/// Add use_stdout for output to stdout
|
/// Add use_stdout for output to stdout
|
||||||
/// Add logger level for log level
|
/// Add logger level for log level
|
||||||
|
/// Add local_logging_enabled for local logging enabled
|
||||||
#[derive(Debug, Deserialize, Clone)]
|
#[derive(Debug, Deserialize, Clone)]
|
||||||
pub struct OtelConfig {
|
pub struct OtelConfig {
|
||||||
pub endpoint: String,
|
pub endpoint: String, // Endpoint for metric collection
|
||||||
pub use_stdout: Option<bool>,
|
pub use_stdout: Option<bool>, // Output to stdout
|
||||||
pub sample_ratio: Option<f64>,
|
pub sample_ratio: Option<f64>, // Trace sampling ratio
|
||||||
pub meter_interval: Option<u64>,
|
pub meter_interval: Option<u64>, // Metric collection interval
|
||||||
pub service_name: Option<String>,
|
pub service_name: Option<String>, // Service name
|
||||||
pub service_version: Option<String>,
|
pub service_version: Option<String>, // Service version
|
||||||
pub environment: Option<String>,
|
pub environment: Option<String>, // Environment
|
||||||
pub logger_level: Option<String>,
|
pub logger_level: Option<String>, // Logger level
|
||||||
|
pub local_logging_enabled: Option<bool>, // Local logging enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
// 辅助函数:从环境变量中提取可观测性配置
|
// Helper function: Extract observable configuration from environment variables
|
||||||
fn extract_otel_config_from_env() -> OtelConfig {
|
fn extract_otel_config_from_env() -> OtelConfig {
|
||||||
OtelConfig {
|
OtelConfig {
|
||||||
endpoint: env::var("RUSTFS_OBSERVABILITY_ENDPOINT").unwrap_or_else(|_| "".to_string()),
|
endpoint: env::var("RUSTFS_OBSERVABILITY_ENDPOINT").unwrap_or_else(|_| "".to_string()),
|
||||||
@@ -54,6 +56,10 @@ fn extract_otel_config_from_env() -> OtelConfig {
|
|||||||
.ok()
|
.ok()
|
||||||
.and_then(|v| v.parse().ok())
|
.and_then(|v| v.parse().ok())
|
||||||
.or(Some(LOGGER_LEVEL.to_string())),
|
.or(Some(LOGGER_LEVEL.to_string())),
|
||||||
|
local_logging_enabled: env::var("RUSTFS_OBSERVABILITY_LOCAL_LOGGING_ENABLED")
|
||||||
|
.ok()
|
||||||
|
.and_then(|v| v.parse().ok())
|
||||||
|
.or(Some(false)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,6 +185,10 @@ pub struct AppConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AppConfig {
|
impl AppConfig {
|
||||||
|
/// Create a new instance of AppConfig with default values
|
||||||
|
///
|
||||||
|
/// # Returns
|
||||||
|
/// A new instance of AppConfig
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
observability: OtelConfig::default(),
|
observability: OtelConfig::default(),
|
||||||
@@ -195,6 +205,7 @@ impl Default for AppConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Default configuration file name
|
||||||
const DEFAULT_CONFIG_FILE: &str = "obs";
|
const DEFAULT_CONFIG_FILE: &str = "obs";
|
||||||
|
|
||||||
/// Loading the configuration file
|
/// Loading the configuration file
|
||||||
|
|||||||
+15
-15
@@ -62,18 +62,18 @@ services:
|
|||||||
dockerfile: Dockerfile.obs
|
dockerfile: Dockerfile.obs
|
||||||
container_name: node1
|
container_name: node1
|
||||||
environment:
|
environment:
|
||||||
- RUSTFS_VOLUMES=/root/data/target/volume/test{1...4}
|
- RUSTFS_VOLUMES=http://node{1...4}:9000/root/data/target/volume/test{1...4}
|
||||||
- RUSTFS_ADDRESS=0.0.0.0:9000
|
- RUSTFS_ADDRESS=0.0.0.0:9000
|
||||||
- RUSTFS_CONSOLE_ENABLE=true
|
- RUSTFS_CONSOLE_ENABLE=true
|
||||||
- RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002
|
- RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002
|
||||||
- RUSTFS_OBS_CONFIG=/etc/observability/config.obs.toml
|
- RUSTFS_OBS_CONFIG=/etc/observability/config/obs.toml
|
||||||
platform: linux/amd64
|
platform: linux/amd64
|
||||||
ports:
|
ports:
|
||||||
- "9001:9000" # 映射宿主机的 9001 端口到容器的 9000 端口
|
- "9001:9000" # 映射宿主机的 9001 端口到容器的 9000 端口
|
||||||
- "9101:9002"
|
- "9101:9002"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/root/data # 将当前路径挂载到容器内的 /root/data
|
# - ./data:/root/data # 将当前路径挂载到容器内的 /root/data
|
||||||
- ./.docker/observability/config/obs.toml:/etc/observability/config.obs.toml
|
- ./.docker/observability/config:/etc/observability/config
|
||||||
networks:
|
networks:
|
||||||
- rustfs-network
|
- rustfs-network
|
||||||
|
|
||||||
@@ -87,14 +87,14 @@ services:
|
|||||||
- RUSTFS_ADDRESS=0.0.0.0:9000
|
- RUSTFS_ADDRESS=0.0.0.0:9000
|
||||||
- RUSTFS_CONSOLE_ENABLE=true
|
- RUSTFS_CONSOLE_ENABLE=true
|
||||||
- RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002
|
- RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002
|
||||||
- RUSTFS_OBS_CONFIG=/etc/observability/config.obs.toml
|
- RUSTFS_OBS_CONFIG=/etc/observability/config/obs.toml
|
||||||
platform: linux/amd64
|
platform: linux/amd64
|
||||||
ports:
|
ports:
|
||||||
- "9002:9000" # 映射宿主机的 9002 端口到容器的 9000 端口
|
- "9002:9000" # 映射宿主机的 9002 端口到容器的 9000 端口
|
||||||
- "9102:9002"
|
- "9102:9002"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/root/data
|
# - ./data:/root/data
|
||||||
- ./.docker/observability/config/obs.toml:/etc/observability/config.obs.toml
|
- ./.docker/observability/config:/etc/observability/config
|
||||||
networks:
|
networks:
|
||||||
- rustfs-network
|
- rustfs-network
|
||||||
|
|
||||||
@@ -104,18 +104,18 @@ services:
|
|||||||
dockerfile: Dockerfile.obs
|
dockerfile: Dockerfile.obs
|
||||||
container_name: node3
|
container_name: node3
|
||||||
environment:
|
environment:
|
||||||
- RUSTFS_VOLUMES=/root/data/target/volume/test{1...4}
|
- RUSTFS_VOLUMES=http://node{1...4}:9000/root/data/target/volume/test{1...4}
|
||||||
- RUSTFS_ADDRESS=0.0.0.0:9000
|
- RUSTFS_ADDRESS=0.0.0.0:9000
|
||||||
- RUSTFS_CONSOLE_ENABLE=true
|
- RUSTFS_CONSOLE_ENABLE=true
|
||||||
- RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002
|
- RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002
|
||||||
- RUSTFS_OBS_CONFIG=/etc/observability/config.obs.toml
|
- RUSTFS_OBS_CONFIG=/etc/observability/config/obs.toml
|
||||||
platform: linux/amd64
|
platform: linux/amd64
|
||||||
ports:
|
ports:
|
||||||
- "9003:9000" # 映射宿主机的 9003 端口到容器的 9000 端口
|
- "9003:9000" # 映射宿主机的 9003 端口到容器的 9000 端口
|
||||||
- "9103:9002"
|
- "9103:9002"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/root/data
|
# - ./data:/root/data
|
||||||
- ./.docker/observability/config/obs.toml:/etc/observability/config.obs.toml
|
- ./.docker/observability/config:/etc/observability/config
|
||||||
networks:
|
networks:
|
||||||
- rustfs-network
|
- rustfs-network
|
||||||
|
|
||||||
@@ -125,18 +125,18 @@ services:
|
|||||||
dockerfile: Dockerfile.obs
|
dockerfile: Dockerfile.obs
|
||||||
container_name: node4
|
container_name: node4
|
||||||
environment:
|
environment:
|
||||||
- RUSTFS_VOLUMES=/root/data/target/volume/test{1...4}
|
- RUSTFS_VOLUMES=http://node{1...4}:9000/root/data/target/volume/test{1...4}
|
||||||
- RUSTFS_ADDRESS=0.0.0.0:9000
|
- RUSTFS_ADDRESS=0.0.0.0:9000
|
||||||
- RUSTFS_CONSOLE_ENABLE=true
|
- RUSTFS_CONSOLE_ENABLE=true
|
||||||
- RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002
|
- RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9002
|
||||||
- RUSTFS_OBS_CONFIG=/etc/observability/config.obs.toml
|
- RUSTFS_OBS_CONFIG=/etc/observability/config/obs.toml
|
||||||
platform: linux/amd64
|
platform: linux/amd64
|
||||||
ports:
|
ports:
|
||||||
- "9004:9000" # 映射宿主机的 9004 端口到容器的 9000 端口
|
- "9004:9000" # 映射宿主机的 9004 端口到容器的 9000 端口
|
||||||
- "9104:9002"
|
- "9104:9002"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/root/data
|
# - ./data:/root/data
|
||||||
- ./.docker/observability/config/obs.toml:/etc/observability/config.obs.toml
|
- ./.docker/observability/config:/etc/observability/config
|
||||||
networks:
|
networks:
|
||||||
- rustfs-network
|
- rustfs-network
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export RUSTFS__OBSERVABILITY__SERVICE_NAME=rustfs
|
|||||||
export RUSTFS__OBSERVABILITY__SERVICE_VERSION=0.1.0
|
export RUSTFS__OBSERVABILITY__SERVICE_VERSION=0.1.0
|
||||||
export RUSTFS__OBSERVABILITY__ENVIRONMENT=develop
|
export RUSTFS__OBSERVABILITY__ENVIRONMENT=develop
|
||||||
export RUSTFS__OBSERVABILITY__LOGGER_LEVEL=debug
|
export RUSTFS__OBSERVABILITY__LOGGER_LEVEL=debug
|
||||||
|
export RUSTFS__OBSERVABILITY__LOCAL_LOGGER_ENABLED=true
|
||||||
export RUSTFS__SINKS__FILE__ENABLED=true
|
export RUSTFS__SINKS__FILE__ENABLED=true
|
||||||
export RUSTFS__SINKS__FILE__PATH="./deploy/logs/rustfs.log"
|
export RUSTFS__SINKS__FILE__PATH="./deploy/logs/rustfs.log"
|
||||||
export RUSTFS__SINKS__WEBHOOK__ENABLED=false
|
export RUSTFS__SINKS__WEBHOOK__ENABLED=false
|
||||||
|
|||||||
Reference in New Issue
Block a user