Skip to content

Commit ccb4157

Browse files
committed
Add project files for Lesson 4
1 parent 77d065f commit ccb4157

File tree

8 files changed

+126
-0
lines changed

8 files changed

+126
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: my-app
5+
labels:
6+
app: my-app
7+
spec:
8+
replicas: 2
9+
selector:
10+
matchLabels:
11+
app: my-app
12+
template:
13+
metadata:
14+
labels:
15+
app: my-app
16+
spec:
17+
containers:
18+
- name: simple-node
19+
image: YOUR_DOCKER_HUB/simple-node
20+
ports:
21+
- containerPort: 80
22+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: my-app
5+
labels:
6+
app: my-app
7+
spec:
8+
replicas: 2
9+
selector:
10+
matchLabels:
11+
app: my-app
12+
template:
13+
metadata:
14+
labels:
15+
app: my-app
16+
spec:
17+
containers:
18+
- name: simple-node
19+
image: YOUR_DOCKER_HUB/simple-node
20+
ports:
21+
- containerPort: 80
22+
livenessProbe:
23+
httpGet:
24+
path: /health
25+
port: 8080
26+
initialDelaySeconds: 3
27+
periodSeconds: 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: my-app
5+
labels:
6+
run: my-app
7+
spec:
8+
ports:
9+
- port: 80
10+
protocol: TCP
11+
selector:
12+
run: my-app
13+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Use NodeJS base image
2+
FROM node:13
3+
4+
# Create app directory
5+
WORKDIR /usr/src/app
6+
7+
# Install app dependencies by copying
8+
# package.json and package-lock.json
9+
COPY package*.json ./
10+
11+
# Install dependencies
12+
RUN npm install
13+
14+
# Copy app source
15+
COPY . .
16+
17+
# Bind the port that the image will run on
18+
EXPOSE 8080
19+
20+
# Define the Docker image's behavior at runtime
21+
CMD ["node", "server.js"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Overview
2+
This is a very simple, bare-bones NodeJS project created for you to use with Docker.
3+
4+
# Local Setup
5+
* Install dependencies: `npm install`
6+
* Run server: `node server.js`
7+
8+
# Container Setup
9+
* Build image: `docker build .`
10+
* Run container with image: `docker run {image_id}` where `image_id` can be retrieved by running `docker images` and found under the column `IMAGE ID`
11+
12+
# Container teardown
13+
* Remove container: `docker kill {container_id}` where `container_id` can be retrieved by running `docker ps` and found under the column `CONTAINER ID`

Diff for: lesson-4-intro-to-orchestration-with-kubernetes/exercises/kubernetes-on-aws/package-lock.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "simple_node",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC",
12+
"dependencies": {}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function sleep(ms) {
2+
return new Promise(resolve => setTimeout(resolve, ms));
3+
}
4+
5+
async function main() {
6+
while(true) {
7+
console.log('Containers rule!');
8+
await sleep(5000);
9+
}
10+
}
11+
12+
main();

0 commit comments

Comments
 (0)