Skip to content

Commit

Permalink
Merge branch 'nephio-project:main' into porch-cert-manager-webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
Catalin-Stratulat-Ericsson authored May 28, 2024
2 parents 4430c61 + a03a8d2 commit 7721087
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
18 changes: 15 additions & 3 deletions controllers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"k8s.io/client-go/tools/leaderelection/resourcelock"
"k8s.io/klog/v2"
"k8s.io/klog/v2/klogr"
"sigs.k8s.io/controller-runtime/pkg/client"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"

Expand All @@ -41,6 +42,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

porchapi "github.com/nephio-project/porch/api/porch/v1alpha1"
"github.com/nephio-project/porch/controllers/fleetsyncs/pkg/controllers/fleetsync"
"github.com/nephio-project/porch/controllers/packagevariants/pkg/controllers/packagevariant"
"github.com/nephio-project/porch/controllers/packagevariantsets/pkg/controllers/packagevariantset"
Expand Down Expand Up @@ -117,19 +119,29 @@ func run(ctx context.Context) error {
return fmt.Errorf("error initializing scheme: %w", err)
}

if err := porchapi.AddToScheme(scheme); err != nil {
return fmt.Errorf("error initializing scheme: %w", err)
}

managerOptions := ctrl.Options{
Scheme: scheme,
Metrics: metricsserver.Options{
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: ":8080",
},
WebhookServer: webhook.NewServer(webhook.Options{
WebhookServer: webhook.NewServer(webhook.Options{
Port: 9443,
}),
HealthProbeBindAddress: ":8081",
LeaderElection: false,
LeaderElectionID: "porch-operators.config.porch.kpt.dev",
LeaderElectionResourceLock: resourcelock.LeasesResourceLock,
MapperProvider: controllerrestmapper.New,
Client: client.Options{
Cache: &client.CacheOptions{
DisableFor: []client.Object{
&porchapi.PackageRevisionResources{}},
},
},
}

ctrl.SetLogger(klogr.New())
Expand Down
8 changes: 8 additions & 0 deletions controllers/packagevariants/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ rules:
- get
- patch
- update
- apiGroups:
- config.porch.kpt.dev
resources:
- repositories
verbs:
- get
- list
- watch
- apiGroups:
- porch.kpt.dev
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const (
//+kubebuilder:rbac:groups=config.porch.kpt.dev,resources=packagevariants/finalizers,verbs=update
//+kubebuilder:rbac:groups=porch.kpt.dev,resources=packagerevisions,verbs=create;delete;get;list;patch;update;watch
//+kubebuilder:rbac:groups=porch.kpt.dev,resources=packagerevisionresources,verbs=create;delete;get;list;patch;update;watch
//+kubebuilder:rbac:groups=config.porch.kpt.dev,resources=repositories,verbs=get;list;watch

// Reconcile implements the main kubernetes reconciliation loop.
func (r *PackageVariantReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
Expand Down
8 changes: 8 additions & 0 deletions controllers/packagevariantsets/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,11 @@ rules:
- get
- patch
- update
- apiGroups:
- config.porch.kpt.dev
resources:
- repositories
verbs:
- get
- list
- watch
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const (
//+kubebuilder:rbac:groups=config.porch.kpt.dev,resources=packagevariantsets/finalizers,verbs=update
//+kubebuilder:rbac:groups=config.porch.kpt.dev,resources=packagevariants,verbs=create;delete;get;list;patch;update;watch
//+kubebuilder:rbac:groups=*,resources=*,verbs=list
//+kubebuilder:rbac:groups=config.porch.kpt.dev,resources=repositories,verbs=get;list;watch

// Reconcile implements the main kubernetes reconciliation loop.
func (r *PackageVariantSetReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
Expand Down
2 changes: 1 addition & 1 deletion func/internal/podevaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (pcm *podCacheManager) podCacheManager() {
func (pcm *podCacheManager) garbageCollector() {
var err error
podList := &corev1.PodList{}
err = pcm.podManager.kubeClient.List(context.Background(), podList, client.InNamespace(pcm.podManager.namespace))
err = pcm.podManager.kubeClient.List(context.Background(), podList, client.InNamespace(pcm.podManager.namespace), client.HasLabels{krmFunctionLabel})
if err != nil {
klog.Warningf("unable to list pods in namespace %v: %v", pcm.podManager.namespace, err)
return
Expand Down

0 comments on commit 7721087

Please sign in to comment.