Skip to content

Commit

Permalink
feat: add leader election configuration (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrejpetras authored Oct 8, 2024
1 parent 9cb471d commit a2e81fb
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 30 deletions.
2 changes: 2 additions & 0 deletions docs/modules/onecx-permission-operator/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ include::onecx-permission-operator-attributes.adoc[opts=optional]

include::docs.adoc[opts=optional]

=== Configuration
include::onecx-permission-operator.adoc[opts=optional]

include::onecx-permission-operator-docs.adoc[opts=optional]
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,3 @@ app:
----

nt:
enabled: true
spec:
kcConfig:
defaultClientScopes: [ ocx-pm:write ]

# Values: JOSDK_WATCH_CURRENT, JOSDK_ALL_NAMESPACES or comma separated list of namespaces
watchNamespaces: "JOSDK_WATCH_CURRENT"

----
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,38 @@ h| Version
| tkit-quarkus-log-cdi

| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-cdi.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link]
| 2.31.0
| https://github.com/1000kit/tkit-quarkus/blob/2.33.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link]
| 2.33.0

| tkit-quarkus-log-rs

| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-rs.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link]
| 2.31.0
| https://github.com/1000kit/tkit-quarkus/blob/2.33.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link]
| 2.33.0

| tkit-quarkus-log-json

| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-json.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link]
| 2.31.0
| https://github.com/1000kit/tkit-quarkus/blob/2.33.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link]
| 2.33.0

| quarkus-arc

| https://quarkus.io/guides/cdi-reference[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-arc.adoc[Link]
| 3.13.2
| 3.15.1
| quarkus-micrometer-registry-prometheus
| https://quarkus.io/guides/telemetry-micrometer[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-micrometer-registry-prometheus.adoc[Link]
| 3.13.2
| 3.15.1
| quarkus-opentelemetry
| https://quarkus.io/guides/opentelemetry[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-opentelemetry.adoc[Link]
| 3.13.2
| 3.15.1
| quarkus-openapi-generator
Expand All @@ -54,37 +54,37 @@ h| Version
| https://quarkus.io/guides/rest-client[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-rest-client.adoc[Link]
| 3.13.2
| 3.15.1
| quarkus-rest-client-jackson
| https://quarkus.io/guides/rest-client[Link]
|
| 3.13.2
| 3.15.1
| tkit-quarkus-security
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-security.html[Link]
| https://github.com/1000kit/tkit-quarkus/blob/2.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link]
| 2.31.0
| https://github.com/1000kit/tkit-quarkus/blob/2.33.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link]
| 2.33.0
| onecx-core
| https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-core.html[Link]
|
| 0.26.0
| 0.31.0
| quarkus-smallrye-health
| https://quarkus.io/guides/smallrye-health[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-smallrye-health.adoc[Link]
| 3.13.2
| 3.15.1
| quarkus-container-image-docker
| https://quarkus.io/guides/container-image[Link]
| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-container-image-docker.adoc[Link]
| 3.13.2
| 3.15.1
| quarkus-operator-sdk-bundle-generator
Expand All @@ -103,13 +103,13 @@ h| Version
|
|
| 3.13.2
| 3.15.1
| quarkus-rest-client-oidc-filter
|
|
| 3.13.2
| 3.15.1
|===
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
:summaryTableId: onecx-permission-operator
[.configuration-legend]
icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime
[.configuration-reference.searchable, cols="80,.^10,.^10"]
|===

h|[.header-title]##Configuration property##
h|Type
h|Default

a| [[onecx-permission-operator_onecx-permission-operator-leader-election-lease-name]] [.property-path]##link:#onecx-permission-operator_onecx-permission-operator-leader-election-lease-name[`onecx.permission.operator.leader-election.lease-name`]##

[.description]
--
Lease name


ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++ONECX_PERMISSION_OPERATOR_LEADER_ELECTION_LEASE_NAME+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++ONECX_PERMISSION_OPERATOR_LEADER_ELECTION_LEASE_NAME+++`
endif::add-copy-button-to-env-var[]
--
|string
|`onecx-permission-operator-lease`

|===


:!summaryTableId:
11 changes: 10 additions & 1 deletion src/main/helm/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,13 @@ rules:
- patch
- update
- create
- delete
- delete
- verbs:
- "get"
- "update"
- "create"
- "patch"
apiGroups:
- "coordination.k8s.io"
resources:
- "leases"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.tkit.onecx.permission.operator;

import jakarta.inject.Singleton;

import io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration;

@Singleton
public class LeaderConfiguration extends LeaderElectionConfiguration {

public LeaderConfiguration(PermissionConfig config) {
super(config.leaderElectionConfig().leaseName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.tkit.onecx.permission.operator;

import io.quarkus.runtime.annotations.ConfigDocFilename;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.quarkus.runtime.annotations.StaticInitSafe;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;
import io.smallrye.config.WithName;

@StaticInitSafe
@ConfigDocFilename("onecx-permission-operator.adoc")
@ConfigMapping(prefix = "onecx.permission.operator")
@ConfigRoot(phase = ConfigPhase.RUN_TIME)
public interface PermissionConfig {

/**
* Leader election configuration
*/
@WithName("leader-election")
LeaderElectionConfig leaderElectionConfig();

/**
* Leader election config
*/
interface LeaderElectionConfig {

/**
* Lease name
*/
@WithName("lease-name")
@WithDefault("onecx-permission-operator-lease")
String leaseName();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.tkit.onecx.permission.operator;

import static org.assertj.core.api.Assertions.assertThat;

import jakarta.inject.Inject;

import org.junit.jupiter.api.Test;
import org.tkit.onecx.permission.test.AbstractTest;

import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
class LeaderConfigurationTest extends AbstractTest {

@Inject
PermissionConfig dataConfig;

@Inject
LeaderConfiguration leaderConfiguration;

@Test
void testLeaderConfiguration() {
assertThat(dataConfig).isNotNull();
assertThat(dataConfig.leaderElectionConfig()).isNotNull();
assertThat(leaderConfiguration).isNotNull();
assertThat(leaderConfiguration.getLeaseName()).isNotNull().isEqualTo(dataConfig.leaderElectionConfig().leaseName());
}
}

0 comments on commit a2e81fb

Please sign in to comment.