-
Notifications
You must be signed in to change notification settings - Fork 0
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 #2 from kalenpeterson/feature-userscript
Feature userscript
- Loading branch information
Showing
19 changed files
with
1,039 additions
and
290 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,3 +100,8 @@ ENV/ | |
|
||
# Remove Shell Tests | ||
tests/ | ||
|
||
# Remove Ansible files | ||
inventory | ||
all.yml | ||
*.env |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
# Build and Push the image for all defined ENVs | ||
|
||
# A version tag is required input and will be appended to the image tag | ||
VERSION_TAG=$1 | ||
if [[ -z ${VERSION_TAG} ]]; then | ||
echo "A Version tag must be provided" | ||
exit 1 | ||
fi | ||
|
||
# Simple Logging function | ||
log () { | ||
echo $(date) [info] $1 | ||
} | ||
|
||
# Build each environment found in this directory | ||
# Use the provided my.env.example as a base for your ENV | ||
# cp my.env.example .my.env" and edit as needed | ||
for env in $(ls -a .*.env |awk -F. '{print $2}') | ||
do | ||
|
||
source .${env}.env | ||
log "Building ${env} Image" | ||
cat .${env}.env \ | ||
| xargs printf -- '--build-arg %s\n' \ | ||
| xargs podman build \ | ||
-t ${IMAGE_NAME}:${env}-v${VERSION_TAG} \ | ||
-t ${IMAGE_NAME}:${env}-latest ../ || exit 1 | ||
|
||
log "Pushing ${env} Image: ${IMAGE_NAME}:${env}-v${VERSION_TAG}" | ||
podman push ${IMAGE_NAME}:${env}-v${VERSION_TAG} || exit 1 | ||
log "Pushing ${env} Image: ${IMAGE_NAME}:${env}-latest " | ||
podman push ${IMAGE_NAME}:${env}-latest || exit 1 | ||
done | ||
|
||
log "Build(s) Completed" |
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 @@ | ||
IMAGE_NAME=docker.io/account/repository |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,81 @@ | ||
--- | ||
- name: Deploy Chargeback Kubernetes Resources | ||
hosts: provision | ||
gather_facts: no | ||
|
||
tasks: | ||
- name: Create Tempfile for Kube Manifest | ||
tempfile: | ||
state: file | ||
suffix: temp | ||
register: temp_kube_manifest | ||
notify: Cleanup Tempfile | ||
|
||
- name: Generate the Manifest from Template | ||
template: | ||
src: templates/kubernetes.yml.j2 | ||
dest: "{{ temp_kube_manifest.path }}" | ||
|
||
- name: Apply Deployment | ||
shell: | | ||
kubectl apply -n "{{ kubernetes.namespace }}" -f "{{ temp_kube_manifest.path }}" | ||
register: kubectl_out | ||
|
||
- name: Print Kubectl Apply Output | ||
debug: | ||
var: kubectl_out.stdout | ||
|
||
handlers: | ||
- name: Cleanup Tempfile | ||
file: | ||
state: absent | ||
path: "{{ temp_kube_manifest }}" | ||
when: temp_kube_manifest.path is defined and | ||
kubernetes.cleanup_temp_manifest is true | ||
|
||
- name: Deploy Chargeback Client Resources | ||
hosts: mgmt | ||
gather_facts: no | ||
|
||
tasks: | ||
- name: Install Python3 Devel | ||
yum: | ||
name: python3-devel | ||
state: present | ||
become: yes | ||
delegate_to: localhost | ||
run_once: true | ||
|
||
- name: Install Python requirements | ||
pip: | ||
executable: pip3 | ||
name: | ||
- requests | ||
- prettytable | ||
- cython | ||
become: yes | ||
|
||
- name: Compile Python to C Binary | ||
shell: | | ||
cython --embed -o /tmp/{{ chargeback.cli_binary_name }}.c ../src/cli.py | ||
gcc -Os -I /usr/include/python3.6m -o /tmp/{{ chargeback.cli_binary_name }} /tmp/{{ chargeback.cli_binary_name }}.c -lpython3.6m -lpthread -lm -lutil -ldl | ||
delegate_to: localhost | ||
run_once: true | ||
|
||
- name: Copy Binary to path | ||
copy: | ||
src: /tmp/{{ chargeback.cli_binary_name }} | ||
dest: /usr/local/bin/{{ chargeback.cli_binary_name }} | ||
mode: 755 | ||
owner: root | ||
become: yes | ||
|
||
- name: Cleanup Temp Files | ||
file: | ||
path: '{{ item }}' | ||
state: absent | ||
loop: | ||
- /tmp/{{ chargeback.cli_binary_name }} | ||
- /tmp/{{ chargeback.cli_binary_name }}.c | ||
delegate_to: localhost | ||
run_once: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
--- | ||
slurm: | ||
job_prev_days: 14 | ||
assoc_backend: slurm_acctdb | ||
partition_filter: '' | ||
cluster_name: | ||
db: | ||
host: | ||
port: 3306 | ||
username: | ||
password: | ||
chargeback: | ||
db: | ||
host: | ||
port: 3306 | ||
username: | ||
password: | ||
schema_name: | ||
table_name: | ||
gpu_usd_cost_per_minute: | ||
cli_binary_name: charges | ||
ssh: | ||
host: | ||
port: 22 | ||
username: | ||
password: | ||
file_cleanup: False | ||
email: | ||
smtp: | ||
host: | ||
port: | ||
username: | ||
password: | ||
to: | ||
address: 'User <user.name@example.com>' | ||
from: | ||
address: 'DGX Chargeback <no-reply@example.com>' | ||
kubernetes: | ||
namespace: default | ||
cleanup_temp_manifest: False | ||
cronjob: | ||
image: docker.io/kalenpeterson/dgx-chargeback:build-19 | ||
api: | ||
replicas: 1 | ||
image: docker.io/kalenpeterson/dgx-chargeback:build-19 |
Oops, something went wrong.