-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix registry mirror issues in packages #7115
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ rules: | |
verbs: | ||
- create | ||
- delete | ||
- get | ||
- apiGroups: | ||
- "" | ||
resources: | ||
|
@@ -376,13 +377,14 @@ kind: Role | |
metadata: | ||
creationTimestamp: null | ||
name: manager-role | ||
namespace: eksa-system | ||
namespace: eksa-packages | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- secrets | ||
verbs: | ||
- get | ||
- patch | ||
- update | ||
- apiGroups: | ||
|
@@ -391,3 +393,19 @@ rules: | |
- packagebundlecontrollers | ||
verbs: | ||
- delete | ||
|
||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
creationTimestamp: null | ||
name: manager-role | ||
namespace: eksa-system | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- secrets | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the cluster role has permissions to do these for secrets |
||
verbs: | ||
- patch | ||
- update |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namePrefix: | ||
- path: metadata/namespace | ||
kind: ServiceAccount | ||
- path: subjects/name | ||
kind: RoleBinding | ||
- path: subjects/namespace | ||
kind: RoleBinding | ||
- path: subjects/name | ||
kind: ClusterRoleBinding | ||
- path: subjects/namespace | ||
kind: ClusterRoleBinding |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
namePrefix: eksa- | ||
|
||
bases: | ||
- ../rbac | ||
|
||
configurations: | ||
- ./apply-namespace.yaml | ||
|
||
transformers: | ||
- |- | ||
apiVersion: builtin | ||
kind: NamespaceTransformer | ||
metadata: | ||
name: notImportantHere2 | ||
namespace: eksa-system | ||
unsetOnly: true | ||
|
||
patchesJson6902: | ||
- patch: |- | ||
- op: replace | ||
path: /metadata/name | ||
value: eksa-packages-rolebinding | ||
target: | ||
group: rbac.authorization.k8s.io | ||
kind: RoleBinding | ||
name: eksa-manager-rolebinding | ||
namespace: eksa-packages | ||
version: v1 | ||
- patch: |- | ||
- op: replace | ||
path: /metadata/name | ||
value: eksa-packages-role | ||
target: | ||
group: rbac.authorization.k8s.io | ||
kind: Role | ||
name: eksa-manager-role | ||
namespace: eksa-packages | ||
version: v1 | ||
Comment on lines
+19
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean that every time we add a role for a different namespace we would need to add a couple entries here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we would need to patch the name of the role for other namespaces since they never get created if there is already another role with the same name in eksa-system. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ | |
EnableFullLifecycle(ctx context.Context, log logr.Logger, clusterName, kubeConfig string, chart *v1alpha1.Image, registry *registrymirror.RegistryMirror, options ...curatedpackages.PackageControllerClientOpt) error | ||
ReconcileDelete(context.Context, logr.Logger, curatedpackages.KubeDeleter, *anywherev1.Cluster) error | ||
Reconcile(context.Context, logr.Logger, client.Client, *anywherev1.Cluster) error | ||
UpdateSecrets(ctx context.Context, client client.Client, cluster *anywherev1.Cluster) error | ||
} | ||
|
||
type ProviderClusterReconcilerRegistry interface { | ||
|
@@ -174,7 +175,7 @@ | |
// +kubebuilder:rbac:groups="",resources=events,verbs=create;patch;update | ||
// +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;delete | ||
// +kubebuilder:rbac:groups="",namespace=eksa-system,resources=secrets,verbs=patch;update | ||
// +kubebuilder:rbac:groups="",resources=namespaces,verbs=create;delete | ||
// +kubebuilder:rbac:groups="",resources=namespaces,verbs=create;delete;get | ||
// +kubebuilder:rbac:groups="",resources=nodes,verbs=list | ||
// +kubebuilder:rbac:groups=addons.cluster.x-k8s.io,resources=clusterresourcesets,verbs=get;list;watch;create;update;patch;delete | ||
// +kubebuilder:rbac:groups=anywhere.eks.amazonaws.com,resources=clusters;gitopsconfigs;snowmachineconfigs;snowdatacenterconfigs;snowippools;vspheredatacenterconfigs;vspheremachineconfigs;dockerdatacenterconfigs;tinkerbellmachineconfigs;tinkerbelldatacenterconfigs;cloudstackdatacenterconfigs;cloudstackmachineconfigs;nutanixdatacenterconfigs;nutanixmachineconfigs;awsiamconfigs;oidcconfigs;awsiamconfigs;fluxconfigs,verbs=get;list;watch;update;patch | ||
|
@@ -194,7 +195,8 @@ | |
// +kubebuilder:rbac:groups=bmc.tinkerbell.org,resources=machines,verbs=list;watch | ||
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=awssnowclusters;awssnowmachinetemplates;awssnowippools;vsphereclusters;vspheremachinetemplates;dockerclusters;dockermachinetemplates;tinkerbellclusters;tinkerbellmachinetemplates;cloudstackclusters;cloudstackmachinetemplates;nutanixclusters;nutanixmachinetemplates,verbs=get;list;watch;create;update;patch;delete | ||
// +kubebuilder:rbac:groups=packages.eks.amazonaws.com,resources=packages,verbs=create;delete;get;list;patch;update;watch | ||
// +kubebuilder:rbac:groups=packages.eks.amazonaws.com,namespace=eksa-system,resources=packagebundlecontrollers,verbs=delete | ||
// +kubebuilder:rbac:groups=packages.eks.amazonaws.com,namespace=eksa-packages,resources=packagebundlecontrollers,verbs=delete | ||
// +kubebuilder:rbac:groups="",namespace=eksa-packages,resources=secrets,verbs=get;patch;update | ||
// +kubebuilder:rbac:groups=anywhere.eks.amazonaws.com,resources=eksareleases,verbs=get;list;watch | ||
// The eksareleases permissions are being moved to the ClusterRole due to client trying to list this resource from cache. | ||
// When trying to list resources not already in cache, it starts an informer for that type using the scope of the cache. | ||
|
@@ -386,6 +388,10 @@ | |
} | ||
} | ||
|
||
if err := r.packagesClient.UpdateSecrets(ctx, r.client, cluster); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could this be part of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So one of the issues I found was that the controller's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. And what would be the problem on waiting until reconcile doesn't return early? |
||
return controller.Result{}, err | ||
} | ||
|
||
return controller.Result{}, nil | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,6 +182,7 @@ func TestClusterReconcilerReconcileSelfManagedCluster(t *testing.T) { | |
registry := newRegistryMock(providerReconciler) | ||
c := fake.NewClientBuilder().WithRuntimeObjects(selfManagedCluster, kcp).Build() | ||
mockPkgs := mocks.NewMockPackagesClient(controller) | ||
mockPkgs.EXPECT().UpdateSecrets(ctx, c, sameName(selfManagedCluster)) | ||
providerReconciler.EXPECT().Reconcile(ctx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(selfManagedCluster)) | ||
mhcReconciler.EXPECT().Reconcile(ctx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(selfManagedCluster)).Return(nil) | ||
|
||
|
@@ -367,6 +368,7 @@ func TestClusterReconcilerReconcileConditions(t *testing.T) { | |
log := testr.New(t) | ||
logCtx := ctrl.LoggerInto(ctx, log) | ||
|
||
mockPkgs.EXPECT().UpdateSecrets(logCtx, testClient, sameName(config.Cluster)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we should think about adding a helper to group all expectations? most tests apparently don't care about the expectations, just about the result |
||
iam.EXPECT().EnsureCASecret(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(controller.Result{}, nil) | ||
iam.EXPECT().Reconcile(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(controller.Result{}, nil) | ||
providerReconciler.EXPECT().Reconcile(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Times(1) | ||
|
@@ -625,6 +627,8 @@ func TestClusterReconcilerReconcileSelfManagedClusterConditions(t *testing.T) { | |
providerReconciler.EXPECT().Reconcile(gomock.Any(), gomock.Any(), gomock.Any()).Times(1) | ||
mhcReconciler.EXPECT().Reconcile(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(nil) | ||
|
||
mockPkgs.EXPECT().UpdateSecrets(logCtx, testClient, sameName(config.Cluster)) | ||
|
||
r := controllers.NewClusterReconciler(testClient, registry, iam, clusterValidator, mockPkgs, mhcReconciler) | ||
|
||
result, err := r.Reconcile(logCtx, clusterRequest(config.Cluster)) | ||
|
@@ -772,6 +776,7 @@ func TestClusterReconcilerReconcileGenerations(t *testing.T) { | |
mhcReconciler := mocks.NewMockMachineHealthCheckReconciler(mockCtrl) | ||
|
||
if tt.wantReconciliation { | ||
mockPkgs.EXPECT().UpdateSecrets(ctx, client, sameName(config.Cluster)) | ||
iam.EXPECT().EnsureCASecret(ctx, gomock.AssignableToTypeOf(logr.Logger{}), gomock.AssignableToTypeOf(config.Cluster)).Return(controller.Result{}, nil) | ||
iam.EXPECT().Reconcile(ctx, gomock.AssignableToTypeOf(logr.Logger{}), gomock.AssignableToTypeOf(config.Cluster)).Return(controller.Result{}, nil) | ||
providerReconciler.EXPECT().Reconcile(ctx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Times(1) | ||
|
@@ -1140,6 +1145,7 @@ func TestClusterReconcilerSkipDontInstallPackagesOnSelfManaged(t *testing.T) { | |
|
||
ctrl := gomock.NewController(t) | ||
mockPkgs := mocks.NewMockPackagesClient(ctrl) | ||
mockPkgs.EXPECT().UpdateSecrets(ctx, mockClient, sameName(cluster)) | ||
mockPkgs.EXPECT().ReconcileDelete(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(0) | ||
mhcReconciler := mocks.NewMockMachineHealthCheckReconciler(ctrl) | ||
mhcReconciler.EXPECT().Reconcile(ctx, gomock.Any(), sameName(cluster)).Return(nil) | ||
|
@@ -1318,6 +1324,7 @@ func TestClusterReconcilerPackagesInstall(s *testing.T) { | |
|
||
mhcReconciler.EXPECT().Reconcile(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(cluster)).Return(nil) | ||
|
||
mockPkgs.EXPECT().UpdateSecrets(logCtx, fakeClient, sameName(cluster)) | ||
mockPkgs.EXPECT(). | ||
EnableFullLifecycle(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). | ||
Times(0) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1137,6 +1137,11 @@ | |
return c.clusterClient.CreateNamespaceIfNotPresent(ctx, cluster.KubeconfigFile, constants.EksaSystemNamespace) | ||
} | ||
|
||
// CreatePackagesNamespace creates the eksa-packages namespace on the cluster if it doesn't already exist. | ||
func (c *ClusterManager) CreatePackagesNamespace(ctx context.Context, cluster *types.Cluster) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. curious, why is this needed now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need the namespace before installing packages or else we can't add role/rolebindings in that ns |
||
return c.clusterClient.CreateNamespaceIfNotPresent(ctx, cluster.KubeconfigFile, constants.EksaPackagesName) | ||
} | ||
|
||
// CreateEKSAResources applies the eks-a cluster specs (cluster, datacenterconfig, machine configs, etc.), as well as the | ||
// release bundle to the cluster. Before applying the spec, we pause eksa controller cluster and datacenter webhook validation | ||
// so that the cluster spec can be created or updated in the cluster without webhook validation error. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious why are we adding this only on prod? don't we want all these permissions regardless of the "target"?