Skip to content

Commit 2ce15be

Browse files
authored
Merge pull request #36 from Bit-Developer/deploy-to-k8s
Add k8s deployment
2 parents bc04972 + 6175574 commit 2ce15be

4 files changed

Lines changed: 59 additions & 2 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# Stage 1, based on Node.js, to build and compile Angular
1313

14-
FROM node:15.12.0-alpine as builder
14+
FROM node:16.10.0-alpine as builder
1515

1616
WORKDIR /ng-app
1717

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ docker run --name text-compare-angular -p 8080:80 text-compare-angular
4040
```
4141
Access http://localhost:8080/ in web browser and click 'Text Compare' menu, enjoy!
4242

43+
# Setup in K8s
44+
45+
```sh
46+
# 1. Build image
47+
docker build -t text-compare-angular .
48+
# 2. Deploy to k8s:
49+
kubectl apply -f k8s/text-compare.yaml
50+
# 3. Create service in minikube:
51+
minikube service text-compare-service
52+
# 4. Web browser will be opened automatically to access the site.
53+
```
54+
4355
# Deployment
4456
Read tutorial [Deploying Text Compare Angular App to Docker](https://jojozhuang.github.io/tutorial/deploying-text-compare-angular-app-to-docker) to learn how this angular app is deployed to Docker.
4557

k8s/text-compare.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Setup loocally
2+
# 1. Build image
3+
# docker build -t text-compare-angular .
4+
# 2. Deploy to k8s:
5+
# kubectl apply -f k8s/text-compare.yaml
6+
# 3. Create service in minikube:
7+
# minikube service text-compare-service
8+
# 4. Web browser will be opened automatically to access the site.
9+
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
metadata:
13+
name: text-compare-deployment
14+
labels:
15+
app: text-compare
16+
spec:
17+
replicas: 1
18+
selector:
19+
matchLabels:
20+
app: text-compare
21+
template:
22+
metadata:
23+
labels:
24+
app: text-compare
25+
spec:
26+
containers:
27+
- name: text-compare
28+
image: jojozhuang/text-compare-angular
29+
ports:
30+
- containerPort: 80
31+
---
32+
apiVersion: v1
33+
kind: Service
34+
metadata:
35+
name: text-compare-service
36+
spec:
37+
selector:
38+
app: text-compare
39+
type: LoadBalancer # assign an external IP address to accept external request
40+
ports:
41+
- protocol: TCP
42+
port: 12011
43+
targetPort: 80
44+
nodePort: 31000 # must be between 30000 and 32767

package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)