Skip to content

Commit 7ff5a20

Browse files
authored
Updates truststore format in CRD (#33)
1 parent 7f82774 commit 7ff5a20

7 files changed

Lines changed: 53 additions & 34 deletions

File tree

operator/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION ?= 0.10.1
1+
VERSION ?= 0.11.0
22
GIT_TAG := operator_v$(VERSION)
33
KEIP_INTEGRATION_IMAGE ?= ghcr.io/octoconsulting/keip/minimal-app:latest
44

operator/controller/core-controller.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ spec:
5656
spec:
5757
containers:
5858
- name: webhook
59-
image: ghcr.io/octoconsulting/keip/route-webhook:0.13.1
59+
image: ghcr.io/octoconsulting/keip/route-webhook:0.14.0
6060
ports:
6161
- containerPort: 7080
6262
name: webhook-http

operator/crd/crd.yaml

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,22 +162,40 @@ spec:
162162
type: object
163163
properties:
164164
truststore:
165-
description: "Configure client TLS connections using a JKS or PKCS12 truststore. A JKS truststore should have its password set to 'changeit', while a PKCS12 truststore should have an empty password."
165+
description: "Configures client TLS connections using a JKS or PKCS12 truststore. A JKS truststore should have its password set to 'changeit', while a PKCS12 truststore should have an empty password."
166166
type: object
167167
properties:
168-
configMapName:
169-
type: string
170-
key:
171-
type: string
172-
type:
173-
type: string
174-
enum:
168+
jks:
169+
type: object
170+
properties:
171+
configMapName:
172+
description: "The name of the ConfigMap resource containing the truststore (truststore.jks)."
173+
type: string
174+
key:
175+
description: "The name of the key containing the truststore in the ConfigMap resource (configMapName)."
176+
type: string
177+
required:
178+
- configMapName
179+
- key
180+
pkcs12:
181+
type: object
182+
properties:
183+
configMapName:
184+
description: "The name of the ConfigMap resource containing the truststore (truststore.p12)."
185+
type: string
186+
key:
187+
description: "The name of the key containing the truststore in the ConfigMap resource (configMapName)."
188+
type: string
189+
required:
190+
- configMapName
191+
- key
192+
oneOf:
193+
- properties:
194+
required:
175195
- jks
196+
- properties:
197+
required:
176198
- pkcs12
177-
required:
178-
- configMapName
179-
- key
180-
- type
181199
keystore:
182200
description: "Configures HTTP server TLS connections using a JKS or PKCS12 keystore. The keystore password should be stored in a Secret resource and referenced in the route's Custom Resource. The format of the Secret is `password=<password>`."
183201
type: object
@@ -192,7 +210,7 @@ spec:
192210
description: "The name of the Secret resource containing the keystore (keystore.jks)."
193211
type: string
194212
key:
195-
description: "The name of the key, containing the keystore, in the Secret resource (secretName)."
213+
description: "The name of the key containing the keystore in the Secret resource (secretName)."
196214
type: string
197215
passwordSecretRef:
198216
description: "The reference to the Secret resource containing the password used to encrypt the JKS keystore."

operator/webhook/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION ?= 0.13.1
1+
VERSION ?= 0.14.0
22
HOST_PORT ?= 7080
33
GIT_TAG := webhook_v$(VERSION)
44

operator/webhook/core/sync.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,16 @@ def get_volumes(self) -> List[Mapping]:
8181
if self._tls_config:
8282
truststore = self._tls_config.get("truststore")
8383
if truststore:
84+
truststore_type = _get_tls_cert_store_type(truststore)
8485
volumes.append(
8586
{
8687
"name": self._tls_truststore_name,
8788
"configMap": {
88-
"name": truststore["configMapName"],
89+
"name": truststore[truststore_type]["configMapName"],
8990
"items": [
9091
{
91-
"key": truststore["key"],
92-
"path": truststore["key"],
92+
"key": truststore[truststore_type]["key"],
93+
"path": truststore[truststore_type]["key"],
9394
}
9495
],
9596
},
@@ -98,7 +99,7 @@ def get_volumes(self) -> List[Mapping]:
9899

99100
keystore = self._tls_config.get("keystore")
100101
if keystore:
101-
keystore_type = _get_keystore_type(keystore)
102+
keystore_type = _get_tls_cert_store_type(keystore)
102103
volumes.append(
103104
{
104105
"name": self._tls_keystore_name,
@@ -227,8 +228,8 @@ def _service_name_env_var(parent) -> Mapping[str, str]:
227228
return {"name": "SERVICE_NAME", "value": parent["metadata"]["name"]}
228229

229230

230-
def _get_keystore_type(keystore) -> str:
231-
return "jks" if "jks" in keystore else "pkcs12"
231+
def _get_tls_cert_store_type(tls_cert_store) -> str:
232+
return "jks" if "jks" in tls_cert_store else "pkcs12"
232233

233234

234235
def _spring_app_config_env_var(parent) -> Optional[Mapping]:
@@ -261,7 +262,7 @@ def _get_keystore_password_env(tls) -> Mapping[str, Any]:
261262
if not keystore:
262263
return {}
263264

264-
keystore_type = _get_keystore_type(keystore)
265+
keystore_type = _get_tls_cert_store_type(keystore)
265266

266267
return {
267268
"name": "SERVER_SSL_KEYSTOREPASSWORD",
@@ -281,12 +282,12 @@ def _get_java_jdk_options(tls) -> Optional[Mapping[str, str]]:
281282
if not truststore:
282283
return None
283284

284-
tls_type = truststore["type"]
285-
truststore_password = "changeit" if tls_type == "jks" else ""
285+
truststore_type = _get_tls_cert_store_type(truststore)
286+
truststore_password = "changeit" if truststore_type == "jks" else ""
286287

287288
return {
288289
"name": "JDK_JAVA_OPTIONS",
289-
"value": f"-Djavax.net.ssl.trustStore={str(PurePosixPath(TRUSTSTORE_PATH, truststore['key']))} -Djavax.net.ssl.trustStorePassword={truststore_password} -Djavax.net.ssl.trustStoreType={tls_type.upper()}",
290+
"value": f"-Djavax.net.ssl.trustStore={str(PurePosixPath(TRUSTSTORE_PATH, truststore[truststore_type]['key']))} -Djavax.net.ssl.trustStorePassword={truststore_password} -Djavax.net.ssl.trustStoreType={truststore_type.upper()}",
290291
}
291292

292293

operator/webhook/core/test/json/full-iroute-request.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@
7171
}
7272
},
7373
"truststore": {
74-
"configMapName": "test-tls-cm",
75-
"key": "test-truststore.p12",
76-
"type": "pkcs12"
74+
"pkcs12": {
75+
"configMapName": "test-tls-cm",
76+
"key": "test-truststore.p12"
77+
}
7778
}
7879
},
7980
"configMaps": [

operator/webhook/core/test/test_sync.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,9 @@ def test_jdk_options_pkcs12_truststore_type(full_route):
212212

213213
def test_jdk_options_jks_truststore_type(full_route):
214214
tls_config = full_route["parent"]["spec"]["tls"]
215-
tls_config["truststore"]["type"] = "jks"
216-
tls_config["truststore"]["key"] = "test-truststore.jks"
215+
tls_config["truststore"] = {
216+
"jks": {"configMapName": "test-tls-cm", "key": "test-truststore.jks"}
217+
}
217218

218219
options = _get_java_jdk_options(tls_config)
219220
assert options["name"] == JDK_OPTIONS_ENV_NAME
@@ -276,9 +277,7 @@ def test_volume_pkcs12_keystore_and_pkcs12_truststore(full_route):
276277
def test_volume_jks_keystore_and_jks_truststore(full_route):
277278
del full_route["parent"]["spec"]["tls"]["truststore"]
278279
full_route["parent"]["spec"]["tls"]["truststore"] = {
279-
"configMapName": "test-tls-cm",
280-
"key": "test-truststore.jks",
281-
"type": "jks",
280+
"jks": {"configMapName": "test-tls-cm", "key": "test-truststore.jks"}
282281
}
283282
expected_keystore_volume = {
284283
"name": "keystore",

0 commit comments

Comments
 (0)