Temporal Operator
repository·main·Indexed 42 days ago
https://github.com/alexandrevilain/temporal-operatorA Kubernetes Operator designed to simplify the deployment and management of Temporal clusters. It provides the TemporalCluster CRD (apiVersion: temporal.io/v1beta1) to configure Temporal versions, history shards, persistence stores (SQL, Cassandra), archival (S3, GCS, Filestore), mTLS, and JWT authorization.
What's inside Temporal Operator
- Temporal Operator is a Kubernetes Operator designed to deploy and manage Temporal clusters. It allows you to manage production-ready Temporal clusters and namespaces using native Kubernetes custom resources.
Override Temporal service manifests with ServiceSpecOverride
mainUse
ServiceSpecOverrideto modify the generated Kubernetes manifests for a specific service. This is useful for applying custom configurations that bypass the standardServiceSpecfields.ServiceSpecOverridecan be applied at two levels:- Global level: Via
spec.services.overridesinServicesSpecto apply to all services. - Service level: Via
spec.services.<serviceName>.overridesto target a specific service. Service-level overrides take precedence over global overrides.
- Global level: Via
Supported Archival Providers
mainThe
temporal-operatorsupports configuring archival for Temporal clusters to back up event histories. The following storage providers are supported:- AWS S3 (and any S3-compatible provider like MinIO or OVHCloud)
- Google Cloud Storage (GCS)
- Filestore
Upgrade Temporal clusters via desired version updates
mainUpgrading a Temporal cluster is simplified by defining a desired Temporal version in your configuration. To perform an upgrade, you simply update the desired version in your resource definition, and the operator handles the upgrade process automatically without requiring manual scripts or intervention.Use ScheduleIntervalSpec for interval-based scheduling
mainThe
ScheduleIntervalSpecmatches times that can be expressed using the formula:Epoch + (n * every) + offset(wherenis any integer ≥ 0).Fields
every:Kubernetes meta/v1.Duration. Describes the period to repeat the interval.offset:Kubernetes meta/v1.Duration(Optional). A fixed offset added to the interval's period. Defaults to 0.
Examples
- Every hour on the hour:
every: 1h,offset: 0 - Every hour at minute 19:
every: 1h,offset: 19m - Every 28 days starting from a specific epoch:
every: 28d,offset: 0
Configure Schedule timing and constraints
mainThe
ScheduleSpecwithin aScheduleallows for fine-grained control over when tasks are triggered using calendars, intervals, and time constraints.Timing Fields:
calendars([]ScheduleCalendarSpec, optional): Calendar-based specifications.intervals([]ScheduleIntervalSpec, optional): Interval-based specifications.excludeCalendars([]ScheduleCalendarSpec, optional): Times that will be skipped. All fields (including seconds) must match exactly.startAt(Kubernetes meta/v1.Time, optional): The start of the schedule. Times before this are skipped.endAt(Kubernetes meta/v1.Time, optional): The end of the schedule. Times after this are skipped.jitter(Kubernetes meta/v1.Duration, optional): A duration used to apply random jitter (0 to the specified amount) to scheduled times.timezoneName(string, optional): IANA time zone name (e.g.,US/Pacific).
Important Note on Timezones and DST: Calendar matching is a literal clock time match. It does not handle Daylight Saving Time (DST) transitions specially:
- If a spec fires at 2:30am and DST causes that time to be skipped, the action is not triggered.
- If a spec fires at 1:30am and DST causes that time to occur twice, the action will be triggered twice.
Manage Temporal clusters with Kubernetes custom resources
mainThe Temporal Operator enables the deployment and management of Temporal clusters and namespaces through native Kubernetes custom resources. This allows you to treat your Temporal infrastructure as code within your Kubernetes environment.Define time ranges with ScheduleDayOfMonthRange, ScheduleDayOfWeekRange, ScheduleHourRange, ScheduleMonthRange, and ScheduleSecondMinuteRange
mainThese range types are used within
ScheduleCalendarSpecto define specific windows of time.Behavioral Note: If
end < start, theendvalue is interpreted as being equal tostart. This allows you to represent a single specific value by settingstartand leavingendandstepunset.Common Fields
start: The beginning of the range (inclusive). Defaults vary by type (e.g., 0 forhour, 1 fordayOfMonth).end: The end of the range (inclusive). Defaults tostartif unset.step: The increment between values. Defaults to 1.
Configure mTLS for Frontend and Internode communication
mainThe
MTLSSpecallows you to enable encryption in transit using mTLS for different parts of the cluster.Frontend mTLS
Defined via
FrontendMTLSSpecfor public endpoints:enabled(bool, Optional): Enables mTLS for the cluster's public endpoints.extraDnsNames([]string): Additional DNS names to be added to the TLS certificate for external service access.
Internode mTLS
Defined via
InternodeMTLSSpecfor cluster node communication:enabled(bool, Optional): Enables mTLS for the network traffic between cluster nodes.
How resource overrides work in TemporalCluster
mainThe
TemporalClusterresource allows you to override properties of the Temporal components (pods/deployments) created by the operator. This is useful for setting custom resource limits, adding sidecars or init containers, mounting extra volumes, or injecting environment variables.There are two ways to apply overrides:
- StrategicPatchMerge: The default method where you provide a partial YAML structure that is merged into the existing resource.
- RFC6902 JSON patches: Used via the
jsonPatchfield when working with fields thatStrategicPatchMergecannot handle correctly (such as specific array manipulations).
You can apply overrides at two scopes:
- Global: For all services using
spec.services.overrides. - Per-service: For a specific service (e.g.,
frontend,history,matching, orworker) usingspec.services.[service_name].overrides.
# Global override example apiVersion: temporal.io/v1beta1 kind: TemporalCluster spec: services: overrides: deployment: spec: template: spec: containers: - name: service # your overrides hereDeploy Temporal with supported databases
mainThe Temporal Operator supports all databases compatible with Temporal, including:
- Cassandra
- PostgreSQL
- MySQL
You can deploy these databases using your preferred method, and the operator will automatically manage the Temporal schema database for you.
Configure Archival for Temporal clusters
mainArchival allows for backing up Workflow Execution Event Histories and Visibility data. You can configure this via the
archivalfield in aTemporalClusterorTemporalNamespace.ArchivalSpec
Controls the archival behavior for a specific persistence type (history or visibility):
enabled(bool): Enables archival by default.paused(bool): Pauses the archival process.enableRead(bool): Allows Temporal to read from the archived Event History.path(string): The storage path.
ArchivalProvider
Defines the type of archiver to use:
filestore: Uses aFilestoreArchiver.s3: Uses anS3Archiver.gcs: Uses aGCSArchiver.
spec: archival: enabled: true provider: s3: # S3 specific configuration