Skip to content

Latest commit

 

History

History
47 lines (24 loc) · 6.83 KB

customizing-the-operator.md

File metadata and controls

47 lines (24 loc) · 6.83 KB

Customizing the CMCC Operator

The Operator is implemented as a Spring Boot application using the Java Operator SDK, which in turn uses the Fabric8 Kubernetes client.

The application has been designed with the expectation that it will need to be customized for a concrete CoreMedia project. There are a number of extension points that allow you to add your own logic and component types.

Overview

The application consists of a number of classes and packages.

CMCCOperatorApplication is the Spring Boot application class. In addition to the main() method, it contains a number of bean definitions.

CoreMediaContentCloudReconciler implements the logic to listen to events like the creation, modification and deletion of the custom resource, build an updated set of Kubernetes resources, and remove outdated ones. The list of updated resources is generated on each loop through a TargetState bean (see below).

Custom Resource Definitions

The Operator SDK includes code to automatically generate a CRD based on annotations in the code. The main class for the custom resource is CoreMediaContentCloud. The package contains all properties used in the CRD as POJOs, utilizing the lombok @Data annotation.

Target State

The task of computing the Kubernetes resources that should be created or updated is delegated from the reconciler to the TargetState bean. The TargetState inspects the custom resource and the state of other resources, builds a list of components that should exist, and finally creates a collection of Kubernetes resources. Kubernetes resources are typically created through the list of components and ingresses, see below.

The DefaultTargetState implements the functionality documented here and in Custom Resource CoreMediaContentClouds. You can modify the existing class, derive your own class from it, or create your own implementation of TargetState. AbstractTargetState contains a number of methods that are likely going to be helpful.

Components

Each component of a CoreMedia system (for example, the Content Management Server or the Content Application Engine) are modelled as a Component. The Component interface allows components to be queried for certain attributes (HasJdbcClient, (HasMongoDBClient, (HasUapiClient and HasService), and will generate zero or more Kubernetes resources from its buildResources() method.

The list of components is managed by the ComponentCollection bean. It utilizes the ComponentBeanFactories bean to created beans based on their ComponentSpec.type property.

You can add your own component by implementing Component and adding a bean definition for your type to ComponentBeanFactories.

The package com.tsystemsmms.cmcc.cmccoperator.components contains Components for all standard CoreMedia components, plus MongoDB and MariaDB components. The abstract classes AbstractComponent, SpringBootComponent, CorbaComponent, and JobComponent can be used to jumpstart new components.

Ingress

The operator will create suitable Ingress resources for the overview, preview CAE, Studio, and live CAEs. The creation of these Ingress resources is implemented through CmccIngressGenerator, which gets instantiated by a Spring Bean implementing CmccIngressGeneratorFactory. Individual Ingress resources are built from IngressBuilder, instantiated by a Spring bean implementing IngressBuilderFactory.

There is one implementation BlueprintCmccIngressGenerator, which implements the default URL mapping logic of CMCC11. If you want to modify the way URLs are built in the CAE, you will likely want to create your own implementation of CmssIngressGenerator.

There is one implementation NginxIngressBuilder, which builds Ingress resources suitable for use with the NGINX Ingress Controller. If you are using a different Ingress controller (for example Traefik), you will need to implement an IngressBuilder for that.

It is necessary to rewrite URLs for the CAEs (for example, you need to rewrite /resource/... to /blueprint/servlet/resource...). The standard Kuberentes Ingress definition does not offer such rewriting functionality, and the different Ingress controllers implement these in incompatible, proprietary ways. NGINX Ingress Controller uses annotations, while Traefik has defined their own CRD. This makes it necessary to have these additional builder classes.

Resource Reconciler

Finally, the package com.tsystemsmms.cmcc.cmccoperator.resource contains classes that help with updating existing resources. The Fabric8 client currently has some limitations when updating existing objects, which might try to modify or overwrite properties that are immutable after creation. These classes help work around that limitation.