Repository navigation
Change Namespace.Spec.Project structure - #67
Conversation
|
@jaypipes I would love to get your opinion on folding the fields under apiVersion: cloud.temporal.io/v1alpha1
kind: Namespace
metadata:
name: payments
spec:
project:
ref:
name: payments-project
connectivityRules:
- ref:
name: payments-privatelink
replicas:
- region: aws-us-east-1
- region: aws-us-west-2
retentionDays: 30
status:
conditions: [...]
resource:
id: payments.a1b2c
version: "1730835700-3"
state: Active
asyncOperationID: 8f2c1e4a-...
createdTime: "2026-11-05T19:40:42Z"
lastModifiedTime: "2026-11-05T19:41:30Z"
projectID: proj-123 # resolved from spec.project.ref
connectivityRuleIDs: # resolved from spec.connectivityRules[].ref
- cr-1a2b3c4d
endpoints:
grpcAddress: us-east-1.aws.api.temporal.io:7233
mtlsGrpcAddress: payments.a1b2c.tmprl.cloud:7233
webAddress: https://cloud.temporal.io/namespaces/payments.a1b2c
replicas:
- region: aws-us-east-1
isPrimary: true
state: Active
- region: aws-us-west-2
isPrimary: false
state: ActiveI would summarize my thought process as follows
|
@tomba7 The reason I created a separate named
As for including other fields in the CRD's apiVersion: cloud.temporal.io/v1alpha1
kind: Namespace
metadata:
name: payments
spec:
project:
ref:
name: payments-project
connectivityRules:
- ref:
name: payments-privatelink
replicas:
- region: aws-us-east-1
- region: aws-us-west-2
retentionDays: 30
status:
conditions: [...]
cloud:
resource:
id: payments.a1b2c
version: "1730835700-3"
state: Active
asyncOperationID: 8f2c1e4a-...
createdTime: "2026-11-05T19:40:42Z"
lastModifiedTime: "2026-11-05T19:41:30Z"
references:
project: proj-123 # resolved from spec.project.ref
connectivityRules: # resolved from spec.connectivityRules[].ref
- cr-1a2b3c4d
info:
endpoints:
grpcAddress: us-east-1.aws.api.temporal.io:7233
mtlsGrpcAddress: payments.a1b2c.tmprl.cloud:7233
webAddress: https://cloud.temporal.io/namespaces/payments.a1b2c
replicas:
- region: aws-us-east-1
isPrimary: true
state: Active
- region: aws-us-west-2
isPrimary: false
state: ActiveIf you would like to flatten the Status struct and remove the apiVersion: cloud.temporal.io/v1alpha1
kind: Namespace
metadata:
name: payments
spec:
project:
ref:
name: payments-project
connectivityRules:
- ref:
name: payments-privatelink
replicas:
- region: aws-us-east-1
- region: aws-us-west-2
retentionDays: 30
status:
conditions: [...]
resource:
id: payments.a1b2c
version: "1730835700-3"
state: Active
asyncOperationID: 8f2c1e4a-...
createdTime: "2026-11-05T19:40:42Z"
lastModifiedTime: "2026-11-05T19:41:30Z"
references:
project: proj-123 # resolved from spec.project.ref
connectivityRules: # resolved from spec.connectivityRules[].ref
- cr-1a2b3c4d
info:
endpoints:
grpcAddress: us-east-1.aws.api.temporal.io:7233
mtlsGrpcAddress: payments.a1b2c.tmprl.cloud:7233
webAddress: https://cloud.temporal.io/namespaces/payments.a1b2c
replicas:
- region: aws-us-east-1
isPrimary: true
state: Active
- region: aws-us-west-2
isPrimary: false
state: Active |
|
Thanks @jaypipes. Very well explained and I love the clean distinction on what each section is intended for. I am opting for the later flattened example as I find it much easier to read from the users perspsective. |
This commit makes some changes to the Namespace CR to make the handling
of Temporal Cloud-returned identifiers more consistent and to provide
extensibility to allow referencing Temporal Cloud resources by their
Kubernetes Custom Resource counterpart.
We modify `api/cloud/common.ResourceStatus` by shortening the name of
the `ResourceVersion` field to just `Version`. This was done because
`ResourceStatus` is now no longer an inlined field in `NamespaceStatus`
but rather a named field inside the `NamespaceStatus` struct.
`NamespaceStatus` struct now has another field called `References` which
contains Temporal Cloud resource identifiers of any related resources --
e.g. Projects or Connectivity Rules:
```go
// NamespaceStatus describes the current status of a Temporal Cloud namespace.
// This struct does not contain a FromProto or ToProto function because there is
// no corresponding NamespaceStatus struct in the Temporal Cloud API.
// +k8s:openapi-gen=true
type NamespaceStatus struct {
tmprlcorev1.StatusBase `json:",inline"`
// Resource contains common information about the Temporal Cloud resource
// that this CR represents.
Resource cloudcommon.ResourceStatus `json:"resource"`
// References is an optional field containing the Temporal Cloud resource
// IDs for any related resources.
References NamespaceReferences `json:"references,omitempty"`
}
// NamespaceReferences is an optional field containing the
// Temporal Cloud resource IDs for any related resources.
type NamespaceReferences struct {
// Project is the Temporal Cloud resource identifier for the Project
// containing this Temporal Namespace.
Project string `json:"project,omitempty"`
// ConnectivityRules is the set of Temporal Cloud resource identifiers for
// any Namespace ConnectivityRules associated with this Temporal Namespace
ConnectivityRules []string `json:"connectivityRules,omitempty"`
}
```
The `NamespaceSpec.Project` field type has been modified from `string`
to `ProjectReferenceOrID`, which is a struct that can contain *either* a
Temporal Cloud resource identifier *or* a reference to a (to be created)
`cloud.temporal.io/Project` CR:
```go
type ProjectReferenceOrID struct {
// Ref is an optional field that points at a cloud.temporal.io/Project.
// +optional
Ref *ProjectReference `json:"ref,omitempty"`
// ID is the Temporal Cloud Project resource identifier
// +optional
ID string `json:"id,omitempty"`
}
// ProjectReference points at a cloud.temporal.io/Project.
type ProjectReference struct {
// Namespace contains the optional Kubernetes Namespace in which to find
// the Project. If empty, the Kubernetes Namespace containing the referring
// object is used.
Namespace string `json:"namespace,omitempty"`
// Name is the name of the Project.
// +required
Name string `json:"name"`
}
```
The reconciler's logic has been changed in the following important way:
`Namespace.Spec.Project` is NEVER mutated once by the user. Prior to
this commit, the `ProjectId` field in the `CreateNamespaceResponse`
struct was used to populate the Spec.Project field. This is no longer
the case. Instead, `ProjectId` is used to populate the
`Status.References.Project` field, which is specifically storing the
Temporal Cloud-returned resource identifier for the Temporal Cloud
Project containing the Temporal Namespace.
Anywhere that was previously checking for whether `Spec.Project` was
set is now checking `Status.References.Project`.
Issue #47
Signed-off-by: Jay Pipes <jay.pipes@temporal.io>
6a34605 to
80c5d18
Compare
This commit makes some changes to the Namespace CR to make the handling
of Temporal Cloud-returned identifiers more consistent and to provide
extensibility to allow referencing Temporal Cloud resources by their
Kubernetes Custom Resource counterpart.
We modify
api/cloud/common.ResourceStatusby shortening the name ofthe
ResourceVersionfield to justVersion. This was done becauseResourceStatusis now no longer an inlined field inNamespaceStatusbut rather a named field inside the
NamespaceStatusstruct.NamespaceStatusstruct now has another field calledReferenceswhichcontains Temporal Cloud resource identifiers of any related resources --
e.g. Projects or Connectivity Rules:
The
NamespaceSpec.Projectfield type has been modified fromstringto
ProjectReferenceOrID, which is a struct that can contain either aTemporal Cloud resource identifier or a reference to a (to be created)
cloud.temporal.io/ProjectCR:The reconciler's logic has been changed in the following important way:
Namespace.Spec.Projectis NEVER mutated once by the user. Prior tothis commit, the
ProjectIdfield in theCreateNamespaceResponsestruct was used to populate the Spec.Project field. This is no longer
the case. Instead,
ProjectIdis used to populate theStatus.References.Projectfield, which is specifically storing theTemporal Cloud-returned resource identifier for the Temporal Cloud
Project containing the Temporal Namespace.
Anywhere that was previously checking for whether
Spec.Projectwasset is now checking
Status.References.Project.Issue #47
Signed-off-by: Jay Pipes jay.pipes@temporal.io