Skip to content

How spring properties can be loaded in DR? #2173

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

Closed
10000-ki opened this issue Dec 20, 2023 · 3 comments
Closed

How spring properties can be loaded in DR? #2173

10000-ki opened this issue Dec 20, 2023 · 3 comments

Comments

@10000-ki
Copy link
Contributor

// application.yml
spring:
  config:
    activate:
      on-profile: dev

iam:
  jwks_uri: https://otoken/dev/keys

---

spring:
  config:
    activate:
      on-profile: real
      
iam:
  jwks_uri: https://otoken/real/keys
@KubernetesDependent(
    resourceDiscriminator = OpenSearchSecurityConfigMapDiscriminator::class,
    labelSelector = "app.kubernetes.io/managed-by=$OPERATOR_LABEL_V1",
)
class OpenSearchSecurityConfigMap : CRUDKubernetesDependentResource<ConfigMap, OpenSearch>(ConfigMap::class.java) {

    private val logger = logger("[OpenSearchSecurityConfigMap]")

    override fun desired(primary: OpenSearch, context: Context<OpenSearch>): ConfigMap {
        val resourceNamespace = primary.metadata.namespace
        val resourceName = primary.resourceName
        val jwkUri = // ... here!

        return KubernetesManifestFileLoader.loadFile<ConfigMap>("opensearch-configmap.yml", primary.getConfigMapManifestParam())
            .also { logger.info { "Desired OpenSearch Security Configmap $resourceNamespace / $resourceName" } }
    }

Is there a way to load spring property values to DR differently by environment?

like spring @Value

@10000-ki
Copy link
Contributor Author

10000-ki commented Dec 20, 2023

�how about putting "properties Map" into ConfigurationService
and this accessible to DRs through context?

@csviri
Copy link
Collaborator

csviri commented Dec 20, 2023

Values can be passed to context:

https://github.com/java-operator-sdk/java-operator-sdk/blob/011c22cdfe15e4cca4c5897486a800bb472128d7/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/managed/ManagedDependentResourceContext.java#L41-L41

Unfortunatelly currently reconciliation of managed dependent happens before reconciler method called. This will be improved in v5: #1898

For now maybe the way to go is either to implement this in SB starter via factory, or just use standalone dependent resources and pass the values. (Or use quarkus where this is implemented AFAIK)

@10000-ki
Copy link
Contributor Author

oh i see

thank you for the comments
I'll take care of it on my own
I'm looking forward to the v5 version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants