Class TypedConfigMap<TConfigMapData>
Extends a Kubernetes V1ConfigMap to support strongly typed configurations. This is implemented by serializing the config data as JSON and adding that to the low-level configmap under the DataPropertyName key.
note
This is typically used for persisting state to the cluster rather than for setting configuration for pods but can be used for that as well.
Namespace: Neon.Kube
Assembly: Neon.Kube.dll
Syntax
public class TypedConfigMap<TConfigMapData> where TConfigMapData : class, new()
Type Parameters
Name | Description |
---|---|
TConfigMapData | Specifies the configmap data type. |
Remarks
To create a configmap, use the TypedConfigMap(string, string, TConfigMapData) constructor, specifying the configmap's Kubernetes name and namespace as well as an instance of the typesafe config; your typed config will be available as the Data property. Configure your config as required and then call IKubernetes.CreateNamespacedTypedConfigMapAsync(), passing UntypedConfigMap as the request body (this holds the V1ConfigMap).
To read an existing configmap, call IKubernetes.CoreV1.ReadNamespacedTypedConfigMapAsync() to retrieve the Kubernetes configmap and then call the static From(V1ConfigMap) method to wrap the result into a TypedConfigMap<TConfigMapData> where your typesafe values can be accessed via the Data property.
To update an existing config, call IKubernetes.CoreV1.ReadNamespacedTypedConfigMapAsync to retrieve it, modify it via the Data property and then call IKubernetes.CoreV1.ReplaceNamespacedTypedConfigMapAsync() passing the new UntypedConfigMap.
Constructors
TypedConfigMap(string, string, TConfigMapData)
Constructs a typed configmap with the specified name and an optional initial value
TConfigMapData
value.
Declaration
public TypedConfigMap(string name, string @namespace, TConfigMapData data = null)
Parameters
Type | Name | Description |
---|---|---|
string | name | Specifies the configmap name. |
string | namespace | specifies the namespace. |
TConfigMapData | data | Optionally specifies the configmap data. A default instance will be created
when this is |
TypedConfigMap(V1ConfigMap)
Constructs an instance from an untyped V1ConfigMap.
Declaration
public TypedConfigMap(V1ConfigMap untypedConfigMap)
Parameters
Type | Name | Description |
---|---|---|
V1ConfigMap | untypedConfigMap | The config map name as it will be persisted to Kubernetes. |
Fields
DataPropertyName
Identifies the key used to store typed data within an untyped configmap.
note
WARNING: DO NOT MODIFY! Any change will break existing clusters.
Declaration
public const string DataPropertyName = "typed-data"
Field Value
Type | Description |
---|---|
string |
Properties
Data
Specifies the current typed configmap data.
Declaration
public TConfigMapData Data { get; set; }
Property Value
Type | Description |
---|---|
TConfigMapData |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the value being set is |
UntypedConfigMap
Returns the associated untyped configmap.
Declaration
public V1ConfigMap UntypedConfigMap { get; }
Property Value
Type | Description |
---|---|
V1ConfigMap |
Methods
From(V1ConfigMap)
Constructs an instance by parsing a V1ConfigMap.
Declaration
public static TypedConfigMap<TConfigMapData> From(V1ConfigMap untypedConfigMap)
Parameters
Type | Name | Description |
---|---|---|
V1ConfigMap | untypedConfigMap | Specifies the untyped config map.. |
Returns
Type | Description |
---|---|
TypedConfigMap<TConfigMapData> | The typed configmap. |
Update()
Updates the configmap by persisting any changes to Data back to the Kubernetes configmap's DataPropertyName key.
Declaration
public void Update()