@@ -94,8 +94,6 @@ func main() {
94
94
95
95
log .Printf ("DeploymentConfig: %+v\n " , deployConfig )
96
96
97
- factory := k8s .NewFunctionFactory (kubeClient , deployConfig , faasClient .OpenfaasV1 ())
98
-
99
97
// the sync interval does not affect the scale to/from zero feature
100
98
// auto-scaling is does via the HTTP API that acts on the deployment Spec.Replicas
101
99
defaultResync := time .Minute * 5
@@ -106,13 +104,20 @@ func main() {
106
104
faasInformerOpt := informers .WithNamespace (config .DefaultFunctionNamespace )
107
105
faasInformerFactory := informers .NewSharedInformerFactoryWithOptions (faasClient , defaultResync , faasInformerOpt )
108
106
107
+ // this is where we need to swap to the faasInformerFactory
108
+ profileInformerOpt := informers .WithNamespace (config .ProfilesNamespace )
109
+ profileInformerFactory := informers .NewSharedInformerFactoryWithOptions (faasClient , defaultResync , profileInformerOpt )
110
+ profileLister := profileInformerFactory .Openfaas ().V1 ().Profiles ().Lister ()
111
+ factory := k8s .NewFunctionFactory (kubeClient , deployConfig , profileLister )
112
+
109
113
setup := serverSetup {
110
- config : config ,
111
- functionFactory : factory ,
112
- kubeInformerFactory : kubeInformerFactory ,
113
- faasInformerFactory : faasInformerFactory ,
114
- kubeClient : kubeClient ,
115
- faasClient : faasClient ,
114
+ config : config ,
115
+ functionFactory : factory ,
116
+ kubeInformerFactory : kubeInformerFactory ,
117
+ faasInformerFactory : faasInformerFactory ,
118
+ profileInformerFactory : profileInformerFactory ,
119
+ kubeClient : kubeClient ,
120
+ faasClient : faasClient ,
116
121
}
117
122
118
123
if ! operator {
@@ -142,9 +147,11 @@ func runController(setup serverSetup) {
142
147
143
148
log .Println ("waiting for openfaas CRD cache sync" )
144
149
faasInformerFactory .WaitForCacheSync (stopCh )
150
+ setup .profileInformerFactory .WaitForCacheSync (stopCh )
145
151
log .Println ("cache sync complete" )
146
152
go faasInformerFactory .Start (stopCh )
147
153
go kubeInformerFactory .Start (stopCh )
154
+ go setup .profileInformerFactory .Start (stopCh )
148
155
149
156
lister := endpointsInformer .Lister ()
150
157
functionLookup := k8s .NewFunctionLookup (config .DefaultFunctionNamespace , lister )
@@ -190,6 +197,7 @@ func runOperator(setup serverSetup) {
190
197
191
198
glog .Infof ("Waiting for cache sync in main" )
192
199
kubeInformerFactory .WaitForCacheSync (stopCh )
200
+ setup .profileInformerFactory .WaitForCacheSync (stopCh )
193
201
glog .Infof ("Cache sync done" )
194
202
195
203
ctrl := controller .NewController (
@@ -204,6 +212,7 @@ func runOperator(setup serverSetup) {
204
212
205
213
go faasInformerFactory .Start (stopCh )
206
214
go kubeInformerFactory .Start (stopCh )
215
+ go setup .profileInformerFactory .Start (stopCh )
207
216
208
217
go srv .Start ()
209
218
if err := ctrl .Run (1 , stopCh ); err != nil {
@@ -214,12 +223,13 @@ func runOperator(setup serverSetup) {
214
223
// serverSetup is a container for the config and clients needed to start the
215
224
// faas-netes controller or operator
216
225
type serverSetup struct {
217
- config types.BootstrapConfig
218
- kubeClient * kubernetes.Clientset
219
- faasClient * clientset.Clientset
220
- functionFactory k8s.FunctionFactory
221
- kubeInformerFactory kubeinformers.SharedInformerFactory
222
- faasInformerFactory informers.SharedInformerFactory
226
+ config types.BootstrapConfig
227
+ kubeClient * kubernetes.Clientset
228
+ faasClient * clientset.Clientset
229
+ functionFactory k8s.FunctionFactory
230
+ kubeInformerFactory kubeinformers.SharedInformerFactory
231
+ faasInformerFactory informers.SharedInformerFactory
232
+ profileInformerFactory informers.SharedInformerFactory
223
233
}
224
234
225
235
func setupLogging () {
@@ -231,7 +241,7 @@ func setupLogging() {
231
241
f2 := klogFlags .Lookup (f1 .Name )
232
242
if f2 != nil {
233
243
value := f1 .Value .String ()
234
- f2 .Value .Set (value )
244
+ _ = f2 .Value .Set (value )
235
245
}
236
246
})
237
247
}
0 commit comments