Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
basic-python-rest-api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Prajwal Amin
basic-python-rest-api
Commits
c8730808
Commit
c8730808
authored
8 months ago
by
Deeksha M
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit by Containerization
parent
ddef6621
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Jenkinsfile
+72
-0
72 additions, 0 deletions
Jenkinsfile
k8/deployment.yaml
+19
-0
19 additions, 0 deletions
k8/deployment.yaml
k8/service.yaml
+11
-0
11 additions, 0 deletions
k8/service.yaml
with
102 additions
and
0 deletions
Jenkinsfile
0 → 100644
+
72
−
0
View file @
c8730808
pipeline
{
agent
any
environment
{
PROJECT_ID
=
"tech-rnd-project"
CLUSTER_NAME
=
"cluster"
LOCATION
=
"us-central1-a"
CREDENTIALS_ID
=
"kubernetes"
MASTER_SERVICE_ACCOUNT_EMAIL
=
"example@tech-rnd-project.iam.gserviceaccount.com"
}
stages
{
stage
(
'Scm Checkout'
)
{
steps
{
checkout
scm
}
}
stage
(
'Build Docker Image'
)
{
steps
{
sh
'whoami'
sh
'sudo chmod 777 /var/run/docker.sock'
sh
'sudo apt update'
sh
'sudo apt install software-properties-common'
sh
'sudo add-apt-repository ppa:cncf-buildpacks/pack-cli'
sh
'sudo apt-get update'
sh
'sudo apt-get install pack-cli'
sh
'pack build java-postgress --builder gcr.io/buildpacks/google-22/builder@sha256:ffa092c09ffb147b2ce9658eb6590aa9af2caffb2d513ab8546bb510b74e0225'
}
}
stage
(
'Push Docker Image'
)
{
steps
{
script
{
echo
'Push Docker Image'
sh
'gcloud config set auth/impersonate_service_account ${MASTER_SERVICE_ACCOUNT_EMAIL}'
sh
'docker tag java-postgress us-central1-docker.pkg.dev/tech-rnd-project/container-node/nodejs'
sh
'gcloud auth configure-docker us-central1-docker.pkg.dev'
sh
'docker push us-central1-docker.pkg.dev/tech-rnd-project/container-node/nodejs'
}
}
}
stage
(
'Deploy to K8'
)
{
steps
{
script
{
sh
"gcloud config set project tech-rnd-project"
sh
"gcloud container clusters get-credentials cluster --zone us-central1-a"
sh
'kubectl apply -f k8/deployment.yaml'
sh
'kubectl apply -f k8/service.yaml'
}
}
}
}
post
{
always
{
emailext
to:
'email_id'
,
subject:
"jenkins build:${currentBuild.currentResult}: ${env.JOB_NAME}"
,
body:
"${currentBuild.currentResult}: Job ${env.JOB_NAME}\nMore Info can be found in the attached log"
,
attachLog:
true
}
}
}
This diff is collapsed.
Click to expand it.
k8/deployment.yaml
0 → 100644
+
19
−
0
View file @
c8730808
apiVersion
:
apps/v1
kind
:
Deployment
metadata
:
name
:
test
spec
:
replicas
:
1
selector
:
matchLabels
:
app
:
test
template
:
metadata
:
labels
:
app
:
test
spec
:
containers
:
-
name
:
test
image
:
us-central1-docker.pkg.dev/tech-rnd-project/container-node/nodejs
ports
:
-
containerPort
:
8080
This diff is collapsed.
Click to expand it.
k8/service.yaml
0 → 100644
+
11
−
0
View file @
c8730808
apiVersion
:
v1
kind
:
Service
metadata
:
name
:
test
spec
:
ports
:
-
port
:
8080
targetPort
:
8080
type
:
LoadBalancer
selector
:
app
:
test
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment