Skip to content

Commit

Permalink
fix(leadership election): add rbac role for V1Lease objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Bühler committed Sep 10, 2020
1 parent 931a49c commit 16e7bbd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/KubeOps/Operator/Commands/Generators/RbacGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static V1ClusterRole GenerateManagerRbac()
new V1ObjectMeta { Name = "operator-role" },
new List<V1PolicyRule>(
GetAttributes<EntityRbacAttribute>(assembly)
.Concat(GetAttributes<EntityRbacAttribute>(Assembly.GetExecutingAssembly()))
.SelectMany(a => a.CreateRbacPolicies())
.Concat(GetAttributes<GenericRbacAttribute>(assembly).Select(a => a.CreateRbacPolicy()))));
}
Expand Down
2 changes: 2 additions & 0 deletions src/KubeOps/Operator/Leadership/LeaderElector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
using System.Threading.Tasks;
using k8s.Models;
using KubeOps.Operator.Client;
using KubeOps.Operator.Rbac;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Rest;
using Timer = System.Timers.Timer;

namespace KubeOps.Operator.Leadership
{
[EntityRbac(typeof(V1Lease), Verbs = RbacVerb.All)]
internal class LeaderElector : IHostedService
{
private readonly ILogger<LeaderElector> _logger;
Expand Down
6 changes: 6 additions & 0 deletions tests/KubeOps.Test/KubeOps.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@
<ProjectReference Include="..\..\src\KubeOps\KubeOps.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Operator\Leadership" />
<Folder Include="Operator\Queue" />
<Folder Include="Operator\Watcher" />
</ItemGroup>

</Project>

0 comments on commit 16e7bbd

Please sign in to comment.