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
efiacor authored May 30, 2024
2 parents 98efbce + e190648 commit ca7f380
Show file tree
Hide file tree
Showing 14 changed files with 304 additions and 445 deletions.
30 changes: 4 additions & 26 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
"mode": "auto",
"program": "${workspaceFolder}/cmd/porch/main.go",
"args": [
"--secure-port=9443",
"--secure-port=4443",
"--v=7",
"--standalone-debug-mode",
"--kubeconfig=${workspaceFolder}/deployments/local/kubeconfig",
"--kubeconfig=${env:KUBECONFIG}",
"--cache-directory=${workspaceFolder}/.cache",
"--function-runner=192.168.8.202:9445"
"--function-runner=172.18.255.201:9445",
"--repo-sync-frequency=60s"
],
"cwd": "${workspaceFolder}"
},
Expand All @@ -44,29 +45,6 @@
"--",
"namespace=foo"
]
},
{
"name": "Launch kpt",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/../main.go",
"args": [
"alpha", "rpkg", "get"
],
"cwd": "${workspaceFolder}/.."
},
{
"name": "Launch kpt e2e test",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${workspaceFolder}/../e2e",
"args": [
"-v",
"-test.run",
"TestPorch"
]
}
]
}
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ generate: generate-api
tidy:
@for f in $(MODULES); do (cd $$f; echo "Tidying $$f"; go mod tidy) || exit 1; done

.PHONY: test-e2e
test-e2e:
E2E=1 go test -v -race --count=1 -failfast ./test/e2e

.PHONY: configure-git
configure-git:
git config --global --add user.name test
Expand Down Expand Up @@ -266,8 +270,8 @@ push-and-deploy: push-images deploy
# `push-and-deploy` etc.)
.PHONY: deployment-config-no-sa
deployment-config-no-sa:
rm -rf $(DEPLOYCONFIG_NO_SA_DIR) || true
mkdir -p $(DEPLOYCONFIG_NO_SA_DIR)
find $(DEPLOYCONFIG_NO_SA_DIR) ! -name 'resourcegroup.yaml' -type f -exec rm -f {} +
./scripts/create-deployment-blueprint.sh \
--destination "$(DEPLOYCONFIG_NO_SA_DIR)" \
--server-image "$(IMAGE_REPO)/$(PORCH_SERVER_IMAGE):$(IMAGE_TAG)" \
Expand Down
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
18 changes: 18 additions & 0 deletions deployments/local/porch-api-endpoints.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Endpoints
metadata:
annotations:
config.kubernetes.io/target-path: 3-porch-server-endpoints.yaml
name: api
namespace: porch-system
subsets:
- addresses:
- ip: 172.17.0.1
ports:
- appProtocol: https
name: api
port: 4443
protocol: TCP
- name: webhooks
port: 8443
protocol: TCP
Loading

0 comments on commit ca7f380

Please sign in to comment.