Skip to content

Commit 79cec7c

Browse files
committed
[TLS] Improve cert defaulting and envtest coverage
Improves defaulting for tls global config to be able to customize only specific parameters and still have the others defaulted. Jira: OSPRH-6749
1 parent 8eb2f97 commit 79cec7c

11 files changed

Lines changed: 536 additions & 78 deletions

‎apis/bases/core.openstack.org_openstackcontrolplanes.yaml‎

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17117,15 +17117,15 @@ spec:
1711717117
ca:
1711817118
duration: 87600h
1711917119
cert:
17120-
duration: 10950h
17120+
duration: 43800h
1712117121
enabled: true
1712217122
podLevel:
1712317123
enabled: true
1712417124
internal:
1712517125
ca:
1712617126
duration: 87600h
1712717127
cert:
17128-
duration: 10950h
17128+
duration: 43800h
1712917129
libvirt:
1713017130
ca:
1713117131
duration: 87600h
@@ -17135,87 +17135,151 @@ spec:
1713517135
ca:
1713617136
duration: 87600h
1713717137
cert:
17138-
duration: 10950h
17138+
duration: 43800h
1713917139
properties:
1714017140
caBundleSecretName:
1714117141
type: string
1714217142
ingress:
17143+
default:
17144+
ca:
17145+
duration: 87600h
17146+
cert:
17147+
duration: 43800h
17148+
enabled: true
1714317149
properties:
1714417150
ca:
17151+
default:
17152+
duration: 87600h
1714517153
properties:
1714617154
customIssuer:
1714717155
type: string
1714817156
duration:
17157+
default: 87600h
1714917158
type: string
1715017159
renewBefore:
1715117160
type: string
1715217161
type: object
1715317162
cert:
17163+
default:
17164+
duration: 43800h
1715417165
properties:
1715517166
duration:
17167+
default: 43800h
1715617168
type: string
1715717169
renewBefore:
1715817170
type: string
1715917171
type: object
1716017172
enabled:
17173+
default: true
1716117174
type: boolean
1716217175
type: object
1716317176
podLevel:
17177+
default:
17178+
enabled: true
17179+
internal:
17180+
ca:
17181+
duration: 87600h
17182+
cert:
17183+
duration: 43800h
17184+
libvirt:
17185+
ca:
17186+
duration: 87600h
17187+
cert:
17188+
duration: 43800h
17189+
ovn:
17190+
ca:
17191+
duration: 87600h
17192+
cert:
17193+
duration: 43800h
1716417194
properties:
1716517195
enabled:
17196+
default: true
1716617197
type: boolean
1716717198
internal:
17199+
default:
17200+
ca:
17201+
duration: 87600h
17202+
cert:
17203+
duration: 43800h
1716817204
properties:
1716917205
ca:
17206+
default:
17207+
duration: 87600h
1717017208
properties:
1717117209
customIssuer:
1717217210
type: string
1717317211
duration:
17212+
default: 87600h
1717417213
type: string
1717517214
renewBefore:
1717617215
type: string
1717717216
type: object
1717817217
cert:
17218+
default:
17219+
duration: 43800h
1717917220
properties:
1718017221
duration:
17222+
default: 43800h
1718117223
type: string
1718217224
renewBefore:
1718317225
type: string
1718417226
type: object
1718517227
type: object
1718617228
libvirt:
17229+
default:
17230+
ca:
17231+
duration: 87600h
17232+
cert:
17233+
duration: 43800h
1718717234
properties:
1718817235
ca:
17236+
default:
17237+
duration: 87600h
1718917238
properties:
1719017239
customIssuer:
1719117240
type: string
1719217241
duration:
17242+
default: 87600h
1719317243
type: string
1719417244
renewBefore:
1719517245
type: string
1719617246
type: object
1719717247
cert:
17248+
default:
17249+
duration: 43800h
1719817250
properties:
1719917251
duration:
17252+
default: 43800h
1720017253
type: string
1720117254
renewBefore:
1720217255
type: string
1720317256
type: object
1720417257
type: object
1720517258
ovn:
17259+
default:
17260+
ca:
17261+
duration: 87600h
17262+
cert:
17263+
duration: 43800h
1720617264
properties:
1720717265
ca:
17266+
default:
17267+
duration: 87600h
1720817268
properties:
1720917269
customIssuer:
1721017270
type: string
1721117271
duration:
17272+
default: 87600h
1721217273
type: string
1721317274
renewBefore:
1721417275
type: string
1721517276
type: object
1721617277
cert:
17278+
default:
17279+
duration: 43800h
1721717280
properties:
1721817281
duration:
17282+
default: 43800h
1721917283
type: string
1722017284
renewBefore:
1722117285
type: string

