1. 설치 환경
설치 환경은 다음과 같습니다. Bastion 노드는 외부 인터넷 통신이 가능한 환경입니다. 향후 Airgap 환경 설치는 따로 정리할 예정입니다. VM 스펙 권장사항은 아래와 같으며 현재 테스트 환경에서는 최소한의 리소스를 사용하여 설치합니다.
1-1. 🖥️ OpenShift 클러스터 노드 OS 및 스펙 정리
역할 | 호스트명 | OS | CPU (vCPU) | 메모리 (RAM) | 디스크 (Storage) | 비고 |
---|---|---|---|---|---|---|
Bastion 서버 | bastion.ttc.ibm.kr | CentOS 8 / RHEL 8 | 2~4 vCPU | 8~16 GB | 50 GB 이상 | DNS, HTTPD, HAProxy, DHCP |
Bootstrap 노드 | bootstrap.ttc.ibm.kr | RHCOS | 4 vCPU | 16 GB | 120 GB 이상 (SSD 권장) | 설치 완료 후 삭제 예정 |
Master 0 | master0.ttc.ibm.kr | RHCOS | 4~8 vCPU | 16~32 GB | 120 GB 이상 | Control Plane 노드 |
Master 1 | master1.ttc.ibm.kr | RHCOS | 4~8 vCPU | 16~32 GB | 120 GB 이상 | Control Plane 노드 |
Master 2 | master2.ttc.ibm.kr | RHCOS | 4~8 vCPU | 16~32 GB | 120 GB 이상 | Control Plane 노드 |
Worker 0 | worker0.ttc.ibm.kr | RHCOS | 4~8 vCPU | 16~32 GB | 120 GB 이상 | Compute 노드 |
Worker 1 | worker1.ttc.ibm.kr | RHCOS | 4~8 vCPU | 16~32 GB | 120 GB 이상 | Compute 노드 |
Worker 2 | worker2.ttc.ibm.kr | RHCOS | 4~8 vCPU | 16~32 GB | 120 GB 이상 | Compute 노드 |
✅ 참고 사항
- 모든 마스터/워커 노드는 OS로 Red Hat CoreOS (RHCOS) 를 사용해야 함
- Master 노드는 안정성을 위해 RAM 32GB 이상을 권장
- Worker 노드는 워크로드에 따라 스펙을 조정할 수 있음
- Bastion 서버는 OpenShift 클러스터에 직접 참여하지 않지만, 설치와 운영을 위한 핵심 인프라임
1-2. 📜 OpenShift 설치용 IP 리스트
역할 | 호스트명 | IP 주소 | 비고 |
---|---|---|---|
Bastion 서버 | bastion.ttc.ibm.kr | 10.10.14.130 | DNS, HTTPD, HAProxy, DHCP 서버 |
Bootstrap 노드 | bootstrap.ttc.ibm.kr | 10.10.14.142 | 설치 완료 후 삭제 예정 |
Master 0 | master0.ttc.ibm.kr | 10.10.14.134 | Control Plane 노드 |
Master 1 | master1.ttc.ibm.kr | 10.10.14.135 | Control Plane 노드 |
Master 2 | master2.ttc.ibm.kr | 10.10.14.136 | Control Plane 노드 |
Worker 0 | worker0.ttc.ibm.kr | 10.10.14.137 | Compute 노드 |
Worker 1 | worker1.ttc.ibm.kr | 10.10.14.138 | Compute 노드 |
Worker 2 | worker2.ttc.ibm.kr | 10.10.14.139 | Compute 노드 |
📍 추가 설정된 VIP (HAProxy에서 사용)
역할 | 도메인 이름 | VIP IP 주소 | 비고 |
---|---|---|---|
API Server VIP | api.ttc.ibm.kr | 10.10.14.131 | Kubernetes API VIP |
Internal API VIP | api-int.ttc.ibm.kr | 10.10.14.132 | Bootstrap, Node Ignition |
Application VIP (HTTP/HTTPS) | *.apps.ttc.ibm.kr | 10.10.14.133 | Route 및 App 통신용 VIP |
1-3. 🔥 OpenShift 설치 시 방화벽 오픈 포트 정리
1. Bastion 서버
포트 | 프로토콜 | 방향 | 설명 |
---|---|---|---|
22 | TCP | Inbound | SSH 접속용 |
53 | TCP/UDP | Inbound | DNS (named 서비스) |
67 | UDP | Inbound | DHCP 서버 응답 (dhcpd 서비스) |
69 | UDP | Inbound | TFTP (PXE 부팅 시 필요, 선택사항) |
80 | TCP | Inbound | HTTP (httpd로 Ignition 파일 제공) |
443 | TCP | Inbound | HTTPS (optional, 주로 app route용) |
6443 | TCP | Inbound | Kubernetes API 서버 포워딩 (HAProxy) |
22623 | TCP | Inbound | MachineConfig API 포워딩 (HAProxy) |
2. Bootstrap 노드
포트 | 프로토콜 | 방향 | 설명 |
---|---|---|---|
22 | TCP | Inbound | SSH 접속용 |
6443 | TCP | Outbound | Kubernetes API 서버 연결 |
22623 | TCP | Outbound | Ignition config 서버 연결 |
80 | TCP | Outbound | HTTP (Ignition 파일 다운로드) |
443 | TCP | Outbound | HTTPS (Release image 다운로드) |
3. Master 노드
포트 | 프로토콜 | 방향 | 설명 |
---|---|---|---|
22 | TCP | Inbound | SSH 접속용 |
6443 | TCP | Inbound | Kubernetes API 통신 |
22623 | TCP | Outbound | MachineConfig 다운로드 |
2379-2380 | TCP | Inbound | etcd 클러스터 통신 (Master 간) |
10250 | TCP | Inbound | Kubelet API |
5000-6000 | TCP/UDP | Outbound | OpenShift 내부 통신 (Service NodePort) |
4. Worker 노드
포트 | 프로토콜 | 방향 | 설명 |
---|---|---|---|
22 | TCP | Inbound | SSH 접속용 |
10250 | TCP | Inbound | Kubelet API |
80 | TCP | Inbound | HTTP (Route로 트래픽 전달) |
443 | TCP | Inbound | HTTPS (Route로 트래픽 전달) |
5000-6000 | TCP/UDP | Outbound | OpenShift 내부 통신 (Service NodePort) |
✅ 추가 주의사항
- Bastion 서버에 기본적으로 ens192 인터페이스를 trusted zone에 추가해야 함
firewall-cmd --zone=trusted --add-interface=ens192 --permanent
- 포트 오픈 예시
firewall-cmd --zone=trusted --add-port=53/tcp --permanent
firewall-cmd --zone=trusted --add-port=53/udp --permanent
firewall-cmd --zone=trusted --add-port=67/udp --permanent
firewall-cmd --zone=trusted --add-port=80/tcp --permanent
firewall-cmd --zone=trusted --add-port=443/tcp --permanent
firewall-cmd --zone=trusted --add-port=6443/tcp --permanent
firewall-cmd --zone=trusted --add-port=22623/tcp --permanent
# 설정 반영
firewall-cmd --reload
- UPI 설치 시 디스크 포맷, 네트워크 설정 등 시스템 초기 설정이 필요하여 SELinux를 비활성화하는 것을 권장함.
sudo vi /etc/selinux/config SELINUX=disabled
2. Bastion 서버 구성
2-1. Bastion 서버 생성
Bastion 서버를 생성합니다. 서버는 RHEL8을 사용하고 있으며, 해당 서버에 DNS, Haproxy, DHCP, httpd를 구성할 예정입니다.
각 항목은 다음의 역할을 합니다.
- DNS(bind)
- Openshift 설치 시 api.ttc.ibm.kr, apps.ttc.ibm.kr 같은 DNS를 사용함. 다음과 같은 도메인을 관리하고 ingres router 등에 대한 레코드를 작성하기 위해 구성
- Httpd(Apache)
- Master, Worker 노드를 생성할 때 CoreOS를 설치하는데 ignition 파일을 읽어야 부팅이 가능함. 이를 웹서버를 통해 읽어 올 수 있도록 하기 위해 필요
- HA Proxy
- Openshift의 Control Plane(API 서버, MachineConfig Server)를 로드밸런싱하기 위해 필요
- DHCP
- PXE(Preboot Excution Environment) 부팅을 사용하여 IP를 자동으로 관리할 때 필요합니다. 현재 환경에서는 수동으로 IP를 할당할 예정이기 때문에 따로 필요하지 않습니다.
가상머신 생성 후 location, Disk Partion 등을 설정한 후 설치를 완료 합니다.
2-2. IP 할당
생성된 가상머신에 nmtui를 통해 IP를 할당합니다. 아래와 같이 IP를 할당하고 Gateway, DNS 주소를 입력합니다. 또한 설치 과정에서 발생할 수 있는 오류를 방지하기 위해 ipv6를 비활성화 하고 Automatically connect
를 설정하여 자동으로 연결할 수 있도록 설정합니다. 향후 Master,Worker 모두 동일한 방법으로 IP를 할당하지만 DNS서버만 bastion 서버 IP로 변경하여 구성합니다.
또한 Set Hostname
을 통해 호스트명을 정의합니다.
이후 IP를 확인하면 다음과 같이 정상적으로 할당된 것을 확인할 수 있습니다.
2-3. DNS 서버 구성
필요한 패키지(dns,haproxy,httpd)를 설치합니다.
dnf install -y dhcp-server bind bind-utils haproxy httpd wget tar unzip
/etc/named.conf 파일을 수정하여 dns 서버 설정을 진행합니다.
options {
listen-on port 53 { any; }; #OCP 노드들이 질의 가능하도록 any로 변경
listen-on-v6 port 53 { any; }; #IPv6는 사용하지 않지만 future-proof 차원 허용
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
secroots-file "/var/named/data/named.secroots";
recursing-file "/var/named/data/named.recursing";
allow-query { any; }; # 외부 질의 허용
recursion no; // OpenShift용 내부 DNS는 authoritative로 설정
dnssec-enable no;
dnssec-validation no;
managed-keys-directory "/var/named/dynamic";
pid-file "/run/named/named.pid";
session-keyfile "/run/named/session.key";
include "/etc/crypto-policies/back-ends/bind.config";
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "ttc.ibm.kr" IN {
type master;
file "ttc.ibm.kr.db";
allow-update { none; };
};
zone "14.10.10.in-addr.arpa" IN {
type master;
file "14.10.10.rev";
allow-update { none; };
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
option
블록내의 있는 부분은 전체 dns 서버의 설정을 관리하는 부분으로 보안과 외부 질의를 허용하는 부분을 수정하였습니다. 이후 Openshift 구성하는 zone은 Forward zone ttc.ibm.kr
과 Reverse Zone14.10.10.in-addr.arpa
로 이루어집니다. 설치 당시에는 Forward zone 설정만 해도 문제 없으나 운영 환경에서 인증,로깅시스템에서 Reverse Lookup을 시도하여 안정적인 운영을 위해 설정이 필요합니다.
#/var/named/ttc.ibm.kr.db
$TTL 1H
@ IN SOA bastion.ttc.ibm.kr. root.ttc.ibm.kr. (
2025042301 ; Serial
1H ; Refresh
15M ; Retry
1W ; Expire
1H ) ; Minimum TTL
IN NS bastion.ttc.ibm.kr.
bastion IN A 10.10.14.130
api IN A 10.10.14.131
api-int IN A 10.10.14.132
*.apps IN A 10.10.14.133
master0 IN A 10.10.14.134
master1 IN A 10.10.14.135
master2 IN A 10.10.14.136
worker0 IN A 10.10.14.137
worker1 IN A 10.10.14.138
worker2 IN A 10.10.14.139
api, api-int, apps 등은 IP를 분리 하지 않아도 되지만 용도와 환경에 따라 분리하여 트래픽을 받도록 설정이 필요합니다.
api
: Kubernetes 외부 API 접근(oc,kubectl,관리자 용도)api-int
: 클러스터 내부 통신 용도(kubelet 등의 컴포넌트)*.apps
: 사용자가 생성하는 유저 앱 (Ingress,Routes 사용)
reverse zone도 다음과 같이 작성합니다.
# /var/named/14.10.10.rev
$TTL 1H
@ IN SOA bastion.ttc.ibm.kr. root.ttc.ibm.kr. (
2025042501 ; Serial
1H ; Refresh
15M ; Retry
1W ; Expire
1H ) ; Minimum TTL
IN NS bastion.ttc.ibm.kr.
130 IN PTR bastion.ttc.ibm.kr.
131 IN PTR api.ttc.ibm.kr.
132 IN PTR api-int.ttc.ibm.kr.
133 IN PTR apps.ttc.ibm.kr.
134 IN PTR master0.ttc.ibm.kr.
135 IN PTR master1.ttc.ibm.kr.
136 IN PTR master2.ttc.ibm.kr.
137 IN PTR worker0.ttc.ibm.kr.
138 IN PTR worker1.ttc.ibm.kr.
139 IN PTR worker2.ttc.ibm.kr.
142 IN PTR bootstrap.ttc.ibm.kr.
다음과 같이 설정파일을 만든 후 적용 합니다. 또한 잘 설정되었는지 질의를 시도합니다.
#문법 검사
named-checkconf /etc/named.conf
named-checkzone ttc.ibm.kr /var/named/ttc.ibm.kr.db
named-checkzone 14.10.10.in-addr.arpa /var/named/14.10.10.rev
# 재시작
systemctl restart named
#Forward 조회 테스트
dig api.ttc.ibm.kr @127.0.0.1
dig api-int.ttc.ibm.kr @127.0.0.1
dig apps.ttc.ibm.kr @127.0.0.1
dig master0.ttc.ibm.kr @127.0.0.1
dig worker0.ttc.ibm.kr @127.0.0.1
#Reverse 조회 테스트
dig -x 10.10.14.131 @127.0.0.1
dig -x 10.10.14.132 @127.0.0.1
dig -x 10.10.14.137 @127.0.0.1
2-3. HAProxy 구성
HAproxy 설정에 필요한 구성은 다음과 같이 총 4개 입니다.
- API 통신: 클러스터 API 서버(6443)
- Machine Config: 설치 및 초기 부팅 설정용(22623)
- App Router HTTP : Openshift 앱용 Http 트래픽(80)
- APP Router HTTPS: Openshift 앱용 Https 트래픽(443)
- 다음과 같이
haprxoy.cfg
파일을 설정합니다.
frontend api
bind *:6443
default_backend api-backend
backend api-backend
balance roundrobin
server bootstrap 10.10.14.142:6443 check
server master0 10.10.14.134:6443 check
server master1 10.10.14.135:6443 check
server master2 10.10.14.136:6443 check
frontend mapi
bind *:22623
default_backend mapi-backend
backend mapi-backend
balance roundrobin
server bootstrap 10.10.14.142:22623 check
server master0 10.10.14.134:22623 check
server master1 10.10.14.135:22623 check
server master2 10.10.14.136:22623 check
frontend http
bind *:80
default_backend apps
frontend https
bind *:443
default_backend apps
backend apps
balance roundrobin
server worker0 10.10.14.137:443 check
server worker1 10.10.14.138:443 check
server worker2 10.10.14.139:443 check
이후 설정 적용을 위해 재시작합니다.
systemctl enable haproxy
systemctl restart haproxy
systemctl status haproxy
또한 Bastion에서 VIP를 사용할 수 있도록 IP를 추가합니다.
nmcli connection modify ens192 +ipv4.addresses 10.10.14.131/26
nmcli connection modify ens192 +ipv4.addresses 10.10.14.132/26
nmcli connection modify ens192 +ipv4.addresses 10.10.14.133/26
nmcli connection down ens192 && nmcli connection up ens192
### 2-4 Openshift-install & httpd 설정
`openshift-install` 을 설치 후 ignition 파일을 생성하여 httpd 서버에 업로드합니다. 해당 파일을 바탕으로 노드를 설치합니다.
2-4. Openshift-install & httpd 설정
Openshift-install CLI를 설치하고 설치에 필요한 Ignition 파일을 생성합니다. 이후 해당 파일을 httpd 서버에 업로드하여 각 노드에서 ignition 파일을 읽을 수 있도록 설정합니다.
curl -LO https://mirror.openshift.com/pub/openshift-v4/clients/ocp/4.17.5/openshift-install-linux.tar.gz
tar -xvzf openshift-install-linux.tar.gz
chmod +x openshift-install
mv openshift-install /usr/local/bin/
노드에 접속을 허용하기 위해 ssh-key 파일을 생성합니다.
ssh-keygen -t rsa -b 4096 -C "openshift-key" -N "" -f ~/.ssh/openshift_rsa
ignition 파일을 생성하기 위한 install-config.yaml 파일을 생성합니다. 위에서 생성한 openshift_rsa.pub 파일을 sshKey에 입력하고, pullSecret은 hybrid console에서 다운받아 입력하여 파일을 생성합니다.
apiVersion: v1
baseDomain: ibm.kr
metadata:
name: ttc
platform:
none: {}
controlPlane:
hyperthreading: Enabled
name: master
replicas: 3
compute:
hyperthreading: Enabled
name: worker
replicas: 3
pullSecret: '{"auths":{...}}' # Red Hat 인증용 Pull Secret
sshKey: 'ssh-rsa AAAA...'
이후 생성된 install-config.yaml 파일을 바탕으로 manifest 와 ignition 파일을 생성합니다.(install-config.yaml 파일이 위치한 곳에서 실행해야합니다.)
openshift-install create manifests --dir=./ttc
openshift-install create ignition-configs --dir=./ttc
이후 다음과 같이 ignition 파일과 auth 폴더가 생성된 것을 확인 할 수 있습니다.
[root@bastion ocp]# ls ttc/
auth bootstrap.ign master.ign metadata.json worker.ign
추가로 install-config.yaml 파일에서 마스터,노드의 수 뿐 아니라 네트워크,프록시, FIPs와 같은 보안 설정도 추가로 진행할 수 있습니다.
```yaml
#Network 설정 예시
networking:
networkType: OVNKubernetes
machineNetwork:
- cidr: 10.10.0.0/16
serviceNetwork:
- 172.30.0.0/16
clusterNetwork:
- cidr: 10.128.0.0/14
hostPrefix: 23
이후 생성된 ignition 파일을 httpd 서버에 업로드하여 외부에서 조회 할 수 있도록 설정합니다.
mkdir /var/www/html/ocp
cp ttc/*.ign /var/www/html/ocp/
chmod -R 755 /var/www/html/ocp
httpd 서버는 기본적으로 80포트를 사용하는데, haproxy 설치하면서 이미 사용하고 있기 때문에 8080포트로 변경하여 실행합니다.
#etc/httpd/conf/httpd.conf
Listen 8080
이후 재실행을 통해 설정을 적용하고 정상적으로 ignition 파일이 조회 되는지 확인합니다.
[root@bastion ocp]# curl http://10.10.14.130:8080/ocp/master.ign
{"ignition":{"config":{"merge":[{"source":"https://api-int.ttc.ibm.kr:22623/config/master"}]},"security":{"tls":{"certificateAuthorities":[{"source":"data:text/plain;charset=utf-8;base64,LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURFRENDQWZpZ0F3SUJBZ0lJRnpRbFJaL0M2MzR3RFFZSktvWklodmNOQVFFTEJRQXdKakVTTUJBR0ExVUUKQ3hNSmIzQmxibk5vYVdaME1SQXdEZ1lEVlFRREV3ZHliMjkwTFdOaE1CNFhEVEkxTURReU9EQXlNRFl4T0ZvWApEVE0xTURReU5qQXlNRFl4T0Zvd0pqRVNNQkFHQTFVRUN4TUpiM0JsYm5Ob2FXWjBNUkF3RGdZRFZRUURFd2R5CmIyOTBMV05oTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUFtRzVoS0p6SW9OZkEKcFY4YVNlWnpwOUROaERLcWtWWHNXVkx1Uklqd0JJb2pIbVU5d2ZxM21XemFXN2xsb1hwRGRacmZxRnpFZVZka
3. Bootstrap 구성
bootstrap 가상머신을 생성합니다. master와 동일한 구성에서 OS를 rhcos로 변경해서 생성합니다.
wget https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rhcos/4.16/4.17.3/rhcos-4.16.3-x86_64-metal.x86_64.raw.gz
wget https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rhcos/4.16/4.17.3/rhcos-4.16.3-x86_64-live.x86_64.iso
이후 가상머신을 실행시키면 다음과 같이 로그인 화면을 볼 수 있습니다.
이후 Bastion과 동일하게 nmtui를 통해 IP와 hostname을 설정합니다. Bastion과 다르게 DNS서버를 bastion 서버의 주소로 입력하여 내부 DNS서버를 바라볼 수 있도록 설정합니다.
이후 coreos-installer 커맨드를 통해 설치를 시작합니다. `-n `옵션을 통해 nmtui로 설정한 IP를 그대로 사용하도록 합니다.
sudo coreos-installer install /dev/sda --insecure-ignition -I http://10.10.14.130:8080/ocp/bootstrap.ign -n
다운로드가 완료되면 reboot을 통해 설치를 진행합니다. 정상적으로 진행 될 경우 다음과 같이 커널로그를 확인 할 수 있습니다.
설치가 완료되면 다음과 같은 화면을 확인 할 수 있습니다.
4. Master 노드 구성
Bootstrap 서버 구성이 완료되면 Master노드를 생성합니다. Bootstrap과 동일하게 마스터 노드 생성후 IP 할당한 후 `coreos-installer` 커맨드를 통해 실행합니다.
sudo coreos-installer install /dev/sda --insecure-ignition -I http://10.10.14.130:8080/ocp/master.ign -n
이후 reboot을 통해 설치를 진행합니다. 현 시점에서 bastion 노드에서 다음 커맨드를 통해 진행상황을 확인 할 수 있습니다.
openshift-install wait-for bootstrap-complete
아래와 같이 화면이 뜨고 커맨드도 실행이 잘 된다면 마스터 노드는 설치가 완료된거고 bootstrap노드를 삭제해도됩니다.
5. Worker 노드 구성
워커 노드도 마스터와 마찬가지로 생성 후 coreos-installer 커맨드를 통해 설치합니다. ignition 파일만 수정해서 설치를 진행합니다.
sudo coreos-installer install /dev/sda --inseucre-ignition --ignition-url=http://10.10.14.130:8080/ocp/worker.ign -n
이후 설치가 완료되면 oc 커맨드를 통해 CSR을 조회합니다.
oc --kubeconfig=./auth/kubeconfig get cs
이후 해당 CSR을 승인해 주면 노드가 조인이 완성됩니다.
oc --kubeconfig=./auth/kubeconfig adm certificate approve csr-rblmh
Pending된 CSR을 전부 승인하는 커맨드
oc --kubeconfig=./auth/kubeconfig get csr --no-headers | awk '/Pending/ {print $1}' | xargs oc --kubeconfig=./auth/kubeconfig adm certificate approve
6. 최종 접속 확인
echo 'export KUBECONFIG=/root/ocp/ttc/auth/kubeconfig' >> ~/.bash_profile
oc get nodes
이후 도메인 등록이나 로컬에서 /etc/hosts에 해당 webconsole 도메인 등록 후 접속하면 web-console에 접속하는 것을 확인 할 수 있습니다.
#/etc/hosts 예시
10.10.14.131 api.ttc.ibm.kr api-int.ttc.ibm.kr
10.10.14.133 console-openshift-console.apps.ttc.ibm.kr oauth-openshift.apps.ttc.ibm.kr
'Kubernetes' 카테고리의 다른 글
서비스 메쉬란?(Linkerd vs Istio) (2) | 2024.04.11 |
---|---|
Kubernetes Pod의 컨테이너는 어떻게 Localhost로 통신 할 수 있을까? (0) | 2024.02.04 |
Kubernetes CSI Driver 란? (1) | 2024.01.21 |
Github Action/ Argo CD를 이용한 CI/CD 구성 (0) | 2024.01.14 |
ETCD MultiMaster Backup/Restore(CronJob 생성) (1) | 2023.11.14 |