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

LCM using s3 #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,37 @@ data:
init.sh: |
{{- if not .Values.gitopsHalyard.enabled }}
#!/bin/bash

# Override Halyard daemon's listen address
cp /opt/halyard/config/* /tmp/config
printf 'server.address: 0.0.0.0\n' > /tmp/config/halyard-local.yml

# Use Redis deployed via the dependent Helm chart
rm -rf /tmp/spinnaker/.hal/default/service-settings
mkdir -p /tmp/spinnaker/.hal/default/service-settings
cp /tmp/service-settings/* /tmp/spinnaker/.hal/default/service-settings/

rm -rf /tmp/spinnaker/.hal/default/profiles
mkdir -p /tmp/spinnaker/.hal/default/profiles
cp /tmp/additionalProfileConfigMaps/* /tmp/spinnaker/.hal/default/profiles/

rm -rf /tmp/spinnaker/.hal/.boms

{{- if .Values.halyard.bom }}
mkdir -p /tmp/spinnaker/.hal/.boms/bom
cp /tmp/halyard-bom/* /tmp/spinnaker/.hal/.boms/bom
{{- end }}

{{- if .Values.halyard.serviceConfigs }}
for filename in /tmp/service-configs/*; do
basename=$(basename -- "$filename")
fname="${basename#*_}"
servicename="${basename%%_*}"

mkdir -p "/tmp/spinnaker/.hal/.boms/$servicename"
cp "$filename" "/tmp/spinnaker/.hal/.boms/$servicename/$fname"
done
{{- end }}

{{- if hasKey .Values.halyard "additionalInitScript" }}
# additionalInitScript
{{ tpl .Values.halyard.additionalInitScript $ | indent 4 }}
{{- end }}
{{- else }}
{{- end }}

{{- if and (.Values.gitopsHalyard.enabled) (eq .Values.gitopsHalyard.repo.type "git") }}
#!/bin/bash -x
rm -rf /tmp/spinnaker/.hal
git clone $GIT_CLONE_PARAM /tmp/spinnaker/test
Expand All @@ -54,9 +48,6 @@ data:
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
{{- if .Values.gitopsHalyard.mTLS.enabled }}
sed -i s/SPINNAKER_NAMESPACE/${SPINNAKER_NAMESPACE}/g /tmp/spinnaker/.hal/default/service-settings/*
{{- end }}
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 All @@ -70,3 +61,23 @@ data:
cp /tmp/spinnaker/.hal/halyard.yaml /tmp/config
fi
{{- end }}
{{- if and (.Values.gitopsHalyard.enabled) (eq .Values.gitopsHalyard.repo.type "s3") }}
#!/bin/bash -x
rm -rf /tmp/spinnaker/.hal
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
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/RELEASE_NAME/{{ .Release.Name }}/g /tmp/spinnaker/.hal/default/service-settings/redis.yml
if [ -f /tmp/spinnaker/.hal/default/profiles/fiat-local.yml ]; then
sed -i s/RELEASE_NAME/{{ .Release.Name }}/g /tmp/spinnaker/.hal/default/profiles/fiat-local.yml
fi
printf 'server.address: 0.0.0.0\n' > /tmp/config/halyard-local.yml
if [ -f /tmp/spinnaker/.hal/halyard.yaml ]; then
cp /tmp/spinnaker/.hal/halyard.yaml /tmp/config
fi
{{- end }}
{{- if .Values.gitopsHalyard.mTLS.enabled }}
sed -i s/SPINNAKER_NAMESPACE/${SPINNAKER_NAMESPACE}/g /tmp/spinnaker/.hal/default/service-settings/*
{{- end }}
30 changes: 26 additions & 4 deletions charts/oes/charts/spinnaker/templates/statefulsets/halyard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,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 All @@ -51,7 +51,7 @@ spec:
- bash
{{- end }}
- /tmp/initscript/init.sh
{{- if .Values.gitopsHalyard.enabled }}
{{- if and (.Values.gitopsHalyard.enabled) (eq .Values.gitopsHalyard.repo.type "git") }}
env:
- name: SPINNAKER_NAMESPACE
valueFrom:
Expand All @@ -78,6 +78,28 @@ spec:
name: {{ .Values.gitopsHalyard.secretName }}
key: dynamicaccountsgituri
{{- end }}
{{- if and (.Values.gitopsHalyard.enabled) (eq .Values.gitopsHalyard.repo.type "s3") }}
env:
- name: SPINNAKER_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- 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
mountPath: /tmp/config
Expand Down Expand Up @@ -106,7 +128,7 @@ spec:
env:
{{ toYaml .Values.halyard.env | indent 8 }}
{{- end }}
{{- if .Values.gitopsHalyard.enabled }}
{{- if and (.Values.gitopsHalyard.enabled) (eq .Values.gitopsHalyard.repo.type "git") }}
- name: "halyardconfig-update"
command:
- sh
Expand Down Expand Up @@ -175,7 +197,7 @@ spec:
configMap:
name: {{ template "spinnaker.fullname" . }}-halyard-overrideurl
{{- end }}
{{- if .Values.gitopsHalyard.enabled }}
{{- if and (.Values.gitopsHalyard.enabled) (eq .Values.gitopsHalyard.repo.type "git") }}
- name: secret-decoder
configMap:
name: {{ template "spinnaker.fullname" . }}-spin-secret-decoder
Expand Down
7 changes: 7 additions & 0 deletions charts/oes/templates/secrets/opsmx-gitops-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@
apiVersion: v1
stringData:
# Repo uri to fetch halyard configuration
{{- if (eq .Values.spinnaker.gitopsHalyard.repo.type "git") }}
gitcloneparam: https://{{ .Values.spinnaker.gitopsHalyard.repo.username }}:{{ .Values.spinnaker.gitopsHalyard.repo.token }}@github.com/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.repository }}.git

# Repo details to fetch dynamic configuration
dynamicaccountsgituri: https://github.com/{{ .Values.spinnaker.gitopsHalyard.repo.organization }}/{{ .Values.spinnaker.gitopsHalyard.repo.dynamicAccRepository }}.git
gituser: {{ .Values.spinnaker.gitopsHalyard.repo.username }}
gittoken: {{ .Values.spinnaker.gitopsHalyard.repo.token }}
{{- end }}
{{- if (eq .Values.spinnaker.gitopsHalyard.repo.type "s3") }}
s3accesskey: {{ .Values.spinnaker.gitopsHalyard.repo.s3accesskey }}
s3secretkey: {{ .Values.spinnaker.gitopsHalyard.repo.s3secretkey }}
s3bucket: {{ .Values.spinnaker.gitopsHalyard.repo.s3bucket }}
Copy link
Contributor

Choose a reason for hiding this comment

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

How to specify dynamic accounts repo when repo type is s3? Are we gonna put dynamic accounts as well in s3?

{{- end }}
kind: Secret
metadata:
name: {{ .Values.spinnaker.gitopsHalyard.secretName }}
Expand Down
3 changes: 3 additions & 0 deletions charts/oes/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,9 @@ spinnaker:
halConfigPath: gitops-haldir/
username: <GitHub_UserName>
token: <GitHub_Token>
s3accesskey: <s3_access_key>
s3secretkey: <s3_secret_key>
s3bucket: <s3_bucket>
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