(작성중)
ingress를 사용해보자 L7 로드밸런서로 보면 된다.
<1> 도커 파일로 이미지를 만들자
<2> 레지스트리에 로그온하고 만든 이미지를 올라자
<3> ingress를 만들자
<4> 잘 동작하는지 테스트 해보자
<1> 도커 파일로 이미지를 만들자
1
mkdir 6
cd 6
2
vi Dockerfile
[root@s17e3bbc1fd7 6]# vi Dockerfile
FROM centos:7
# Install Apache
RUN yum -y update && yum install -y httpd httpd-tools && yum install -y telnet
RUN mkdir /var/www/html/b
# change index.html
RUN echo '<!DOCTYPE html> \
<head> \
<title>NCP</title> \
</head>\
<body style="text-align:center">\
<h2> NCP TEST에 오신걸 환영합니다! </h2>\
<div><b>Subject :</b> Kubernetes Service를 활용한 컨테이너 관리 </div>\
<div style="color:#fff;background:#00FF00;"><b>Version</b> : 3.0.0</div>\
</body>\
</html>' > /var/www/html/b/index.html
CMD ["systemctl","restart","httpd"]
#Start Apache
CMD ["/usr/sbin/httpd","-D","FOREGROUND"]
[root@s17e3bbc1fd7 6]#
3
docker build -t image_apache_2 .
4
docker images
[root@s17e3bbc1fd7 6]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
image_apache_2 latest f849bab1a9f6 5 seconds ago 521MB
<2> 레지스트리에 로그온하고 만든 이미지를 올라자
1
docker login –u <access-key-id> <registry-name>.kr.ncr.ntruss.com –p <secret-key>
docker login -u tUBxxxxxxxxx m6n7b87w.kr.private-ncr.ntruss.com
2
docker run -tid -p 4000:80 --name=hello_apache2 image_apache_2
# docker run -tid -p 7000:80 --name=hello_apache2 image_apache_2
docker: Error response from daemon: Conflict. The container name "/hello_apache2" is already in use by container "3268f53e0971cb2bd4c752b382040afdd5b449a592ebc6e029c04a14bc4c7c8b". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
3
docker image tag image_apache_2 <private-endpoint>/image_apache_2:1.0
docker image tag image_apache_2 m6n7b87w.kr.ncr.ntruss.com/image_apache_2:1.0
4
docker push m6n7b87w.kr.ncr.ntruss.com/image_apache_2:1.0
The push refers to repository [m6n7b87w.kr.ncr.ntruss.com/image_apache_2]
61c2024c67fc: Preparing
d04bd79f8323: Preparing
f57bf25422cf: Preparing
174f56854903: Preparing
denied: requested access to the resource is denied
5
어플리케이션 배포
kubectl apply -f https://gist.githubusercontent.com/NaverCloudPlatformDeveloper/c47620d8d25b2a0e08648f225043adf6/raw/675addde0a56ba727824f30f92a73b40550fb73c/nks-tutorial-hello-service.yaml
6
인그레스 컨트롤러 배포
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controllerv0.43.0/deploy/static/provider/cloud/deploy.yaml
7
서비스 생성
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingressnginx/2de5a893aa15f14102d714e918b0045b960ad1a5/deploy/static/provider/cloud-generic.yaml
<3> ingress를 만들자
유입 트래픽 분기 인그레스
vi ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ab-ingress
annotations:
kubernetes.io/ingress.class: nginx
ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- http:
paths:
- path: /a
backend:
serviceName: a-svc
servicePort: 80
- path: /b
backend:
serviceName: b-svc
kubectl create –f ingress.yaml
error: error parsing ingress.yaml: error converting YAML to JSON: yaml: line 16: did not find expected key
2
kubectl create –f ingress.yaml
3
kubectl get ingress
<4> 잘 동작하는지 테스트 해보자
curl (ingress domain)/a
curl (ingress domain)/b
감사합니다.
감사합니다.