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

feat(metadata): use manifest to drive config #1701

Merged
merged 8 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from 6 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
18 changes: 15 additions & 3 deletions gen3/bin/kube-setup-metadata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ DB_HOST=$(jq -r .db_host < "$secretsFolder/dbcreds.json")
DB_USER=$(jq -r .db_username < "$secretsFolder/dbcreds.json")
DB_PASSWORD=$(jq -r .db_password < "$secretsFolder/dbcreds.json")
DB_DATABASE=$(jq -r .db_database < "$secretsFolder/dbcreds.json")
USE_AGG_MDS=false
AGG_MDS_NAMESPACE=$(gen3 db namespace)
ADMIN_LOGINS=gateway:$password
EOM
# make it easy for nginx to get the Authorization header ...
Expand All @@ -59,7 +57,21 @@ if ! setup_database; then
exit 1
fi

if grep "USE_AGG_MDS=true" "$(gen3_secrets_folder)/g3auto/metadata/metadata.env" > /dev/null 2>&1; then
aggregateConfigFile="$(dirname $(g3k_manifest_path))/metadata/aggregate_config.json"
if [ -f "${aggregateConfigFile}" ]; then
if g3kubectl get secrets metadata-config > /dev/null 2>&1; then
g3kubectl delete secret metadata-config
fi
g3kubectl create secret generic metadata-config --from-file="${aggregateConfigFile}"
fi

# Create the metadata manifest configmap if it doesn't exist
if ! kubectl get configmap manifest-metadata > /dev/null 2>&1; then
gen3 gitops configmaps
fi

# Check the metadata manifest configmap to see if the agg mds is enabled
if g3kubectl get configmap manifest-metadata -o json | jq -r '.data.json' | jq '.USE_AGG_MDS == true' > /dev/null 2>&1; then
gen3_log_info "kube-setup-metadata setting up aws-es-proxy dependency"
gen3 kube-setup-aws-es-proxy || true
wait_for_esproxy
Expand Down
40 changes: 33 additions & 7 deletions kube/services/metadata/metadata-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ spec:
topologyKey: "kubernetes.io/hostname"
automountServiceAccountToken: false
volumes:
- name: config-volume-g3auto
secret:
secretName: metadata-g3auto
- name: config-volume
secret:
secretName: "metadata-g3auto"
secretName: metadata-config
- name: config-manifest
configMap:
name: manifest-metadata
containers:
- name: metadata
GEN3_METADATA_IMAGE
Expand All @@ -51,6 +57,18 @@ spec:
GEN3_DEBUG_FLAG|-value: "False"-|
- name: GEN3_ES_ENDPOINT
value: http://esproxy-service:9200
- name: USE_AGG_MDS
valueFrom:
configMapKeyRef:
name: manifest-metadata
key: USE_AGG_MDS
optional: true
- name: AGG_MDS_NAMESPACE
valueFrom:
configMapKeyRef:
name: manifest-metadata
key: AGG_MDS_NAMESPACE
optional: true
imagePullPolicy: Always
livenessProbe:
httpGet:
Expand All @@ -66,10 +84,18 @@ spec:
ports:
- containerPort: 80
volumeMounts:
- name: "config-volume"
- name: config-volume-g3auto
readOnly: true
mountPath: /src/.env
subPath: metadata.env
- name: config-volume
readOnly: true
mountPath: /aggregate_config.json
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm trying to do one thing at a time, but in conjunction with this PR we should update the cdis-manifest entries as needed add an aggregate_config.json file per-commons. I'll work on the automated process/init process for importing data automatically on a roll or whatever, but the immediate change would be...

kubectl exec $(gen3 pod metadata) -- python /src/src/mds/populate.py --config /aggregate_config.json --hostname esproxy-service --port 9200

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have this in an init-container instead? The init-container can run this before starting the service.

Copy link
Contributor

Choose a reason for hiding this comment

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

If there's no config then init container will exit 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I think you're right. I was going to wait to do https://ctds-planx.atlassian.net/browse/HP-287, but I think I may as well do this while I'm updating the rest of it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

subPath: aggregate_config.json
- name: config-manifest
readOnly: true
mountPath: "/src/.env"
subPath: "metadata.env"
mountPath: /metadata.json
subPath: json
resources:
requests:
cpu: 0.4
Expand All @@ -82,10 +108,10 @@ spec:
GEN3_METADATA_IMAGE
imagePullPolicy: Always
volumeMounts:
- name: "config-volume"
- name: config-volume-g3auto
readOnly: true
mountPath: "/src/.env"
subPath: "metadata.env"
mountPath: /src/.env
subPath: metadata.env
resources:
limits:
cpu: 0.8
Expand Down