Kubernetes Custom Resource Definition use cases

12/20/2018

I got a fair bit of CRD understanding by reading hello world type examples. I don't see a need for CRDs for my use cases. Could you list the business use cases solved by CRDs?

Update: by business use cases I meant requirements in an organization that are implemented using CRDs.

Example: every application deployed in "prod" namespace should have minimum pod replica count of 2. Define a CRD to store the minimum replica count and use that CRD (instance) in Admission controller to enforce the requirement? I'm not sure this approach is valid. I would like to know such requirements.

-- dsatish
kubernetes
kubernetes-custom-resources

1 Answer

12/20/2018

This is a broad question. They can be used for lots of different things. For example listing all the CRDs on my cluster shows all these:

$ kubectl get crd
NAME                                          CREATED AT
adapters.config.istio.io                      2018-09-21T04:33:18Z
alertmanagers.monitoring.coreos.com           2018-11-10T00:30:22Z
apikeys.config.istio.io                       2018-09-21T04:33:17Z
attributemanifests.config.istio.io            2018-09-21T04:33:17Z
authorizations.config.istio.io                2018-09-21T04:33:17Z
bgpconfigurations.crd.projectcalico.org       2018-07-23T22:22:59Z
bgppeers.crd.projectcalico.org                2018-07-23T22:22:59Z
bypasses.config.istio.io                      2018-09-21T04:33:17Z
certificates.certmanager.k8s.io               2018-09-21T04:33:51Z
checknothings.config.istio.io                 2018-09-21T04:33:17Z
circonuses.config.istio.io                    2018-09-21T04:33:17Z
clusterinformations.crd.projectcalico.org     2018-07-23T22:22:59Z
clusterissuers.certmanager.k8s.io             2018-09-21T04:33:51Z
deniers.config.istio.io                       2018-09-21T04:33:17Z
destinationrules.networking.istio.io          2018-09-21T04:33:17Z
edges.config.istio.io                         2018-09-21T04:33:17Z
envoyfilters.networking.istio.io              2018-09-21T04:33:17Z
etcdbackups.etcd.database.coreos.com          2018-07-31T00:07:01Z
etcdclusters.etcd.database.coreos.com         2018-07-31T00:07:01Z
etcdrestores.etcd.database.coreos.com         2018-07-31T00:07:01Z
felixconfigurations.crd.projectcalico.org     2018-07-23T22:22:59Z
fluentds.config.istio.io                      2018-09-21T04:33:17Z
gateways.networking.istio.io                  2018-09-21T04:33:17Z
globalnetworkpolicies.crd.projectcalico.org   2018-07-23T22:22:59Z
globalnetworksets.crd.projectcalico.org       2018-07-23T22:22:59Z
handlers.config.istio.io                      2018-09-21T04:33:18Z
hostendpoints.crd.projectcalico.org           2018-07-23T22:22:59Z
httpapispecbindings.config.istio.io           2018-09-21T04:33:17Z
httpapispecs.config.istio.io                  2018-09-21T04:33:17Z
instances.config.istio.io                     2018-09-21T04:33:18Z
ippools.crd.projectcalico.org                 2018-07-23T22:22:59Z
issuers.certmanager.k8s.io                    2018-09-21T04:33:51Z
kongconsumers.configuration.konghq.com        2018-09-26T06:06:44Z
kongcredentials.configuration.konghq.com      2018-09-26T06:06:44Z
kongingresses.configuration.konghq.com        2018-09-26T06:06:44Z
kongplugins.configuration.konghq.com          2018-09-26T06:06:44Z
kubernetesenvs.config.istio.io                2018-09-21T04:33:17Z
kuberneteses.config.istio.io                  2018-09-21T04:33:17Z
listcheckers.config.istio.io                  2018-09-21T04:33:17Z
listentries.config.istio.io                   2018-09-21T04:33:17Z
logentries.config.istio.io                    2018-09-21T04:33:17Z
memquotas.config.istio.io                     2018-09-21T04:33:17Z
meshpolicies.authentication.istio.io          2018-09-21T04:33:17Z
metrics.config.istio.io                       2018-09-21T04:33:17Z
networkpolicies.crd.projectcalico.org         2018-07-23T22:22:59Z
noops.config.istio.io                         2018-09-21T04:33:17Z
opas.config.istio.io                          2018-09-21T04:33:17Z
policies.authentication.istio.io              2018-09-21T04:33:17Z
prometheuses.config.istio.io                  2018-09-21T04:33:17Z
prometheuses.monitoring.coreos.com            2018-11-10T00:30:22Z
prometheusrules.monitoring.coreos.com         2018-11-10T00:30:22Z
quotas.config.istio.io                        2018-09-21T04:33:17Z
quotaspecbindings.config.istio.io             2018-09-21T04:33:17Z
quotaspecs.config.istio.io                    2018-09-21T04:33:17Z
rbacconfigs.rbac.istio.io                     2018-09-21T04:33:17Z
rbacs.config.istio.io                         2018-09-21T04:33:17Z
redisquotas.config.istio.io                   2018-09-21T04:33:17Z
reportnothings.config.istio.io                2018-09-21T04:33:17Z
rules.config.istio.io                         2018-09-21T04:33:17Z
servicecontrolreports.config.istio.io         2018-09-21T04:33:17Z
servicecontrols.config.istio.io               2018-09-21T04:33:17Z
serviceentries.networking.istio.io            2018-09-21T04:33:17Z
servicemonitors.monitoring.coreos.com         2018-11-10T00:30:22Z
servicerolebindings.rbac.istio.io             2018-09-21T04:33:18Z
serviceroles.rbac.istio.io                    2018-09-21T04:33:18Z
signalfxs.config.istio.io                     2018-09-21T04:33:17Z
solarwindses.config.istio.io                  2018-09-21T04:33:17Z
stackdrivers.config.istio.io                  2018-09-21T04:33:17Z
statsds.config.istio.io                       2018-09-21T04:33:17Z
stdios.config.istio.io                        2018-09-21T04:33:17Z
templates.config.istio.io                     2018-09-21T04:33:18Z
tracespans.config.istio.io                    2018-09-21T04:33:17Z
vaultservices.vault.security.coreos.com       2018-07-31T00:07:49Z
virtualservices.networking.istio.io           2018-09-21T04:33:17Z

Every one of them is a resource that you can use a definition with the Kind type. You see all kinds of stuff, for example:

bgpconfigurations.crd.projectcalico.org => Calico BGP
prometheuses.config.istio.io => Prometheus config
fluentds.config.istio.io => Fluentd config
...
-- Rico
Source: StackOverflow