Skip to content

Commit

Permalink
add local db, remove kubelet
Browse files Browse the repository at this point in the history
Signed-off-by: Sunyanan Choochotkaew <[email protected]>
  • Loading branch information
sunya-ch committed Jan 25, 2024
1 parent 07c71c6 commit a088376
Show file tree
Hide file tree
Showing 28 changed files with 940 additions and 253 deletions.
134 changes: 80 additions & 54 deletions .github/workflows/build-push.yml
Original file line number Diff line number Diff line change
@@ -1,84 +1,110 @@
name: BuildPushDeployImage
name: Build-Push Kepler Model Server Image

on:
push:
branches: [ main ]
workflow_call:
secrets:
docker_username:
description: 'Docker username'
required: false
docker_password:
description: 'Docker password'
required: false
inputs:
base_change:
description: 'Change flag on base image'
required: true
type: string
image_repo:
description: 'The image repo to use'
required: true
type: string
image_tag:
description: 'The image tag to use'
required: true
type: string
push:
description: 'Push image'
required: false
type: string
default: false

env:
base_change: ${{ inputs.base_change }}
base_image: ${{ inputs.image_repo }}/kepler_model_server_base:${{ inputs.image_tag }}
image: ${{ inputs.image_repo }}/kepler_model_server:${{ inputs.image_tag }}

jobs:

changes:
check-secret:
runs-on: ubuntu-latest

outputs:
src: ${{ steps.changes.outputs.src }}
available: ${{ steps.check-secret.outputs.available }}

steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- 'dockerfiles/requirements.txt'
- 'dockerfiles/Dockerfile.base'
- '.github/workflows/build-push.yml'
- name: Check Secret
id: check-secret
env:
SECRET: ${{ secrets.docker_password }}
run: |
if [ "$SECRET" == "" ]; then
echo "available=false" >> "$GITHUB_OUTPUT"
else
echo "available=true" >> "$GITHUB_OUTPUT"
fi
buildbase:
needs: changes
if: ${{ needs.changes.outputs.src == 'true' }}
check-base-exist:
runs-on: ubuntu-latest

outputs:
exists: ${{ steps.check-base-exist.outputs.exists }}

steps:
- name: Check if Docker base image exists
id: check-base-exist
run: |
if docker pull ${{ env.base_image }}; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
build-base:
runs-on: ubuntu-latest
needs: [check-secret, check-base-exist]
steps:
- name: checkout
uses: actions/checkout@v4
- name: set up QEMU
uses: docker/setup-qemu-action@v3
- name: set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Quay
if: ${{ (github.repository_owner == 'sustainable-computing-io') && (github.ref == 'refs/heads/main') }}
- name: Login to Docker
if: ${{ needs.check-secret.outputs.available == 'true' }}
uses: docker/login-action@v3
with:
registry: quay.io/sustainable_computing_io
username: ${{ secrets.BOT_NAME }}
password: ${{ secrets.BOT_TOKEN }}
- name: Build and push base image
registry: ${{ inputs.image_repo }}
username: ${{ secrets.docker_username }}
password: ${{ secrets.docker_password }}
- name: Build-push base image
if: ${{ (needs.check-secret.outputs.available == 'true') && ((needs.check-base-exist.outputs.exists == 'false') || (env.base_change == 'true')) }}
uses: docker/build-push-action@v5
with:
context: dockerfiles
platforms: linux/amd64
push: true
tags: quay.io/sustainable_computing_io/kepler_model_server_base:v0.7
tags: ${{ env.base_image }}
file: dockerfiles/Dockerfile.base
- name: Build and push Docker image
- name: Replace value in file
if: ${{ (needs.check-secret.outputs.available == 'true') && ((needs.check-base-exist.outputs.exists == 'false') || (env.base_change == 'true')) }}
run: |
sed -i "s|quay.io/sustainable_computing_io/kepler_model_server_base:v0.7|${{ env.base_image }}|" dockerfiles/Dockerfile
- name: Build-push image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: quay.io/sustainable_computing_io/kepler_model_server:latest,quay.io/sustainable_computing_io/kepler_model_server:v0.7
file: dockerfiles/Dockerfile

