Can I store my application data in kubernetes configuration resources?
Asked Answered
D

1

2

I am trying to find a DB (object storage) for my application. The application is really a wrapper over ISTIO Network Routing API. Basically simplifying the ISTIO configuratin for my network. Kubernetes (k8s) Custom Resource Definition (CRD) seems to fit my requirements. Also love the watch and REST API capability provided by CRD.

DB requirement

  • Few 100 MBs data - worst case
  • Ability to watch objects
  • REST API support for object
  • Persistence
  • Around 2k writes/sec and similar/more reads/sec. Although I do have my application acting as a proxy for CRD where things can be cached.

Why using CRD will be a good or a bad idea? Are there any performance implication using CRD. This 2016 stackflow answer suggest that etcd data is not in RAM. Whereas etcd link suggest that etcd can do 10k writes/sec (so even things are not in RAM and purely in disk, who cares).

I am seeing multiple application using k8s CRDs.

  • Helm uses CRDs to store releases
  • Istio uses CRDs to store their networking routing API objects
Divisive answered 29/9, 2018 at 4:33 Comment(0)
J
3

Considering that (CRD page)

  • A resource is an endpoint in the Kubernetes API that stores a collection of API objects of a certain kind. For example, the built-in pods resource contains a collection of Pod objects.

  • A custom resource is an extension of the Kubernetes API that is not necessarily available on every Kubernetes cluster. In other words, it represents a customization of a particular Kubernetes installation.

A CRD is for extending Kubernetes itself, it is not for application data.

The helm-crd/examples/mariadb.yaml is about lightweight metadata which will enable Kubernetes to download the right release and through Helm install it.

It is not to store data for a random application which could exist without Kubernetes (as opposed to Helm releases, which make sense only in a Kubernetes deployment scenario)

Similarly, Istio CRD makes sense only in a Kubernetes context:

Kubernetes currently implements the Istio configuration on Custom Resource Definitions (CRDs). These CRDs correspond to namespace-scope and cluster-scope CRDs and automatically inherit access protection via the Kubernetes RBAC.

That approach (using etcd to store any application data) would not scale.

Jameljamerson answered 29/9, 2018 at 4:39 Comment(4)
Unless your application data directly helps Kubernetes manages its resources, it will better live in a dedicated external database of your choice (mysql, postgresql, ...)Jameljamerson
Thanks for the answer. The application is really just a wrapper over ISTIO CRDs...but have some app specific metadata..I will update the question with the same.Divisive
what do you mean by not scale...I do not see data more than few hundred MBs.Divisive
@JayRajput I meant more as a general comment on "storing data as CRD". If your data is linked to Kubernetes management (like Istio CRD is), then yes, that would work.Jameljamerson

© 2022 - 2024 — McMap. All rights reserved.