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

Kelsey's demo #4

Open
wants to merge 4 commits into
base: master
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node
FROM node:8-alpine
WORKDIR /app
COPY . .
RUN yarn install
Expand Down
3 changes: 3 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- define "name" -}}
{{- printf "%s-%s" .Release.Name .Chart.Name -}}
{{- end -}}
6 changes: 6 additions & 0 deletions chart/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "name" . }}
data:
version: "3"
14 changes: 11 additions & 3 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: kube-hello-world
name: {{ template "name" . }}
spec:
replicas: 1
template:
metadata:
labels:
name: kube-hello-world
name: {{ template "name" . }}
annotations:
checksum: {{ include (print $.Chart.Name "/templates/configmap.yaml") . | sha256sum }}
spec:
containers:
- name: hello-world-nodejs
image: first-container
image: {{ .Values.image }}
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
env:
- name: VERSION
valueFrom:
configMapKeyRef:
name: {{ template "name" . }}
key: version
12 changes: 4 additions & 8 deletions chart/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: kube-hello-world-ingress
name: {{ template "name" . }}
spec:
rules:
- http:
paths:
- backend:
serviceName: kube-hello-world-service
servicePort: 80
path: /
backend:
serviceName: {{ template "name" . }}
servicePort: 80

10 changes: 5 additions & 5 deletions chart/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ apiVersion: v1
kind: Service
metadata:
labels:
name: kube-hello-world-service
name: kube-hello-world-service
name: {{ template "name" . }}
name: {{ template "name" . }}
spec:
ports:
- name: exposed-port
port: 80
- port: 80
targetPort: 8080
selector:
name: kube-hello-world
name: {{ template "name" . }}
type: NodePort
1 change: 1 addition & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
image: learnk8s/node-hello-world
22 changes: 18 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
const express = require('express')
const app = express()
const port = process.env.PORT || 8080;
const Redis = require('ioredis')

const VERSION = '2.0.0'

const redis = new Redis()

redis.on('error', () => {})

app.get('/', (req, res) => {
res.send('Hello World!')
})

app.get('/version', (req, res) => {
res.send(process.env.VERSION || 'No version')
res.send(VERSION)
})

app.get('/healthz', (req, res) => {
if (redis.status === 'ready') {
res.sendStatus(200)
} else {
res.sendStatus(500)
}
})

