본문 바로가기

쿠버네티스

프론트엔드(HTML, CSS, Nginx) 서버를 파드(Pod)로 띄워보기

728x90
반응형

- index.html 아래와 같이 넣기

<!DOCTYPE html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <h1>My Web Page</h1>
</body>
</html>

 

- style.css 아래와 같이 넣기

* {
    color: blue;
}

 

- Dockerfile 에 아래와 같이 넣기

FROM nginx
COPY ./ /usr/share/nginx/html

 

 

terminal에서 

 

도커 이미지 빌드

 

docker build -t my-web-server .

 

파드를 띄우기 위해서는 manifest( yaml )이 필요함

 

web-server-pod.yaml

apiVersion: v1
kind: Pod

metadata:
  name: web-server-pod

spec:
  containers:
    - name: web-server-container
      image: my-web-server
      imagePullPolicy: IfNotPresent
      ports:
        - containerPort: 80

 

이 manifest를 기반으로 파드 생성

kubectl apply -f web-server-pod.yaml

 

파드 확인

kubectl get pods

 

포트포워딩

kubectl port-forward web-server-pod 5000:80

 

728x90
반응형