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

chore(es-proxy-scratch): Updated code to support scratch image #2687

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 1 addition & 10 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -722,15 +722,6 @@
"line_number": 65
}
],
"kube/services/aws-es-proxy/aws-es-proxy-deploy.yaml": [
{
"type": "Secret Keyword",
"filename": "kube/services/aws-es-proxy/aws-es-proxy-deploy.yaml",
"hashed_secret": "7f834ccb442433fc12ec9532f75c3a4b6a748d4c",
"is_verified": false,
"line_number": 47
}
],
"kube/services/cogwheel/cogwheel-deploy.yaml": [
{
"type": "Secret Keyword",
Expand Down Expand Up @@ -3253,5 +3244,5 @@
}
]
},
"generated_at": "2024-11-25T11:39:59Z"
"generated_at": "2024-12-13T12:56:42Z"
}
30 changes: 15 additions & 15 deletions gen3/bin/kube-setup-secrets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,21 @@ if [[ -z "$fenceIndexdPassword" || "null" == "$fenceIndexdPassword" ]]; then
/bin/rm -rf .rendered_indexd_userdb
fi

# update aws-es-proxy secrets
if ! g3kubectl get secrets/aws-es-proxy > /dev/null 2>&1; then
credsFile=$(mktemp -p "$XDG_RUNTIME_DIR" "creds.json_XXXXXX")
creds=$(jq -r ".es|tostring" < creds.json |sed -e 's/[{-}]//g' -e 's/"//g' -e 's/:/=/g')
if [[ "$creds" != null ]]; then
echo "[default]" > "$credsFile"
IFS=',' read -ra CREDS <<< "$creds"
for i in "${CREDS[@]}"; do
echo ${i} >> "$credsFile"
done
g3kubectl create secret generic aws-es-proxy "--from-file=credentials=${credsFile}"
else
echo "WARNING: creds.json does not include AWS elastic search credentials - not initializing aws-es-proxy secret"
fi
rm "$credsFile"

credsFile=$(mktemp -p "$XDG_RUNTIME_DIR" "creds.json_XXXXXX")
creds=$(jq -r ".es|tostring" < creds.json |sed -e 's/[{-}]//g' -e 's/"//g' -e 's/:/=/g')
if [[ "$creds" != null ]]; then
echo "[default]" > "$credsFile"
IFS=',' read -ra CREDS <<< "$creds"
for i in "${CREDS[@]}"; do
echo ${i} >> "$credsFile"
done
g3kubectl delete secret aws-es-proxy || true
g3kubectl create secret generic aws-es-proxy "--from-file=credentials=${credsFile}" --from-literal=aws_access_key_id=$(cat creds.json| jq -r .es.aws_access_key_id) --from-literal=aws_secret_access_key=$(cat creds.json| jq -r .es.aws_secret_access_key)
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be a little more readable

g3kubectl create secret generic aws-es-proxy \
  "--from-file=credentials=${credsFile}" \
  --from-literal=aws_access_key_id=$(cat creds.json | jq -r .es.aws_access_key_id) \
  --from-literal=aws_secret_access_key=$(cat creds.json | jq -r .es.aws_secret_access_key)

else
echo "WARNING: creds.json does not include AWS elastic search credentials - not initializing aws-es-proxy secret"
fi
rm "$credsFile"

# We also want to update the metadata-config secret if such manifest file exists
# So that metadata-aggregate-sync can run more seamlessly
Expand Down Expand Up @@ -336,3 +335,4 @@ if ! g3kubectl get secrets/grafana-admin > /dev/null 2>&1; then
fi
rm -f "${credsFile}"
fi

10 changes: 10 additions & 0 deletions kube/services/aws-es-proxy/aws-es-proxy-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ spec:
env:
- name: "ES_ENDPOINT"
GEN3_ES_ENDPOINT|-value: es.internal.io-|
- name: "AWS_ACCESS_KEY_ID"
valueFrom:
secretKeyRef:
name: aws-es-proxy
key: aws_access_key_id
- name: "AWS_SECRET_ACCESS_KEY"
valueFrom:
secretKeyRef:
name: aws-es-proxy
key: aws_secret_access_key
volumeMounts:
- name: "credentials"
readOnly: true
Expand Down
Loading