MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / main

Function main

crates/openshell-driver-kubernetes/src/main.rs:114–164  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

112
113#[tokio::main]
114async fn main() -> Result<()> {
115 let args = Args::parse();
116 tracing_subscriber::fmt()
117 .with_env_filter(
118 EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(&args.log_level)),
119 )
120 .init();
121
122 let driver = KubernetesComputeDriver::new(KubernetesComputeConfig {
123 namespace: args.sandbox_namespace,
124 service_account_name: args.sandbox_service_account,
125 default_image: args.sandbox_image.unwrap_or_default(),
126 image_pull_policy: args.sandbox_image_pull_policy.unwrap_or_default(),
127 image_pull_secrets: args.sandbox_image_pull_secrets,
128 supervisor_image: args
129 .supervisor_image
130 .unwrap_or_else(|| openshell_core::config::DEFAULT_SUPERVISOR_IMAGE.to_string()),
131 supervisor_image_pull_policy: args.supervisor_image_pull_policy.unwrap_or_default(),
132 supervisor_sideload_method: args.supervisor_sideload_method,
133 supervisor_topology: args.supervisor_topology,
134 grpc_endpoint: args.grpc_endpoint.unwrap_or_default(),
135 ssh_socket_path: args.sandbox_ssh_socket_path,
136 client_tls_secret_name: args.client_tls_secret_name.unwrap_or_default(),
137 host_gateway_ip: args.host_gateway_ip.unwrap_or_default(),
138 enable_user_namespaces: args.enable_user_namespaces,
139 app_armor_profile: args.app_armor_profile,
140 workspace_default_storage_size: std::env::var(
141 "OPENSHELL_K8S_WORKSPACE_DEFAULT_STORAGE_SIZE",
142 )
143 .unwrap_or_else(|_| {
144 openshell_driver_kubernetes::DEFAULT_WORKSPACE_STORAGE_SIZE.to_string()
145 }),
146 default_runtime_class_name: std::env::var("OPENSHELL_K8S_DEFAULT_RUNTIME_CLASS_NAME")
147 .unwrap_or_default(),
148 sa_token_ttl_secs: args.sa_token_ttl_secs,
149 provider_spiffe_workload_api_socket_path: args
150 .provider_spiffe_workload_api_socket_path
151 .unwrap_or_default(),
152 sandbox_uid: args.sandbox_uid,
153 sandbox_gid: args.sandbox_gid,
154 })
155 .await
156 .into_diagnostic()?;
157
158 info!(address = %args.bind_address, "Starting Kubernetes compute driver");
159 tonic::transport::Server::builder()
160 .add_service(ComputeDriverServer::new(ComputeDriverService::new(driver)))
161 .serve(args.bind_address)
162 .await
163 .into_diagnostic()
164}

Callers

nothing calls this directly

Calls 1

serveMethod · 0.80

Tested by

no test coverage detected