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