Files
cozystack/packages/system/cozystack-controller/definitions/internal.cozystack.io_tenantprojections.yaml
T
Aleksei Sviridkin 37a91f98b8 feat(cozystack-controller): extract application CA into a key-free tenant Secret
Every catalog engine issues a per-release CA, but the object holding
ca.crt usually holds a private key beside it (cert-manager's tls.key,
CloudNativePG's ca.key), so granting a tenant read on it hands over key
material too. Add a controller that publishes the trust anchor as one
canonical, key-free Secret per release, "<release>.tenant-ca", holding
only ca.crt.

A chart declares the anchor by rendering a namespaced TenantProjection
sentinel (internal.cozystack.io/v1alpha1) that names the source Secret
and key. The controller rebuilds ca.crt from the parsed certificate DER
rather than copying the source, refuses any value carrying private key
material, and owns the projection by owner reference so a foreign Secret
at the same name is never overwritten. No tenant RBAC grants any verb on
internal.cozystack.io; a ValidatingAdmissionPolicy pins writes to
helm-controller as defence in depth.

The controller does not grant tenant read access — the lineage webhook
does, from the ApplicationDefinition's spec.secrets. This side stamps the
engine-agnostic internal.cozystack.io/tenant-ca label and forces a
re-admission when those selectors change.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-07-21 23:59:48 +03:00

175 lines
7.7 KiB
YAML

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.4
name: tenantprojections.internal.cozystack.io
spec:
group: internal.cozystack.io
names:
kind: TenantProjection
listKind: TenantProjectionList
plural: tenantprojections
shortNames:
- tproj
singular: tenantprojection
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .status.conditions[?(@.type=="Ready")].status
name: Ready
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: |-
TenantProjection is the Schema for the tenantprojections API.
It is a namespaced, platform-internal sentinel a chart renders to declare
which of an application's Secrets should be published to the tenant as a
key-free copy. The cozystack-controller reconciles the projected Secret
from this object and owns it via an OwnerReference back to this sentinel.
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: TenantProjectionSpec declares the projections to publish
for a tenant.
properties:
projections:
description: |-
Projections is the list of artifacts to publish from source Secrets
in this namespace.
items:
description: |-
TenantProjectionEntry declares one artifact to project from a source
Secret into a tenant-visible, key-free Secret.
properties:
sourceKey:
default: ca.crt
description: |-
SourceKey is the key inside the source Secret holding the CA
certificate in PEM form. The certificate is always republished
under "ca.crt", whatever it is called at the source.
type: string
sourceSecretName:
description: |-
SourceSecretName names the Secret in the TenantProjection's own
namespace holding the material to project. Only the extracted,
key-free certificate is ever published, so naming a Secret that
also carries private key material does not widen tenant visibility.
minLength: 1
type: string
type:
description: Type selects what to project. CACert is the only
supported type.
enum:
- CACert
type: string
required:
- sourceSecretName
- type
type: object
minItems: 1
type: array
required:
- projections
type: object
status:
description: TenantProjectionStatus reports the observed state of the
projections.
properties:
conditions:
description: |-
Conditions describes the current state of the TenantProjection.
Standard condition types: Ready. Ready is False with reason
SourceNotFound while a referenced source Secret does not exist.
items:
description: Condition contains details for one aspect of the current
state of this API Resource.
properties:
lastTransitionTime:
description: |-
lastTransitionTime is the last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: |-
message is a human readable message indicating details about the transition.
This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: |-
observedGeneration represents the .metadata.generation that the condition was set based upon.
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
with respect to the current state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: |-
reason contains a programmatic identifier indicating the reason for the condition's last transition.
Producers of specific condition types may define expected values and meanings for this field,
and whether the values are considered a guaranteed API.
The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
observedGeneration:
description: |-
ObservedGeneration mirrors the .metadata.generation reflected in the
latest reconciled state.
format: int64
type: integer
type: object
type: object
served: true
storage: true
subresources:
status: {}