Package io.micronaut.kubernetes.util
Class KubernetesUtils
java.lang.Object
io.micronaut.kubernetes.util.KubernetesUtils
Utility class with methods to help with ConfigMaps and Secrets.
- Since:
- 1.0.0
- Author:
- Álvaro Sánchez-Mariscal
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcomputeLabelSelector(Map<String, String> labels) Determines the value of a Kubernetes labelSelector filter based on the passed labels.static reactor.core.publisher.Mono<String>computePodLabelSelector(io.micronaut.kubernetes.client.reactor.CoreV1ApiReactorClient client, List<String> podLabelKeys, String namespace, Map<String, String> labels, boolean exceptionOnPodLabelsMissing) static io.micronaut.context.env.PropertySourceconfigMapAsPropertySource(io.kubernetes.client.openapi.models.V1ConfigMap configMap) Converts aV1ConfigMapinto aPropertySource.static List<io.micronaut.context.env.PropertySource>configMapAsPropertySource(String mountPoint, Map<String, String> data) Converts config map mounted as volume into property sources.static Predicate<io.kubernetes.client.common.KubernetesObject>getExcludesFilter(Collection<String> excludes) static Predicate<io.kubernetes.client.common.KubernetesObject>getIncludesFilter(Collection<String> includes) static Predicate<io.kubernetes.client.common.KubernetesObject>getLabelsFilter(Map<String, String> labels) static StringobjectNameOrNull(io.kubernetes.client.common.KubernetesObject kubernetesObject) static io.micronaut.context.env.PropertySourcesecretAsPropertySource(io.kubernetes.client.openapi.models.V1Secret secret)
-
Field Details
-
ENV_KUBERNETES_SERVICE_HOST
- See Also:
-
-
Constructor Details
-
KubernetesUtils
public KubernetesUtils()
-
-
Method Details
-
configMapAsPropertySource
public static io.micronaut.context.env.PropertySource configMapAsPropertySource(io.kubernetes.client.openapi.models.V1ConfigMap configMap) Converts aV1ConfigMapinto aPropertySource.- Parameters:
configMap- the ConfigMap- Returns:
- A PropertySource
-
configMapAsPropertySource
public static List<io.micronaut.context.env.PropertySource> configMapAsPropertySource(String mountPoint, Map<String, String> data) Converts config map mounted as volume into property sources.- Parameters:
mountPoint- the mount pointdata- the configmaps data in the mounted volume where keys are file names and values is the file content- Returns:
- list of property sources
-
computeLabelSelector
Determines the value of a Kubernetes labelSelector filter based on the passed labels.- Parameters:
labels- the labels- Returns:
- the value of the labelSelector filter
-
secretAsPropertySource
public static io.micronaut.context.env.PropertySource secretAsPropertySource(io.kubernetes.client.openapi.models.V1Secret secret) - Parameters:
secret- TheV1Secretto transform- Returns:
- The converted
PropertySource.
-
getIncludesFilter
public static Predicate<io.kubernetes.client.common.KubernetesObject> getIncludesFilter(Collection<String> includes) - Parameters:
includes- the objects to include- Returns:
- a
Predicatebased on a collection of object names to include
-
getExcludesFilter
public static Predicate<io.kubernetes.client.common.KubernetesObject> getExcludesFilter(Collection<String> excludes) - Parameters:
excludes- the objects to excludes- Returns:
- a
Predicatebased on a collection of object names to excludes
-
getLabelsFilter
public static Predicate<io.kubernetes.client.common.KubernetesObject> getLabelsFilter(Map<String, String> labels) - Parameters:
labels- the labels to include- Returns:
- a
Predicatebased on labels the kubernetes objects has to match to return true
-
objectNameOrNull
public static String objectNameOrNull(io.kubernetes.client.common.KubernetesObject kubernetesObject) -
computePodLabelSelector
public static reactor.core.publisher.Mono<String> computePodLabelSelector(io.micronaut.kubernetes.client.reactor.CoreV1ApiReactorClient client, List<String> podLabelKeys, String namespace, Map<String, String> labels, boolean exceptionOnPodLabelsMissing) - Parameters:
client- theCoreV1ApiReactorClientpodLabelKeys- the list of labels inside a podnamespace- in the configurationlabels- the labelsexceptionOnPodLabelsMissing- should and exception be thrown if configured pod label is not found- Returns:
- the filtered labels of the current pod
-