@@ -73,18 +73,18 @@ const (
73
73
// the kubernetes postrouting chain
74
74
kubePostroutingChain utiliptables.Chain = "KUBE-POSTROUTING"
75
75
76
- // the mark-for-masquerade chain
76
+ // KubeMarkMasqChain is the mark-for-masquerade chain
77
77
KubeMarkMasqChain utiliptables.Chain = "KUBE-MARK-MASQ"
78
78
79
- // the mark-for-drop chain
79
+ // KubeMarkDropChain is the mark-for-drop chain
80
80
KubeMarkDropChain utiliptables.Chain = "KUBE-MARK-DROP"
81
81
82
82
// the kubernetes forward chain
83
83
kubeForwardChain utiliptables.Chain = "KUBE-FORWARD"
84
84
)
85
85
86
- // IPTablesVersioner can query the current iptables version.
87
- type IPTablesVersioner interface {
86
+ // Versioner can query the current iptables version.
87
+ type Versioner interface {
88
88
// returns "X.Y.Z"
89
89
GetVersion () (string , error )
90
90
}
@@ -100,7 +100,7 @@ type KernelCompatTester interface {
100
100
// the iptables version and for the existence of kernel features. It may return
101
101
// an error if it fails to get the iptables version without error, in which
102
102
// case it will also return false.
103
- func CanUseIPTablesProxier (iptver IPTablesVersioner , kcompat KernelCompatTester ) (bool , error ) {
103
+ func CanUseIPTablesProxier (iptver Versioner , kcompat KernelCompatTester ) (bool , error ) {
104
104
minVersion , err := utilversion .ParseGeneric (iptablesMinVersion )
105
105
if err != nil {
106
106
return false , err
@@ -124,12 +124,14 @@ func CanUseIPTablesProxier(iptver IPTablesVersioner, kcompat KernelCompatTester)
124
124
return true , nil
125
125
}
126
126
127
+ // LinuxKernelCompatTester is the Linux implementation of KernelCompatTester
127
128
type LinuxKernelCompatTester struct {}
128
129
130
+ // IsCompatible checks for the required sysctls. We don't care about the value, just
131
+ // that it exists. If this Proxier is chosen, we'll initialize it as we
132
+ // need.
129
133
func (lkct LinuxKernelCompatTester ) IsCompatible () error {
130
- // Check for the required sysctls. We don't care about the value, just
131
- // that it exists. If this Proxier is chosen, we'll initialize it as we
132
- // need.
134
+
133
135
_ , err := utilsysctl .New ().GetSysctl (sysctlRouteLocalnet )
134
136
return err
135
137
}
@@ -507,21 +509,29 @@ func (proxier *Proxier) isInitialized() bool {
507
509
return atomic .LoadInt32 (& proxier .initialized ) > 0
508
510
}
509
511
512
+ // OnServiceAdd is called whenever creation of new service object
513
+ // is observed.
510
514
func (proxier * Proxier ) OnServiceAdd (service * v1.Service ) {
511
515
proxier .OnServiceUpdate (nil , service )
512
516
}
513
517
518
+ // OnServiceUpdate is called whenever modification of an existing
519
+ // service object is observed.
514
520
func (proxier * Proxier ) OnServiceUpdate (oldService , service * v1.Service ) {
515
521
if proxier .serviceChanges .Update (oldService , service ) && proxier .isInitialized () {
516
522
proxier .syncRunner .Run ()
517
523
}
518
524
}
519
525
526
+ // OnServiceDelete is called whenever deletion of an existing service
527
+ // object is observed.
520
528
func (proxier * Proxier ) OnServiceDelete (service * v1.Service ) {
521
529
proxier .OnServiceUpdate (service , nil )
522
530
523
531
}
524
532
533
+ // OnServiceSynced is called once all the initial even handlers were
534
+ // called and the state is fully propagated to local cache.
525
535
func (proxier * Proxier ) OnServiceSynced () {
526
536
proxier .mu .Lock ()
527
537
proxier .servicesSynced = true
@@ -532,20 +542,28 @@ func (proxier *Proxier) OnServiceSynced() {
532
542
proxier .syncProxyRules ()
533
543
}
534
544
545
+ // OnEndpointsAdd is called whenever creation of new endpoints object
546
+ // is observed.
535
547
func (proxier * Proxier ) OnEndpointsAdd (endpoints * v1.Endpoints ) {
536
548
proxier .OnEndpointsUpdate (nil , endpoints )
537
549
}
538
550
551
+ // OnEndpointsUpdate is called whenever modification of an existing
552
+ // endpoints object is observed.
539
553
func (proxier * Proxier ) OnEndpointsUpdate (oldEndpoints , endpoints * v1.Endpoints ) {
540
554
if proxier .endpointsChanges .Update (oldEndpoints , endpoints ) && proxier .isInitialized () {
541
555
proxier .syncRunner .Run ()
542
556
}
543
557
}
544
558
559
+ // OnEndpointsDelete is called whever deletion of an existing endpoints
560
+ // object is observed.
545
561
func (proxier * Proxier ) OnEndpointsDelete (endpoints * v1.Endpoints ) {
546
562
proxier .OnEndpointsUpdate (endpoints , nil )
547
563
}
548
564
565
+ // OnEndpointsSynced is called once all the initial event handlers were
566
+ // called and the state is fully propagated to local cache.
549
567
func (proxier * Proxier ) OnEndpointsSynced () {
550
568
proxier .mu .Lock ()
551
569
proxier .endpointsSynced = true
0 commit comments