Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit d5b6645

Browse files
committed
Use experimental instead of unsafe and add vault token
requirements to helm template Signed-off-by: jaellio <[email protected]>
1 parent 96df713 commit d5b6645

9 files changed

+147
-32
lines changed

charts/osm/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ The following table lists the configurable parameters of the osm chart and their
9393
| osm.enableReconciler | bool | `false` | Enable reconciler for OSM's CRDs and mutating webhook |
9494
| osm.enforceSingleMesh | bool | `true` | Enforce only deploying one mesh in the cluster |
9595
| osm.envoyLogLevel | string | `"error"` | Log level for the Envoy proxy sidecar. Non developers should generally never set this value. In production environments the LogLevel should be set to `error` |
96+
| osm.experimental | object | `{"enableMeshRootCertificate":false}` | Experimental values. Behavior is not supported. |
97+
| osm.experimental.enableMeshRootCertificate | bool | `false` | Enable the MeshRootCertificate to configure the OSM certificate provider. |
9698
| osm.featureFlags.enableAsyncProxyServiceMapping | bool | `false` | Enable async proxy-service mapping |
9799
| osm.featureFlags.enableEgressPolicy | bool | `true` | Enable OSM's Egress policy API. When enabled, fine grained control over Egress (external) traffic is enforced |
98100
| osm.featureFlags.enableEnvoyActiveHealthChecks | bool | `false` | Enable Envoy active health checks |
@@ -265,14 +267,12 @@ The following table lists the configurable parameters of the osm chart and their
265267
| osm.tracing.port | int | `9411` | Port of the tracing collector service |
266268
| osm.tracing.tolerations | list | `[]` | Node tolerations applied to control plane pods. The specified tolerations allow pods to schedule onto nodes with matching taints. |
267269
| osm.trustDomain | string | `"cluster.local"` | The trust domain to use as part of the common name when requesting new certificates. |
268-
| osm.unsafe | object | `{"enableMeshRootCertificate":false}` | Unsafe values. Behavior is not supported. |
269-
| osm.unsafe.enableMeshRootCertificate | bool | `false` | Enable the MeshRootCertificate to configure the OSM certificate provider. |
270270
| osm.validatorWebhook.webhookConfigurationName | string | `""` | Name of the ValidatingWebhookConfiguration |
271271
| osm.vault.host | string | `""` | Hashicorp Vault host/service - where Vault is installed |
272272
| osm.vault.port | int | `8200` | port to use to connect to Vault |
273273
| osm.vault.protocol | string | `"http"` | protocol to use to connect to Vault |
274274
| osm.vault.role | string | `"openservicemesh"` | Vault role to be used by Open Service Mesh |
275-
| osm.vault.secret | object | `{"key":"","name":""}` | The Kubernetes secret storing the Vault token used in OSM |
275+
| osm.vault.secret | object | `{"key":"","name":""}` | The Kubernetes secret storing the Vault token used in OSM. The secret must be located in the namespace of the OSM installation |
276276
| osm.vault.secret.key | string | `""` | The Kubernetes secret key with the value bring the Vault token |
277277
| osm.vault.secret.name | string | `""` | The Kubernetes secret name storing the Vault token used in OSM |
278278
| osm.vault.token | string | `""` | token that should be used to connect to Vault |

charts/osm/templates/osm-bootstrap-deployment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ spec:
6161
"--osm-version", "{{ .Chart.AppVersion }}",
6262
"--ca-bundle-secret-name", "{{.Values.osm.caBundleSecretName}}",
6363
"--certificate-manager", "{{.Values.osm.certificateProvider.kind}}",
64-
"--enable-mesh-root-certificate={{.Values.osm.unsafe.enableMeshRootCertificate}}",
64+
"--enable-mesh-root-certificate={{.Values.osm.experimental.enableMeshRootCertificate}}",
6565
{{ if eq .Values.osm.certificateProvider.kind "vault" }}
6666
"--vault-host", "{{.Values.osm.vault.host}}",
6767
"--vault-port", "{{.Values.osm.vault.port}}",

