Skip to content

Commit

Permalink
-add discoveryv1 mapper
Browse files Browse the repository at this point in the history
-fix function in iptables module
  • Loading branch information
francescodanzi committed Mar 16, 2023
1 parent 6219016 commit 15e13fc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
23 changes: 18 additions & 5 deletions cmd/liqonet/gateway-operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ func runGatewayOperator(commonFlags *liqonetCommonFlags, gatewayFlags *gatewayOp
klog.Errorf("unable to get pod namespace: %v", err)
os.Exit(1)
}

/* podsLabelRequirement, err := labels.NewRequirement(liqoconst.ManagedByLabelKey, selection.Equals, []string{liqoconst.ManagedByShadowPodValue})
utilruntime.Must(err)
endpointslicesLabelRequirement, err := labels.NewRequirement(discoveryv1.LabelManagedBy, selection.Equals, []string{liqovk.EndpointSliceManagedBy})
utilruntime.Must(err) */

main, err := ctrl.NewManager(restcfg.SetRateLimiter(ctrl.GetConfigOrDie()), ctrl.Options{
MapperProvider: mapper.LiqoMapperProvider(scheme),
Scheme: scheme,
Expand All @@ -106,11 +113,17 @@ func runGatewayOperator(commonFlags *liqonetCommonFlags, gatewayFlags *gatewayOp
LeaseDuration: &leaseDuration,
RenewDeadline: &renewDeadLine,
RetryPeriod: &retryPeriod,
// NewCache: cache.BuilderWithOptions(cache.Options{
// SelectorsByObject: cache.SelectorsByObject{
// &corev1.Pod{}: {Field: fields.OneTermEqualSelector("metadata.namespace", podNamespace)},
// },
// }),
/* NewCache: cache.BuilderWithOptions(cache.Options{
SelectorsByObject: cache.SelectorsByObject{
&corev1.Pod{}: {
Field: fields.OneTermEqualSelector("metadata.namespace", podNamespace),
Label: labels.NewSelector().Add(*podsLabelRequirement),
},
&discoveryv1.EndpointSlice{}: {
Label: labels.NewSelector().Add(*endpointslicesLabelRequirement),
},
},
}), */
})
if err != nil {
klog.Errorf("unable to get main manager: %s", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ type reflectedEndpointsliceController struct {
endpointslicesInfo *sync.Map
}

//+kubebuilder:rbac:groups=discovery.k8s.io,resources=endpointslices,verbs=get;list;watch;
//+kubebuilder:rbac:groups=discovery.k8s.io,resources=endpointslices/endpoints,verbs=get;list;watch;
//+kubebuilder:rbac:groups=discovery.k8s.io,resources=endpointslices/endpoints/addresses,verbs=get;list;watch;
// +kubebuilder:rbac:groups=discovery.k8s.io,resources=endpointslices,verbs=get;list;watch
// +kubebuilder:rbac:groups=discovery.k8s.io,resources=endpointslices/endpoints,verbs=get;list;watch
// +kubebuilder:rbac:groups=discovery.k8s.io,resources=endpointslices/endpoints/addresses,verbs=get;list;watch

// NewOffloadedPodController instantiates and initializes the offloaded service controller.
func NewReflectedEndpointsliceController(cl client.Client, gatewayNetns ns.NetNS) (*reflectedEndpointsliceController, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/liqonet/iptables/iptables.go
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ func buildRulesPerClusterForRemoteEndpointslicesReflected(endpointslicesInfo *sy
"-j", DROP},
IPTableRule{
"-m", setModule,
"--match-set", ipset.Name, "dst",
"--match-set", ipset.Name, "src",
"-j", ACCEPT})
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/utils/mapper/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package mapper
import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"
rbacv1 "k8s.io/api/rbac/v1"
storagev1 "k8s.io/api/storage/v1"
"k8s.io/apimachinery/pkg/api/meta"
Expand Down Expand Up @@ -86,6 +87,9 @@ func addDefaults(dClient *discovery.DiscoveryClient, mapper *meta.DefaultRESTMap
if err = addGroup(dClient, corev1.SchemeGroupVersion, mapper); err != nil {
return err
}
if err = addGroup(dClient, discoveryv1.SchemeGroupVersion, mapper); err != nil {
return err
}
if err = addGroup(dClient, appsv1.SchemeGroupVersion, mapper); err != nil {
return err
}
Expand Down

0 comments on commit 15e13fc

Please sign in to comment.