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

pipeline-1 #181

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
96 changes: 87 additions & 9 deletions .github/workflows/continuous-integration-build.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,91 @@
name: CI Build
name: gs-spring-boot-suriya #suriya-main

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
push:
branches:
-main

jobs:
build:
uses: spring-guides/getting-started-macros/.github/workflows/build_initial_complete_maven_gradle.yml@main
deploy-gs-spring-boot-suriya:
runs-on: ubuntu-latest
steps:
- name: "checkout to branch"
uses: actions/checkout@v4

- name: "setting up java 17"
uses: actions/checkout@v4
with:
distribution: "Spring Boot"
java-version: "17"

- name: "set up Maven"
uses: actions/setup-java@v4
with:
maven-version: 4.0.0

- name: "build jar with maven"
run: |
#!/bin/bash

mvn package --file pom.xml
shell: bash

- name: "Building docker image"
run: |
#!/bin/bash

docker build -t spring-boot .
shell: bash

- name: "Setup GCP SDK"
uses: google-github-actions/setup-gcloud@v2

- name: "Configure Service Account"
uses: google-github-actions/auth@v2
with:
credentials_json: "${{ secrets.SERVICE_ACCOUNT_CREDS }}"

- name: "Configure k8 component"
run: |
#!/bin/bash

gcloud components install kubectl gke-gcloud-auth-plugin

gcloud config set project prefab-icon-441814-j7

gcloud config set compute/region us-central1

gcloud container clusters get-credentials surya-gke-cluster --region=us-central1

kubectl version --client
shell: bash

- name: "Setting up Docker Credentials"
run: |
#!/bin/bash

gcloud auth configure-docker us-central1-docker.pkg.dev
shell: bash

- name: "Upload image to gcp artifacts"
run: |
#!/bin/bash

docker tag spring-boot:latest us-central1-docker.pkg.dev/prefab-icon-441814-j7/surya-artifact/spring-boot:latest

docker push us-central1-docker.pkg.dev/prefab-icon-441814-j7/surya-artifact/spring-boot:latest

- name: "Create spring-boot stream deployment"
run: |
#!/bin/bash

kubectl apply -f deployment.yml --validate=false
kubectl rollout restart deployment

shell: bash
working-directory: deployment-k8




8 changes: 8 additions & 0 deletions Docker file
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Use an official openjdk image to run your application
FROM openjdk:17-jdk-slim

# Copy the JAR file from the current directory to the container
COPY target/myapp.jar /app.jar

# Set the command to run the application
ENTRYPOINT ["java", "-jar", "/app.jar"]
71 changes: 71 additions & 0 deletions deployment-k8/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: springboot-deployment
namespace: surya-namespace
spec:
replicas: 15
revisionHistoryLimit: 5
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
selector:
matchLabels:
run: springboot-deployment
template:
metadata:
labels:
run: springboot-deployment
spec:
containers:
- name: springboot-deployment
image: us-central1-docker.pkg.dev/prefab-icon-441814-j7/surya-artifact/spring-boot:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
protocol: TCP
env:
- name: APP_NAME
value: surya-gcp-streams
- name: ENV_PROFILE
value: TEST
resources:
limits:
cpu: 600m
memory: 2Gi
requests:
cpu: 90m
memory: 1Gi
livenessProbe:
exec:
command:
- /bin/true
initial Delay Seconds: 120
periodSeconds: 30
successThreshold: 1
failureThreshold: 5
timeoutSeconds: 30
readinessProbe:
exec:
command:
- /bin/true
initialDelaySeconds: 120
periodSeconds: 30
successThreshold: 1
failureThreshold: 5
timeoutSeconds: 30
securityContext:
runAsUser: 1005
capabilities:
drop:
- KILL
- MKNOD
- SYS_CHROOT
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
schedulerName: default-scheduler