charts/osm/templates/osm-deployment.yaml

+8-4
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,18 @@ spec:
6161
"--validator-webhook-config", "{{ include "osm.validatorWebhookConfigName" . }}",
6262
"--ca-bundle-secret-name", "{{.Values.osm.caBundleSecretName}}",
6363
"--certificate-manager", "{{.Values.osm.certificateProvider.kind}}",
64-
"--enable-mesh-root-certificate={{.Values.osm.unsafe.enableMeshRootCertificate}}",
64+
"--enable-mesh-root-certificate={{.Values.osm.experimental.enableMeshRootCertificate}}",
6565
{{ if eq .Values.osm.certificateProvider.kind "vault" }}
6666
"--vault-host", "{{ required "osm.vault.host is required when osm.certificateProvider.kind==vault" .Values.osm.vault.host }}",
6767
"--vault-port", "{{.Values.osm.vault.port}}",
6868
"--vault-protocol", "{{.Values.osm.vault.protocol}}",
69-
"--vault-token", "{{ .Values.osm.vault.token }}",
70-
"--vault-token-secret-name", "{{ .Values.osm.vault.secret.name }}",
71-
"--vault-token-secret-key", "{{ .Values.osm.vault.secret.key }}",
69+
{{ if and (empty .Values.osm.vault.secret.name) (empty .Values.osm.vault.secret.key) }}
70+
"--vault-token", "{{ required "osm.vault.token is required when osm.certificateProvider.kind==vault and osm.vault.secret.name and osm.vault.secret.key are empty" .Values.osm.vault.token }}",
71+
{{- end }}
72+
{{ if empty .Values.osm.vault.token }}
73+
"--vault-token-secret-name", "{{ required "osm.vault.secret.name is required when osm.certificateProvider.kind==vault and osm.vault.token is empty" .Values.osm.vault.secret.name }}",
74+
"--vault-token-secret-key", "{{ required "osm.vault.secret.key is required when osm.certificateProvider.kind==vault and osm.vault.token is empty" .Values.osm.vault.secret.key }}",
75+
{{- end }}
7276
{{- end }}
7377
"--cert-manager-issuer-name", "{{.Values.osm.certmanager.issuerName}}",
7478
"--cert-manager-issuer-kind", "{{.Values.osm.certmanager.issuerKind}}",

charts/osm/templates/osm-injector-deployment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ spec:
5858
"--webhook-timeout", "{{.Values.osm.injector.webhookTimeoutSeconds}}",
5959
"--ca-bundle-secret-name", "{{.Values.osm.caBundleSecretName}}",
6060
"--certificate-manager", "{{.Values.osm.certificateProvider.kind}}",
61-
"--enable-mesh-root-certificate={{.Values.osm.unsafe.enableMeshRootCertificate}}",
61+
"--enable-mesh-root-certificate={{.Values.osm.experimental.enableMeshRootCertificate}}",
6262
{{ if eq .Values.osm.certificateProvider.kind "vault" }}
6363
"--vault-host", "{{.Values.osm.vault.host}}",
6464
"--vault-port", "{{.Values.osm.vault.port}}",

charts/osm/templates/preset-mesh-root-certificate.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if .Values.osm.unsafe.enableMeshRootCertificate }}
1+
{{- if .Values.osm.experimental.enableMeshRootCertificate }}
22
apiVersion: v1
33
kind: ConfigMap
44
metadata:

