Updated map ids in Kubernetes

World service will create logic instance with a log level that can be adjusted at runtime
This commit is contained in:
2025-06-24 14:09:26 -04:00
parent 72949da095
commit 4c91fe3557
3 changed files with 20 additions and 5 deletions

View File

@@ -91,6 +91,10 @@ services:
env: env:
SERVICE_PORT: 50054 SERVICE_PORT: 50054
LOG_LEVEL: "debug" LOG_LEVEL: "debug"
LOGIC_LOG_LEVEL: "debug"
# MAP_IDS: "1,2,3,4,5,6,8,9,10,11,15,16,17,18,20,21,22,23,24,25,26,27,28,29,31,32,33,34,35,36,37,40,42,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,70,71,72,73,74,75,76,77,78,79,80"
MAP_IDS: "1,2,3,4,5,6,8,9,10,11,15,16,17,18,20"
WORLD_SERVICE_NAME: "Athena"
service: service:
annotations: annotations:
name: "Athena" name: "Athena"

View File

@@ -1,3 +1,4 @@
use std::env;
use kube::{ use kube::{
api::{Api, PostParams, DeleteParams}, api::{Api, PostParams, DeleteParams},
Client, Client,
@@ -21,6 +22,10 @@ pub struct K8sOrchestrator {
namespace: String, namespace: String,
} }
fn get_log_level() -> String {
env::var("LOGIC_LOG_LEVEL").unwrap_or_else(|_| env::var("LOG_LEVEL").unwrap_or_else(|_| "info".to_string()))
}
impl K8sOrchestrator { impl K8sOrchestrator {
/// Creates a new orchestrator for the given namespace. /// Creates a new orchestrator for the given namespace.
pub async fn new(namespace: &str) -> Result<Self, Box<dyn Error>> { pub async fn new(namespace: &str) -> Result<Self, Box<dyn Error>> {
@@ -61,10 +66,16 @@ impl K8sOrchestrator {
"containerPort": 50056, "containerPort": 50056,
"name": "grpc" "name": "grpc"
}], }],
"env": [{ "env": [
"name": "MAP_ID", {
"value": map_id_str "name": "MAP_ID",
}], "value": map_id_str
},
{
"name": "LOG_LEVEL",
"value": get_log_level()
}
],
"volumeMounts": [{ "volumeMounts": [{
"name": "game-data", "name": "game-data",
"mountPath": "/opt/data", "mountPath": "/opt/data",

View File

@@ -49,7 +49,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
} }
Err(e) => { Err(e) => {
if e.to_string().contains("AlreadyExists") { if e.to_string().contains("AlreadyExists") {
info!("Game-logic instance already exists: {}", e); warn!("Game-logic instance already exists: {}", e);
// No reason to return an error here. // No reason to return an error here.
//TODO: We may want to check to make sure the pod is working correctly. //TODO: We may want to check to make sure the pod is working correctly.
} else { } else {