Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

JINIers

k8s ingress & cloud armor 설정 본문

GCP/구성연습

k8s ingress & cloud armor 설정

JINIers 2022. 8. 19. 16:57

* 수정

22-08-23 : cloud armor update

22-08-30 : ingress 내용 update


 

1. vpc 생성

vpc name : testnw

vpc network 생성


2. GKE cluster 생성

이 순서로 생성해주면 된다.

Kubernetes Engine > Clusters > create cluster > standard mode 선택 > 설정

* 설정
   [default-pool]
   - number of nodes: 1
   [Cluster]
   - network: 설정한 VPC로 변경(나는 ‘testnw’로 해줌)

standard 모드로 설정해야한다.

 

클러스터 생성완료


3. workload 생성(deploy 생성)

test-1부터 test-3까지 생성해준다.

- service name : test1

- namespace name : test1-ns

 

deploy 생성

 

* Deploy를 생성하면 service가 자동으로 생성된다.X

deploy 에서 서비스 설정을 해줘야한다.

저걸 눌러

생성하면 service type 설정하라고 뜸(Cluster IP / LoadBalancer / Node port 일 것)

나는 LB로 설정해줬다.

아래 회색 부분은 스킵하고 넘어가도 됨ㅋ


* 보안상 internal ip인 cluster ip로 설정해줘야함

안그러면 k8s service external ip에 다이렉트로 붙어버릴 수 있음 < 그럼 cloud armor 써 봤자 소용없찡

service type을 LB로 설정 시

 

cluster ip로는 LB 인그레스를 못만들어줌

frontends에 ip가 생기지 않음

nodeport 나 LB로 만들어주어야한다.

node port - ingress 조합으로 써야한다.

node port - ingress LB 조합


service 생성 확인


4. ingress 생성

 

services & ingress > 1. ingress를 만들 서비스 선택 > 2. create ingress

 

create ingress

 

host and path rules > backend를 service로 설정해준다.

ingress 생성

 

[ingress 생성결과]

k8s engine > service & ingress > ingress 탭

ingress 생성결과


5. firewall 및 cloud armor 설정

 

firewall 설정

vpc network > firewall > create firewall rule

network : testnw

firewall 생성

Cloud Armor 설정

* 우리는 생성한 ingress를 cloud armor에 연결시켜 backend service로 보낸다.

 

Network Security > Cloud Armor > create policy
Deny 정책을 default로 만듦
allow 정책 : test를 위해 생성&삭제

apply policy to targets

 - type & backend service target 설정

 

cloud armor target 설정

 

cloud armor 설정 최종

 

 

cloud armor target 설정 결과


6. test

k8s service ‘test1-service’를 이용

Cloud armor의 allow 규칙 추가 후 test

allow 규칙 생성&삭제하며 test

 

 

[allow  규칙을 추가했을 때]

allow 규칙 추가 시


[allow 규칙을 삭제했을 때]

allow 규칙 삭제 시


* allow 규칙을 삭제 후 재생성 및 재적용 시 적용되는 시간이 걸린다.


service & ingress 설정 간단 정리

1. service : LB 로 설정 시

service : external LB로 설정 시

service와 ingress 둘 다 외부 ip를 가지게 되어 endpoint ip를 넣으면 armor를 거치지 않고 다이렉트로 접속하게 된다.

 

 

2. service : cluster ip로 설정 시

서비스를 cluster ip로 설정 시 ingress 경로가 생기지 않는다.

경고

cluster ip 대신 node port, LB를 사용하라고 경고한다.

 

 

 

3. service : node port 사용 시

nodeport를 사용하면 서비스는 internal ip만 생성되고 external ip는 생성되지 않는다.

오로지 ingress ip를 이용해야만 접속할 수 있다.


cloud armor 관련 간략하게 정리 한 것

https://jiniers.tistory.com/84

Comments