-
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.
- Loading branch information
0 parents
commit e60f998
Showing
21 changed files
with
992 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/mvnw text eol=lf | ||
*.cmd text eol=crlf |
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,119 @@ | ||
name: Test on PR | ||
|
||
on: | ||
# For demo purposes only | ||
workflow_dispatch: | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
DOCKER_BUILD_RECORD_RETENTION_DAYS: 1 | ||
VCLUSTER_VERSION: v0.21.2 | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
id-token: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Log into registry ${{ env.REGISTRY }} | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=raw,value=${{github.run_id}} | ||
- name: Build and push Docker image | ||
id: build-and-push | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
push: true | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
- name: Install kustomize | ||
run: | | ||
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash | ||
sudo mv kustomize /usr/local/bin | ||
- name: Edit image tag with GitHub Run ID | ||
run: (cd kubernetes && kustomize edit set image ghcr.io/ajavageek/vcluster-pipeline=:${{github.run_id}}) | ||
- name: Authenticate on Google Cloud | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
workload_identity_provider: projects/49535911505/locations/global/workloadIdentityPools/github-actions/providers/github-provider | ||
service_account: [email protected] | ||
- name: Set up Google Cloud CLI | ||
uses: google-github-actions/setup-gcloud@v2 | ||
with: | ||
version: latest | ||
- name: Set GKE credentials | ||
uses: google-github-actions/get-gke-credentials@v2 | ||
with: | ||
cluster_name: minimal-cluster | ||
location: europe-west9 | ||
- name: Install vCluster | ||
run: wget -O vcluster "https://github.com/loft-sh/vcluster/releases/download/${{ env.VCLUSTER_VERSION }}/vcluster-linux-amd64" && chmod u+x vcluster && mv vcluster /usr/local/bin | ||
- name: Create a vCluster | ||
run: vcluster create vcluster-pipeline-${{github.run_id}} && exit 0 | ||
- name: Connect to the vCluster | ||
run: vcluster connect vcluster-pipeline-${{github.run_id}} | ||
- name: Schedule PostgreSQL | ||
run: | | ||
helm repo add bitnami https://charts.bitnami.com/bitnami | ||
helm dependency build kubernetes/helm | ||
helm install postgresql kubernetes/helm | ||
- name: Set environment variables from values.yaml | ||
run: | | ||
echo "PG_HOST=$(yq .postgresql.fullnameOverride kubernetes/values.yaml)" >> $GITHUB_ENV | ||
echo "PG_USER=$(yq .postgresql.auth.user kubernetes/values.yaml)" >> $GITHUB_ENV | ||
echo "PG_PASSWORD=$(yq .postgresql.auth.password kubernetes/values.yaml)" >> $GITHUB_ENV | ||
- name: Set config map from values.yaml | ||
run: | | ||
kubectl create configmap postgres-config \ | ||
--from-literal="SPRING_FLYWAY_URL=jdbc:postgresql://${{ env.PG_HOST }}:5432/" \ | ||
--from-literal="SPRING_R2DBC_URL=r2dbc:postgresql://${{ env.PG_HOST }}:5432/" \ | ||
--from-literal="SPRING_R2DBC_USERNAME=${{ env.PG_USER }}" \ | ||
--from-literal="SPRING_R2DBC_PASSWORD=${{ env.PG_PASSWORD }}" | ||
- name: Create Docker Registry Secret | ||
run: | | ||
kubectl create secret docker-registry github-docker-registry \ | ||
--docker-server=${{ env.REGISTRY }} --docker-email="[email protected]" \ | ||
--docker-username="${GITHUB_USERNAME}" --docker-password="${GITHUB_TOKEN}" \ | ||
--dry-run=client -o yaml | kubectl apply -f - | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_USERNAME: ${{ github.actor }} | ||
- name: Wait for PostgreSQL to be ready | ||
run: kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=postgresql --timeout=300s | ||
- name: Deploy Kustomized manifest to Google Cloud | ||
run: | | ||
kustomize build kubernetes > manifest.yml | ||
kubectl apply -f manifest.yml | ||
- name: Install JRE | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 21 | ||
- name: Run the tests | ||
run: > | ||
./mvnw -Dspring.r2dbc.username=${{ env.PG_PASSWORD }} \ | ||
-Dspring.r2dbc.password=${{ env.PG_PASSWORD }} \ | ||
-Dspring.r2dbc.url=jdbc:postgresql://${{ env.PG_HOST }}:5432/ test | ||
- name: Delete the vCluster | ||
run: vcluster delete vcluster-pipeline-${{github.run_id}} |
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,33 @@ | ||
HELP.md | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ |
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,19 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
wrapperVersion=3.3.2 | ||
distributionType=only-script | ||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip |
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,17 @@ | ||
#docker build -t vcluster-pipeline:1.0 . | ||
FROM eclipse-temurin:21-jdk-jammy AS build | ||
|
||
COPY .mvn .mvn | ||
COPY mvnw . | ||
COPY pom.xml . | ||
COPY src src | ||
|
||
RUN --mount=type=cache,target=/root/.m2,rw ./mvnw package -DskipTests | ||
|
||
FROM eclipse-temurin:21-jre-jammy | ||
|
||
COPY --from=build target/vcluster-pipeline-1.0.jar vcluster-pipeline.jar | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["java", "-jar", "vcluster-pipeline.jar"] |
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,21 @@ | ||
apiVersion: v2 | ||
name: vcluster-pipeline-infra | ||
description: Infrastructure for vCluster Pipeline | ||
|
||
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: 1.0.0 | ||
|
||
# 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: "1.0.0" | ||
|
||
dependencies: | ||
- name: postgresql | ||
version: "16.2.1" | ||
repository: https://charts.bitnami.com/bitnami |
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,7 @@ | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
resources: | ||
- vcluster-pipeline.yaml | ||
images: | ||
- name: ghcr.io/ajavageek/vcluster-pipeline | ||
newTag: github.run_id |
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,9 @@ | ||
postgresql: | ||
fullnameOverride: postgres | ||
auth: | ||
user: postgres | ||
password: root | ||
postgresPassword: roottoo | ||
primary: | ||
persistence: | ||
enabled: false |
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,37 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: vcluster-pipeline | ||
labels: | ||
type: app | ||
app: vcluster-pipeline | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: vcluster-pipeline | ||
template: | ||
metadata: | ||
labels: | ||
type: app | ||
app: vcluster-pipeline | ||
spec: | ||
containers: | ||
- name: vcluster-pipeline | ||
image: ghcr.io/ajavageek/vcluster-pipeline:latest | ||
envFrom: | ||
- configMapRef: | ||
name: postgres-config | ||
imagePullSecrets: | ||
- name: github-docker-registry | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: vcluster-pipeline | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- port: 8080 | ||
selector: | ||
app: vcluster-pipeline |
Oops, something went wrong.