‎apis/core/v1beta1/openstackcontrolplane_types.go‎

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ type OpenStackControlPlaneSpec struct {
8080

8181
// +kubebuilder:validation:Optional
8282
// +operator-sdk:csv:customresourcedefinitions:type=spec
83-
// +kubebuilder:default={ingress: {enabled: true, ca: {duration: "87600h"}, cert: {duration: "10950h"}}, podLevel: {enabled: true, internal:{ca: {duration: "87600h"}, cert: {duration: "10950h"}}, libvirt: {ca: {duration: "87600h"}, cert: {duration: "43800h"}}, ovn: {ca: {duration: "87600h"}, cert: {duration: "10950h"}}}}
83+
// +kubebuilder:default={ingress: {enabled: true, ca: {duration: "87600h"}, cert: {duration: "43800h"}}, podLevel: {enabled: true, internal:{ca: {duration: "87600h"}, cert: {duration: "43800h"}}, libvirt: {ca: {duration: "87600h"}, cert: {duration: "43800h"}}, ovn: {ca: {duration: "87600h"}, cert: {duration: "43800h"}}}}
8484
// TLS - Parameters related to the TLS
8585
TLS TLSSection `json:"tls"`
8686

@@ -190,10 +190,12 @@ type OpenStackControlPlaneSpec struct {
190190
type TLSSection struct {
191191
// +kubebuilder:validation:optional
192192
//+operator-sdk:csv:customresourcedefinitions:type=spec
193+
// +kubebuilder:default={enabled: true, ca: {duration: "87600h"}, cert: {duration: "43800h"}}
193194
Ingress TLSIngressConfig `json:"ingress,omitempty"`
194195

195196
// +kubebuilder:validation:optional
196197
//+operator-sdk:csv:customresourcedefinitions:type=spec
198+
// +kubebuilder:default={enabled: true, internal:{ca: {duration: "87600h"}, cert: {duration: "43800h"}}, libvirt: {ca: {duration: "87600h"}, cert: {duration: "43800h"}}, ovn: {ca: {duration: "87600h"}, cert: {duration: "43800h"}}}
197199
PodLevel TLSPodLevelConfig `json:"podLevel,omitempty"`
198200

199201
// +kubebuilder:validation:optional
@@ -209,6 +211,7 @@ type TLSIngressConfig struct {
209211
// +kubebuilder:validation:Optional
210212
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
211213
// Enabled - Whether TLS should be enabled for endpoint type
214+
// +kubebuilder:default=true
212215
Enabled bool `json:"enabled"`
213216

214217
// +kubebuilder:validation:optional
@@ -221,43 +224,62 @@ type TLSPodLevelConfig struct {
221224
// +kubebuilder:validation:Optional
222225
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
223226
// Enabled - Whether TLS should be enabled for endpoint type
227+
// +kubebuilder:default=true
224228
Enabled bool `json:"enabled"`
225229

226230
// +kubebuilder:validation:Optional
227231
// +operator-sdk:csv:customresourcedefinitions:type=spec
232+
// +kubebuilder:default={ca: {duration: "87600h"}, cert: {duration: "43800h"}}
228233
// Internal - default CA used for all OpenStackControlPlane and OpenStackDataplane endpoints,
229234
// except OVN related CA and certs
230-
Internal CertSection `json:"internal,omitempty"`
235+
Internal CertSection `json:"internal"`
231236

232237
// +kubebuilder:validation:Optional
233238
// +operator-sdk:csv:customresourcedefinitions:type=spec
239+
// +kubebuilder:default={ca: {duration: "87600h"}, cert: {duration: "43800h"}}
234240
// Libvirt - CA used for libvirt/qemu services on OpenStackControlPlane and OpenStackDataplane
235-
Libvirt CertSection `json:"libvirt,omitempty"`
241+
Libvirt CertSection `json:"libvirt"`
236242

237243
// +kubebuilder:validation:Optional
238244
// +operator-sdk:csv:customresourcedefinitions:type=spec
245+
// +kubebuilder:default={ca: {duration: "87600h"}, cert: {duration: "43800h"}}
239246
// Ovn - CA used for all OVN services on OpenStackControlPlane and OpenStackDataplane
240-
Ovn CertSection `json:"ovn,omitempty"`
247+
Ovn CertSection `json:"ovn"`
241248
}
242249

243250
// CertSection defines details for CA config and its certs
244251
type CertSection struct {
245252
// +kubebuilder:validation:Optional
246253
// +operator-sdk:csv:customresourcedefinitions:type=spec
254+
// +kubebuilder:default={duration: "43800h"}
247255
// Cert - defines details for cert config
248-
Cert CertConfig `json:"cert,omitempty"`
256+
Cert CertConfig `json:"cert"`
249257

250258
// +kubebuilder:validation:Optional
251259
// +operator-sdk:csv:customresourcedefinitions:type=spec
260+
// +kubebuilder:default={duration: "87600h"}
252261
// Ca - defines details for CA cert config
253-
Ca CACertConfig `json:"ca,omitempty"`
262+
Ca CACertConfig `json:"ca"`
254263
}
255264

256265
// CACertConfig defines details for ca cert configs
257266
type CACertConfig struct {
258-
// +kubebuilder:validation:optional
259-
//+operator-sdk:csv:customresourcedefinitions:type=spec
260-
CertConfig `json:",inline"`
267+
// +kubebuilder:validation:Optional
268+
// +kubebuilder:default="87600h"
269+
// The requested 'duration' (i.e. lifetime) of the Certificate.
270+
// The Certificate will be renewed either 2/3 through its duration or
271+
// `renewBefore` period before its expiry, whichever is later. Minimum
272+
// accepted duration is 1 hour. Value must be in units accepted by Go
273+
// time.ParseDuration https://golang.org/pkg/time/#ParseDuration
274+
Duration *metav1.Duration `json:"duration"`
275+
276+
// +kubebuilder:validation:Optional
277+
// How long before the currently issued certificate's expiry
278+
// cert-manager should renew the certificate. The default is 2/3 of the
279+
// issued certificate's duration. Minimum accepted value is 5 minutes.
280+
// Value must be in units accepted by Go time.ParseDuration
281+
// https://golang.org/pkg/time/#ParseDuration
282+
RenewBefore *metav1.Duration `json:"renewBefore,omitempty"`
261283

262284
// +kubebuilder:validation:Optional
263285
// CustomIssuer - use pre-created issue for this CA. No CA and issure is being created
@@ -267,20 +289,21 @@ type CACertConfig struct {
267289

268290
// CertConfig defines details for cert configs
269291
type CertConfig struct {
292+
// +kubebuilder:validation:Optional
293+
// +kubebuilder:default="43800h"
270294
// The requested 'duration' (i.e. lifetime) of the Certificate.
271295
// The Certificate will be renewed either 2/3 through its duration or
272296
// `renewBefore` period before its expiry, whichever is later. Minimum
273297
// accepted duration is 1 hour. Value must be in units accepted by Go
274298
// time.ParseDuration https://golang.org/pkg/time/#ParseDuration
275-
// +optional
276-
Duration *metav1.Duration `json:"duration,omitempty"`
299+
Duration *metav1.Duration `json:"duration"`
277300

301+
// +kubebuilder:validation:Optional
278302
// How long before the currently issued certificate's expiry
279303
// cert-manager should renew the certificate. The default is 2/3 of the
280304
// issued certificate's duration. Minimum accepted value is 5 minutes.
281305
// Value must be in units accepted by Go time.ParseDuration
282306
// https://golang.org/pkg/time/#ParseDuration
283-
// +optional
284307
RenewBefore *metav1.Duration `json:"renewBefore,omitempty"`
285308
}
286309

‎apis/core/v1beta1/zz_generated.deepcopy.go‎

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

0 commit comments

Comments
 (0)