diff --git a/.github/workflows/facebook.yml b/.github/workflows/facebook.yml index 92ad6202..5cb806fb 100644 --- a/.github/workflows/facebook.yml +++ b/.github/workflows/facebook.yml @@ -7,13 +7,11 @@ on: branches: - "**" paths: + - "dataplug/**" - "build.sbt" - "dataplug-facebook/**" - ".github/workflows/facebook.yml" -env: - DATAPLUG: dataplug-facebook - jobs: deploy: runs-on: ubuntu-latest @@ -27,6 +25,9 @@ jobs: path: ~/.cache/coursier/v1/https key: ${{ runner.OS }}-coursier-cache + - name: Cache - Resolvers + run: curl https://${{ secrets.ARTIFACTS_CACHE_BUCKET }}/resolvers.sbt --create-dirs -o ~/.sbt/resolvers.sbt + - name: Setup Java uses: actions/setup-java@v2 with: @@ -35,35 +36,51 @@ jobs: java-package: jdk architecture: x64 - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - name: Container - Prepare + run: sbt "project dataplug-facebook" docker:stage - - name: Container Image Prepare - run: sbt "project $DATAPLUG" docker:stage + - name: Container - Setup QEMU + uses: docker/setup-qemu-action@v1 - - name: Container Image Build - run: docker build -t hubofallthings/$DATAPLUG:$GITHUB_SHA $DATAPLUG/target/docker/stage/ + - name: Container - Setup Buildx + uses: docker/setup-buildx-action@v1 - - name: Container Image Push - run: docker push hubofallthings/$DATAPLUG:$GITHUB_SHA + - name: Container - Meta + id: meta + uses: docker/metadata-action@v3 + with: + images: dataswift/dataplug-facebook + tags: | + type=match,prefix=v,pattern=facebook-v(\d.\d.\d),group=1 + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/heads/main') }} + type=sha,prefix=main-,format=long,enable=${{ startsWith(github.ref, 'refs/heads/main') }} + type=sha,prefix=dev-,format=long,suffix=-${{ github.run_id }} - - name: Extract Branch Name - run: | - echo "BRANCH=$(echo ${GITHUB_REF})" >> $GITHUB_ENV + - name: Container - Login DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_DATASWIFT_USER }} + password: ${{ secrets.DOCKERHUB_DATASWIFT_PASS }} - - name: Container Image Push - Master - if: contains(env.BRANCH, 'main') - run: | - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:main - docker push hubofallthings/$DATAPLUG:main + - name: Container - Build & Push + uses: docker/build-push-action@v2 + with: + push: true + context: dataplug-facebook/target/docker/stage/ + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 + cache-from: type=registry,ref=ghcr.io/datasiwft/dataplug-facebook:latest - - name: Container Image Push - Tag - if: contains(env.BRANCH, 'tags') - run: | - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:$(echo $GITHUB_REF | sed -e "s/refs\/tags\///g") - docker push hubofallthings/$DATAPLUG:$(echo $GITHUB_REF | sed -e "s/refs\/tags\///g") - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:latest - docker push hubofallthings/$DATAPLUG:latest + - name: Slack + uses: lazy-actions/slatify@master + if: failure() + with: + type: ${{ job.status }} + job_name: "*${{ github.workflow }}*" + channel: "ci" + commit: true + mention: "here" + mention_if: "failure" + token: ${{ secrets.GITHUB_TOKEN }} + url: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/fitbit.yml b/.github/workflows/fitbit.yml index b1c8ed2c..ea800e7c 100644 --- a/.github/workflows/fitbit.yml +++ b/.github/workflows/fitbit.yml @@ -7,13 +7,11 @@ on: branches: - "**" paths: + - "dataplug/**" - "build.sbt" - "dataplug-fitbit/**" - ".github/workflows/fitbit.yml" -env: - DATAPLUG: dataplug-fitbit - jobs: deploy: runs-on: ubuntu-latest @@ -27,6 +25,9 @@ jobs: path: ~/.cache/coursier/v1/https key: ${{ runner.OS }}-coursier-cache + - name: Cache - Resolvers + run: curl https://${{ secrets.ARTIFACTS_CACHE_BUCKET }}/resolvers.sbt --create-dirs -o ~/.sbt/resolvers.sbt + - name: Setup Java uses: actions/setup-java@v2 with: @@ -35,35 +36,51 @@ jobs: java-package: jdk architecture: x64 - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - name: Container - Prepare + run: sbt "project dataplug-fitbit" docker:stage - - name: Container Image Prepare - run: sbt "project $DATAPLUG" docker:stage + - name: Container - Setup QEMU + uses: docker/setup-qemu-action@v1 - - name: Container Image Build - run: docker build -t hubofallthings/$DATAPLUG:$GITHUB_SHA $DATAPLUG/target/docker/stage/ + - name: Container - Setup Buildx + uses: docker/setup-buildx-action@v1 - - name: Container Image Push - run: docker push hubofallthings/$DATAPLUG:$GITHUB_SHA + - name: Container - Meta + id: meta + uses: docker/metadata-action@v3 + with: + images: dataswift/dataplug-fitbit + tags: | + type=match,prefix=v,pattern=fitbit-v(\d.\d.\d),group=1 + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/heads/main') }} + type=sha,prefix=main-,format=long,enable=${{ startsWith(github.ref, 'refs/heads/main') }} + type=sha,prefix=dev-,format=long,suffix=-${{ github.run_id }} - - name: Extract Branch Name - run: | - echo "BRANCH=$(echo ${GITHUB_REF})" >> $GITHUB_ENV + - name: Container - Login DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_DATASWIFT_USER }} + password: ${{ secrets.DOCKERHUB_DATASWIFT_PASS }} - - name: Container Image Push - Master - if: contains(env.BRANCH, 'main') - run: | - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:main - docker push hubofallthings/$DATAPLUG:main + - name: Container - Build & Push + uses: docker/build-push-action@v2 + with: + push: true + context: dataplug-fitbit/target/docker/stage/ + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 + cache-from: type=registry,ref=ghcr.io/datasiwft/dataplug-fitbit:latest - - name: Container Image Push - Tag - if: contains(env.BRANCH, 'tags') - run: | - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:$(echo $GITHUB_REF | sed -e "s/refs\/tags\///g") - docker push hubofallthings/$DATAPLUG:$(echo $GITHUB_REF | sed -e "s/refs\/tags\///g") - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:latest - docker push hubofallthings/$DATAPLUG:latest + - name: Slack + uses: lazy-actions/slatify@master + if: failure() + with: + type: ${{ job.status }} + job_name: "*${{ github.workflow }}*" + channel: "ci" + commit: true + mention: "here" + mention_if: "failure" + token: ${{ secrets.GITHUB_TOKEN }} + url: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/gcalendar.yml b/.github/workflows/gcalendar.yml new file mode 100644 index 00000000..1960be44 --- /dev/null +++ b/.github/workflows/gcalendar.yml @@ -0,0 +1,86 @@ +name: Build gcalendar plug + +on: + push: + tags: + - "gcalendar-v**" + branches: + - "**" + paths: + - "dataplug/**" + - "build.sbt" + - "dataplug-gcalendar/**" + - ".github/workflows/gcalendar.yml" + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Cache - GHA + uses: actions/cache@v1 + with: + path: ~/.cache/coursier/v1/https + key: ${{ runner.OS }}-coursier-cache + + - name: Cache - Resolvers + run: curl https://${{ secrets.ARTIFACTS_CACHE_BUCKET }}/resolvers.sbt --create-dirs -o ~/.sbt/resolvers.sbt + + - name: Setup Java + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 11 + java-package: jdk + architecture: x64 + + - name: Container - Prepare + run: sbt "project dataplug-gcalendar" docker:stage + + - name: Container - Setup QEMU + uses: docker/setup-qemu-action@v1 + + - name: Container - Setup Buildx + uses: docker/setup-buildx-action@v1 + + - name: Container - Meta + id: meta + uses: docker/metadata-action@v3 + with: + images: dataswift/dataplug-gcalendar + tags: | + type=match,prefix=v,pattern=gcalendar-v(\d.\d.\d),group=1 + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/heads/main') }} + type=sha,prefix=main-,format=long,enable=${{ startsWith(github.ref, 'refs/heads/main') }} + type=sha,prefix=dev-,format=long,suffix=-${{ github.run_id }} + + - name: Container - Login DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_DATASWIFT_USER }} + password: ${{ secrets.DOCKERHUB_DATASWIFT_PASS }} + + - name: Container - Build & Push + uses: docker/build-push-action@v2 + with: + push: true + context: dataplug-gcalendar/target/docker/stage/ + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 + cache-from: type=registry,ref=ghcr.io/datasiwft/dataplug-gcalendar:latest + + - name: Slack + uses: lazy-actions/slatify@master + if: failure() + with: + type: ${{ job.status }} + job_name: "*${{ github.workflow }}*" + channel: "ci" + commit: true + mention: "here" + mention_if: "failure" + token: ${{ secrets.GITHUB_TOKEN }} + url: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/google-calendar.yml b/.github/workflows/google-calendar.yml deleted file mode 100644 index fac46da4..00000000 --- a/.github/workflows/google-calendar.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: Build Google Calendar plug - -on: - push: - tags: - - "gcalendar-v**" - branches: - - "**" - paths: - - "build.sbt" - - "dataplug-gcalendar/**" - - ".github/workflows/gcalendar.yml" - -env: - DATAPLUG: dataplug-gcalendar - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Cache - GHA - uses: actions/cache@v1 - with: - path: ~/.cache/coursier/v1/https - key: ${{ runner.OS }}-coursier-cache - - - name: Setup Java - uses: actions/setup-java@v2 - with: - distribution: adopt - java-version: 11 - java-package: jdk - architecture: x64 - - - name: Add extra resolvers - run: curl https://${{ secrets.ARTIFACTS_CACHE_BUCKET }}/resolvers.sbt --create-dirs -o ~/.sbt/resolvers.sbt - - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Container Image Prepare - run: sbt "project $DATAPLUG" docker:stage - - - name: Container Image Build - run: docker build -t hubofallthings/$DATAPLUG:$GITHUB_SHA $DATAPLUG/target/docker/stage/ - - - name: Container Image Push - run: docker push hubofallthings/$DATAPLUG:$GITHUB_SHA - - - name: Extract Branch Name - run: | - echo "BRANCH=$(echo ${GITHUB_REF})" >> $GITHUB_ENV - - - name: Container Image Push - Master - if: contains(env.BRANCH, 'main') - run: | - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:main - docker push hubofallthings/$DATAPLUG:main - - - name: Container Image Push - Tag - if: contains(env.BRANCH, 'tags') - run: | - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:$(echo $GITHUB_REF | sed -e "s/refs\/tags\///g") - docker push hubofallthings/$DATAPLUG:$(echo $GITHUB_REF | sed -e "s/refs\/tags\///g") - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:latest - docker push hubofallthings/$DATAPLUG:latest diff --git a/.github/workflows/instagram.yml b/.github/workflows/instagram.yml index 7159942f..9cc55a70 100644 --- a/.github/workflows/instagram.yml +++ b/.github/workflows/instagram.yml @@ -1,4 +1,4 @@ -name: Build Instagram plug +name: Build instagram plug on: push: @@ -7,13 +7,11 @@ on: branches: - "**" paths: + - "dataplug/**" - "build.sbt" - "dataplug-instagram/**" - ".github/workflows/instagram.yml" -env: - DATAPLUG: dataplug-instagram - jobs: deploy: runs-on: ubuntu-latest @@ -27,6 +25,9 @@ jobs: path: ~/.cache/coursier/v1/https key: ${{ runner.OS }}-coursier-cache + - name: Cache - Resolvers + run: curl https://${{ secrets.ARTIFACTS_CACHE_BUCKET }}/resolvers.sbt --create-dirs -o ~/.sbt/resolvers.sbt + - name: Setup Java uses: actions/setup-java@v2 with: @@ -35,35 +36,51 @@ jobs: java-package: jdk architecture: x64 - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - name: Container - Prepare + run: sbt "project dataplug-instagram" docker:stage - - name: Container Image Prepare - run: sbt "project $DATAPLUG" docker:stage + - name: Container - Setup QEMU + uses: docker/setup-qemu-action@v1 - - name: Container Image Build - run: docker build -t hubofallthings/$DATAPLUG:$GITHUB_SHA $DATAPLUG/target/docker/stage/ + - name: Container - Setup Buildx + uses: docker/setup-buildx-action@v1 - - name: Container Image Push - run: docker push hubofallthings/$DATAPLUG:$GITHUB_SHA + - name: Container - Meta + id: meta + uses: docker/metadata-action@v3 + with: + images: dataswift/dataplug-instagram + tags: | + type=match,prefix=v,pattern=instagram-v(\d.\d.\d),group=1 + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/heads/main') }} + type=sha,prefix=main-,format=long,enable=${{ startsWith(github.ref, 'refs/heads/main') }} + type=sha,prefix=dev-,format=long,suffix=-${{ github.run_id }} - - name: Extract Branch Name - run: | - echo "BRANCH=$(echo ${GITHUB_REF})" >> $GITHUB_ENV + - name: Container - Login DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_DATASWIFT_USER }} + password: ${{ secrets.DOCKERHUB_DATASWIFT_PASS }} - - name: Container Image Push - Master - if: contains(env.BRANCH, 'main') - run: | - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:main - docker push hubofallthings/$DATAPLUG:main + - name: Container - Build & Push + uses: docker/build-push-action@v2 + with: + push: true + context: dataplug-instagram/target/docker/stage/ + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 + cache-from: type=registry,ref=ghcr.io/datasiwft/dataplug-instagram:latest - - name: Container Image Push - Tag - if: contains(env.BRANCH, 'tags') - run: | - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:$(echo $GITHUB_REF | sed -e "s/refs\/tags\///g") - docker push hubofallthings/$DATAPLUG:$(echo $GITHUB_REF | sed -e "s/refs\/tags\///g") - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:latest - docker push hubofallthings/$DATAPLUG:latest + - name: Slack + uses: lazy-actions/slatify@master + if: failure() + with: + type: ${{ job.status }} + job_name: "*${{ github.workflow }}*" + channel: "ci" + commit: true + mention: "here" + mention_if: "failure" + token: ${{ secrets.GITHUB_TOKEN }} + url: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/spotify.yml b/.github/workflows/spotify.yml index e1481326..1341ca44 100644 --- a/.github/workflows/spotify.yml +++ b/.github/workflows/spotify.yml @@ -1,4 +1,4 @@ -name: Build Spotify plug +name: Build spotify plug on: push: @@ -7,13 +7,11 @@ on: branches: - "**" paths: + - "dataplug/**" - "build.sbt" - "dataplug-spotify/**" - ".github/workflows/spotify.yml" -env: - DATAPLUG: dataplug-spotify - jobs: deploy: runs-on: ubuntu-latest @@ -27,6 +25,9 @@ jobs: path: ~/.cache/coursier/v1/https key: ${{ runner.OS }}-coursier-cache + - name: Cache - Resolvers + run: curl https://${{ secrets.ARTIFACTS_CACHE_BUCKET }}/resolvers.sbt --create-dirs -o ~/.sbt/resolvers.sbt + - name: Setup Java uses: actions/setup-java@v2 with: @@ -35,35 +36,51 @@ jobs: java-package: jdk architecture: x64 - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - name: Container - Prepare + run: sbt "project dataplug-spotify" docker:stage - - name: Container Image Prepare - run: sbt "project $DATAPLUG" docker:stage + - name: Container - Setup QEMU + uses: docker/setup-qemu-action@v1 - - name: Container Image Build - run: docker build -t hubofallthings/$DATAPLUG:$GITHUB_SHA $DATAPLUG/target/docker/stage/ + - name: Container - Setup Buildx + uses: docker/setup-buildx-action@v1 - - name: Container Image Push - run: docker push hubofallthings/$DATAPLUG:$GITHUB_SHA + - name: Container - Meta + id: meta + uses: docker/metadata-action@v3 + with: + images: dataswift/dataplug-spotify + tags: | + type=match,prefix=v,pattern=spotify-v(\d.\d.\d),group=1 + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/heads/main') }} + type=sha,prefix=main-,format=long,enable=${{ startsWith(github.ref, 'refs/heads/main') }} + type=sha,prefix=dev-,format=long,suffix=-${{ github.run_id }} - - name: Extract Branch Name - run: | - echo "BRANCH=$(echo ${GITHUB_REF})" >> $GITHUB_ENV + - name: Container - Login DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_DATASWIFT_USER }} + password: ${{ secrets.DOCKERHUB_DATASWIFT_PASS }} - - name: Container Image Push - Master - if: contains(env.BRANCH, 'main') - run: | - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:main - docker push hubofallthings/$DATAPLUG:main + - name: Container - Build & Push + uses: docker/build-push-action@v2 + with: + push: true + context: dataplug-spotify/target/docker/stage/ + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 + cache-from: type=registry,ref=ghcr.io/datasiwft/dataplug-spotify:latest - - name: Container Image Push - Tag - if: contains(env.BRANCH, 'tags') - run: | - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:$(echo $GITHUB_REF | sed -e "s/refs\/tags\///g") - docker push hubofallthings/$DATAPLUG:$(echo $GITHUB_REF | sed -e "s/refs\/tags\///g") - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:latest - docker push hubofallthings/$DATAPLUG:latest + - name: Slack + uses: lazy-actions/slatify@master + if: failure() + with: + type: ${{ job.status }} + job_name: "*${{ github.workflow }}*" + channel: "ci" + commit: true + mention: "here" + mention_if: "failure" + token: ${{ secrets.GITHUB_TOKEN }} + url: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/trivy.yml b/.github/workflows/trivy.yml index 17d6e2c0..c3312617 100644 --- a/.github/workflows/trivy.yml +++ b/.github/workflows/trivy.yml @@ -3,67 +3,30 @@ name: Trivy on: workflow_dispatch: schedule: - - cron: '0 4 * * MON' + - cron: "30 3 * * *" env: - REGISTRY: hubofallthings/dataplug-facebook + IMAGE: dataswift/dataplug-facebook:latest jobs: trivy-scan: name: Trivy Scan runs-on: ubuntu-latest - timeout-minutes: 20 - steps: - - name: Container - Login - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Container - Pull - run: docker pull ${{ env.REGISTRY }}:main - - - name: Container - Scan - create git issue - uses: lazy-actions/gitrivy@v3 - id: trivy - with: - token: ${{ secrets.GITHUB_TOKEN }} - image: ${{ env.REGISTRY }}:main - issue: 'true' - issue_label: trivy, vulnerability, security - issue_title: Trivy Security Alert - - - name: Jira Login - if: steps.trivy.outputs.issue_number != '' - uses: atlassian/gajira-login@master - env: - JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} - JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} - JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} - - - name: Create Jira ticket from Issue - id: jira - if: steps.trivy.outputs.issue_number != '' - uses: atlassian/gajira-create@master - with: - project: ${{ secrets.JIRA_TRIVY_PROJECT }} - issuetype: ${{ secrets.JIRA_TRIVY_ISSUE_TYPE }} - summary: Trivy Security Alert - ${{ github.repository }} - description: ${{steps.trivy.outputs.html_url}} - - - name: Container - Scan - Save Result - if: steps.trivy.outputs.issue_number != '' + timeout-minutes: 10 + steps: + - name: Container - Scan uses: aquasecurity/trivy-action@master with: - image-ref: "${{ env.REGISTRY }}:main" + image-ref: $IMAGE format: "template" + exit-code: 1 + ignore-unfixed: true template: "@/contrib/sarif.tpl" output: "trivy-results.sarif" - severity: "CRITICAL,HIGH" + severity: "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL" - - name: Upload scan results - if: steps.trivy.outputs.issue_number != '' + - name: Container - Scan - Upload results uses: github/codeql-action/upload-sarif@v1 + if: ${{ failure() && github.event_name == 'schedule' && github.ref == 'refs/heads/main' }} with: sarif_file: "trivy-results.sarif" - diff --git a/.github/workflows/twitter.yml b/.github/workflows/twitter.yml index f64e0eb8..26ac4661 100644 --- a/.github/workflows/twitter.yml +++ b/.github/workflows/twitter.yml @@ -1,4 +1,4 @@ -name: Build Twitter plug +name: Build twitter plug on: push: @@ -7,13 +7,11 @@ on: branches: - "**" paths: + - "dataplug/**" - "build.sbt" - "dataplug-twitter/**" - ".github/workflows/twitter.yml" -env: - DATAPLUG: dataplug-twitter - jobs: deploy: runs-on: ubuntu-latest @@ -27,6 +25,9 @@ jobs: path: ~/.cache/coursier/v1/https key: ${{ runner.OS }}-coursier-cache + - name: Cache - Resolvers + run: curl https://${{ secrets.ARTIFACTS_CACHE_BUCKET }}/resolvers.sbt --create-dirs -o ~/.sbt/resolvers.sbt + - name: Setup Java uses: actions/setup-java@v2 with: @@ -35,35 +36,51 @@ jobs: java-package: jdk architecture: x64 - - name: Login to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - name: Container - Prepare + run: sbt "project dataplug-twitter" docker:stage - - name: Container Image Prepare - run: sbt "project $DATAPLUG" docker:stage + - name: Container - Setup QEMU + uses: docker/setup-qemu-action@v1 - - name: Container Image Build - run: docker build -t hubofallthings/$DATAPLUG:$GITHUB_SHA $DATAPLUG/target/docker/stage/ + - name: Container - Setup Buildx + uses: docker/setup-buildx-action@v1 - - name: Container Image Push - run: docker push hubofallthings/$DATAPLUG:$GITHUB_SHA + - name: Container - Meta + id: meta + uses: docker/metadata-action@v3 + with: + images: dataswift/dataplug-twitter + tags: | + type=match,prefix=v,pattern=twitter-v(\d.\d.\d),group=1 + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/heads/main') }} + type=sha,prefix=main-,format=long,enable=${{ startsWith(github.ref, 'refs/heads/main') }} + type=sha,prefix=dev-,format=long,suffix=-${{ github.run_id }} - - name: Extract Branch Name - run: | - echo "BRANCH=$(echo ${GITHUB_REF})" >> $GITHUB_ENV + - name: Container - Login DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_DATASWIFT_USER }} + password: ${{ secrets.DOCKERHUB_DATASWIFT_PASS }} - - name: Container Image Push - Master - if: contains(env.BRANCH, 'main') - run: | - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:main - docker push hubofallthings/$DATAPLUG:main + - name: Container - Build & Push + uses: docker/build-push-action@v2 + with: + push: true + context: dataplug-twitter/target/docker/stage/ + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 + cache-from: type=registry,ref=ghcr.io/datasiwft/dataplug-twitter:latest - - name: Container Image Push - Tag - if: contains(env.BRANCH, 'tags') - run: | - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:$(echo $GITHUB_REF | sed -e "s/refs\/tags\///g") - docker push hubofallthings/$DATAPLUG:$(echo $GITHUB_REF | sed -e "s/refs\/tags\///g") - docker tag hubofallthings/$DATAPLUG:$GITHUB_SHA hubofallthings/$DATAPLUG:latest - docker push hubofallthings/$DATAPLUG:latest + - name: Slack + uses: lazy-actions/slatify@master + if: failure() + with: + type: ${{ job.status }} + job_name: "*${{ github.workflow }}*" + channel: "ci" + commit: true + mention: "here" + mention_if: "failure" + token: ${{ secrets.GITHUB_TOKEN }} + url: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/build.sbt b/build.sbt index 04b86429..5a8ac400 100644 --- a/build.sbt +++ b/build.sbt @@ -19,7 +19,7 @@ lazy val packageSettings = Seq( maintainer in Docker := maintainer.value, version in Docker := version.value, dockerExposedPorts := Seq(9000), - dockerBaseImage := "adoptopenjdk/openjdk11:jre-11.0.10_9-alpine", + dockerBaseImage := "dataswift/base:v0.2.1", dockerEntrypoint := Seq(s"bin/${packageName.value}") ) diff --git a/charts/README.md b/charts/README.md new file mode 100644 index 00000000..dee06fc1 --- /dev/null +++ b/charts/README.md @@ -0,0 +1,14 @@ +# Helm Chart + +The DataPlug solutions are easily deployable on top of Kubernetes. + +## Prerequisites + +- Kubernetes > 1.12 +- Helm > 3.0.0 + +## Using the chart + +``` Bash +helm install -f charts/dataplug/values.yaml dataplug-XXX ./charts/dataplug +``` diff --git a/charts/dataplug/.helmignore b/charts/dataplug/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/dataplug/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/dataplug/Chart.yaml b/charts/dataplug/Chart.yaml new file mode 100644 index 00000000..f28b40fa --- /dev/null +++ b/charts/dataplug/Chart.yaml @@ -0,0 +1,26 @@ +apiVersion: v2 +name: dataplug +description: A Helm chart for DataPlug + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates tdataplug can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.2.2 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "v2.8.0" + +icon: "" diff --git a/charts/dataplug/templates/NOTES.txt b/charts/dataplug/templates/NOTES.txt new file mode 100644 index 00000000..df20d02d --- /dev/null +++ b/charts/dataplug/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "dataplug.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "dataplug.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "dataplug.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "dataplug.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/charts/dataplug/templates/_helpers.tpl b/charts/dataplug/templates/_helpers.tpl new file mode 100644 index 00000000..91d1f7b0 --- /dev/null +++ b/charts/dataplug/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "dataplug.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "dataplug.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "dataplug.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "dataplug.labels" -}} +helm.sh/chart: {{ include "dataplug.chart" . }} +{{ include "dataplug.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "dataplug.selectorLabels" -}} +app.kubernetes.io/name: {{ include "dataplug.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "dataplug.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "dataplug.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/dataplug/templates/configmap.yaml b/charts/dataplug/templates/configmap.yaml new file mode 100644 index 00000000..99fb01db --- /dev/null +++ b/charts/dataplug/templates/configmap.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "dataplug.fullname" . }} + labels: + app.kubernetes.io/component: app + {{- include "dataplug.labels" . | nindent 4 }} +data: + {{- range $key, $val := .Values.env.config }} + {{ $key }}: {{ $val | quote }} + {{- end }} diff --git a/charts/dataplug/templates/deployment.yaml b/charts/dataplug/templates/deployment.yaml new file mode 100644 index 00000000..067e43bb --- /dev/null +++ b/charts/dataplug/templates/deployment.yaml @@ -0,0 +1,71 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "dataplug.fullname" . }} + labels: + app.kubernetes.io/component: app + {{- include "dataplug.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + app.kubernetes.io/component: app + {{- include "dataplug.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + app.kubernetes.io/component: app + {{- include "dataplug.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "dataplug.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ include "dataplug.fullname" . }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + envFrom: + - configMapRef: + name: {{ include "dataplug.fullname" . }} + {{- if .Values.env.secret.enabled }} + - secretRef: + name: {{ .Values.env.secret.name }} + {{- end }} + ports: + - name: http + containerPort: 9000 + protocol: TCP + livenessProbe: + tcpSocket: + port: http + readinessProbe: + tcpSocket: + port: http + initialDelaySeconds: 30 + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/dataplug/templates/hpa.yaml b/charts/dataplug/templates/hpa.yaml new file mode 100644 index 00000000..449b08d8 --- /dev/null +++ b/charts/dataplug/templates/hpa.yaml @@ -0,0 +1,29 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "dataplug.fullname" . }} + labels: + app.kubernetes.io/component: app + {{- include "dataplug.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "dataplug.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/dataplug/templates/ingress.yaml b/charts/dataplug/templates/ingress.yaml new file mode 100644 index 00000000..270c5c32 --- /dev/null +++ b/charts/dataplug/templates/ingress.yaml @@ -0,0 +1,42 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "dataplug.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app.kubernetes.io/component: app + {{- include "dataplug.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} diff --git a/charts/dataplug/templates/prometheusrules.yaml b/charts/dataplug/templates/prometheusrules.yaml new file mode 100644 index 00000000..acedc6e1 --- /dev/null +++ b/charts/dataplug/templates/prometheusrules.yaml @@ -0,0 +1,23 @@ +{{- if and .Values.metrics.enabled .Values.metrics.prometheusRule.enabled -}} +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: {{ include "dataplug.fullname" . }} +{{- if .Values.metrics.prometheusRule.namespace }} + namespace: {{ .Values.metrics.prometheusRule.namespace | quote }} +{{- else }} + namespace: {{ .Release.Namespace | quote }} +{{- end }} + labels: + app.kubernetes.io/component: metrics + {{- include "dataplug.labels" . | nindent 4 }} + {{- if .Values.metrics.prometheusRule.additionalLabels }} + {{- toYaml .Values.metrics.prometheusRule.additionalLabels | nindent 4 }} + {{- end }} +spec: +{{- if .Values.metrics.prometheusRule.rules }} + groups: + - name: {{ include "dataplug.fullname" . }} + rules: {{- toYaml .Values.metrics.prometheusRule.rules | nindent 4 }} +{{- end }} +{{- end }} diff --git a/charts/dataplug/templates/service-metrics.yaml b/charts/dataplug/templates/service-metrics.yaml new file mode 100644 index 00000000..84b42d2a --- /dev/null +++ b/charts/dataplug/templates/service-metrics.yaml @@ -0,0 +1,24 @@ +{{- if .Values.metrics.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "dataplug.fullname" . }}-metrics + namespace: {{ .Release.Namespace | quote }} + labels: + app.kubernetes.io/component: metrics + {{- include "dataplug.labels" . | nindent 4 }} + {{- with .Values.metrics.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: {{ .Values.metrics.service.type }} + ports: + - port: {{ .Values.metrics.service.port }} + targetPort: http + protocol: TCP + name: metrics + selector: + app.kubernetes.io/component: app + {{- include "dataplug.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/charts/dataplug/templates/service.yaml b/charts/dataplug/templates/service.yaml new file mode 100644 index 00000000..78fb15cf --- /dev/null +++ b/charts/dataplug/templates/service.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "dataplug.fullname" . }} + labels: + app.kubernetes.io/component: app + {{- include "dataplug.labels" . | nindent 4 }} + {{- with .Values.metrics.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + app.kubernetes.io/component: app + {{- include "dataplug.selectorLabels" . | nindent 4 }} diff --git a/charts/dataplug/templates/serviceaccount.yaml b/charts/dataplug/templates/serviceaccount.yaml new file mode 100644 index 00000000..dd768560 --- /dev/null +++ b/charts/dataplug/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "dataplug.serviceAccountName" . }} + labels: + app.kubernetes.io/component: app + {{- include "dataplug.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/dataplug/templates/servicemonitor.yaml b/charts/dataplug/templates/servicemonitor.yaml new file mode 100644 index 00000000..343dc1f7 --- /dev/null +++ b/charts/dataplug/templates/servicemonitor.yaml @@ -0,0 +1,46 @@ +{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled -}} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "dataplug.fullname" . }} +{{- if .Values.metrics.serviceMonitor.namespace }} + namespace: {{ .Values.metrics.serviceMonitor.namespace | quote }} +{{- else }} + namespace: {{ .Release.Namespace | quote }} +{{- end }} + labels: + {{- include "dataplug.labels" . | nindent 4 }} + {{- if .Values.metrics.serviceMonitor.additionalLabels }} + {{- toYaml .Values.metrics.serviceMonitor.additionalLabels | nindent 4 }} + {{- end }} +spec: + endpoints: + - port: metrics + interval: {{ .Values.metrics.serviceMonitor.scrapeInterval }} + {{- if .Values.metrics.serviceMonitor.honorLabels }} + honorLabels: true + {{- end }} + {{- if .Values.metrics.serviceMonitor.metricRelabelings }} + metricRelabelings: {{ toYaml .Values.metrics.serviceMonitor.metricRelabelings | nindent 8 }} + {{- end }} +{{- if .Values.metrics.serviceMonitor.jobLabel }} + jobLabel: {{ .Values.metrics.serviceMonitor.jobLabel | quote }} +{{- end }} +{{- if .Values.metrics.serviceMonitor.namespaceSelector }} + namespaceSelector: {{ toYaml .Values.metrics.serviceMonitor.namespaceSelector | nindent 4 }} +{{ else }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} +{{- end }} +{{- if .Values.metrics.serviceMonitor.targetLabels }} + targetLabels: + {{- range .Values.metrics.serviceMonitor.targetLabels }} + - {{ . }} + {{- end }} +{{- end }} + selector: + matchLabels: + app.kubernetes.io/component: metrics + {{- include "dataplug.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/charts/dataplug/templates/tests/test-connection.yaml b/charts/dataplug/templates/tests/test-connection.yaml new file mode 100644 index 00000000..79ee8a7f --- /dev/null +++ b/charts/dataplug/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "dataplug.fullname" . }}-test-connection" + labels: + {{- include "dataplug.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "dataplug.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/dataplug/values.yaml b/charts/dataplug/values.yaml new file mode 100644 index 00000000..e19d4553 --- /dev/null +++ b/charts/dataplug/values.yaml @@ -0,0 +1,157 @@ +# Default values for dataplug. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: dataswift/dataplug + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + # tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +env: + config: [] + secret: + enabled: false + name: "" + +service: + enabled: true + annotations: {} + type: ClusterIP + port: 9000 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: {} + # - host: chart-example.local + # paths: + # - path: / + # backend: + # serviceName: chart-example.local + # servicePort: 80 + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +metrics: + enabled: true + + service: + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "9000" + + type: ClusterIP + port: 9000 + + serviceMonitor: + enabled: true + additionalLabels: {} + # The label to use to retrieve the job name from. + # jobLabel: "app.kubernetes.io/name" + namespace: "" + namespaceSelector: {} + # Default: scrape .Release.Namespace only + # To scrape all, use the following: + # namespaceSelector: + # any: true + scrapeInterval: 30s + # honorLabels: true + targetLabels: [] + metricRelabelings: [] + + prometheusRule: + enabled: false + additionalLabels: {} + # namespace: "" + rules: [] + # # These are just examples rules, please adapt them to your needs + # - alert: NGINXConfigFailed + # expr: count(nginx_ingress_controller_config_last_reload_successful == 0) > 0 + # for: 1s + # labels: + # severity: critical + # annotations: + # description: bad ingress config - nginx config test failed + # summary: uninstall the latest ingress changes to allow config reloads to resume + # - alert: NGINXCertificateExpiry + # expr: (avg(nginx_ingress_controller_ssl_expire_time_seconds) by (host) - time()) < 604800 + # for: 1s + # labels: + # severity: critical + # annotations: + # description: ssl certificate(s) will expire in less then a week + # summary: renew expiring certificates to avoid downtime + # - alert: NGINXTooMany500s + # expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"5.+"} ) / sum(nginx_ingress_controller_requests) ) > 5 + # for: 1m + # labels: + # severity: warning + # annotations: + # description: Too many 5XXs + # summary: More than 5% of all requests returned 5XX, this requires your attention + # - alert: NGINXTooMany400s + # expr: 100 * ( sum( nginx_ingress_controller_requests{status=~"4.+"} ) / sum(nginx_ingress_controller_requests) ) > 5 + # for: 1m + # labels: + # severity: warning + # annotations: + # description: Too many 4XXs + # summary: More than 5% of all requests returned 4XX, this requires your attention + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/dataplug/app/com/hubofallthings/dataplug/modules/AwsSesModule.scala b/dataplug/app/com/hubofallthings/dataplug/modules/AwsSesModule.scala index c7202ff6..f02e103c 100644 --- a/dataplug/app/com/hubofallthings/dataplug/modules/AwsSesModule.scala +++ b/dataplug/app/com/hubofallthings/dataplug/modules/AwsSesModule.scala @@ -1,12 +1,10 @@ package com.hubofallthings.dataplug.modules -import com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper -import com.amazonaws.services.simpleemail.{AmazonSimpleEmailService, AmazonSimpleEmailServiceClientBuilder} +import com.amazonaws.services.simpleemail.{ AmazonSimpleEmailService, AmazonSimpleEmailServiceClientBuilder } import com.google.inject.Provides import net.codingwell.scalaguice.ScalaModule -import play.api.Configuration -import javax.inject.{Singleton => JSingleton} +import javax.inject.{ Singleton => JSingleton } class AwsSesModule extends ScalaModule { @@ -14,11 +12,6 @@ class AwsSesModule extends ScalaModule { @Provides @JSingleton - def provideAwsEmailService(config: Configuration): AmazonSimpleEmailService = - AmazonSimpleEmailServiceClientBuilder - .standard() - .withRegion(config.get[String]("mailer.awsRegion")) - .withCredentials(new EC2ContainerCredentialsProviderWrapper) - .build() + def provideAwsEmailService: AmazonSimpleEmailService = AmazonSimpleEmailServiceClientBuilder.defaultClient() }