Skip to content
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

feat: add leader election configuration #68

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ include::onecx-product-store-mfe-operator-attributes.adoc[opts=optional]

include::docs.adoc[opts=optional]

=== Configuration
include::onecx-product-store-mfe-operator.adoc[opts=optional]

include::onecx-product-store-mfe-operator-docs.adoc[opts=optional]
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,3 @@ app:

----

t:
enabled: true
spec:
kcConfig:
defaultClientScopes: [ ocx-ps-mfe: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-product-store-mfe-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-product-store-mfe-operator_onecx-product-store-operator-mfe-leader-election-lease-name]] [.property-path]##link:#onecx-product-store-mfe-operator_onecx-product-store-operator-mfe-leader-election-lease-name[`onecx.product-store.operator.mfe.leader-election.lease-name`]##

[.description]
--
Lease name


ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++ONECX_PRODUCT_STORE_OPERATOR_MFE_LEADER_ELECTION_LEASE_NAME+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++ONECX_PRODUCT_STORE_OPERATOR_MFE_LEADER_ELECTION_LEASE_NAME+++`
endif::add-copy-button-to-env-var[]
--
|string
|`onecx-product-store-ms-operator-lease`

|===


:!summaryTableId:
9 changes: 9 additions & 0 deletions src/main/helm/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@ rules:
- "update"
- "create"
- "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.product.store.mfe.operator;

import jakarta.inject.Singleton;

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

@Singleton
public class LeaderConfiguration extends LeaderElectionConfiguration {

public LeaderConfiguration(MicrofrontendConfig config) {
super(config.leaderElectionConfig().leaseName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.tkit.onecx.product.store.mfe.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-product-store-mfe-operator.adoc")
@ConfigMapping(prefix = "onecx.product-store.operator.mfe")
@ConfigRoot(phase = ConfigPhase.RUN_TIME)
public interface MicrofrontendConfig {

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

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

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

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

import jakarta.inject.Inject;

import org.junit.jupiter.api.Test;
import org.tkit.onecx.product.store.mfe.test.AbstractTest;

import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
class LeaderConfigurationTest extends AbstractTest {

@Inject
MicrofrontendConfig 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());
}
}
Loading