How to connect applications with services created through Kubernetes operators?

5/31/2019

I am looking for best practices to connect applications with services. I have a database operator which creates a service, and there is an application pod which needs to connect to it. Is the following approach going to work?

  1. The operator injects the access details into the pods as Secret and ConfigMap.
  2. The operator identifies application pods through label selectors (e.g., connects-to: mysql).
  3. The application pod receives service access details through environment variables.
  4. The operator can document the environment variables and the label selectors.

If the above flow is going to work, how can I inject values into pods? I can see a few mechanisms. Which one would be better?

  1. PodPreset (alpha since 2017)
  2. Initializer
  3. MutatingAdmissionWebhook

This is the expected interaction between controllers and actors (PodPreset can be substituted with other choices):

Creating Database and Application

-- baijum
kubernetes

2 Answers

5/31/2019

your question is not completely clear.

if I understand your question , you can use helm with multiple values file to it.

helm install ./repo/ --name repo --values ./values.file 

you can also --set command to the help to add values that are not in the values file for some reason

-- eran meiri
Source: StackOverflow

6/3/2019

Looking into the question it seems to general.

For example you can find more information about "CONTAINERS & KUBERNETES - Best practices for building Kubernetes Operators and stateful apps" here.

As per documentation the most important are:

Operators exercise one of the most valuable capabilities of Kubernetes—its extensibility—through the use of CRDs and custom controllers. Operators extend the Kubernetes API to support the modernization of different categories of workloads and provide improved lifecycle management, scheduling.

Please refer to "Application management made easier with Kubernetes Operators on GCP Marketplace" As you can see - in GCP was published a set of Kubernetes operators to encapsulate best practices and end-to-end solutions for specific applications.

In stack overflow you can find discussion about CRD

As an example please see postgress opeartor with comparison between two methods to set the Postgres Operator configuration here. In this case "The CRD-based configuration is more powerful than the one based on ConfigMaps and should be used unless there is a compatibility requirement to use an already existing configuration" Here you can also find information "When to use configMap or a custom resource?"

Hope this help

-- Hanx
Source: StackOverflow