Skip to content

Commit 294fd97

Browse files
nightkrsiegfriedweberhjiayzhjiayzKeruspe
authored
TrustStore CRD (#557)
Co-authored-by: Siegfried Weber <mail@siegfriedweber.net> Co-authored-by: hjiayz <hjiayz@gmail.com> Co-authored-by: hjiayz <hjiayz@163.com> Co-authored-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com> Co-authored-by: Patrick Amrein <amrein@ubique.ch> Co-authored-by: Julius Michaelis <glitter@liftm.de>
1 parent 7aac3d7 commit 294fd97

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2668
-204
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
1717
- Use `--file-log-max-files` (or `FILE_LOG_MAX_FILES`) to limit the number of log files kept.
1818
- Use `--file-log-rotation-period` (or `FILE_LOG_ROTATION_PERIOD`) to configure the frequency of rotation.
1919
- Use `--console-log-format` (or `CONSOLE_LOG_FORMAT`) to set the format to `plain` (default) or `json`.
20+
- Added TrustStore CRD for requesting CA certificate information ([#557]).
2021

2122
### Changed
2223

@@ -38,6 +39,7 @@ All notable changes to this project will be documented in this file.
3839

3940
- Use `json` file extension for log files ([#586]).
4041

42+
[#557]: https://github.com/stackabletech/secret-operator/pull/557
4143
[#572]: https://github.com/stackabletech/secret-operator/pull/572
4244
[#581]: https://github.com/stackabletech/secret-operator/pull/581
4345
[#586]: https://github.com/stackabletech/secret-operator/pull/586

Cargo.lock

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

Lines changed: 40 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ bindgen = "0.71"
1919
built = { version = "0.7", features = ["chrono", "git2"] }
2020
byteorder = "1.5"
2121
clap = "4.5"
22+
const_format = "0.2.34"
2223
futures = { version = "0.3", features = ["compat"] }
2324
h2 = "0.4"
25+
kube-runtime = { version = "0.99", features = ["unstable-runtime-stream-control"] }
2426
ldap3 = { version = "0.11", default-features = false, features = ["gssapi", "tls"] }
2527
libc = "0.2"
2628
native-tls = "0.2"
2729
openssl = "0.10"
28-
p12 = "0.6"
2930
pin-project = "1.1"
3031
pkg-config = "0.3"
3132
prost = "0.13"

deploy/helm/secret-operator/crds/crds.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,15 @@ spec:
218218
description: The Secret objects are located in the same namespace as the Pod object. Should be used for Secrets that are provisioned by the application administrator.
219219
type: object
220220
type: object
221+
trustStoreConfigMapName:
222+
description: |-
223+
Name of a ConfigMap that contains the information required to validate against this SecretClass.
224+
225+
Resolved relative to `search_namespace`.
226+
227+
Required to request a TrustStore for this SecretClass.
228+
nullable: true
229+
type: string
221230
required:
222231
- searchNamespace
223232
type: object
@@ -346,3 +355,53 @@ spec:
346355
served: true
347356
storage: true
348357
subresources: {}
358+
---
359+
apiVersion: apiextensions.k8s.io/v1
360+
kind: CustomResourceDefinition
361+
metadata:
362+
name: truststores.secrets.stackable.tech
363+
annotations:
364+
helm.sh/resource-policy: keep
365+
spec:
366+
group: secrets.stackable.tech
367+
names:
368+
categories: []
369+
kind: TrustStore
370+
plural: truststores
371+
shortNames: []
372+
singular: truststore
373+
scope: Namespaced
374+
versions:
375+
- additionalPrinterColumns: []
376+
name: v1alpha1
377+
schema:
378+
openAPIV3Schema:
379+
description: Auto-generated derived type for TrustStoreSpec via `CustomResource`
380+
properties:
381+
spec:
382+
description: |-
383+
A [TrustStore](https://docs.stackable.tech/home/nightly/secret-operator/truststore) requests information about how to validate secrets issued by a [SecretClass](https://docs.stackable.tech/home/nightly/secret-operator/secretclass).
384+
385+
The requested information is written to a ConfigMap with the same name as the TrustStore.
386+
properties:
387+
format:
388+
description: The [format](https://docs.stackable.tech/home/nightly/secret-operator/secretclass#format) that the data should be converted into.
389+
enum:
390+
- tls-pem
391+
- tls-pkcs12
392+
- kerberos
393+
nullable: true
394+
type: string
395+
secretClassName:
396+
description: The name of the SecretClass that the request concerns.
397+
type: string
398+
required:
399+
- secretClassName
400+
type: object
401+
required:
402+
- spec
403+
title: TrustStore
404+
type: object
405+
served: true
406+
storage: true
407+
subresources: {}

deploy/helm/secret-operator/templates/roles.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ rules:
5555
- create
5656
- patch
5757
- update
58+
- apiGroups:
59+
- ""
60+
resources:
61+
- configmaps
62+
verbs:
63+
- create
64+
- patch
65+
- get
66+
- watch
67+
- list
5868
- apiGroups:
5969
- ""
6070
resources:
@@ -96,8 +106,11 @@ rules:
96106
- secrets.stackable.tech
97107
resources:
98108
- secretclasses
109+
- truststores
99110
verbs:
100111
- get
112+
- watch
113+
- list
101114
- apiGroups:
102115
- listeners.stackable.tech
103116
resources:
@@ -114,6 +127,13 @@ rules:
114127
- get
115128
- patch
116129
- create
130+
- apiGroups:
131+
- events.k8s.io
132+
resources:
133+
- events
134+
verbs:
135+
- create
136+
- patch
117137
{{ if .Capabilities.APIVersions.Has "security.openshift.io/v1" }}
118138
- apiGroups:
119139
- security.openshift.io

docs/modules/secret-operator/examples/secretclass-tls.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ spec:
1717
pod: {}
1818
# or...
1919
name: my-namespace
20+
trustStoreConfigMapName: tls-ca # <4>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
apiVersion: secrets.stackable.tech/v1alpha1
3+
kind: TrustStore
4+
metadata:
5+
name: truststore-pem # <1>
6+
spec:
7+
secretClassName: tls # <2>
8+
format: tls-pem # <3>

docs/modules/secret-operator/pages/secretclass.adoc

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ include::example$secretclass-tls.yaml[]
1717
<1> Backends are mutually exclusive, only one may be used by each SecretClass
1818
<2> Configures and selects the xref:#backend-autotls[] backend
1919
<3> Configures and selects the xref:#backend-k8ssearch[] backend
20+
<4> Provides a trust root to be requested by xref:truststore.adoc[]
2021

2122
[#backend]
2223
== Backend
@@ -28,6 +29,8 @@ Each SecretClass is a associated with a single backend, which dictates the mecha
2829

2930
*Format*: xref:#format-tls-pem[]
3031

32+
*TrustStore*: Yes
33+
3134
Issues a TLS certificate signed by the Secret Operator.
3235
The certificate authority can be provided by the administrator, or managed automatically by the Secret Operator.
3336

@@ -150,6 +153,8 @@ spec:
150153

151154
*Format*: xref:#format-tls-pem[]
152155

156+
*TrustStore*: No
157+
153158
Injects a TLS certificate issued by {cert-manager}[Cert-Manager].
154159

155160
WARNING: This backend is experimental, and subject to change.
@@ -213,6 +218,8 @@ spec:
213218

214219
*Format*: xref:#format-kerberos[]
215220

221+
*TrustStore*: No
222+
216223
Creates a Kerberos keytab file for a selected realm. The Kerberos KDC and administrator credentials must be provided by the administrator.
217224

218225
IMPORTANT: Only MIT Kerberos (krb5) and Active Directory are currently supported.
@@ -368,6 +375,8 @@ spec:
368375

369376
*Format*: Free-form
370377

378+
*TrustStore*: If configured
379+
371380
This backend can be used to mount `Secret` across namespaces into pods. The `Secret` object is selected based on two things:
372381

373382
1. The xref:scope.adoc[scopes] specified on the `Volume` using the attribute `secrets.stackable.tech/scope`.
@@ -444,14 +453,16 @@ spec:
444453
pod: {}
445454
# or...
446455
name: my-namespace
456+
trustStoreConfigMapName: tls-ca
447457
----
448458

449459
`k8sSearch`:: Declares that the `k8sSearch` backend is used.
450-
`k8sSearch.searchNamespace`:: Configures the namespace searched for `Secret` objects.
451-
`k8sSearch.searchNamespace.pod`:: The `Secret` objects are located in the same namespace as the `Pod` object. Should be used
460+
`k8sSearch.searchNamespace`:: Configures the namespace searched for Secrets.
461+
`k8sSearch.searchNamespace.pod`:: The Secret objects are located in the same namespace as the Pod. Should be used
452462
for secrets that are provisioned by the application administrator.
453-
`k8sSearch.searchNamespace.name`:: The `Secret` objects are located in a single global namespace. Should be used for secrets
463+
`k8sSearch.searchNamespace.name`:: The Secrets are located in a single global namespace. Should be used for secrets
454464
that are provisioned by the cluster administrator.
465+
`k8sSearch.trustStoreConfigMapName`:: ConfigMap used to provision xref:truststore.adoc[].
455466

456467
==== Format
457468

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
= TrustStore
2+
:description: A TrustStore in Kubernetes retrieves the trust anchors from a SecretClass.
3+
4+
A _TrustStore_ is a Kubernetes resource that can be used to request the trust anchor information (such as the TLS certificate authorities) from a xref:secretclass.adoc[].
5+
6+
This can be used to access a protected service from other services that do not require their own certificates (or from clients running outside of Kubernetes).
7+
8+
A TrustStore looks like this:
9+
10+
[source,yaml]
11+
----
12+
include::example$truststore-tls.yaml[]
13+
----
14+
<1> Also used to name the created ConfigMap
15+
<2> The name of the xref:secretclass.adoc[]
16+
<3> The requested xref:secretclass.adoc#format[format]
17+
18+
This will create a ConfigMap named `truststore-pem` containing a `ca.crt` with the trust root certificates.
19+
It can then either be mounted into a Pod or retrieved and used from outside of Kubernetes.
20+
21+
NOTE: Make sure to have a procedure for updating the retrieved certificates.
22+
The Secret Operator will automatically rotate the xref:secretclass.adoc#backend-autotls[autoTls] certificate authority as needed, but all trust roots will require some form of update occasionally.

docs/modules/secret-operator/partials/nav.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
** xref:secret-operator:secretclass.adoc[]
77
** xref:secret-operator:scope.adoc[]
88
** xref:secret-operator:volume.adoc[]
9+
** xref:secret-operator:truststore.adoc[]
910
* Guides
1011
** xref:secret-operator:cert-manager.adoc[]
1112
* xref:secret-operator:security.adoc[]

0 commit comments

Comments
 (0)