app.listen(port, () => {
console.log(`Example app listening on port ${port}!`)
app.listen(3000, () => {
console.log('Example app listening on port 3000!')
})
27 changes: 27 additions & 0 deletions kube/deployment-v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: helloworld-v2
spec:
replicas: 1
template:
metadata:
labels:
app: helloworld
version: v2
spec:
containers:
- name: web
image: learnk8s/demo:2.0.0
ports:
- containerPort: 3000
livenessProbe:
initialDelaySeconds: 2
periodSeconds: 5
httpGet:
path: /healthz
port: 3000
- name: redis
image: redis:4.0.2-alpine
ports:
- containerPort: 6379
27 changes: 27 additions & 0 deletions kube/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: helloworld
spec:
replicas: 1
template:
metadata:
labels:
app: helloworld
version: v1
spec:
containers:
- name: web
image: learnk8s/demo:1.0.0
ports:
- containerPort: 3000
livenessProbe:
initialDelaySeconds: 2
periodSeconds: 5
httpGet:
path: /healthz
port: 3000
- name: redis
image: redis:4.0.2-alpine
ports:
- containerPort: 6379
13 changes: 13 additions & 0 deletions kube/service-v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: helloworld-v2
spec:
ports:
- nodePort: 32001
port: 80
targetPort: 3000
selector:
app: helloworld
version: v2
type: NodePort
12 changes: 12 additions & 0 deletions kube/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: helloworld
spec:
ports:
- nodePort: 32000
port: 80
targetPort: 3000
selector:
app: helloworld
type: NodePort
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"author": "<[email protected]>",
"license": "MIT",
"dependencies": {
"express": "^4.16.2"
"express": "^4.16.2",
"ioredis": "^3.2.1"
},
"scripts": {
"test": "node test.js",
Expand Down
118 changes: 117 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"

bluebird@^3.3.4:
version "3.5.1"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.1.tgz#d9551f9de98f1fcda1e683d17ee91a0602ee2eb9"

[email protected]:
version "1.18.2"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.2.tgz#87678a19d84b47d859b83199bd59bce222b10454"
Expand All @@ -43,6 +47,10 @@ [email protected]:
version "3.0.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048"

cluster-key-slot@^1.0.6:
version "1.0.8"
resolved "https://registry.yarnpkg.com/cluster-key-slot/-/cluster-key-slot-1.0.8.tgz#7654556085a65330932a2e8b5976f8e2d0b3e414"

[email protected]:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
Expand All @@ -63,7 +71,7 @@ [email protected]:
version "0.3.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"

[email protected]:
[email protected], debug@^2.2.0:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
dependencies:
Expand All @@ -84,6 +92,10 @@ defined@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693"

denque@^1.1.0:
version "1.2.2"
resolved "https://registry.yarnpkg.com/denque/-/denque-1.2.2.tgz#e06cf7cf0da8badc88cbdaabf8fc0a70d659f1d4"

[email protected], depd@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.1.tgz#5783b4e1c459f06fa5ca27f991f3d06e7a310359"
Expand Down Expand Up @@ -173,6 +185,10 @@ [email protected]:
statuses "~1.3.1"
unpipe "~1.0.0"

[email protected]:
version "0.0.6"
resolved "https://registry.yarnpkg.com/flexbuffer/-/flexbuffer-0.0.6.tgz#039fdf23f8823e440c38f3277e6fef1174215b30"

for-each@~0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.2.tgz#2c40450b9348e97f281322593ba96704b9abd4d4"
Expand Down Expand Up @@ -240,6 +256,34 @@ inherits@2, [email protected], inherits@~2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"

ioredis@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-3.2.1.tgz#4c10bcce9659fdb0af923b0e7915208fe023d3f0"
dependencies:
bluebird "^3.3.4"
cluster-key-slot "^1.0.6"
debug "^2.2.0"
denque "^1.1.0"
flexbuffer "0.0.6"
lodash.assign "^4.2.0"
lodash.bind "^4.2.1"
lodash.clone "^4.5.0"
lodash.clonedeep "^4.5.0"
lodash.defaults "^4.2.0"
lodash.difference "^4.5.0"
lodash.flatten "^4.4.0"
lodash.foreach "^4.5.0"
lodash.isempty "^4.4.0"
lodash.keys "^4.2.0"
lodash.noop "^3.0.1"
lodash.partial "^4.2.1"
lodash.pick "^4.4.0"
lodash.sample "^4.2.1"
lodash.shuffle "^4.2.0"
lodash.values "^4.3.0"
redis-commands "^1.2.0"
redis-parser "^2.4.0"

[email protected]:
version "1.5.2"
resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.5.2.tgz#d4b505bde9946987ccf0fc58d9010ff9607e3fa0"
Expand All @@ -266,6 +310,70 @@ is-symbol@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"

lodash.assign@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.assign/-/lodash.assign-4.2.0.tgz#0d99f3ccd7a6d261d19bdaeb9245005d285808e7"

lodash.bind@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/lodash.bind/-/lodash.bind-4.2.1.tgz#7ae3017e939622ac31b7d7d7dcb1b34db1690d35"

lodash.clone@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.clone/-/lodash.clone-4.5.0.tgz#195870450f5a13192478df4bc3d23d2dea1907b6"

lodash.clonedeep@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"

lodash.defaults@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"

lodash.difference@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.difference/-/lodash.difference-4.5.0.tgz#9ccb4e505d486b91651345772885a2df27fd017c"

lodash.flatten@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f"

lodash.foreach@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53"

lodash.isempty@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.isempty/-/lodash.isempty-4.4.0.tgz#6f86cbedd8be4ec987be9aaf33c9684db1b31e7e"

lodash.keys@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-4.2.0.tgz#a08602ac12e4fb83f91fc1fb7a360a4d9ba35205"

lodash.noop@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash.noop/-/lodash.noop-3.0.1.tgz#38188f4d650a3a474258439b96ec45b32617133c"

lodash.partial@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/lodash.partial/-/lodash.partial-4.2.1.tgz#49f3d8cfdaa3bff8b3a91d127e923245418961d4"

lodash.pick@^4.4.0:
version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3"

lodash.sample@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/lodash.sample/-/lodash.sample-4.2.1.tgz#5e4291b0c753fa1abeb0aab8fb29df1b66f07f6d"

lodash.shuffle@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.shuffle/-/lodash.shuffle-4.2.0.tgz#145b5053cf875f6f5c2a33f48b6e9948c6ec7b4b"

lodash.values@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/lodash.values/-/lodash.values-4.3.0.tgz#a3a6c2b0ebecc5c2cba1c17e6e620fe81b53d347"

[email protected]:
version "0.3.0"
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
Expand Down Expand Up @@ -370,6 +478,14 @@ [email protected]:
iconv-lite "0.4.19"
unpipe "1.0.0"

redis-commands@^1.2.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/redis-commands/-/redis-commands-1.3.1.tgz#81d826f45fa9c8b2011f4cd7a0fe597d241d442b"

redis-parser@^2.4.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/redis-parser/-/redis-parser-2.6.0.tgz#52ed09dacac108f1a631c07e9b69941e7a19504b"

resolve@~1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.4.0.tgz#a75be01c53da25d934a98ebd0e4c4a7312f92a86"
Expand Down