Commit ea6774e3 authored by JooHan Hong's avatar JooHan Hong

k8s, oper update3

parent 76f2c7a6
Pipeline #6065 passed with stages
in 1 minute and 18 seconds
......@@ -2,7 +2,7 @@
# MON Operation Overview
> K8s 기반의 **Nginx** Front-End System Overview
> K8s 기반의 **Node.js** DB API Front-End System Overview
# K8s Deployment Current Status
......@@ -28,19 +28,19 @@ monitor-nodejs-f68967947-vrchl 1/1 Running 0 5d23h 10
# monitor Deployment Status
## Nginx Deployment yaml
## Node.js DB API Deployment yaml
> 역할 : Nginx POD를 배포하는 Deployment를 작성한다.
> 역할 : Node.js DB API POD를 배포하는 Deployment를 작성한다.
```
# cat mon_nginx.yaml
# cat mon_nodejs_db.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginx
name: monitor-nginx
app: dbapi
name: monitor-dbapi
spec:
replicas: 2
strategy:
......@@ -50,11 +50,11 @@ spec:
maxUnavailable: 0
selector:
matchLabels:
app: nginx
app: dbapi
template:
metadata:
labels:
app: nginx
app: dbapi
spec:
affinity:
nodeAffinity:
......@@ -70,9 +70,10 @@ spec:
- labelSelector:
matchExpressions:
- key: app
#- key: servertype
operator: In
values:
- nginx
- dbapi
topologyKey: "kubernetes.io/hostname"
volumes:
- name: mon-home-volume
......@@ -85,61 +86,61 @@ spec:
- 61.100.0.136
- 61.100.0.152
containers:
- image: harbor.hongsnet.net/monitor/monitoring-nginx:20220801_32
- image: harbor.hongsnet.net/monitor/monitoring-nodejs-db:20220801_6
imagePullPolicy: IfNotPresent
name: monitor-nginx
name: monitor-dbapi
volumeMounts:
- mountPath: /home
name: mon-home-volume
imagePullSecrets:
- name: harbor-login
```
## Nginx HPA Scale yaml
## Node.js DB API HPA Scale yaml
> 역할 : AutoScaling 정책을 작성한다.
```
# cat mon_scale_nginx.yaml
# cat mon_scale_nodejs_db.yaml
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: nginx-hpa
name: dbapi-hpa
namespace: default
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: monitor-nginx
name: monitor-dbapi
minReplicas: 2
maxReplicas: 3
targetCPUUtilizationPercentage: 80
targetCPUUtilizationPercentage: 60
```
## Nginx Service yaml
## Node.js DB API Service yaml
> 역할 : Nginx Service를 작성한다. 여기서는 NodePort 방식을 통해 배포한다.
> 역할 : Node.js DB API Service를 작성한다. 여기서는 NodePort 방식을 통해 배포한다.
```
# cat mon_service_nginx.yaml
# cat mon_service_nodejs_db.yaml
apiVersion: v1
kind: Service
metadata:
name: monitor-nginx
name: monitor-dbapi
spec:
externalTrafficPolicy: Local
type: NodePort
selector:
app: nginx
app: dbapi
ports:
- name: nginx
port: 80
protocol: TCP
targetPort: 80
nodePort: 32000
- name: dbapi
port: 8900
targetPort: 8900
nodePort: 32002
```
......@@ -147,45 +148,46 @@ spec:
> 배포 및 관리는 여러 가지 방법이 있지만, 여기서는 **kubectl** 을 사용하여 실행한다.
- **시작**
- **시작** 스크립트
```
# cat start-mon_nginx.sh
# cat start-mon_nodejs_db.sh
#!/bin/bash
kubectl create -f mon_nginx.yaml
kubectl create -f mon_scale_nginx.yaml
kubectl create -f mon_service_nginx.yaml
kubectl create -f mon_nodejs_db.yaml
kubectl create -f mon_scale_nodejs_db.yaml
kubectl create -f mon_service_nodejs_db.yaml
```
실행결과는 다음과 같다.
```
# ./start-mon_nginx.sh
deployment.apps/monitor-nginx created
horizontalpodautoscaler.autoscaling/nginx-hpa created
service/monitor-nginx created
# ./start-mon_nodejs_db.sh
deployment.apps/monitor-dbapi created
horizontalpodautoscaler.autoscaling/dbapi-hpa created
service/monitor-dbapi created
```
- **중지**
- **중지** 스크립트
```
# cat stop-mon_nginx.sh
#!/bin/bash
kubectl delete -f mon_service_nginx.yaml
kubectl delete -f mon_scale_nginx.yaml
kubectl delete -f mon_nginx.yaml
#kubectl delete hpa monitor-nginx
kubectl delete -f mon_service_nodejs_db.yaml
kubectl delete -f mon_scale_nodejs_db.yaml
kubectl delete -f mon_nodejs_db.yaml
```
실행결과는 다음과 같다.
```
# ./stop-mon_nginx.sh
service "monitor-nginx" deleted
horizontalpodautoscaler.autoscaling "nginx-hpa" deleted
deployment.apps "monitor-nginx" deleted
# ./stop-mon_nodejs_db.sh
service "monitor-dbapi" deleted
horizontalpodautoscaler.autoscaling "dbapi-hpa" deleted
deployment.apps "monitor-dbapi" deleted
```
......@@ -147,7 +147,7 @@ spec:
> 배포 및 관리는 여러 가지 방법이 있지만, 여기서는 **kubectl** 을 사용하여 실행한다.
- **시작**
- **시작** 스크립트
```
# cat start-mon_nginx.sh
......@@ -168,7 +168,7 @@ horizontalpodautoscaler.autoscaling/nginx-hpa created
service/monitor-nginx created
```
- **중지**
- **중지** 스크립트
```
# cat stop-mon_nginx.sh
......
......@@ -2,7 +2,7 @@
# MON Operation Overview
> K8s 기반의 **Nginx** Front-End System Overview
> K8s 기반의 **Node.js API** Front-End System Overview
# K8s Deployment Current Status
......@@ -28,19 +28,19 @@ monitor-nodejs-f68967947-vrchl 1/1 Running 0 5d23h 10
# monitor Deployment Status
## Nginx Deployment yaml
## Node.js Deployment yaml
> 역할 : Nginx POD를 배포하는 Deployment를 작성한다.
> 역할 : Node.js API POD를 배포하는 Deployment를 작성한다.
```
# cat mon_nginx.yaml
# cat mon_nodejs.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginx
name: monitor-nginx
app: nodejs
name: monitor-nodejs
spec:
replicas: 2
strategy:
......@@ -50,11 +50,11 @@ spec:
maxUnavailable: 0
selector:
matchLabels:
app: nginx
app: nodejs
template:
metadata:
labels:
app: nginx
app: nodejs
spec:
affinity:
nodeAffinity:
......@@ -72,7 +72,7 @@ spec:
- key: app
operator: In
values:
- nginx
- nodejs
topologyKey: "kubernetes.io/hostname"
volumes:
- name: mon-home-volume
......@@ -83,11 +83,11 @@ spec:
nameservers:
- 8.8.8.8
- 61.100.0.136
- 61.100.0.152
- 61.100.0.252
containers:
- image: harbor.hongsnet.net/monitor/monitoring-nginx:20220801_32
- image: harbor.hongsnet.net/monitor/monitoring-nodejs:20220801_24
imagePullPolicy: IfNotPresent
name: monitor-nginx
name: monitor-nodejs
volumeMounts:
- mountPath: /home
name: mon-home-volume
......@@ -95,97 +95,96 @@ spec:
- name: harbor-login
```
## Nginx HPA Scale yaml
## Node.js API HPA Scale yaml
> 역할 : AutoScaling 정책을 작성한다.
```
# cat mon_scale_nginx.yaml
# cat mon_scale_nodejs.yaml
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: nginx-hpa
name: nodejs-hpa
namespace: default
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: monitor-nginx
name: monitor-nodejs
minReplicas: 2
maxReplicas: 3
targetCPUUtilizationPercentage: 80
targetCPUUtilizationPercentage: 50
```
## Nginx Service yaml
## Node.js API Service yaml
> 역할 : Nginx Service를 작성한다. 여기서는 NodePort 방식을 통해 배포한다.
> 역할 : Node.js API Service를 작성한다. 여기서는 NodePort 방식을 통해 배포한다.
```
# cat mon_service_nginx.yaml
# cat mon_service_nodejs.yaml
apiVersion: v1
kind: Service
metadata:
name: monitor-nginx
name: monitor-nodejs
spec:
externalTrafficPolicy: Local
type: NodePort
selector:
app: nginx
app: nodejs
ports:
- name: nginx
port: 80
protocol: TCP
targetPort: 80
nodePort: 32000
- name: nodejs
port: 8081
targetPort: 8081
nodePort: 32001
```
## 실행
> 배포 및 관리는 여러 가지 방법이 있지만, 여기서는 **kubectl** 을 사용하여 실행한다.
- **시작**
- **시작** 스크립트
```
# cat start-mon_nginx.sh
# cat start-mon_nodejs.sh
#!/bin/bash
kubectl create -f mon_nginx.yaml
kubectl create -f mon_scale_nginx.yaml
kubectl create -f mon_service_nginx.yaml
kubectl create -f mon_nodejs.yaml
kubectl create -f mon_scale_nodejs.yaml
kubectl create -f mon_service_nodejs.yaml
```
실행결과는 다음과 같다.
```
# ./start-mon_nginx.sh
deployment.apps/monitor-nginx created
horizontalpodautoscaler.autoscaling/nginx-hpa created
service/monitor-nginx created
# ./start-mon_nodejs.sh
deployment.apps/monitor-nodejs created
horizontalpodautoscaler.autoscaling/nodejs-hpa created
service/monitor-nodejs created
```
- **중지**
- **중지** 스크립트
```
# cat stop-mon_nginx.sh
# cat stop-mon_nodejs.sh
#!/bin/bash
kubectl delete -f mon_service_nginx.yaml
kubectl delete -f mon_scale_nginx.yaml
kubectl delete -f mon_nginx.yaml
#kubectl delete hpa monitor-nginx
kubectl delete -f mon_service_nodejs.yaml
kubectl delete -f mon_scale_nodejs.yaml
kubectl delete -f mon_nodejs.yaml
```
실행결과는 다음과 같다.
```
# ./stop-mon_nginx.sh
service "monitor-nginx" deleted
horizontalpodautoscaler.autoscaling "nginx-hpa" deleted
deployment.apps "monitor-nginx" deleted
# ./stop-mon_nodejs.sh
service "monitor-nodejs" deleted
horizontalpodautoscaler.autoscaling "nodejs-hpa" deleted
deployment.apps "monitor-nodejs" deleted
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment