Skip to content

Commit d4b506a

Browse files
committed
Merge branch 'kenzanlabs-master'
2 parents e969f3a + 262dc20 commit d4b506a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1592
-506
lines changed

README.md

+230-98
Large diffs are not rendered by default.

applications/crossword/README.md

-34
This file was deleted.

applications/crossword/bash.sh

-12
This file was deleted.

applications/crossword/build.sh

-10
This file was deleted.

applications/kr8sswordz-pages/Dockerfile

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ RUN mkdir -p /usr/src/app
55
WORKDIR /usr/src/app
66

77
# Install app dependencies
8-
COPY package.json /usr/src/app/
9-
COPY gulpfile.js /usr/src/app/
8+
COPY package.json gulpfile.js yarn.lock /usr/src/app/
109

11-
RUN npm install
10+
RUN yarn --pure-lockfile
1211

1312
# Bundle app source
1413
COPY . /usr/src/app
+7-23
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
11
## Kr8ssword Puzzle Kubernetes CI / CD , Microservices Example
2-
## NOTE: For full functionality please ensure the part2/server setup has been completed.
32

43
# setup
5-
Go through part1. Ensure that:
6-
- europa is up and running
4+
From the root directory of the repository, use 'npm run part1' to setup the minikube cluster.
75

8-
### Update k8s/deployment.yaml to replace MINIKUBEIP with your minikube ip
9-
host: kr8sswordz.MINIKUBEIP.xip.io
10-
11-
## Manual steps to build and deploy
12-
### Build and Push to Europa
13-
docker build -t `minikube ip`:30912/kr8sswordz:1.0.0 .
14-
docker push `minikube ip`:30912/kr8sswordz:1.0.0
15-
16-
### Make europa Repo public
17-
Note: Replace MINIKUBEIP with your minikube ip
18-
19-
1) Go to http://europa.MINIKUBEIP.xip.io/repositories/kr8sswordz
20-
2) Go to repository settings
21-
3) Select Public
22-
23-
### Deploy to kubernetes
24-
kubectl apply -f k8s/deployment.yaml
25-
26-
## Automated script
27-
./build.sh
6+
### Building
7+
Use or review <root>/scripts/kr8sswordz-pages.sh for build/deployment steps
288

299
## Load application
10+
Run 'minikube service kr8sswordz'
11+
12+
or
13+
3014
Change MINIKUBEIP to your minikube ip and load the application below
3115

3216
http://kr8sswordz.MINIKUBEIP.xip.io/

applications/kr8sswordz-pages/build.sh

-5
This file was deleted.

applications/kr8sswordz-pages/src/actions/puzzleActions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as actions from './actionTypes';
22
import constants from '../constants';
3-
const baseUrl = `http://services.kr8sswordz.${constants.minikubeIp}.xip.io/puzzle/v1`;
3+
const baseUrl = `http://puzzle.${constants.minikubeIp}.xip.io/puzzle/v1`;
44
const arrowDisplayTime = 1000;
55

