Recently I am indexing the k8s resource object in ES. There are some problems with storing configmap.
configmap defines as bellow:
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ConfigMap holds configuration data for pods to consume.
type ConfigMap struct {
metav1.TypeMeta `json:",inline"`
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Immutable, if set to true, ensures that data stored in the ConfigMap cannot
// be updated (only object metadata can be modified).
// If not set to true, the field can be modified at any time.
// Defaulted to nil.
// +optional
Immutable *bool `json:"immutable,omitempty" protobuf:"varint,4,opt,name=immutable"`
// Data contains the configuration data.
// Each key must consist of alphanumeric characters, '-', '_' or '.'.
// Values with non-UTF-8 byte sequences must use the BinaryData field.
// The keys stored in Data must not overlap with the keys in
// the BinaryData field, this is enforced during validation process.
// +optional
Data map[string]string `json:"data,omitempty" protobuf:"bytes,2,rep,name=data"`
// BinaryData contains the binary data.
// Each key must consist of alphanumeric characters, '-', '_' or '.'.
// BinaryData can contain byte sequences that are not in the UTF-8 range.
// The keys stored in BinaryData must not overlap with the ones in
// the Data field, this is enforced during validation process.
// Using this field will require 1.10+ apiserver and
// kubelet.
// +optional
BinaryData map[string][]byte `json:"binaryData,omitempty" protobuf:"bytes,3,rep,name=binaryData"`
}
The Data property is map[string]string. This means the following definitions are all legal:
kind: ConfigMap
apiVersion: v1
metadata:
name: configmap-test1
namespace: default
data:
.dockerconfig: value
kind: ConfigMap
apiVersion: v1
metadata:
name: configmap-test2
namespace: default
data:
path.subpath: value
kind: ConfigMap
apiVersion: v1
metadata:
name: configmap-test3
namespace: default
data:
path: value
The configmap-test1 will failed to index because .dockerconfig starts with dot.
The configmap-test3 will failed to index beacuse path in configmap-test3 conflicts with configmap-test2.
My solution is replace the ”.“ to "dot" . Is there any better way to handle this situation in es?