build:
needs: [changes]
if: ${{ needs.changes.outputs.src == 'false' }}
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: set up QEMU
uses: docker/setup-qemu-action@v3
- name: set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Quay
if: ${{ (github.repository_owner == 'sustainable-computing-io') && (github.ref == 'refs/heads/main') }}
uses: docker/login-action@v3
with:
registry: quay.io/sustainable_computing_io
username: ${{ secrets.BOT_NAME }}
password: ${{ secrets.BOT_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: quay.io/sustainable_computing_io/kepler_model_server:latest,quay.io/sustainable_computing_io/kepler_model_server:v0.7
push: ${{ inputs.push }}
tags: ${{ env.image }}
file: dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Reusable workflow example
name: Self-hosted Collect Data Workflow

on:
workflow_call:
Expand Down Expand Up @@ -31,10 +31,19 @@ on:
description: 'The instance type to use for the EC2 instance'
required: true
type: string
model_server_image:
description: 'Kepler Model Server image'
required: true
type: string
push:
description: 'Push model to s3'
required: false
type: string
default: false


env:
KUBECONFIG: /root/.kube/config
VERSION: 0.7

jobs:
setup-runner:
Expand Down Expand Up @@ -145,7 +154,8 @@ jobs:
kubectl apply -f tasks
kubectl apply -f tasks/s3-pusher
kubectl apply -f pipelines
- name: Run Tekton Pipeline
- name: Run Tekton Pipeline with S3Push
if: ${{ inputs.push == 'true' }}
run: |
cat <<EOF | kubectl apply -f -
apiVersion: tekton.dev/v1
Expand All @@ -161,22 +171,45 @@ jobs:
persistentVolumeClaim:
claimName: task-pvc
params:
- name: PIPELINE_NAME
value: std_v${VERSION}
- name: OUTPUT_TYPE
value: AbsPower
- name: MODEL_SERVER_IMAGE
value: ${{ inputs.model_server_image }}}
- name: COS_PROVIDER
value: aws
- name: COS_SECRET_NAME
value: aws-cos-secret
- name: MACHINE_ID
value: ${{ inputs.instance_type }}-${{ inputs.ami_id }}
pipelineRef:
name: single-train-pipeline
name: collect-data-pipeline
EOF
- name: Run Tekton Pipeline without S3Push
if: ${{ inputs.push == 'false' }}
run: |
cat <<EOF | kubectl apply -f -
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
name: self-hosted-aws
spec:
timeouts:
pipeline: "6h"
tasks: "5h50m"
workspaces:
- name: mnt
persistentVolumeClaim:
claimName: task-pvc
params:
- name: MODEL_SERVER_IMAGE
value: ${{ inputs.model_server_image }}}
- name: MACHINE_ID
value: ${{ inputs.instance_type }}-${{ inputs.ami_id }}
pipelineRef:
name: collect-data-pipeline
EOF
- name: Wait for PipelineRun
run: |
./hack/k8s_helper.sh wait_for_pipelinerun self-hosted-aws
df -h
destroy-runner:
if: always()
needs: [setup-runner, train-power-model]
Expand Down
File renamed without changes.
79 changes: 79 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Workflow on Push
# - unit test
# - build image (push if docker-secret exists)
# - collect data (if aws-secret exists)
# - train model (if aws-secret exists)

name: Workflow on PR

on:
branch_protection_rule:
pull_request:
paths-ignore:
- 'fig/**'
- '.github/ISSUE_TEMPLATE/**'
- '.vscode/**'
- 'LICENSE'
- '.gitignore'
- '*.md'
- '**/*.md'

jobs:
check-change:
runs-on: ubuntu-latest

outputs:
base-change: ${{ steps.base-change.outputs.src }}
data-change: ${{ steps.data-change.outputs.src }}
modeling-change: ${{ steps.modeling-change.outputs.src }}

steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: base-change
with:
filters: |
src:
- 'dockerfiles/requirements.txt'
- 'dockerfiles/Dockerfile.base'
- '.github/workflows/build-push.yml'
- uses: dorny/paths-filter@v2
id: metric-change
with:
filters: |
src:
- 'src/util/prom_types.py'
- 'src/util/train_types.py'
- 'src/train/prom/**'
- 'model_training/tekton/tasks/stressng-task.yaml'
- 'model_training/tekton/pipelines/collect.yaml'
- 'hack/**'
- '.github/workflows/collect-data-self-hosted.yml'
- uses: dorny/paths-filter@v2
id: modeling-change
with:
filters: |
src:
- 'src/**'
- 'model_training/**'
- 'hack/**'
- '.github/workflows/collect-data-self-hosted.yml'
- '.github/workflows/train-model.yml'
unit-test:
needs: [check-change]
uses: ./.github/workflows/unit-test.yml
with:
base_change: ${{ needs.check-change.outputs.base-change }}

build-push:
needs: [check-change]
uses: ./.github/workflows/build-push.yml
with:
base_change: ${{ needs.check-change.outputs.base-change }}
image_repo: quay.io/sustainable_computing_io
image_tag: pr-${{ github.event.number }}
push: true
secrets:
docker_username: ${{ secrets.BOT_NAME }}
docker_password: ${{ secrets.BOT_TOKEN }}
Loading

0 comments on commit a088376

Please sign in to comment.