Class KubernetesCredentialFactory
- All Implemented Interfaces:
ISecretProvider
CredentialFactory for Kubernetes Secret. Fetches credentials from Kubernetes secrets.
The credentials are stored in Kubernetes secrets, which are base64 encoded. The keys used for the secrets are "username" and "password".
The `KubernetesCredentialFactory` class uses several properties to configure its behavior. These properties are set in the
credentialproperties.properties file and are used to customize the connection to the Kubernetes cluster and the namespace from which secrets are
fetched. Here's a description of the properties:
credentialFactory.kubernetes.username- the username for authenticating with the Kubernetes clustercredentialFactory.kubernetes.password- the password for authenticating with the Kubernetes clustercredentialFactory.kubernetes.masterUrl- the master URL of the Kubernetes clustercredentialFactory.kubernetes.namespace- the namespace from which secrets should be fetched (default value: 'current-namespace')
Example configuration:
credentialFactory.kubernetes.username=admin
credentialFactory.kubernetes.password=example-password
credentialFactory.kubernetes.masterUrl=http://localhost:8080
credentialFactory.kubernetes.namespace=my-namespace
By setting these properties, you can control how the `KubernetesCredentialFactory` interacts with the Kubernetes cluster and retrieves credentials.
Adding a Kubernetes secret can be done by executing:
kubectl create secret generic db-alias-name \
--from-literal=username=admin --from-literal=password='example-password'
-
Field Summary
Fields inherited from class AbstractKubernetesCredentialProvider
client, DEFAULT_NAMESPACE, namespace -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturn a list of all configured aliases, should provide an empty list if none can be provided.getSecret(@NonNull CredentialAlias alias) protected List<io.fabric8.kubernetes.api.model.Secret> protected voidpostInitialize(CredentialConstants appConstants) Methods inherited from class AbstractKubernetesCredentialProvider
close, hasSecret, initialize, isAliasNameValid, warnIfAliasNameInvalid
-
Constructor Details
-
KubernetesCredentialFactory
public KubernetesCredentialFactory()
-
-
Method Details
-
postInitialize
- Specified by:
postInitializein classAbstractKubernetesCredentialProvider
-
getSecret
- Throws:
NoSuchElementException
-
getConfiguredAliases
Description copied from interface:ISecretProviderReturn a list of all configured aliases, should provide an empty list if none can be provided. -
getSecretsFromKubernetes
-