@@ -137,6 +137,10 @@ var (
137
137
runserver .DefaultConfigText ,
138
138
"The configuration specified as text, in lieu of a file" )
139
139
140
+ modelServerMetricsPort = flag .Int ("modelServerMetricsPort" , 0 , "Port to scrape metrics from pods. " +
141
+ "Default value will be set to InferencePool.Spec.TargetPortNumber if not set." )
142
+ modelServerMetricsPath = flag .String ("modelServerMetricsPath" , "/metrics" , "Path to scrape metrics from pods" )
143
+
140
144
setupLog = ctrl .Log .WithName ("setup" )
141
145
142
146
// Environment variables
@@ -168,7 +172,32 @@ func (r *Runner) WithSchedulerConfig(schedulerConfig *scheduling.SchedulerConfig
168
172
return r
169
173
}
170
174
175
+ func bindEnvToFlags () {
176
+ // map[ENV_VAR]flagName – add more as needed
177
+ for env , flg := range map [string ]string {
178
+ "GRPC_PORT" : "grpcPort" ,
179
+ "GRPC_HEALTH_PORT" : "grpcHealthPort" ,
180
+ "MODEL_SERVER_METRICS_PORT" : "modelServerMetricsPort" ,
181
+ "MODEL_SERVER_METRICS_PATH" : "modelServerMetricsPath" ,
182
+ "DESTINATION_ENDPOINT_HINT_KEY" : "destinationEndpointHintKey" ,
183
+ "POOL_NAME" : "poolName" ,
184
+ "POOL_NAMESPACE" : "poolNamespace" ,
185
+ // durations & bools work too; flag.Set expects the *string* form
186
+ "REFRESH_METRICS_INTERVAL" : "refreshMetricsInterval" ,
187
+ "SECURE_SERVING" : "secureServing" ,
188
+ } {
189
+ if v := os .Getenv (env ); v != "" {
190
+ // ignore error; Parse() will catch invalid values later
191
+ _ = flag .Set (flg , v )
192
+ }
193
+ }
194
+ }
195
+
171
196
func (r * Runner ) Run (ctx context.Context ) error {
197
+ // Defaults already baked into flag declarations
198
+ // Load env vars as "soft" overrides
199
+ bindEnvToFlags ()
200
+
172
201
opts := zap.Options {
173
202
Development : true ,
174
203
}
@@ -210,7 +239,11 @@ func (r *Runner) Run(ctx context.Context) error {
210
239
return err
211
240
}
212
241
verifyMetricMapping (* mapping , setupLog )
213
- pmf := backendmetrics .NewPodMetricsFactory (& backendmetrics.PodMetricsClientImpl {MetricMapping : mapping }, * refreshMetricsInterval )
242
+ pmf := backendmetrics .NewPodMetricsFactory (& backendmetrics.PodMetricsClientImpl {
243
+ MetricMapping : mapping ,
244
+ ModelServerMetricsPort : int32 (* modelServerMetricsPort ),
245
+ ModelServerMetricsPath : * modelServerMetricsPath ,
246
+ }, * refreshMetricsInterval )
214
247
215
248
datastore := datastore .NewDatastore (ctx , pmf )
216
249
0 commit comments