-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
171 inject Secret Store CSI driver
deployment_spec.tpl
(#172)
* docs: Update README.adoc - added a row to features section * test: add failing test to check if csi block is present * test: check env section is added * chore: update deployment spec - added csi block in the volumes section - tpl needs a mix of funcitonality from volume and env types of secrets - added service account name to test * Update TestK8SServiceDeploymentCheckSecretStoreCSIBlock test * Move check for injecting secrets as env var from csi to another file * simplify values definition * add CSI block to the secrets{} docs * move readOnly to volume setting * small changes * remove comments about failing tests * update README --------- Co-authored-by: nadiia-caspar <[email protected]>
- Loading branch information
1 parent
75c2eb8
commit 5675e6d
Showing
7 changed files
with
167 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//go:build all || tpl | ||
// +build all tpl | ||
|
||
// NOTE: We use build flags to differentiate between template tests and integration tests so that you can conveniently | ||
// run just the template tests. See the test README for more information. | ||
|
||
package test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestK8SServiceDeploymentCheckSecretStoreCSIBlock(t *testing.T) { | ||
t.Parallel() | ||
|
||
deployment := renderK8SServiceDeploymentWithSetValues( | ||
t, | ||
map[string]string{ | ||
"secrets.dbsettings.as": "csi", | ||
"secrets.dbsettings.mountPath": "/etc/db", | ||
"secrets.dbsettings.readOnly": "true", | ||
|
||
"secrets.dbsettings.csi.driver": "secrets-store.csi.k8s.io", | ||
"secrets.dbsettings.csi.secretProviderClass": "secret-provider-class", | ||
|
||
"secrets.dbsettings.items.host.envVarName": "DB_HOST", | ||
"secrets.dbsettings.items.port.envVarName": "DB_PORT", | ||
}, | ||
) | ||
|
||
// Verify that there is only one container and only one volume | ||
renderedPodContainers := deployment.Spec.Template.Spec.Containers | ||
require.Equal(t, len(renderedPodContainers), 1) | ||
renderedPodVolumes := deployment.Spec.Template.Spec.Volumes | ||
require.Equal(t, len(renderedPodVolumes), 1) | ||
podVolume := renderedPodVolumes[0] | ||
|
||
// Check that the pod volume has a correct name | ||
assert.Equal(t, podVolume.Name, "dbsettings-volume") | ||
|
||
// Check that the pod volume has CSI block | ||
assert.NotNil(t, podVolume.CSI) | ||
|
||
// Check that the pod volume has correct CSI driver and attributes | ||
assert.Equal(t, podVolume.CSI.Driver, "secrets-store.csi.k8s.io") | ||
assert.NotNil(t, podVolume.CSI.VolumeAttributes) | ||
assert.Equal(t, podVolume.CSI.VolumeAttributes, map[string]string{ | ||
"secretProviderClass": "secret-provider-class", | ||
}) | ||
} |