charts/osm/values.schema.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -438,15 +438,15 @@
438438
"envoyproxy/envoy-windows:v1.22.1@sha256:92733f8e5beae5c45df204a0e13edbd29e99adf962d1b1c7869b197d85c64bd0"
439439
]
440440
},
441-
"unsafe": {
442-
"$id": "#/properties/osm/properties/unsafe",
441+
"experimental": {
442+
"$id": "#/properties/osm/properties/experimental",
443443
"type": "object",
444-
"title": "The unsafe schema",
444+
"title": "The experimental schema",
445445
"description": "Parameters that are unsupported by OSM",
446446
"additionalProperties": false,
447447
"properties": {
448448
"enableMeshRootCertificate": {
449-
"$id": "#/properties/osm/properties/unsafe/properties/enableMeshRootCertificate",
449+
"$id": "#/properties/osm/properties/experimental/properties/enableMeshRootCertificate",
450450
"type": "boolean",
451451
"title": "Enable the MeshRootCertificate",
452452
"description": "Using the MeshRootCertificate to configure the OSM certificate provider is not supported",

charts/osm/values.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ osm:
167167
# The specified tolerations allow pods to schedule onto nodes with matching taints.
168168
tolerations: []
169169

170-
# -- Unsafe values. Behavior is not supported.
171-
unsafe:
170+
# -- Experimental values. Behavior is not supported.
171+
experimental:
172172
# -- Enable the MeshRootCertificate to configure the OSM certificate provider.
173173
enableMeshRootCertificate: false
174174

@@ -196,7 +196,7 @@ osm:
196196
token: ""
197197
# -- Vault role to be used by Open Service Mesh
198198
role: openservicemesh
199-
# -- The Kubernetes secret storing the Vault token used in OSM
199+
# -- The Kubernetes secret storing the Vault token used in OSM. The secret must be located in the namespace of the OSM installation
200200
secret:
201201
# -- The Kubernetes secret name storing the Vault token used in OSM
202202
name: ""

cmd/cli/install_test.go

+120-8
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ import (
2828
)
2929

3030
const (
31-
testRegistrySecret = "test-registry-secret"
32-
testVaultHost = "vault.osm.svc.cluster.local"
33-
testVaultToken = "token"
34-
testChartPath = "testdata/test-chart"
35-
kubeVersionMajor = 1
36-
kubeVersionMinor = 22
37-
kubeVersionPatch = 9
31+
testRegistrySecret = "test-registry-secret"
32+
testVaultHost = "vault.osm.svc.cluster.local"
33+
testVaultToken = "token"
34+
testVaultSecretName = "secret"
35+
testVaultSecretKey = "key"
36+
testChartPath = "testdata/test-chart"
37+
kubeVersionMajor = 1
38+
kubeVersionMinor = 22
39+
kubeVersionPatch = 9
3840
)
3941

4042
func helmCapabilities() *chartutil.Capabilities {
@@ -181,7 +183,7 @@ var _ = Describe("Running the install command", func() {
181183
})
182184
})
183185

184-
Describe("with the vault cert manager", func() {
186+
Describe("with the vault cert manager using vault token", func() {
185187
var (
186188
out *bytes.Buffer
187189
store *storage.Storage
@@ -258,6 +260,87 @@ var _ = Describe("Running the install command", func() {
258260
})
259261
})
260262

263+
Describe("with the vault cert manager using token secret ref", func() {
264+
var (
265+
out *bytes.Buffer
266+
store *storage.Storage
267+
config *helm.Configuration
268+
err error
269+
)
270+
271+
BeforeEach(func() {
272+
out = new(bytes.Buffer)
273+
store = storage.Init(driver.NewMemory())
274+
if mem, ok := store.Driver.(*driver.Memory); ok {
275+
mem.SetNamespace(settings.Namespace())
276+
}
277+
278+
config = &helm.Configuration{
279+
Releases: store,
280+
KubeClient: &kubefake.PrintingKubeClient{
281+
Out: ioutil.Discard},
282+
Capabilities: helmCapabilities(),
283+
Log: func(format string, v ...interface{}) {},
284+
}
285+
286+
installCmd := getDefaultInstallCmd(out)
287+
288+
installCmd.setOptions = []string{
289+
"osm.certificateProvider.kind=vault",
290+
fmt.Sprintf("osm.vault.host=%s", testVaultHost),
291+
"osm.vault.token=",
292+
fmt.Sprintf("osm.vault.secret.name=%s", testVaultSecretName),
293+
fmt.Sprintf("osm.vault.secret.key=%s", testVaultSecretKey),
294+
}
295+
err = installCmd.run(config)
296+
})
297+
298+
It("should not error", func() {
299+
Expect(err).NotTo(HaveOccurred())
300+
})
301+
302+
It("should give a message confirming the successful install", func() {
303+
Expect(out.String()).To(Equal("OSM installed successfully in namespace [osm-system] with mesh name [osm]\n"))
304+
})
305+
306+
Context("the Helm release", func() {
307+
var (
308+
rel *release.Release
309+
err error
310+
)
311+
312+
BeforeEach(func() {
313+
rel, err = config.Releases.Get(defaultMeshName, 1)
314+
})
315+
316+
It("should not error when retrieved", func() {
317+
Expect(err).NotTo(HaveOccurred())
318+
})
319+
320+
It("should have the correct values", func() {
321+
expectedValues := getDefaultValues()
322+
valuesConfig := []string{
323+
fmt.Sprintf("osm.certificateProvider.kind=%s", "vault"),
324+
fmt.Sprintf("osm.vault.host=%s", testVaultHost),
325+
"osm.vault.token=",
326+
fmt.Sprintf("osm.vault.secret.name=%s", testVaultSecretName),
327+
fmt.Sprintf("osm.vault.secret.key=%s", testVaultSecretKey),
328+
}
329+
for _, val := range valuesConfig {
330+
// parses Helm strvals line and merges into a map
331+
err := strvals.ParseInto(val, expectedValues)
332+
Expect(err).NotTo(HaveOccurred())
333+
}
334+
335+
Expect(rel.Config).To(BeEquivalentTo(expectedValues))
336+
})
337+
338+
It("should be installed in the correct namespace", func() {
339+
Expect(rel.Namespace).To(Equal(settings.Namespace()))
340+
})
341+
})
342+
})
343+
261344
Describe("without required vault parameters", func() {
262345
var (
263346
installCmd installCmd
@@ -290,6 +373,35 @@ var _ = Describe("Running the install command", func() {
290373
err := installCmd.run(config)
291374
Expect(err.Error()).To(ContainSubstring("osm.vault.host is required"))
292375
})
376+
377+
It("should error when token and token secret key are not set", func() {
378+
installCmd.setOptions = append(installCmd.setOptions,
379+
"osm.vault.host=my-host",
380+
"osm.vault.secret.name=secret",
381+
)
382+
err := installCmd.run(config)
383+
Expect(err).To(HaveOccurred())
384+
Expect(err.Error()).To(ContainSubstring("osm.vault.secret.key is required"))
385+
})
386+
387+
It("should error when token and token secret name are not set", func() {
388+
installCmd.setOptions = append(installCmd.setOptions,
389+
"osm.vault.host=my-host",
390+
"osm.vault.secret.key=key",
391+
)
392+
err := installCmd.run(config)
393+
Expect(err).To(HaveOccurred())
394+
Expect(err.Error()).To(ContainSubstring("osm.vault.secret.name is required"))
395+
})
396+
397+
It("should error when token and token secret name and key are not set", func() {
398+
installCmd.setOptions = append(installCmd.setOptions,
399+
"osm.vault.host=my-host",
400+
)
401+
err := installCmd.run(config)
402+
Expect(err).To(HaveOccurred())
403+
Expect(err.Error()).To(ContainSubstring("osm.vault.token is required"))
404+
})
293405
})
294406

295407
Describe("with the cert-manager certificate manager", func() {

pkg/certificate/providers/config_test.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ func TestGetCertificateManager(t *testing.T) {
3939
expectError bool
4040

4141
// params
42-
kubeClient kubernetes.Interface
43-
restConfig *rest.Config
44-
cfg configurator.Configurator
45-
providerNamespace string
46-
options Options
47-
msgBroker *messaging.Broker
48-
informerCollectionFunc func(testCase) (*informers.InformerCollection, error)
42+
kubeClient kubernetes.Interface
43+
restConfig *rest.Config
44+
cfg configurator.Configurator
45+
providerNamespace string
46+
options Options
47+
msgBroker *messaging.Broker
4948
}
5049
testCases := []testCase{
5150
{

0 commit comments

Comments
 (0)