66
export function getPuzzleDataSuccess (json) {

applications/monitor/Dockerfile renamed to applications/monitor-scale/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
FROM node:7
1+
FROM node:boron
22

33
# Create app directory
44
RUN mkdir -p /usr/src/app
55
WORKDIR /usr/src/app
66

77
# Install app dependencies
8-
COPY package.json /usr/src/app/
8+
COPY package.json yarn.lock /usr/src/app/
99

10-
RUN npm install
10+
RUN yarn --pure-lockfile
1111

1212
# Bundle app source
1313
COPY . /usr/src/app

applications/monitor/Jenkinsfile renamed to applications/monitor-scale/Jenkinsfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ node {
1414

1515
stage "Build"
1616

17-
sh "docker build -t ${imageName} applications/monitor"
17+
sh "docker build -t ${imageName} applications/monitor-scale"
1818

1919
stage "Push"
2020

2121
sh "docker push ${imageName}"
2222

2323
stage "Deploy"
2424

25-
sh "sed 's#127.0.0.1:30400/monitor-scale:latest#'$BUILDIMG'#' applications/monitor/k8s/monitor-scale.yaml | kubectl apply -f -"
25+
sh "sed 's#127.0.0.1:30400/monitor-scale:latest#'$BUILDIMG'#' applications/monitor-scale/k8s/deployment.yaml | kubectl apply -f -"
2626
}

applications/monitor-scale/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== monitor-scale server ===
2+
This appication provides an API to track when servers go up and down, caching that data and sending the list of crossword servers to the frontend using websockets. Additionally, this API provides an endpoint to scale the crossword deployment.
3+
4+
## Kr8sswordz Monitor-Scale Kubernetes CI / CD , Microservices Example
5+
6+
# setup
7+
From the root directory of the repository, use 'npm run part1' to setup the minikube cluster.
8+
9+
### Building
10+
Use or review <root>/scripts/monitor-scale.sh for build/deployment steps

applications/monitor/index.js renamed to applications/monitor-scale/index.js

+17-13
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ app.use(express.static('public'))
1313

1414
var bodyParser = require("body-parser");
1515

16-
//var servicesHost = process.env.SERVICES_SERVICE_HOST;
17-
//var servicesPort = process.env.SERVICES_SERVICE_PORT;
18-
1916
app.use(bodyParser.urlencoded({ extended: false }));
2017
app.use(bodyParser.json());
2118
app.use(cors());
@@ -33,12 +30,12 @@ watcher.on("change", function(val) {
3330
app.post('/scale', function (req, res) {
3431
var scale = req.body.count;
3532
console.log('Count requested is: %s', scale);
36-
var url = "http://127.0.0.1:2345/apis/extensions/v1beta1/namespaces/default/deployments/services/scale";
33+
var url = "http://127.0.0.1:2345/apis/extensions/v1beta1/namespaces/default/deployments/puzzle/scale";
3734
var putBody = {
3835
kind:"Scale",
3936
apiVersion:"extensions/v1beta1",
4037
metadata: {
41-
name:"services",
38+
name:"puzzle",
4239
namespace:"default"
4340
},
4441
spec: {
@@ -61,7 +58,7 @@ app.post('/loadtest/concurrent', function (req, res) {
6158

6259
var count = req.body.count;
6360
console.log('Count requested is: %s', count);
64-
var url = "http://services:3000/puzzle/v1/crossword";
61+
var url = "http://puzzle:3000/puzzle/v1/crossword";
6562
var myUrls = [];
6663
for (var i = 0; i < req.body.count; i++) {
6764
myUrls.push(url);
@@ -83,16 +80,23 @@ app.post('/loadtest/concurrent', function (req, res) {
8380
app.post('/loadtest/consecutive', function (req, res) {
8481

8582
var count = req.body.count;
86-
var url = "http://services:3000/puzzle/v1/crossword";
83+
var url = "http://puzzle:3000/puzzle/v1/crossword";
84+
var callArray = [];
85+
8786
for (var i = 0; i < req.body.count; i++) {
88-
request(url, function(error, response, html) {
89-
if (response && response.hasOwnProperty("statusCode")) {
90-
console.log(response.statusCode);
91-
} else {
92-
console.log("Error:" + error);
93-
}
87+
88+
callArray.push(function (cb) {
89+
setTimeout(function () {
90+
request(url, function(error, response, html) {
91+
cb(null, response && response.statusCode);
92+
});
93+
}, 100);
9494
});
9595
}
96+
async.series(callArray, function (err, results) {
97+
var finalCount = results && results.length;
98+
console.log(`${finalCount} requests sent.`)
99+
});
96100
res.send('consecutive done');
97101
});
98102

applications/monitor/package.json renamed to applications/monitor-scale/package.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
{
2-
"name": "monitor",
2+
"name": "monitor-scale",
33
"version": "1.0.0",
44
"description": "A service for updating the cache and emitting websocket events back to the frontend",
55
"main": "index.js",
66
"scripts": {
7-
"debug": "node --inspect index.js"
8-
},
9-
"repository": {
10-
"type": "git",
11-
"url": "git+https://github.com/kenzanlabs/kubernetes-ci-cd.git"
7+
"start": "node ."
128
},
9+
"repository": "git+https://github.com/kenzanlabs/kubernetes-ci-cd.git",
1310
"keywords": [
1411
"monitor",
1512
"cache",

0 commit comments

Comments
 (0)