Skip to content

Commit

Permalink
Update k8s and k8s-rotation dev environments with encoded secret
Browse files Browse the repository at this point in the history
  • Loading branch information
gl-johnson committed Mar 21, 2023
1 parent 231c303 commit 4274d14
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ junit.xml
# Temporary directory to store the CyberArk proxy CA certificate
build_ca_certificate/

# Ignore generated policy files
deploy/policy/generated/
# Ignore generated policy files and manifests
deploy/**/generated/
3 changes: 3 additions & 0 deletions deploy/config/k8s/k8s-secret.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ stringData:
var_with_spaces: secrets/var with spaces
var_with_pluses: secrets/var+with+pluses
var_with_umlaut: secrets/umlaut
var_with_encoded:
id: secrets/encoded
content-type: base64
non-conjur-key: some-value
3 changes: 3 additions & 0 deletions deploy/config/openshift/k8s-secret.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ stringData:
var_with_spaces: secrets/var with spaces
var_with_pluses: secrets/var+with+pluses
var_with_umlaut: secrets/umlaut
var_with_encoded:
id: secrets/encoded
content-type: base64
non-conjur-key: some-value
5 changes: 5 additions & 0 deletions deploy/dev/config/k8s/secrets-provider-init-container.sh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ spec:
secretKeyRef:
name: test-k8s-secret
key: var_with_umlaut
- name: VARIABLE_WITH_ENCODED_SECRET
valueFrom:
secretKeyRef:
name: test-k8s-secret
key: var_with_encoded
- name: NON_CONJUR_SECRET
valueFrom:
secretKeyRef:
Expand Down
5 changes: 5 additions & 0 deletions deploy/dev/config/k8s/secrets-provider-k8s-rotation.sh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ spec:
secretKeyRef:
name: test-k8s-secret
key: var_with_umlaut
- name: VARIABLE_WITH_ENCODED_SECRET
valueFrom:
secretKeyRef:
name: test-k8s-secret
key: var_with_encoded
- name: NON_CONJUR_SECRET
valueFrom:
secretKeyRef:
Expand Down
1 change: 1 addition & 0 deletions deploy/policy/load_policies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ conjur variable set -i secrets/test_secret -v "some-secret"
conjur variable set -i "secrets/var with spaces" -v "some-secret"
conjur variable set -i "secrets/var+with+pluses" -v "some-secret"
conjur variable set -i "secrets/umlaut" -v "some-secret"
conjur variable set -i "secrets/encoded" -v "c2VjcmV0LXZhbHVl" # == secret-value
conjur variable set -i secrets/url -v "postgresql://test-app-backend.app-test.svc.cluster.local:5432"
conjur variable set -i secrets/username -v "some-user"
conjur variable set -i secrets/password -v "7H1SiSmYp@5Sw0rd"
Expand Down
1 change: 1 addition & 0 deletions deploy/policy/templates/conjur-secrets.template.sh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cat << EOL
- !variable var with spaces
- !variable var+with+pluses
- !variable umlaut
- !variable encoded
- !variable url
- !variable username
- !variable password
Expand Down
16 changes: 10 additions & 6 deletions deploy/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ deploy_chart() {
}

set_config_directory_path() {
export DEV_CONFIG_DIR="dev/config/k8s"
export CONFIG_DIR="config/k8s"
if [[ "$PLATFORM" = "openshift" ]]; then
export CONFIG_DIR="config/openshift"
Expand Down Expand Up @@ -380,8 +381,9 @@ deploy_init_env() {
echo "Running Deployment Manifest"

if [[ "$DEV" = "true" ]]; then
./dev/config/k8s/secrets-provider-init-container.sh.yml > ./dev/config/k8s/secrets-provider-init-container.yml
$cli_with_timeout apply -f ./dev/config/k8s/secrets-provider-init-container.yml
mkdir -p $DEV_CONFIG_DIR/generated
$DEV_CONFIG_DIR/secrets-provider-init-container.sh.yml > $DEV_CONFIG_DIR/generated/secrets-provider-init-container.yml
$cli_with_timeout apply -f $DEV_CONFIG_DIR/generated/secrets-provider-init-container.yml

$cli_with_timeout "get pods --namespace=$APP_NAMESPACE_NAME --selector app=init-env --no-headers | wc -l"
else
Expand All @@ -407,8 +409,9 @@ deploy_k8s_rotation_env() {
echo "Running Deployment Manifest"

if [[ "$DEV" = "true" ]]; then
./dev/config/k8s/secrets-provider-k8s-rotation.sh.yml > ./dev/config/k8s/secrets-provider-k8s-rotation.yml
$cli_with_timeout apply -f ./dev/config/k8s/secrets-provider-k8s-rotation.yml
mkdir -p $DEV_CONFIG_DIR/generated
$DEV_CONFIG_DIR/secrets-provider-k8s-rotation.sh.yml > $DEV_CONFIG_DIR/generated/secrets-provider-k8s-rotation.yml
$cli_with_timeout apply -f $DEV_CONFIG_DIR/generated/secrets-provider-k8s-rotation.yml

$cli_with_timeout "get pods --namespace=$APP_NAMESPACE_NAME --selector app=test-app --no-headers | wc -l"
else
Expand Down Expand Up @@ -649,8 +652,9 @@ deploy_push_to_file() {
deployment_name="test-env"

if [[ "$DEV" = "true" ]]; then
"./dev/config/k8s/$dev_yaml_file_name.sh.yml" > "./dev/config/k8s/$dev_yaml_file_name.yml"
$cli_with_timeout apply -f "./dev/config/k8s/$dev_yaml_file_name.yml"
mkdir -p $DEV_CONFIG_DIR/generated
"$DEV_CONFIG_DIR/$dev_yaml_file_name.sh.yml" > "$DEV_CONFIG_DIR/generated/$dev_yaml_file_name.yml"
$cli_with_timeout apply -f "$DEV_CONFIG_DIR/generated/$dev_yaml_file_name.yml"

$cli_with_timeout "get pods --namespace=$APP_NAMESPACE_NAME --selector app=$deployment_name --no-headers | wc -l"
else
Expand Down

0 comments on commit 4274d14

Please sign in to comment.