-
Notifications
You must be signed in to change notification settings - Fork 193
/
types.go
1230 lines (1094 loc) · 40.9 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*-
* Copyright (c) 2016-2021, F5 Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package controller
import (
cisapiv1 "github.com/F5Networks/k8s-bigip-ctlr/v3/config/apis/cis/v1"
"github.com/F5Networks/k8s-bigip-ctlr/v3/pkg/ipmanager"
"github.com/F5Networks/k8s-bigip-ctlr/v3/pkg/networkmanager"
"github.com/F5Networks/k8s-bigip-ctlr/v3/pkg/tokenmanager"
"net/http"
"sync"
ficV1 "github.com/F5Networks/f5-ipam-controller/pkg/ipamapis/apis/fic/v1"
"k8s.io/apimachinery/pkg/util/intstr"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
routeclient "github.com/openshift/client-go/route/clientset/versioned/typed/route/v1"
"github.com/F5Networks/k8s-bigip-ctlr/v3/pkg/teem"
"github.com/F5Networks/k8s-bigip-ctlr/v3/config/client/clientset/versioned"
//apm "github.com/F5Networks/k8s-bigip-ctlr/v3/pkg/appmanager"
"github.com/F5Networks/k8s-bigip-ctlr/v3/pkg/clustermanager"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
)
type (
// Controller defines the structure of K-Native and Custom Resource Controller
Controller struct {
resources *ResourceStore
clientsets *ClientSets
namespacesMutex sync.Mutex
namespaces map[string]bool
initialResourceCount int
resourceQueue workqueue.RateLimitingInterface
PostParams PostParams
RequestHandler *RequestHandler
PoolMemberType string
UseNodeInternal bool
initState bool
shareNodes bool
ipamHandler *ipmanager.IPAMHandler
defaultRouteDomain int
TeemData *teem.TeemsData
requestMap *requestMap
StaticRoutingMode bool
OrchestrationCNI string
StaticRouteNodeCIDR string
cacheIPAMHostSpecs CacheIPAM
multiClusterConfigs *clustermanager.MultiClusterConfig
multiClusterResources *MultiClusterResourceStore
multiClusterMode string
haModeType cisapiv1.HAModeType
clusterRatio map[string]*int
clusterAdminState map[string]cisapiv1.AdminState
managedResources ManagedResources
resourceSelectorConfig ResourceSelectorConfig
CMTokenManager *tokenmanager.TokenManager
bigIpMap BigIpMap
respChan chan *agentConfig
networkManager *networkmanager.NetworkManager
ControllerIdentifier string
resourceContext
}
ClientSets struct {
kubeCRClient versioned.Interface
kubeClient kubernetes.Interface
routeClientV1 routeclient.RouteV1Interface
}
ManagedResources struct {
ManageRoutes bool
ManageCustomResources bool
ManageTransportServer bool
ManageVirtualServer bool
ManageEDNS bool
ManageIL bool
ManageTLSProfile bool
ManageSecrets bool
}
ResourceSelectorConfig struct {
NamespaceLabel string
NodeLabel string
RouteLabel string
nativeResourceSelector labels.Selector
customResourceSelector labels.Selector
}
resourceContext struct {
resourceQueue workqueue.RateLimitingInterface
comInformers map[string]*CommonInformer
nrInformers map[string]*NRInformer
crInformers map[string]*CRInformer
nsInformers map[string]*NSInformer
multiClusterPoolInformers map[string]map[string]*MultiClusterPoolInformer
multiClusterNodeInformers map[string]*NodeInformer
CISConfigCRKey string
namespaceLabelMode bool
processedHostPath *ProcessedHostPath
}
// Params defines parameters
Params struct {
Config *rest.Config
Namespaces []string
UserAgent string
UseNodeInternal bool
NodePollInterval int
IPAM bool
DefaultRouteDomain int
CISConfigCRKey string
MultiClusterMode string
CMConfigDetails *CMConfig
CMTrustedCerts string
CMSSLInsecure bool
HttpAddress string
ManageCustomResources bool
httpClientMetrics bool
}
// CMConfig defines the Central Manager config
CMConfig struct {
URL string
UserName string
Password string
}
// CRInformer defines the structure of Custom Resource Informer
CRInformer struct {
namespace string
stopCh chan struct{}
vsInformer cache.SharedIndexInformer
tlsInformer cache.SharedIndexInformer
tsInformer cache.SharedIndexInformer
ilInformer cache.SharedIndexInformer
}
CommonInformer struct {
namespace string
stopCh chan struct{}
svcInformer cache.SharedIndexInformer
epsInformer cache.SharedIndexInformer
ednsInformer cache.SharedIndexInformer
plcInformer cache.SharedIndexInformer
podInformer cache.SharedIndexInformer
secretsInformer cache.SharedIndexInformer
configCRInformer cache.SharedIndexInformer
}
// NRInformer is informer context for Native Resources of Kubernetes/Openshift
NRInformer struct {
namespace string
stopCh chan struct{}
routeInformer cache.SharedIndexInformer
}
NodeInformer struct {
stopCh chan struct{}
nodeInformer cache.SharedIndexInformer
clusterName string
oldNodes []Node
}
NSInformer struct {
stopCh chan struct{}
cluster string
nsInformer cache.SharedIndexInformer
}
rqKey struct {
namespace string
kind string
rscName string
rsc interface{}
event string
clusterName string
svcPortUpdated bool
}
metaData struct {
Active bool
ResourceType string
// resource name as key, resource kind as value
baseResources map[string]string
namespace string
hosts []string
Protocol string
httpTraffic string
defaultPoolType string
}
// Virtual server config
Virtual struct {
Name string `json:"name"`
PoolName string `json:"pool,omitempty"`
Partition string `json:"-"`
Destination string `json:"destination"`
Enabled bool `json:"enabled"`
IpProtocol string `json:"ipProtocol,omitempty"`
SourceAddrTranslation SourceAddrTranslation `json:"sourceAddressTranslation,omitempty"`
Policies []nameRef `json:"policies,omitempty"`
Profiles ProfileRefs `json:"profiles,omitempty"`
IRules []string `json:"rules,omitempty"`
Description string `json:"description,omitempty"`
VirtualAddress *virtualAddress `json:"-"`
AdditionalVirtualAddresses []string `json:"additionalVirtualAddresses,omitempty"`
SNAT string `json:"snat,omitempty"`
ConnectionMirroring string `json:"connectionMirroring,omitempty"`
WAF string `json:"waf,omitempty"`
Firewall string `json:"firewallPolicy,omitempty"`
LogProfiles []string `json:"logProfiles,omitempty"`
ProfileL4 string `json:"profileL4,omitempty"`
ProfileMultiplex string `json:"profileMultiplex,omitempty"`
ProfileWebSocket string `json:"profileWebSocket,omitempty"`
ProfileDOS string `json:"profileDOS,omitempty"`
ProfileBotDefense string `json:"profileBotDefense,omitempty"`
TCP ProfileTCP `json:"tcp,omitempty"`
HTTP2 ProfileHTTP2 `json:"http2,omitempty"`
Mode string `json:"mode,omitempty"`
TranslateServerAddress bool `json:"translateServerAddress"`
TranslateServerPort bool `json:"translateServerPort"`
Source string `json:"source,omitempty"`
AllowVLANs []string `json:"allowVlans,omitempty"`
PersistenceProfile string `json:"persistenceProfile,omitempty"`
TLSTermination string `json:"-"`
AllowSourceRange []string `json:"allowSourceRange,omitempty"`
HttpMrfRoutingEnabled *bool `json:"httpMrfRoutingEnabled,omitempty"`
IpIntelligencePolicy string `json:"ipIntelligencePolicy,omitempty"`
AutoLastHop string `json:"lastHop,omitempty"`
AnalyticsProfiles AnalyticsProfiles `json:"analyticsProfiles,omitempty"`
MultiPoolPersistence MultiPoolPersistence `json:"multiPoolPersistence,omitempty"`
}
MultiPoolPersistence struct {
Method string `json:"method,omitempty"`
TimeOut int32 `json:"timeOut,omitempty"`
}
// Virtuals is slice of virtuals
Virtuals []Virtual
AnalyticsProfiles struct {
HTTPAnalyticsProfile string `json:"http,omitempty"`
}
ProfileTCP struct {
Client string `json:"client,omitempty"`
Server string `json:"server,omitempty"`
}
ProfileHTTP2 struct {
Client string `json:"client,omitempty"`
Server string `json:"server,omitempty"`
}
// ServiceAddress Service IP address definition (BIG-IP virtual-address).
ServiceAddress struct {
ArpEnabled bool `json:"arpEnabled,omitempty"`
ICMPEcho string `json:"icmpEcho,omitempty"`
RouteAdvertisement string `json:"routeAdvertisement,omitempty"`
TrafficGroup string `json:"trafficGroup,omitempty"`
SpanningEnabled bool `json:"spanningEnabled,omitempty"`
}
// SourceAddrTranslation is Virtual Server Source Address Translation
SourceAddrTranslation struct {
Type string `json:"type"`
Pool string `json:"pool,omitempty"`
}
// frontend bindaddr and port
virtualAddress struct {
BindAddr string `json:"bindAddr,omitempty"`
Port int32 `json:"port,omitempty"`
}
// nameRef is virtual server policy/profile reference
nameRef struct {
Name string `json:"name"`
Partition string `json:"partition"`
}
// ResourceConfig contains a set of LTM resources to create a Virtual Server
ResourceConfig struct {
MetaData metaData `json:"-"`
Virtual Virtual `json:"virtual,omitempty"`
Pools Pools `json:"pools,omitempty"`
Policies Policies `json:"policies,omitempty"`
Monitors []Monitor `json:"monitors,omitempty"`
ServiceAddress []ServiceAddress `json:"serviceAddress,omitempty"`
IRulesMap IRulesMap
IntDgMap InternalDataGroupMap
customProfiles map[SecretKey]CustomProfile
}
// ResourceConfigs is group of ResourceConfig
ResourceConfigs []*ResourceConfig
// ResourceStore contain processed LTM and GTM resource data
ResourceStore struct {
bigIpMap BigIpMap
bigIpMapCache BigIpMap
nplStore NPLStore
supplementContextCache
}
// LTMConfig contain partition based ResourceMap
LTMConfig map[string]*PartitionConfig
// PartitionConfig contains ResourceMap and priority of partition
PartitionConfig struct {
ResourceMap ResourceMap
Priority *int
PriorityMutex sync.RWMutex
}
// ResourceMap key is resource name, value is pointer to config. May be shared.
ResourceMap map[string]*ResourceConfig
// PoolMemberCache key is namespace/service
PoolMemberCache map[MultiClusterServiceKey]*poolMembersInfo
// Store of CustomProfiles
CustomProfileStore struct {
sync.Mutex
Profs map[SecretKey]CustomProfile
}
// key is namespace/pod. stores list of npl annotation on pod
NPLStore map[string]NPLAnnoations
// GTMConfig key is domainName and value is WideIP
WideIPs struct {
WideIPs []WideIP `json:"wideIPs"`
}
// GTMConfig key is PartitionName
GTMConfig map[string]GTMPartitionConfig
GTMPartitionConfig struct {
// WideIPs: key is domainName, and value is WideIP
WideIPs map[string]WideIP
}
WideIP struct {
DomainName string `json:"name"`
ClientSubnetPreferred *bool `json:"clientSubnetPreferred,omitempty"`
RecordType string `json:"recordType"`
LBMethod string `json:"LoadBalancingMode"`
PersistenceEnabled bool `json:"persistenceEnabled"`
PersistCidrIPv4 uint8 `json:"persistCidrIpv4"`
PersistCidrIPv6 uint8 `json:"persistCidrIpv6"`
TTLPersistence uint32 `json:"ttlPersistence"`
Pools []GSLBPool `json:"pools"`
UID string
}
GSLBPool struct {
Name string `json:"name"`
RecordType string `json:"recordType"`
LBMethod string `json:"LoadBalancingMode"`
LBModeFallBack string `json:"fallbackMode"`
PriorityOrder int `json:"order"`
Ratio int `json:"ratio"`
Members []string `json:"members"`
Monitors []Monitor `json:"monitors,omitempty"`
DataServer string
}
// ResourceConfigRequest Each BigIPConfig per BigIP HA pair to put into the queue to process
ResourceConfigRequest struct {
bigIpKey BigIpKey
bigIpResourceConfig BigIpResourceConfig
reqMeta requestMeta
poolMemberType string
}
// BigIpMap Where key is the BigIP structure and value is the bigip-next configuration
BigIpMap map[cisapiv1.BigIpConfig]BigIpResourceConfig
// BigIP struct to hold the bigip address and label for HA pairs
BIGIPConfigs []cisapiv1.BigIpConfig
BigIpKey struct {
BigIpAddress string
BigIpLabel string
}
// BigIpResourceConfig struct to hold the bigip-next ltm and gtm configuration
BigIpResourceConfig struct {
ltmConfig LTMConfig
gtmConfig GTMConfig
shareNodes bool
}
resourceRef struct {
kind string
name string
namespace string
}
VSSpecProperties struct {
PoolWAF bool
}
// Pool config
Pool struct {
Name string `json:"name"`
Partition string `json:"-"`
ServiceName string `json:"-"`
ServiceNamespace string `json:"-"`
ServicePort intstr.IntOrString `json:"-"`
Balance string `json:"loadBalancingMethod,omitempty"`
Members []PoolMember `json:"members"`
NodeMemberLabel string `json:"-"`
MonitorNames []MonitorName `json:"monitors,omitempty"`
MinimumMonitors intstr.IntOrString `json:"minimumMonitors,omitempty"`
ReselectTries int32 `json:"reselectTries,omitempty"`
ServiceDownAction string `json:"serviceDownAction,omitempty"`
SlowRampTime int32 `json:"slowRampTime,omitempty"`
Weight int32 `json:"weight,omitempty"`
AlternateBackends []AlternateBackend `json:"alternateBackends"`
MultiClusterServices []cisapiv1.MultiClusterServiceReference `json:"_"`
Cluster string `json:"-"`
ConnectionLimit int32 `json:"-"`
}
CacheIPAM struct {
IPAM *ficV1.IPAM
sync.Mutex
}
// AlternateBackends lists backend svc of A/B
AlternateBackend struct {
Service string `json:"service"`
ServiceNamespace string `json:"serviceNamespace,omitempty"`
Weight int32 `json:"weight,omitempty"`
}
// Pools is slice of pool
Pools []Pool
portRef struct {
name string
port int32
}
poolMembersInfo struct {
svcType v1.ServiceType
portSpec []v1.ServicePort
memberMap map[portRef][]PoolMember
}
// Monitor is Pool health monitor
Monitor struct {
Name string `json:"name"`
Partition string `json:"-"`
Interval int `json:"interval,omitempty"`
Type string `json:"type,omitempty"`
Send string `json:"send,omitempty"`
Recv string `json:"recv"`
Timeout int `json:"timeout,omitempty"`
TargetPort int32 `json:"targetPort,omitempty"`
Path string `json:"path,omitempty"`
TimeUntilUp *int `json:"timeUntilUp,omitempty"`
}
MonitorName struct {
Name string `json:"name"`
// Reference is used to link existing health monitor on bigip
Reference string `json:"reference,omitempty"`
}
// Monitors is slice of monitor
Monitors []Monitor
supplementContextCache struct {
baseRouteConfig cisapiv1.BaseRouteConfig
poolMemCache PoolMemberCache
sslContext map[string]*v1.Secret
extdSpecMap extendedSpecMap
invertedNamespaceLabelMap map[string]string
processedNativeResources map[resourceRef]struct{}
// stores valid externalClustersConfig from extendendCM
externalClustersConfig map[string]cisapiv1.ExternalClusterConfig
}
// key is group identifier
extendedSpecMap map[string]*extendedParsedSpec
// Extended Spec for each group of Routes/Ingress
extendedParsedSpec struct {
override bool
local *cisapiv1.ExtendedRouteGroupSpec
global *cisapiv1.ExtendedRouteGroupSpec
defaultrg *cisapiv1.ExtendedRouteGroupSpec
namespaces []string
partition string
}
// This is the format for each item in the health monitor annotation used
// in the ServiceType LB objects.
ServiceTypeLBHealthMonitor struct {
Interval int `json:"interval"`
Timeout int `json:"timeout"`
}
// Rule config for a Policy
Rule struct {
Name string `json:"name"`
FullURI string `json:"-"`
Ordinal int `json:"ordinal,omitempty"`
Actions []*action `json:"actions,omitempty"`
Conditions []*condition `json:"conditions,omitempty"`
}
// action config for a Rule
action struct {
Name string `json:"name"`
Pool string `json:"pool,omitempty"`
HTTPHost bool `json:"httpHost,omitempty"`
HttpReply bool `json:"httpReply,omitempty"`
HTTPURI bool `json:"httpUri,omitempty"`
Forward bool `json:"forward,omitempty"`
Location string `json:"location,omitempty"`
Path string `json:"path,omitempty"`
Redirect bool `json:"redirect,omitempty"`
Replace bool `json:"replace,omitempty"`
Request bool `json:"request,omitempty"`
Reset bool `json:"reset,omitempty"`
Select bool `json:"select,omitempty"`
Value string `json:"value,omitempty"`
WAF bool `json:"waf,omitempty"`
Policy string `json:"policy,omitempty"`
Drop bool `json:"drop,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Log bool `json:"log,omitempty"`
Message string `json:"message,omitempty"`
}
// condition config for a Rule
condition struct {
Name string `json:"name"`
Address bool `json:"address,omitempty"`
CaseInsensitive bool `json:"caseInsensitive,omitempty"`
Equals bool `json:"equals,omitempty"`
EndsWith bool `json:"endsWith,omitempty"`
External bool `json:"external,omitempty"`
HTTPHost bool `json:"httpHost,omitempty"`
Host bool `json:"host,omitempty"`
HTTPURI bool `json:"httpUri,omitempty"`
Index int `json:"index,omitempty"`
Matches bool `json:"matches,omitempty"`
Path bool `json:"path,omitempty"`
PathSegment bool `json:"pathSegment,omitempty"`
Present bool `json:"present,omitempty"`
Remote bool `json:"remote,omitempty"`
Request bool `json:"request,omitempty"`
Scheme bool `json:"scheme,omitempty"`
Tcp bool `json:"tcp,omitempty"`
Values []string `json:"values"`
SSLExtensionClient bool `json:"-"`
}
// Rules is a slice of Rule
Rules []*Rule
ruleMap map[string]*Rule
// iRules
IRule struct {
Name string `json:"name"`
Partition string `json:"-"`
Code string `json:"apiAnonymous"`
}
IRulesMap map[NameRef]*IRule
InternalDataGroup struct {
Name string `json:"name"`
Partition string `json:"-"`
Type string `json:"-"`
Records InternalDataGroupRecords `json:"records"`
}
InternalDataGroupRecord struct {
Name string `json:"name"`
Data string `json:"data"`
}
InternalDataGroupRecords []InternalDataGroupRecord
DataGroupNamespaceMap map[string]*InternalDataGroup
InternalDataGroupMap map[NameRef]DataGroupNamespaceMap
// virtual server policy/profile reference
NameRef struct {
Name string `json:"name"`
Partition string `json:"partition"`
}
// Policy Virtual policy
Policy struct {
Name string `json:"name"`
Partition string `json:"-"`
SubPath string `json:"subPath,omitempty"`
Controls []string `json:"controls,omitempty"`
Description string `json:"description,omitempty"`
Legacy bool `json:"legacy,omitempty"`
Requires []string `json:"requires,omitempty"`
Rules Rules `json:"rules,omitempty"`
Strategy string `json:"strategy,omitempty"`
}
// Policies is slice of policy
Policies []Policy
// ProfileRef is a Reference to pre-existing profiles
ProfileRef struct {
Name string `json:"name"`
Partition string `json:"partition"`
Context string `json:"context"` // 'clientside', 'serverside', or 'all'
// Used as reference to which Namespace/Ingress this profile came from
// (for deletion purposes)
Namespace string `json:"-"`
BigIPProfile bool `json:"-"`
}
// ProfileRefs is a list of ProfileRef
ProfileRefs []ProfileRef
SecretKey struct {
Name string
ResourceName string
}
// SSL Profile loaded from Secret or Route object
CustomProfile struct {
Name string `json:"name"`
Partition string `json:"-"`
Context string `json:"context"` // 'clientside', 'serverside', or 'all'
Ciphers string `json:"ciphers,omitempty"`
CipherGroup string `json:"cipherGroup,omitempty"`
TLS1_3Enabled bool `json:"tls1_3Enabled"`
ServerName string `json:"serverName,omitempty"`
SNIDefault bool `json:"sniDefault,omitempty"`
PeerCertMode string `json:"peerCertMode,omitempty"`
CAFile string `json:"caFile,omitempty"`
ChainCA string `json:"chainCA,omitempty"`
Certificates []certificate
}
certificate struct {
Cert string `json:"cert"`
Key string `json:"key"`
}
portStruct struct {
protocol string
port int32
}
requestMap struct {
sync.Mutex
requestMap map[BigIpKey]requestMeta
}
requestMeta struct {
partitionMap map[string]map[string]string
id int
}
Node struct {
Name string
Addr string
Labels map[string]string
}
// NPL information from pod annotation
NPLAnnotation struct {
PodPort int32 `json:"podPort"`
NodeIP string `json:"nodeIP"`
NodePort int32 `json:"nodePort"`
}
// List of NPL annotations
NPLAnnoations []NPLAnnotation
// Store of CustomProfiles
ProcessedHostPath struct {
sync.Mutex
processedHostPathMap map[string]metav1.Time
removedHosts []string
}
)
type (
Services []*v1.Service
NodeList []v1.Node
RouteBackendCxt struct {
Weight float64
Name string
Cluster string
SvcNamespace string
}
SvcBackendCxt struct {
Weight float64
Name string
SvcNamespace string `json:"svcNamespace,omitempty"`
Cluster string
}
)
type L3PostManager struct {
}
type (
RequestHandler struct {
PostManagers PostManagers
reqChan chan ResourceConfigRequest
userAgent string
PostParams PostParams
respChan chan *agentConfig
CMTokenManager *tokenmanager.TokenManager
HAMode bool
PrimaryClusterHealthProbeParams PrimaryClusterHealthProbeParams
httpClientMetrics bool
}
PostManager struct {
AS3PostManager *AS3PostManager
L3PostManager *L3PostManager
tokenManager *tokenmanager.TokenManager
// cachedTenantDeclMap,incomingTenantDeclMap hold tenant names and corresponding AS3 config
cachedTenantDeclMap map[string]as3Tenant
postChan chan agentConfig
defaultPartition string
respChan chan *agentConfig
PostParams
postManagerPrefix string
tenantDeclarationIDMap map[string]string
}
PostManagers struct {
sync.RWMutex
PostManagerMap map[BigIpKey]*PostManager
}
AS3PostManager struct {
AS3VersionInfo as3VersionInfo
AS3Config cisapiv1.AS3Config
bigIPAS3Version float64
firstPost bool
bigipLabel string
}
PrimaryClusterHealthProbeParams struct {
paramLock *sync.RWMutex
EndPoint string
EndPointType string
statusRunning bool
statusChanged bool
probeInterval int
retryInterval int
}
PostParams struct {
HTTPClientMetrics bool
httpClient *http.Client
AS3Config cisapiv1.AS3Config
tokenManager *tokenmanager.TokenManager
UserAgent string
}
tenantResponse struct {
agentResponseCode int
isDeleted bool
}
//agentConfig holds as3config and l3config to put onto post channel
agentConfig struct {
as3Config as3Config
l3Config l3Config
id int
BigIpKey BigIpKey
reqMeta requestMeta
}
//as3Config to put into post channel
as3Config struct {
data string
targetAddress string
as3APIURL string
id int
tenantResponseMap map[string]tenantResponse
acceptedTaskId string
failedTenants map[string]struct{}
incomingTenantDeclMap map[string]as3Tenant
deleted bool
}
//TODO L3Config to put into post channel. Handle with L3Postmanager implementation
l3Config struct {
deployL3Status bool
}
// AS3 version struct
as3VersionInfo struct {
as3Version string
as3SchemaVersion string
as3Release string
}
as3Declaration string
as3JSONWithArbKeys map[string]interface{}
// TODO: Need to remove omitempty tag for the mandatory fields
// as3JSONDeclaration maps to ADC in AS3 Resources
as3ADC as3JSONWithArbKeys
// target bigip
as3Target as3JSONWithArbKeys
// as3Tenant maps to Tenant in AS3 Resources
as3Tenant as3JSONWithArbKeys
// as3Application maps to Application in AS3 Resources
as3Application as3JSONWithArbKeys
// as3EndpointPolicy maps to Endpoint_Policy in AS3 Resources
as3EndpointPolicy struct {
Class string `json:"class,omitempty"`
Rules []*as3Rule `json:"rules,omitempty"`
Strategy string `json:"strategy,omitempty"`
}
// as3Rule maps to Endpoint_Policy_Rule in AS3 Resources
as3Rule struct {
Name string `json:"name,omitempty"`
Conditions []*as3Condition `json:"conditions,omitempty"`
Actions []*as3Action `json:"actions,omitempty"`
}
as3ProfileTCP struct {
Ingress *as3ResourcePointer `json:"ingress,omitempty"`
Egress *as3ResourcePointer `json:"egress,omitempty"`
}
as3ProfileHTTP2 struct {
Ingress *as3ResourcePointer `json:"ingress,omitempty"`
Egress *as3ResourcePointer `json:"egress,omitempty"`
}
// as3Action maps to Policy_Action in AS3 Resources
as3Action struct {
Type string `json:"type,omitempty"`
Event string `json:"event,omitempty"`
Select *as3ActionForwardSelect `json:"select,omitempty"`
Policy *as3ResourcePointer `json:"policy,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Location string `json:"location,omitempty"`
Replace *as3ActionReplaceMap `json:"replace,omitempty"`
Write *as3LogMessage `json:"write,omitempty"`
}
as3ActionReplaceMap struct {
Value string `json:"value,omitempty"`
Name string `json:"name,omitempty"`
Path string `json:"path,omitempty"`
}
as3LogMessage struct {
Message string `json:"message,omitempty"`
}
// as3Condition maps to Policy_Condition in AS3 Resources
as3Condition struct {
Type string `json:"type,omitempty"`
Name string `json:"name,omitempty"`
Event string `json:"event,omitempty"`
All *as3PolicyCompareString `json:"all,omitempty"`
Index int `json:"index,omitempty"`
Host *as3PolicyCompareString `json:"host,omitempty"`
PathSegment *as3PolicyCompareString `json:"pathSegment,omitempty"`
Path *as3PolicyCompareString `json:"path,omitempty"`
ServerName *as3PolicyCompareString `json:"serverName,omitempty"`
Address *as3PolicyAddressString `json:"address,omitempty"`
}
// as3ActionForwardSelect maps to Policy_Action_Forward_Select in AS3 Resources
as3ActionForwardSelect struct {
Pool *as3ResourcePointer `json:"pool,omitempty"`
Service *as3ResourcePointer `json:"service,omitempty"`
}
// as3MultiTypeParam can be used for parameters that accept values of different types
// Eg: profileHTTP (string | Service_HTTP_profileHTTP) in Service_HTTP in AS3 Resources
as3MultiTypeParam interface{}
// as3PolicyCompareString maps to Policy_Compare_String in AS3 Resources
as3PolicyCompareString struct {
CaseSensitive bool `json:"caseSensitive,omitempty"`
Values []string `json:"values,omitempty"`
Operand string `json:"operand"`
}
// as3PolicyAddressString maps to Policy_Compare_String in AS3 Resources
as3PolicyAddressString struct {
Values []string `json:"values,omitempty"`
}
// as3Pool maps to Pool in AS3 Resources
as3Pool struct {
Class string `json:"class,omitempty"`
LoadBalancingMode string `json:"loadBalancingMode,omitempty"`
Members []as3PoolMember `json:"members,omitempty"`
Monitors []as3ResourcePointer `json:"monitors,omitempty"`
SlowRampTime int32 `json:"slowRampTime,omitempty"`
}
// as3PoolMember maps to Pool_Member in AS3 Resources
as3PoolMember struct {
AddressDiscovery string `json:"addressDiscovery,omitempty"`
ServerAddresses []string `json:"serverAddresses,omitempty"`
ServicePort int32 `json:"servicePort,omitempty"`
ShareNodes bool `json:"shareNodes,omitempty"`
AdminState string `json:"adminState,omitempty"`
ConnectionLimit int32 `json:"connectionLimit,omitempty"`
}
// as3ResourcePointer maps to following in AS3 Resources
// - Pointer_*
// - Service_HTTP_*
// - Service_HTTPS_*
// - Service_TCP_*
// - Service_UDP_*
as3ResourcePointer struct {
BigIP string `json:"bigip,omitempty"`
Use string `json:"use,omitempty"`
CM string `json:"cm,omitempty"`
}
// as3Service maps to the following in AS3 Resources
// - Service_HTTP
// - Service_HTTPS
// - Service_TCP
// - Service_UDP
as3Service struct {
Layer4 string `json:"layer4,omitempty"`
Class string `json:"class,omitempty"`
VirtualAddresses []as3MultiTypeParam `json:"virtualAddresses,omitempty"`
VirtualPort int `json:"virtualPort,omitempty"`
SNAT as3MultiTypeParam `json:"snat,omitempty"`
Mirroring string `json:"mirroring,omitempty"`
PolicyEndpoint as3MultiTypeParam `json:"policyEndpoint,omitempty"`
ClientTLS as3MultiTypeParam `json:"clientTLS,omitempty"`
ServerTLS as3MultiTypeParam `json:"serverTLS,omitempty"`
IRules as3MultiTypeParam `json:"iRules,omitempty"`
Redirect80 *bool `json:"redirect80,omitempty"`
//Pool *as3ResourcePointer `json:"pool,omitempty"`
Pool interface{} `json:"pool,omitempty"`
WAF as3MultiTypeParam `json:"policyWAF,omitempty"`
Firewall as3MultiTypeParam `json:"policyFirewallEnforced,omitempty"`
LogProfiles []as3ResourcePointer `json:"securityLogProfiles,omitempty"`
ProfileL4 as3MultiTypeParam `json:"profileL4,omitempty"`
PersistenceMethods *[]as3MultiTypeParam `json:"persistenceMethods,omitempty"`
ProfileTCP as3MultiTypeParam `json:"profileTCP,omitempty"`
ProfileUDP as3MultiTypeParam `json:"profileUDP,omitempty"`
ProfileHTTP as3MultiTypeParam `json:"profileHTTP,omitempty"`
ProfileHTTP2 as3MultiTypeParam `json:"profileHTTP2,omitempty"`
ProfileMultiplex as3MultiTypeParam `json:"profileMultiplex,omitempty"`
HttpAnalyticsProfile *as3ResourcePointer `json:"profileAnalytics,omitempty"`
}
// as3ServiceAddress maps to VirtualAddress in AS3 Resources
as3ServiceAddress struct {
Class string `json:"class,omitempty"`
VirtualAddress string `json:"virtualAddress,omitempty"`
ArpEnabled bool `json:"arpEnabled"`
ICMPEcho string `json:"icmpEcho,omitempty"`
RouteAdvertisement string `json:"routeAdvertisement,omitempty"`
TrafficGroup string `json:"trafficGroup,omitempty"`
SpanningEnabled bool `json:"spanningEnabled"`
}
// as3Monitor maps to the following in AS3 Resources
// - Monitor
// - Monitor_HTTP
// - Monitor_HTTPS
as3Monitor struct {
Class string `json:"class,omitempty"`
Interval int `json:"interval,omitempty"`
MonitorType string `json:"monitorType,omitempty"`
Timeout int `json:"timeout,omitempty"`
TimeUnitilUp *int `json:"timeUntilUp,omitempty"`
Receive string `json:"receive"`
Send string `json:"send"`