Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3task #83

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,32 @@ data:
# additionalInitScript
{{ tpl .Values.halyard.additionalInitScript $ | indent 4 }}
{{- end }}
{{- else }}

{{- else if eq .Values.gitopsHalyard.repoType "git" }}
#!/bin/bash -x
echo "+++++++++++running git commands+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
git clone $GIT_CLONE_PARAM /tmp/spinnaker/.hal
GIT_USER=`echo $GIT_USER | sed 's/ *$//g'`
raghuramopsmx marked this conversation as resolved.
Show resolved Hide resolved
GIT_TOKEN=`echo $GIT_TOKEN | sed 's/ *$//g'`
DYNAMIC_ACCOUNTS_REPO=`echo $DYNAMIC_ACCOUNTS_REPO | sed 's/ *$//g'`
sed -i s/SPINNAKER_NAMESPACE/${SPINNAKER_NAMESPACE}/ /tmp/spinnaker/.hal/config
{{- end }}

{{- else }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These s3 instructions will be executed even if repo type is not s3, so it should be handled properly. Let's say repoType is not s3, not git, but "vault" even then this conditon will be hit and executed. So, handle it something like below

{{- else if eq .Values.gitopsHalyard.repoType "s3" }}

#!/bin/bash -x
echo "+++++++++++++++++++++++++++++++++++running s3 script++++++++++++++++++++++++++++++++++++++++++"
AWS_ACCESS_KEY_ID=$S3_ACCESSKEY AWS_SECRET_ACCESS_KEY=$S3_SECRETKEY aws s3 cp s3://$S3_BUCKET/config /tmp/spinnaker/.hal/config
AWS_ACCESS_KEY_ID=$S3_ACCESSKEY AWS_SECRET_ACCESS_KEY=$S3_SECRETKEY aws s3 cp s3://$S3_BUCKET/default/ /tmp/spinnaker/.hal/default --recursive
AWS_ACCESS_KEY_ID=$S3_ACCESSKEY AWS_SECRET_ACCESS_KEY=$S3_SECRETKEY aws s3 cp s3://$S3_BUCKET/halyard.yaml /tmp/spinnaker/.hal/halyard.yaml
{{- end }}

{{- if .Values.gitopsHalyard.mTLS.enabled }}
sed -i s/SPINNAKER_NAMESPACE/${SPINNAKER_NAMESPACE}/g /tmp/spinnaker/.hal/default/service-settings/*
{{- end }}

{{- if .Values.gitopsHalyard.enabled }}
GIT_USER=`echo $GIT_USER | sed 's/ *$//g'`
GIT_TOKEN=`echo $GIT_TOKEN | sed 's/ *$//g'`
DYNAMIC_ACCOUNTS_REPO=`echo $DYNAMIC_ACCOUNTS_REPO | sed 's/ *$//g'`
sed -i s/SPINNAKER_NAMESPACE/${SPINNAKER_NAMESPACE}/ /tmp/spinnaker/.hal/config
sed -i s/RELEASE_NAME/{{ .Release.Name }}/g /tmp/spinnaker/.hal/config
sed -i s/GIT_USER/${GIT_USER}/g /tmp/spinnaker/.hal/default/profiles/spinnakerconfig.yml
sed -i s/GIT_TOKEN/${GIT_TOKEN}/g /tmp/spinnaker/.hal/default/profiles/spinnakerconfig.yml
Expand Down
17 changes: 16 additions & 1 deletion charts/oes/charts/spinnaker/templates/statefulsets/halyard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
initContainers:
- name: "create-halyard-local"
{{- if .Values.gitopsHalyard.enabled }}
image: alpine/git:v2.26.2
image: quay.io/opsmxpublic/awsgit:v1
{{- else }}
image: {{ .Values.halyard.image.repository }}:{{ .Values.halyard.image.tag }}
{{- end }}
Expand Down Expand Up @@ -78,6 +78,21 @@ spec:
secretKeyRef:
name: {{ .Values.gitopsHalyard.secretName }}
key: dynamicaccountsgituri
- name: S3_ACCESSKEY
valueFrom:
secretKeyRef:
name: {{ .Values.gitopsHalyard.secretName }}
key: s3accesskey
- name: S3_SECRETKEY
valueFrom:
secretKeyRef:
name: {{ .Values.gitopsHalyard.secretName }}
key: s3secretkey
- name: S3_BUCKET
valueFrom:
secretKeyRef:
name: {{ .Values.gitopsHalyard.secretName }}
key: s3bucket
{{- end }}
volumeMounts:
- name: halyard-config
Expand Down
3 changes: 3 additions & 0 deletions charts/oes/templates/secrets/opsmx-gitops-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ data:
dynamicaccountsgituri: https://github.com/OpsMx/gitops-accounts-sample.git # In base64 format
gittoken: <gittoken>
gituser: <gituserID>
s3accesskey: <S3_ACCESSKEY>
s3secretkey: <S3_SECRETKEY>
s3bucket: <S3_BUCKET>
kind: Secret
metadata:
name: opsmx-gitops-auth
Expand Down
2 changes: 1 addition & 1 deletion charts/oes/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ spinnaker:
enabled: false # Enable mTLS for Spinnaker Services and SSL for Deck and Gate
deckIngressHost: spindeck.{{ .Release.Name }}.domain.com # Used by OES to create ingress for deck
gateIngressHost: spingate.{{ .Release.Name }}.domain.com # Used by OES to create ingress for gate
repo-type: git # git, S3, vault, only git support at this point
repoType: git # git, S3, vault, only git support at this point
secretName: opsmx-gitops-auth
# Max time(in secs) that an init container of halyard should wait
# to fetch External Load Balancer IP of spin-deck and spin-gate
Expand Down