Skip to content

Commit 16e7bbd

Browse files
author
Christoph Bühler
committed
fix(leadership election): add rbac role for V1Lease objects
1 parent 931a49c commit 16e7bbd

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/KubeOps/Operator/Commands/Generators/RbacGenerator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public static V1ClusterRole GenerateManagerRbac()
3838
new V1ObjectMeta { Name = "operator-role" },
3939
new List<V1PolicyRule>(
4040
GetAttributes<EntityRbacAttribute>(assembly)
41+
.Concat(GetAttributes<EntityRbacAttribute>(Assembly.GetExecutingAssembly()))
4142
.SelectMany(a => a.CreateRbacPolicies())
4243
.Concat(GetAttributes<GenericRbacAttribute>(assembly).Select(a => a.CreateRbacPolicy()))));
4344
}

src/KubeOps/Operator/Leadership/LeaderElector.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
using System.Threading.Tasks;
66
using k8s.Models;
77
using KubeOps.Operator.Client;
8+
using KubeOps.Operator.Rbac;
89
using Microsoft.Extensions.Hosting;
910
using Microsoft.Extensions.Logging;
1011
using Microsoft.Rest;
1112
using Timer = System.Timers.Timer;
1213

1314
namespace KubeOps.Operator.Leadership
1415
{
16+
[EntityRbac(typeof(V1Lease), Verbs = RbacVerb.All)]
1517
internal class LeaderElector : IHostedService
1618
{
1719
private readonly ILogger<LeaderElector> _logger;

tests/KubeOps.Test/KubeOps.Test.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@
1919
<ProjectReference Include="..\..\src\KubeOps\KubeOps.csproj" />
2020
</ItemGroup>
2121

22+
<ItemGroup>
23+
<Folder Include="Operator\Leadership" />
24+
<Folder Include="Operator\Queue" />
25+
<Folder Include="Operator\Watcher" />
26+
</ItemGroup>
27+
2228
</Project>

0 commit comments

Comments
 (0)