Cluster IP를 web, was에 설정하여 연동할 수 있도록 yaml 파일 생성
1. was yaml 파일 생성 및 배포
yaml 파일용 디렉토리 생성
# mkdir yaml
# cd yaml
# vi was.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: was-server
spec:
replicas: 2
selector:
matchLabels:
app: was
template:
metadata:
labels:
app: was
spec:
containers:
- image: [ACR]/was:1
name: was-server
ports:
- containerPort: 8080
resources:
requests:
cpu: 200m
readinessProbe:
tcpSocket:
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: was-server-svc
spec:
type: ClusterIP
selector:
app: was
ports:
- port: 8080
targetPort: 8080
was pod 배포
# kubectl apply -f was.yaml
# kubectl get pods
# kubectl get svc
클러스터ip생성 확인
2. web-was 연동
# docker exec -it web01 bash
# vi /etc/httpd/conf/httpd.conf
페이지아래 was의 클러스터ip로 수정
# exit
# docker restat web01
수정한 web 이미지 commit, push
# docker stop web01
# docker commit web01 [로그인서버]/web:v2
# docker push [로그인서버]/web:v2
v2 생
pull하여 작동 확인
# docker rmi [로그인서버]/web:v2
# docker pull [로그인서버]/web:v2
# docker run -d --name web02 -p 80:80 [로그인서버]/web:v2
3. web.yaml 파일 생성 및 배포
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-server
spec:
replicas: 2
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- image: [로그인서버]/web:v2
name: web
ports:
- containerPort: 80
resources:
requests:
cpu: 200m
readinessProbe:
tcpSocket:
port: 80
initialDelaySeconds: 5
periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: web-server-svc
spec:
type: LoadBalancer
selector:
app: web
ports:
- port: 80
name: http # SERVICE port name
protocol: TCP # The protocol the SERVICE will listen to
targetPort: 80
web pod 배포
# kubectl apply -f web.yaml
# kubectl get pods
# kubectl get svc
external-ip로 접속
4. DB테스트
FIND OWNER > Add Owner
테이블 조회
**이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.
'Cloud > Azure' 카테고리의 다른 글
Linux VM에서 가상 하드 디스크 확장 (1) | 2023.11.20 |
---|---|
AKS(Azure Kubernetes Service) 3Tire - 5 (0) | 2023.11.16 |
AKS(Azure Kubernetes Service) 3Tire - 3 (0) | 2023.11.08 |
AKS(Azure Kubernetes Service) 3Tire - 2 (0) | 2023.11.06 |
AKS(Azure Kubernetes Service) 3Tire - 1 (0) | 2023.11.06 |