Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f203236
Add dockerfile and jenkinsfile for department service
BryanDollery Aug 23, 2020
c6b9abf
add volume try 1
BryanDollery Aug 23, 2020
fed40b3
trying again
BryanDollery Aug 23, 2020
1f23ed2
change name of docker socket volume
BryanDollery Aug 23, 2020
59a17c3
first attempt at deployment
BryanDollery Aug 23, 2020
e2ae2c0
2nd attempt at deployment
BryanDollery Aug 23, 2020
22100c4
added service account
BryanDollery Aug 23, 2020
4dbe49f
debugging
BryanDollery Aug 23, 2020
1e17420
try without a type
BryanDollery Aug 23, 2020
4dbea48
experimental debugging
BryanDollery Aug 24, 2020
a89b52e
trying the token
BryanDollery Aug 24, 2020
5004b29
debugging
BryanDollery Aug 24, 2020
0d1fbbc
debugging more
BryanDollery Aug 24, 2020
60ee449
trying token again
BryanDollery Aug 24, 2020
7ae21d6
fix typo
BryanDollery Aug 24, 2020
28a5975
working
BryanDollery Aug 24, 2020
7a8eafb
adding deployment and service
BryanDollery Aug 24, 2020
8883741
changed var to token
BryanDollery Aug 24, 2020
b591936
changed dir
BryanDollery Aug 24, 2020
a7f20eb
fixed typo in deploy.yaml
BryanDollery Aug 24, 2020
4df88ea
moving to jenkins namespace
BryanDollery Aug 24, 2020
ba7c56a
debugging
BryanDollery Aug 24, 2020
e43c89b
trying a new token
BryanDollery Aug 24, 2020
dc5d99e
update debugger
BryanDollery Aug 24, 2020
17c3e33
debugging
BryanDollery Aug 24, 2020
8a48e7b
experimenting
BryanDollery Aug 24, 2020
a16a5c9
trying a different url
BryanDollery Aug 24, 2020
9762f51
fix typo in namespace
BryanDollery Aug 24, 2020
0d16ca7
simplifying
BryanDollery Aug 24, 2020
383c777
testing
BryanDollery Aug 24, 2020
6de6a8e
trying jenkins namespace and a new token
BryanDollery Aug 24, 2020
f0c1b92
fix typo
BryanDollery Aug 24, 2020
530a1a2
trying k8s token
BryanDollery Aug 24, 2020
041a048
fix typos
BryanDollery Aug 24, 2020
7104d42
simplified
BryanDollery Aug 24, 2020
e9509dd
trying tester token again
BryanDollery Aug 24, 2020
f0d6355
fix typo
BryanDollery Aug 24, 2020
f4728e0
Update Jenkinsfile
walaafahad1994 Aug 25, 2020
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
10 changes: 10 additions & 0 deletions department-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from node as build
copy index.js /src/
copy package* /src/
run cd /src && \
npm install
from node
copy --from=build /src/node_modules /dist/node_modules/
copy index.js /dist/
workdir /dist
cmd ["node", "index.js"]
75 changes: 75 additions & 0 deletions department-service/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
pipeline {
agent {
kubernetes {
yaml """
apiVersion: v1
kind: Pod
metadata:
labels:
service_name: department-service
service_type: REST
spec:
containers:
- name: dnd
image: docker:latest
command:
- cat
tty: true
volumeMounts:
- mountPath: /var/run/docker.sock
name: docker-sock
- name: kubectl
image: bryandollery/terraform-packer-aws-alpine
command:
- cat
tty: true
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
type: Socket
"""
}
}
environment {
CREDS = credentials('bryan_docker_creds')
DOCKER_NAMESPACE = 'bryandollery'
SERVICE_NAME = 'department-service'
TOKEN=credentials('tester_token')
}
stages {
stage("Build") {
steps {
container('dnd') {
sh '''
cd $SERVICE_NAME
docker build --tag $DOCKER_NAMESPACE/$SERVICE_NAME .
'''
}
}
}
stage("Release") {
steps {
container('dnd') {
sh '''
docker login -p $CREDS_PSW -u $CREDS_USR
docker push $DOCKER_NAMESPACE/$SERVICE_NAME
'''
}
}
}
stage("Deploy") {
steps {
container('kubectl') {
sh '''
cd $SERVICE_NAME
kubectl --token=$TOKEN -n test get all
kubectl --token=$TOKEN -n test apply -f deploy.yaml -f service.yaml
kubectl --token=$TOKEN -n test get all

'''
}
}
}
}
}
9 changes: 6 additions & 3 deletions department-service/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
build:
docker build --tag department-service .build
run:
docker run -it --rm -p 8082:80 department-service
docker build --tag $$DOCKER_NAMESPACE/$$SERVICE_NAME .

release:
docker login -p $$CREDS_PSW -u $$CREDS_USR
docker push $$DOCKER_NAMESPACE/SERVICE_NAME

22 changes: 22 additions & 0 deletions department-service/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: department-service
labels:
app: department-service
type: api
spec:
replicas: 1
selector:
matchLabels:
app: department-service
template:
metadata:
labels:
app: department-service
spec:
containers:
- name: department-service
image: bryandollery/department-service
ports:
- containerPort: 80
5 changes: 3 additions & 2 deletions department-service/readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
## A nodejs REST service to return departments
### Simple API to provide a service for the DevOps Bootcamp

Designed to run in a node:lts-alpine3.10 container
Designed to run in a node container

Exposes an http service endpoint on port 80 with the /department/ context path

eg

http://{host}/department/
http://{host}/department/
11 changes: 11 additions & 0 deletions department-service/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: department-service
spec:
type: NodePort
selector:
app: department-service
ports:
- port: 80
targetPort: 80
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ Once the builds are successful, the same pipeline can deploy the app to kubernet
Each of the 5 services needs a separate deployment and service object definition.
Your services should expose NodePorts so that they can be accessed from your browser.
The complexity here is that you need to have known port for each service otherwise you will not be able to access it from the UI.
Remember, the calls to the separate REST services are made from the browser, not from the UI service.
Remember, the calls to the separate REST services are made from the browser, not from the UI service.
There is no inter-service chatter.