-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Helm subchart for test app w/ Secrets Provider in standalone mode
- Loading branch information
diverdane
committed
Aug 16, 2021
1 parent
abea077
commit 5d9083f
Showing
13 changed files
with
358 additions
and
35 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
25 changes: 25 additions & 0 deletions
25
helm/conjur-app-deploy/charts/app-secrets-provider-standalone/Chart.yaml
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,25 @@ | ||
apiVersion: v2 | ||
name: app-secrets-provider-standalone | ||
home: https://www.conjur.org | ||
version: 0.1.0 | ||
description: A Helm chart deploying an application that uses the Cyberark | ||
Secrets Provider running as a standalone Kubernetes Job to | ||
provide the application with Kubernetes Secrets containing | ||
credentials retrieved from Conjur | ||
icon: https://www.cyberark.com/wp-content/uploads/2015/12/cybr-aim.jpg | ||
keywords: | ||
- security | ||
- "secrets management" | ||
sources: | ||
- https://github.com/cyberark/conjur-authn-k8s-client | ||
- https://github.com/cyberark/secrets-provider-for-k8s | ||
- https://github.com/cyberark/conjur-oss-helm-chart | ||
- https://github.com/cyberark/conjur | ||
maintainers: | ||
- name: Conjur Maintainers | ||
email: [email protected] | ||
|
||
dependencies: | ||
- name: secrets-provider | ||
repository: "https://cyberark.github.io/helm-charts" | ||
version: "1.1.5" |
2 changes: 2 additions & 0 deletions
2
helm/conjur-app-deploy/charts/app-secrets-provider-standalone/README.md
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,2 @@ | ||
# Helm Chart to Deploy an Application that uses a Secrets Provider as a Standalone K8S Job | ||
|
9 changes: 9 additions & 0 deletions
9
helm/conjur-app-deploy/charts/app-secrets-provider-standalone/templates/NOTES.txt
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,9 @@ | ||
The Application deployment is complete. | ||
The following have been deployed: | ||
- A sample "Pet Store" application that uses a Kubernetes Secret to configure | ||
its backend database credentials. | ||
- A CyberArk Secrets Provider Job that, upon startup, updates the Kubernetes | ||
Secret that is used by the "Pet Store" application with backend database | ||
credentials that the Secrets Provider has retrieved from Conjur. | ||
|
||
Application is now available at test-app-secrets-provider-standalone.{{ .Release.Namespace }}.svc.cluster.local |
10 changes: 10 additions & 0 deletions
10
helm/conjur-app-deploy/charts/app-secrets-provider-standalone/templates/secret.yaml
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,10 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: test-app-secrets-provider-standalone-secret | ||
type: Opaque | ||
stringData: | ||
conjur-map: |- | ||
DB_URL: test-secrets-provider-standalone-app-db/url | ||
DB_USERNAME: test-secrets-provider-standalone-app-db/username | ||
DB_PASSWORD: test-secrets-provider-standalone-app-db/password |
57 changes: 57 additions & 0 deletions
57
...harts/app-secrets-provider-standalone/templates/test_app_secrets_provider_standalone.yaml
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,57 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: test-app-secrets-provider-standalone | ||
labels: | ||
app: test-app-secrets-provider-standalone | ||
spec: | ||
ports: | ||
- protocol: TCP | ||
port: 8080 | ||
targetPort: 8080 | ||
selector: | ||
app: test-app-secrets-provider-standalone | ||
type: {{ .Values.global.appServiceType }} | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: test-app-secrets-provider-standalone | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: test-app-secrets-provider-standalone | ||
name: test-app-secrets-provider-standalone | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: test-app-secrets-provider-standalone | ||
template: | ||
metadata: | ||
labels: | ||
app: test-app-secrets-provider-standalone | ||
spec: | ||
serviceAccountName: test-app-secrets-provider-standalone | ||
containers: | ||
- image: {{ printf "%s:%s" .Values.app.image.repository .Values.app.image.tag }} | ||
imagePullPolicy: {{ .Values.app.image.pullPolicy }} | ||
name: test-app | ||
ports: | ||
- name: http | ||
containerPort: 8080 | ||
readinessProbe: | ||
httpGet: | ||
path: /pets | ||
port: http | ||
initialDelaySeconds: 15 | ||
timeoutSeconds: 5 | ||
envFrom: | ||
- secretRef: | ||
name: test-app-secrets-provider-standalone-secret | ||
{{- if eq .Values.app.platform "kubernetes" }} | ||
imagePullSecrets: | ||
- name: dockerpullsecret | ||
{{- end }} |
82 changes: 82 additions & 0 deletions
82
helm/conjur-app-deploy/charts/app-secrets-provider-standalone/test-schema
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,82 @@ | ||
#!/bin/bash | ||
|
||
# This script tests the restrictions on chart values | ||
# as defined in the 'values.schema.json' file. | ||
# | ||
# Requirements: | ||
# - Helm v3.5.3 or later | ||
|
||
# Run this script from the directory in which this script resides | ||
# regardless of where it is invoked. | ||
cd "$(dirname "$0")" | ||
chart_dir="$(pwd)" | ||
|
||
source ../../../common/utils.sh | ||
|
||
# Default required settings | ||
declare -a DEFAULT_SETTINGS="--set secrets-provider.environment.conjur.authnLogin=host/conjur/authn-k8s/my-id/my-group/my-app \ | ||
--set secrets-provider.environment.conjur.conjurConnConfigMap=conjur-connect" | ||
|
||
# Global test state | ||
num_passed=0 | ||
num_failed=0 | ||
test_failed=false | ||
|
||
function global_app_service_type_test() { | ||
helm lint . --strict $DEFAULT_SETTINGS --set "global.appServiceType=$1" | ||
} | ||
|
||
function app_image_repository_test() { | ||
helm lint . --strict $DEFAULT_SETTINGS --set "app.image.repository=$1" | ||
} | ||
|
||
function app_image_pull_policy_test() { | ||
helm lint . --strict $DEFAULT_SETTINGS --set "app.image.pullPolicy=$1" | ||
} | ||
|
||
function main() { | ||
banner $BOLD "Running Helm schema tests for chart\n" \ | ||
"\"$chart_dir\"" | ||
check_helm_version | ||
|
||
announce "Updating Helm dependencies to ensure that Secrets Provider\n" \ | ||
"Helm chart has been downloaded" | ||
helm dependency update . | ||
|
||
declare -a svc_types=("ClusterIP" "NodePort" "LoadBalancer" "ExternalName") | ||
for type in "${svc_types[@]}"; do | ||
announce "Application ServiceType of $type is accepted" | ||
global_app_service_type_test "$type" | ||
update_results "$?" | ||
done | ||
|
||
announce "Application ServiceType of nodePort (begins w/ lower case) is rejected" | ||
global_app_service_type_test "nodePort" | ||
update_results "$?" "$EXPECT_FAILURE" | ||
|
||
announce "Valid app image Docker repository accepted" | ||
app_image_repository_test "my-org/abc_123" | ||
update_results "$?" | ||
|
||
announce "App image Docker repository with '#' is rejected" | ||
app_image_repository_test "my-org/abc#123" | ||
update_results "$?" "$EXPECT_FAILURE" | ||
|
||
declare -a pull_policy_types=("Always" "Never" "IfNotPresent") | ||
for policy in "${pull_policy_types[@]}"; do | ||
announce "App image pullPolicy of $policy is accepted" | ||
app_image_pull_policy_test "$policy" | ||
update_results "$?" | ||
done | ||
|
||
announce "App image pullPolicy of lower case 'always' is rejected" | ||
app_image_pull_policy_test "always" | ||
update_results "$?" "$EXPECT_FAILURE" | ||
|
||
display_final_results | ||
if [ "$num_failed" -ne 0 ]; then | ||
exit 1 | ||
fi | ||
} | ||
|
||
main "$@" |
14 changes: 14 additions & 0 deletions
14
helm/conjur-app-deploy/charts/app-secrets-provider-standalone/test-unit
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,14 @@ | ||
#!/bin/bash | ||
|
||
# Runs a Helm unit test using the 'helm-unittest' Helm plugin. | ||
# Reference: https://github.com/quintush/helm-unittest/blob/master/DOCUMENT.md | ||
|
||
# Run this script from the directory in which this script resides | ||
# regardless of where it is invoked. | ||
cd "$(dirname "$0")" | ||
chart_dir="$(pwd)" | ||
|
||
source ../../../common/utils.sh | ||
|
||
banner $BOLD "Running Helm unit tests for chart \"$chart_dir\"" | ||
run_helm_unittest |
67 changes: 67 additions & 0 deletions
67
...arts/app-secrets-provider-standalone/tests/test_app_secrets_provider_standalone_test.yaml
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,67 @@ | ||
suite: test test_app_secrets_provider_init | ||
|
||
templates: | ||
- test_app_secrets_provider_standalone.yaml | ||
|
||
defaults: &defaultRequired | ||
secrets-provider.environment.conjur.authnLogin: "host/conjur/authn-k8s/my-id/my-group/my-app" | ||
secrets-provider.environment.conjur.conjurConnConfigMap: "conjur-connect" | ||
secrets-provider.environment.k8sSecrets: ["my-app-secret"] | ||
|
||
tests: | ||
#======================================================================= | ||
- it: should use default values for Service | ||
#======================================================================= | ||
set: | ||
# Set required values | ||
<<: *defaultRequired | ||
|
||
documentIndex: 0 | ||
|
||
asserts: | ||
- isKind: | ||
of: Service | ||
|
||
- equal: | ||
path: spec.type | ||
value: NodePort | ||
- equal: | ||
path: metadata.name | ||
value: test-app-secrets-provider-standalone | ||
- equal: | ||
path: metadata.labels.app | ||
value: test-app-secrets-provider-standalone | ||
|
||
#======================================================================= | ||
- it: should create a ServiceAccount | ||
#======================================================================= | ||
set: | ||
# Set required values | ||
<<: *defaultRequired | ||
|
||
documentIndex: 1 | ||
|
||
asserts: | ||
- hasDocuments: | ||
count: 3 | ||
- isKind: | ||
of: ServiceAccount | ||
|
||
#======================================================================= | ||
- it: should use default values for Deployment | ||
#======================================================================= | ||
set: | ||
# Set required values | ||
<<: *defaultRequired | ||
|
||
documentIndex: 2 | ||
|
||
asserts: | ||
- isKind: | ||
of: Deployment | ||
- equal: | ||
path: spec.template.spec.containers[0].image | ||
value: cyberark/demo-app:latest | ||
- equal: | ||
path: spec.template.spec.containers[0].imagePullPolicy | ||
value: "Always" |
34 changes: 34 additions & 0 deletions
34
helm/conjur-app-deploy/charts/app-secrets-provider-standalone/values.schema.json
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,34 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema", | ||
"properties": { | ||
"app": { | ||
"properties": { | ||
"image": { | ||
"properties": { | ||
"repository": { | ||
"type": "string", | ||
"pattern": "^[a-z0-9:./_-]+$" | ||
}, | ||
"tag": { | ||
"type": "string" | ||
}, | ||
"pullPolicy": { | ||
"type": "string", | ||
"pattern": "^(Always|Never|IfNotPresent)$" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"global": { | ||
"properties": { | ||
"appServiceType": { | ||
"type": "string", | ||
"pattern": "^(ClusterIP|NodePort|LoadBalancer|ExternalName)$" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.