2023. 10. 30. 23:20ㆍDevOps/Kubernetes
어느 화창한 가을날
OKD 클러스터에 Ingress Controller를 이용해서 SSL/TLS 인증을 적용해야 하는 막중한 엄무를 전달받았다.
그 중에서도
CBC(Cipher Block Chaining) 암호화 모드를 지원해야 하는 추가 주문이 있었다.
OKD에서는 HaProxy가 Default인 듯 한데
HaProxy Ingress Controller를 지원하지 않아서 Nginx 기반의 Ingress Controller를 적용해야 했다.
이 마저도 삽질으 엄청나게 했던게,,, Nginx Ingress Controller를 설치해야되는데
Ingress Nginx Controller를 설치해놓고 희희 다대따 희희 하다가
다시 원점으로 복귀해버렸다...
https://devwhy.tistory.com/entry/Nginx-Ingress%EC%9D%B8%EA%B0%80-Ingress-Nginx%EC%9D%B8%EA%B0%80
Nginx Ingress인가 Ingress Nginx인가
정답은 둘다이다. Nginx Ingress는 Nginx.org에서 만든 Ingress Controller https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-manifests/ Installation with Manifests | NGINX Ingress Controller Installation with Manifests
devwhy.tistory.com
그래도 일단 Nginx Ingress Controller의 경우에는 설치 방법이 친절하게 나와있다.
천천히 순서대로 manifest를 적용해주면서 필요없는 것들은 빼면서 진행하면 완료된다(ex: WAF, DOS 를 위한 모듈들)
https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-manifests/
[Download Manifest Code]
git clone https://github.com/nginxinc/kubernetes-ingress.git --branch v3.3.1
cd kubernetes-ingress/deployments
[Namespace & RBAC]
kubectl apply -f common/ns-and-sa.yaml
kubectl apply -f rbac/rbac.yaml
[Common Resource: Secret, ConfigMap]
kubectl apply -f ../examples/shared-examples/default-server-secret/default-server-secret.yaml
# The default server returns the Not Found page with the 404 status code for all requests
# for domains for which there are no Ingress rules defined.
# For testing purposes we include a self-signed certificate and key that we generated.
# However, we recommend that you use your own certificate and key.
[IngressClass: nginx]
kubectl apply -f common/ingress-class.yaml
[Custom Resource Definition]
kubectl apply -f common/crds/k8s.nginx.org_virtualservers.yaml
kubectl apply -f common/crds/k8s.nginx.org_virtualserverroutes.yaml
kubectl apply -f common/crds/k8s.nginx.org_transportservers.yaml
kubectl apply -f common/crds/k8s.nginx.org_policies.yaml
kubectl apply -f common/crds/k8s.nginx.org_globalconfigurations.yaml # for TCP UDP Load Balancing Feature
[Deployment]
kubectl apply -f deployment/nginx-ingress.yaml
kubectl get pods --namespace=nginx-ingress
or
[DaemonSet]
kubectl apply -f daemon-set/nginx-ingress.yaml
kubectl get pods --namespace=nginx-ingress
[Service]
kubectl create -f service/nodeport.yaml
이렇게 진행하고 나면 바닐라 쿠버네티스의 경우에는 정상적으로
Nginx Ingress Controller POD 가 생성이 스케쥴링&생성이 된다.
하지만, OKD에는 참^_^ 신기한 SCC라는...(Security Context Constraints)가 존재해서
이걸로 권한을 설정해줘야 하는 것 같았다.
[방법 1: ingress-scc.yaml 설치 및 적용]
위 manifest 코드를 이용해서 scc를 생성해준다.
# 위 ServiceAccount는 상이할 수 있다.
# oc get sa -n nginx-ingress를 이용해서 nginx-ingress 네임스페이스 내 Service Account 확인
# scc 적용 방법
oc adm policy add-scc-to-user [SCC_NAME] -z [SERVICE_ACCOUNT_NAME] -n [NAMESPACE]
or
oc adm policy add-scc-to-user [SCC_NAME] [USER_NAME]
# scc 삭제 방법
oc adm policy remove-scc-to-user [SCC_NAME] -z [SERVICE_ACCOUNT_NAME] -n [NAMESPACE]
or
oc adm policy remove-scc-to-user [SCC_NAME] [USER_NAME]
oc apply -f ingress-scc.yaml
oc adm policy add-scc-to-user ingress-scc -z default -n nginx-ingress
oc adm policy add-scc-to-user ingress-scc -z nginx-ingress -n nginx-ingress
--- 여기까지만 하면 Pod가 Scheduling 되는데, 혹시몰라서 SA 전부 등록해주었다..
oc adm policy add-scc-to-user ingress-scc -z builder -n nginx-ingress
oc adm policy add-scc-to-user ingress-scc -z deployer -n nginx-ingress
[방법 2: 기존에 있던 privileged scc 적용]
일단 빠른 설치가 목표여서 자세하게 파보지는 못했지만
privileged 라는 SCC는 약간 Admin 권한과 비슷한 느낌이라서
ingress-scc.yaml을 통해서 설치하는 게 좋을 것 같다.
# 위 ServiceAccount는 상이할 수 있다.
# oc get sa -n nginx-ingress를 이용해서 nginx-ingress 네임스페이스 내 Service Account 확인
oc get scc | grep privileged
oc adm policy add-scc-to-user privileged -z default -n nginx-ingress
oc adm policy add-scc-to-user privileged -z nginx-ingress -n nginx-ingress
--- 여기까지만 하면 Pod가 Scheduling 되는데, 혹시몰라서 SA 전부 등록해주었다..
oc adm policy add-scc-to-user privileged -z builder -n nginx-ingress
oc adm policy add-scc-to-user privileged -z deployer -n nginx-ingress
OKD 어렵다.
'DevOps > Kubernetes' 카테고리의 다른 글
Nginx Ingress인가 Ingress Nginx인가 (0) | 2023.10.30 |
---|---|
Rocky Linux RKE2 Intsall (1) | 2023.10.23 |
[Kubernetes] CSI(Container Storage Interface) (0) | 2023.09.13 |
[CKA] 2023 CKA(Certified Kubernetes Administrator) 합격 후기 (0) | 2023.09.05 |
EKS 클러스터에 HTTPS 통신 구성(Ingress, Cert-Manager) (0) | 2023.09.04 |