-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from OpsMx/encp_secrets
Implemented Encrypted Secrets and Folder Structure for GitOps Style of Spinnaker Implement…
- Loading branch information
Showing
6 changed files
with
85 additions
and
6 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
56 changes: 56 additions & 0 deletions
56
charts/oes/charts/spinnaker/templates/configmap/secret-decoder.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,56 @@ | ||
{{- if .Values.gitopsHalyard.enabled }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ template "spinnaker.fullname" . }}-spin-secret-decoder | ||
labels: | ||
{{ include "spinnaker.standard-labels" . | indent 4 }} | ||
data: | ||
run.sh: |- | ||
#!/bin/bash | ||
echo "##########Replacing Secret#########" | ||
grep -ir encrypted: /tmp/spinnaker/.hal | sort -t: -u -k1,1 |cut -d : -f1 > tmp.list | ||
while IFS= read -r file; do | ||
grep encrypted: $file > tmp1.list | ||
while read line ; do | ||
echo ${line#*encrypted:} ; | ||
done < tmp1.list > secret-strings.list | ||
while read secret ; do | ||
secretName=${secret%%:*} | ||
echo "---------$secretName---" | ||
keyName=${secret#*:} | ||
echo "----------$keyName--" | ||
#echo "secret Name= $secretName and key is = $keyName" | ||
#kubectl get secret -o jis | ||
#echo kubectl --kubeconfig /home/srini/ibm-cloud/staging/ibmstaging.config -n ninja-srini get secret $secretName -o json jq -r ".data.$keyName" | ||
jqParam=".data.\"$keyName\"" | ||
value=$(kubectl get secret $secretName -o json | jq -r $jqParam | base64 -d) | ||
value=$(echo $value | sed -e 's`[][\\/.*^$]`\\&`g') | ||
echo "-----------$value---" | ||
#echo "secret Name= $secretName and key is = $keyName and value is $value" | ||
sed -i s/encrypted:$secret/$value/g $file | ||
done < secret-strings.list | ||
done < tmp.list | ||
echo "########### Replacing Kubeconfigs ############" | ||
grep encryptedFile /tmp/spinnaker/.hal/config > tmp.list | ||
while read line ; do | ||
echo ${line#*encryptedFile:} ; | ||
done < tmp.list > secret-files.list | ||
while read secret ; do | ||
secretName=${secret%%:*} | ||
keyName=${secret#*:} | ||
#echo "secret Name= $secretName and key is = $keyName" | ||
jqParam=".data.\"$keyName\"" | ||
mkdir -p /tmp/spinnaker/kubeconfigdir | ||
kubectl get secret $secretName -o json | jq -r $jqParam | base64 -d > /tmp/spinnaker/kubeconfigdir/$keyName | ||
#echo "secret Name= $secretName and key is = $keyName and value is in $keyName" | ||
old_value="encryptedFile:$secret" | ||
new_value="/home/spinnaker/kubeconfigdir/$keyName" | ||
#echo $old_value | ||
#echo $new_value | ||
sed -i "s/${old_value}/$(echo $new_value | sed 's_/_\\/_g')/g" /tmp/spinnaker/.hal/config | ||
done < secret-files.list | ||
rm -rf secret-files.list secret-strings.list tmp.list | ||
{{- end -}} |
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