@@ -90,7 +90,10 @@ func main() {
9090 ctx := initLogger (* logFormat , logLevels [* logLevel ], os .Stdout )
9191 l := nl .LoggerFromContext (ctx )
9292
93- cleanupSocketFiles (l )
93+ // TODO: Use fake manager
94+ if * proxyURL == "" {
95+ cleanupSocketFiles (l )
96+ }
9497
9598 initValidate (ctx )
9699 parsedFlags := os .Args [1 :]
@@ -103,10 +106,36 @@ func main() {
103106 if err := validateKubernetesVersionInfo (ctx , kubeClient ); err != nil {
104107 nl .Fatal (l , err )
105108 }
106- pod , err := kubeClient .CoreV1 ().Pods (controllerNamespace ).Get (context .TODO (), podName , meta_v1.GetOptions {})
107- if err != nil {
108- nl .Fatalf (l , "Failed to get pod: %v" , err )
109+
110+ var pod * api_v1.Pod
111+
112+ if * proxyURL != "" {
113+ if controllerNamespace == "" {
114+ controllerNamespace = "nginx-ingress"
115+ }
116+ if podName == "" {
117+ podName = "nginx-ingress-controller-proxy-mode"
118+ }
119+ pod = & api_v1.Pod {
120+ ObjectMeta : meta_v1.ObjectMeta {
121+ Name : podName ,
122+ Namespace : controllerNamespace ,
123+ OwnerReferences : []meta_v1.OwnerReference {
124+ {
125+ Kind : "Deployment" ,
126+ Name : "nginx-ingress-controller-proxy-mode" ,
127+ },
128+ },
129+ },
130+ }
131+ } else {
132+ var err error
133+ pod , err = kubeClient .CoreV1 ().Pods (controllerNamespace ).Get (context .TODO (), podName , meta_v1.GetOptions {})
134+ if err != nil {
135+ nl .Fatalf (l , "Failed to get pod: %v" , err )
136+ }
109137 }
138+
110139 eventBroadcaster := record .NewBroadcaster ()
111140 eventBroadcaster .StartLogging (func (format string , args ... interface {}) {
112141 nl .Infof (l , format , args ... )
@@ -129,13 +158,13 @@ func main() {
129158
130159 var licenseReporter * license_reporting.LicenseReporter
131160
132- if * nginxPlus {
161+ if * nginxPlus && * proxyURL == "" {
133162 licenseReporter = license_reporting .NewLicenseReporter (kubeClient , eventRecorder , pod )
134163 }
135164
136165 var deploymentMetadata * metadata.Metadata
137166
138- if * agent {
167+ if * agent && * proxyURL == "" {
139168 deploymentMetadata = metadata .NewMetadataReporter (kubeClient , pod , version )
140169 }
141170
@@ -156,15 +185,28 @@ func main() {
156185 }
157186
158187 var agentVersion string
159- if * agent {
188+ if * agent && * proxyURL == "" {
160189 agentVersion = getAgentVersionInfo (nginxManager )
161190 }
162191
163- go updateSelfWithVersionInfo (ctx , eventRecorder , kubeClient , version , appProtectVersion , agentVersion , nginxVersion , 10 , time .Second * 5 )
192+ // Skip pod label updates in proxy mode since the pod may not exist or be accessible
193+ if * proxyURL == "" {
194+ go updateSelfWithVersionInfo (ctx , eventRecorder , kubeClient , version , appProtectVersion , agentVersion , nginxVersion , 10 , time .Second * 5 )
195+ }
164196
165197 var mgmtCfgParams * configs.MGMTConfigParams
166198 if * nginxPlus {
167- mgmtCfgParams = processMGMTConfigMap (kubeClient , configs .NewDefaultMGMTConfigParams (ctx ), eventRecorder , pod )
199+ if * proxyURL == "" {
200+ mgmtCfgParams = processMGMTConfigMap (kubeClient , configs .NewDefaultMGMTConfigParams (ctx ), eventRecorder , pod )
201+ } else {
202+ // In proxy mode, also process the mgmt configmap if specified
203+ if * mgmtConfigMap != "" {
204+ mgmtCfgParams = processMGMTConfigMap (kubeClient , configs .NewDefaultMGMTConfigParams (ctx ), eventRecorder , pod )
205+ } else {
206+ mgmtCfgParams = configs .NewDefaultMGMTConfigParams (ctx )
207+ }
208+ }
209+
168210 if err := processLicenseSecret (kubeClient , nginxManager , mgmtCfgParams , controllerNamespace ); err != nil {
169211 logEventAndExit (ctx , eventRecorder , pod , secretErrorReason , err )
170212 }
@@ -176,7 +218,6 @@ func main() {
176218 if err := processClientAuthSecret (kubeClient , nginxManager , mgmtCfgParams , controllerNamespace ); err != nil {
177219 logEventAndExit (ctx , eventRecorder , pod , secretErrorReason , err )
178220 }
179-
180221 }
181222
182223 templateExecutor , templateExecutorV2 := createTemplateExecutors (ctx )
@@ -236,12 +277,10 @@ func main() {
236277 DefaultCABundle : caBundlePath ,
237278 }
238279
239- if * nginxPlus {
240- if cfgParams .ZoneSync .Enable && cfgParams .ZoneSync .Port != 0 {
241- err := createAndValidateHeadlessService (ctx , kubeClient , cfgParams , controllerNamespace , pod )
242- if err != nil {
243- logEventAndExit (ctx , eventRecorder , pod , nl .EventReasonServiceFailedToCreate , err )
244- }
280+ if * nginxPlus && cfgParams .ZoneSync .Enable && cfgParams .ZoneSync .Port != 0 {
281+ err := createAndValidateHeadlessService (ctx , kubeClient , cfgParams , controllerNamespace , pod )
282+ if err != nil {
283+ logEventAndExit (ctx , eventRecorder , pod , nl .EventReasonServiceFailedToCreate , err )
245284 }
246285 }
247286
@@ -255,7 +294,7 @@ func main() {
255294 process := startChildProcesses (nginxManager , appProtectV5 )
256295
257296 plusClient := createPlusClient (ctx , * nginxPlus , useFakeNginxManager , nginxManager )
258- if * nginxPlus {
297+ if * nginxPlus && * proxyURL == "" {
259298 licenseReporter .Config .PlusClient = plusClient
260299 }
261300
@@ -570,6 +609,9 @@ func createTemplateExecutors(ctx context.Context) (*version1.TemplateExecutor, *
570609 if * transportServerTemplatePath != "" {
571610 nginxTransportServerTemplatePath = * transportServerTemplatePath
572611 }
612+ if * oidcTemplatePath != "" {
613+ nginxOIDCConfTemplatePath = * oidcTemplatePath
614+ }
573615
574616 templateExecutor , err := version1 .NewTemplateExecutor (nginxConfTemplatePath , nginxIngressTemplatePath )
575617 if err != nil {
@@ -588,7 +630,7 @@ func createNginxManager(ctx context.Context, managerCollector collectors.Manager
588630 useFakeNginxManager := * proxyURL != ""
589631 var nginxManager nginx.Manager
590632 if useFakeNginxManager {
591- nginxManager = nginx .NewFakeManager ("/etc/nginx" )
633+ nginxManager = nginx .NewFakeManager (ctx , "/etc/nginx" )
592634 } else {
593635 timeout := time .Duration (* nginxReloadTimeout ) * time .Millisecond
594636 nginxManager = nginx .NewLocalManager (ctx , "/etc/nginx/" , * nginxDebug , managerCollector , licenseReporter , deploymentMetadata , timeout , * nginxPlus )
0 commit comments