OKD - on openstack
0. 사양
설치 버전 : okd 4.13.0.- 9.30
Instance Flavor : VCPUs 6, RAM 24GB, DISK 100GB, Ephemeral DISK 10GB, Swap 0MB
최소 Flavor 사양 : VCPUs 4, RAM 16GB, DISK 100GB
https://github.com/okd-project/okd/releases/tag/4.13.0-0.okd-2023-09-30-084937
1. 준비단계
0. openstack 설정
- 값을 -1로 설정하여 이 설치에 사용할 프로젝트에 대한 다음 할당량 제한을 제거
openstack quota set --cores -1 PROJECT_NAME
openstack quota set --ram -1 PROJECT_NAME
- floating ip 4개 생성
openstack floating ip create --description "API okd test cluster" External
openstack floating ip create --description "APPS okd test cluster" External
.
.
.
192.168.100.160 APPS_FLOATING_IP > 자동으로 10.0.0.5와 연결
192.168.100.161 API_FLOATING_IP > 자동으로 10.0.0.7과 연결
192.168.100.162 API_FLOATING_IP_2 > 생성된 master-0 인스턴스에 배정할 용도
192.168.100.163 APPS_FLOATING_IP_2 > 생성된 worker-0 인스턴스에 배정할 용도
- DNS 변경 - mass controller web
BOOTSTRAP_IP bootstrap.okd.test
API_FLOATING_IP api.okd.test
API_FLOATING_IP api-int..okd.test
APPS_FLOATING_IP grafana-openshift-monitoring.apps.okd.test
APPS_FLOATING_IP prometheus-k8s-openshift-monitoring.apps.okd.test
APPS_FLOATING_IP oauth-openshift.apps.okd.test
APPS_FLOATING_IP console-openshift-console.apps.okd.test
APPS_FLOATING_IP integrated-oauth-server-openshift-authentication.apps.okd.test
- bootstrap ip : “openshift-install create cluster 진행 한 뒤, 는 bootstrap 인스턴스가 실행 된 후에 배정받은 ip를 dns에 입력해준다. 마스터 0, 1, 2 인스턴스가 생성된 다음으로 생성된다.
- 설치 진행 중에 DNS를 알맞게 수정해주는 것이 중요하다.
1. client와 openshift-install 다운로드
- 폴더 생성
mkdir ~/okd/ && cd ~/okd/
- 다운로드
wget https://github.com/okd-project/okd/releases/download/4.13.0-0.okd-2023-09-30-084937/openshift-client-linux-4.13.0-0.okd-2023-09-30-084937.tar.gz
wget https://github.com/okd-project/okd/releases/download/4.13.0-0.okd-2023-09-30-084937/openshift-install-linux-4.13.0-0.okd-2023-09-30-084937.tar.gz
- 압축 파일 해제
tar -zxvf openshift-client-linux-*.tar.gz
tar -zxvf openshift-install-linux-*.tar.gz
- 바이너리를 PATH로 이동
sudo mv kubectl oc openshift-install /usr/local/bin/
- 경로 내보내기
echo "export PATH=\$PATH:/usr/local/bin" | sudo tee -a /etc/profile
source /etc/profile
- 설치 확인
test@maascontroller:~$ oc version
W1010 16:12:52.839669 2401167 loader.go:222] Config not found: /home/test/okd/install-directory3/auth/kubeconfig
Client Version: 4.13.0-0.okd-2023-09-30-084937
Kustomize Version: v4.5.7
test@maascontroller:~$ openshift-install version
openshift-install 4.13.0-0.okd-2023-09-30-084937
built from commit 7cbe79cbc9a8704552b95c96721b7c73e0d5e552
release image quay.io/openshift/okd@sha256:fc0dd43b87942f40d7eec16782ca2965199ced131906405127837884b5342b92
release architecture amd64
test@maascontroller:~$
2. ssh 시크릿 준비
- ssh 키 생성
# ssh-keygen -q -N ""
Enter file in which to save the key (/root/.ssh/id_rsa):
3. 풀시크릿 준비
- fake key : 현재 설치 okd 는 fakekey로 설치했다.
{"auths":{"fake":{"auth":"aWQ6cGFzcwo="}}}
풀시크릿을 사용할 경우 유효기간인 24시간 내, workernode구성까지 완료해야 한다.
2. 설치
1. clouds.yaml 생성
- clouds.yaml
# This is a clouds.yaml file, which can be used by OpenStack tools as a source
# of configuration on how to connect to a cloud. If this is your only cloud,
# just put this file in ~/.config/openstack/clouds.yaml and tools like
# python-openstackclient will just work with no further config. (You will need
# to add your password to the auth section)
# If you have more than one cloud account, add the cloud entry to the clouds
# section of your existing file and you can refer to them by name with
# OS_CLOUD=openstack or --os-cloud=openstack
clouds:
openstack:
auth:
auth_url: https://192.168.100.124:5000/v3
username: "testadmin"
password: "admin"
project_id: ea3626d7c5654450ac4a314ab26920aa
project_name: "k8s"
user_domain_name: "test"
region_name: "RegionOne"
interface: "public"
identity_api_version: 3
cacert: "/home/test/snap/openstackclients/common/root-ca.crt"
- 생성한 clouds.yaml 이 있는 경로에서 아래 명령어를 실행하여 install-config.yaml을 생성한다.
openshift-install create install-config --dir ~/okd/install-directory
? SSH Public Key /root/.ssh/id_okd.pub
? Platform openstack
? Cloud openstack
? ExternalNetwork External
? APIFloatingIPAddress 192.168.100.161
? FlavorName test.medium
? Base Domain test
? Cluster Name okd
? Pull Secret [? for help] {"auths":{"fake":{"auth":"aWQ6cGFzcwo="}}}
2. 생성된 install-config.yaml 편집
변경 사항
- 보안 그룹 uuid 추가 - platform.openstack,additionalSecurityGroupIDs
- externalDNS: - 192.168.100.10 ( mass web ip 추가)
install-config.yaml
additionalTrustBundlePolicy: Proxyonly
apiVersion: v1
baseDomain: test
compute:
- architecture: amd64
hyperthreading: Enabled
name: worker
platform:
openstack:
additionalSecurityGroupIDs:
- deba1502-318b-42e1-9d2d-db509ae8bcd7
type: ""
replicas: 3
controlPlane:
architecture: amd64
hyperthreading: Enabled
name: master
platform:
openstack:
additionalSecurityGroupIDs:
- deba1502-318b-42e1-9d2d-db509ae8bcd7
type: ""
replicas: 3
metadata:
creationTimestamp: null
name: okd
networking:
clusterNetwork:
- cidr: 10.128.0.0/14
hostPrefix: 23
machineNetwork:
- cidr: 10.0.0.0/16
networkType: OVNKubernetes
serviceNetwork:
- 172.30.0.0/16
platform:
openstack:
apiFloatingIP: 192.168.100.161
apiVIPs:
- 10.0.0.5
cloud: openstack
defaultMachinePlatform:
type: test.medium
externalDNS:
- 192.168.100.10
externalNetwork: external
ingressFloatingIP: 192.168.100.160
ingressVIPs:
- 10.0.0.7
publish: External
pullSecret: '{"auths":{"fake":{"auth":"aWQ6cGFzcwo="}}}'
sshKey: |
ssh-rsa AB3NzaC1ycC .....
주요 파라미터 값
clusterNetwork: 구축하는 k8s 클러스터 환경에서 생성하는 pod들의 네트워크 대역
machineNetwork: 생성 인스턴스가 서로 소통하는 내부 네트워크 대역
networkType: OVNKubernetes
OpenShiftSDN 다음으로 나온 네트워크 방식으로 4.6 버전 부터 해당 설정을 OVNKubernetes 으로 지정하는 것으로 공식문서에서 추천하고 있다.
serviceNetwork: 구축하는 k8s 환경에 띄우는 service들의 네트워크 대역
3. 설치
openshift-install create cluster --dir ~/okd/install-directory/ --log-level=debug
- 설치 진행 시, 작성했던 install config 파일이 사라지니 미리 백업 할 것
- 백업 하는 것을 잊고 이미 실행했다면 설치 중 install-config 명령어를 다시 입력해서 진행 중인 install-config를 복원할 수 있다.
openshift-install create install-config
3. 설치 중
1. 로그 확인
- 설치가 시작되면, master 0, master 1, master 2 가 생성되고 부트스트랩 인스턴스가 생성된다. 부트스트랩 인스턴스에 임의의 새로운 floating ip 가 배정 되는데 이를 DNS에 지정해줘야 한다.
192.168.100.xxx bootstrap.okd.test
- 부트스트랩에 floatingIP로 접속해서 로그를 확인 할 수 있다.
ssh core@BOOTSTRAP_IP
journalctl -b -f -u release-image.service -u bootkube.service
- 기동된 인스턴스에 접속은 아래처럼 mass> floatingIP > 내부 ip (10.x.x.x)를 통해 접속 가능하다.
ssh -J core@192.168.100.184 core@10.0.2.104
exit
- 각 인스턴스에 접속해보고 부팅과정에서 failed 된 부분이 있는지 확인하고
reset
해준다. 주로 기동 안되는 부분이 hostname, ssh 관련 서비스인데, 이 부분이 오류가 있으면 인스턴스 간 소통에 문제가 있어서 오류가 날 수 있다.
sudo systemctl reset-failed
sudo systemctl list-units --state=failed
- 각 인스턴스에 뜬 pod를 확인하려면, 아래 명령어로 확인 할 수 있다.
sudo crictl ps
2. bootstrap 설치 확인 및 DNS 수정
- openshift-install을 시작한 곳에서, 중간에 api.okd.test:6443으로 호출하다가 에러가 나며 로그가 끝나는 경우가 있다. 그럴 때는 아래 명령어로 부트스트랩 시작이 완료 될 때까지의 로그를 다시 살펴볼 수 있다. 이 호출 에러가 나더라도 부트스트랩에서는 설치 과정이 진행되고 있으니 부트스트랩 인스턴스에서 동작 로그를 계속 확인한다.
openshift-install --dir=install_dir/ wait-for bootstrap-complete --log-level=debug
- 3개의 worker 인스턴스가 모두 기동 완료 된 후 mass에서는 api, 부트스트랩에서는 api-int를 찾고 있다고 로그에 뜨면, 미리 생성해 놓은 두 floating ip(192.168.100.162, 192.168.100.163)를 인스턴스에 붙이고, DNS를 수정해준다.
인스턴스에 floatingIP 연결
192.168.100.162 ------ master-0
192.168.100.163 ------ worker-0 (worker 중 하나)
# bootstrap과 master-0 인스턴스에 각각 접속해서
# sudo crictl ps | grep kube-apiserver 로
# bootstrap에 기동되어 있던 임시 kube-apiserver가 사라졌는지,
master-0에 kube-apiserver pod가 기동되었는지를 확인 할 수 있다.
수정 전
192.168.100.161 api.okd.test
192.168.100.161 api-int..okd.test
192.168.100.160 grafana-openshift-monitoring.apps.okd.test
192.168.100.160 prometheus-k8s-openshift-monitoring.apps.okd.test
192.168.100.160 oauth-openshift.apps.okd.test
192.168.100.160 console-openshift-console.apps.okd.test
192.168.100.160 integrated-oauth-server-openshift-authentication.apps.okd.test
수정 후
192.168.100.162 api.okd.test
192.168.100.162 api-int..okd.test
192.168.100.163 grafana-openshift-monitoring.apps.okd.test
192.168.100.163 prometheus-k8s-openshift-monitoring.apps.okd.test
192.168.100.163 oauth-openshift.apps.okd.test
192.168.100.163 console-openshift-console.apps.okd.test
192.168.100.163 integrated-oauth-server-openshift-authentication.apps.okd.test
- bootstrap이 완료되었다고 로그를 확인 한 뒤에는 bootstrap이 자동으로 삭제된다.
time="2023-10-10T17:55:34+09:00" level=debug msg="Using Install Config loaded from state file"
time="2023-10-10T17:55:34+09:00" level=info msg="Waiting up to 30m0s (until 6:25PM) for bootstrapping to complete..."
time="2023-10-10T17:55:34+09:00" level=debug msg="Bootstrap status: complete"
time="2023-10-10T17:55:34+09:00" level=info msg="Destroying the bootstrap resources..."
3. 설치 완료
- 로그를 확인하고, 해당 로그를 저장해 둔다.
DEBUG Cluster is initialized
INFO Checking to see if there is a route at openshift-console/console...
DEBUG Route found in openshift-console namespace: console
DEBUG OpenShift console route is admitted
INFO Install complete!
INFO To access the cluster as the system:admin user when using 'oc', run 'export KUBECONFIG=/home/test/okd/install-directory/auth/kubeconfig'
INFO Access the OpenShift web-console here: https://console-openshift-console.apps.test.test
INFO Login to the console with user: "kubeadmin", and password: "yiQn9-jgxuH-bYbyi-Sj39w"
DEBUG Time elapsed per stage:
DEBUG Bootstrap Destroy: 25s
DEBUG Cluster Operators: 9m21s
INFO Time elapsed: 9m46s
4. 설치 후
1. 웹 콘솔
- 설치가 완료된 후 출력된 사용자 이름과 비밀번호를 사용해서 로그인 한다.
- 콘솔 대시보드 주소: https://console-openshift-console.apps.okd.test
- 비밀번호를 저장하는 것을 잊은 경우 비밀번호는 자동으로 생성되는
auth
디렉터리에서 확인할 수 있다. - 웹에 접속 하려면, C:\Windows\System32\drivers\etc 에 있는 hosts 파일에도 ip 등록을 해줘야 한다. (관리자 권한으로 실행하여 수정)
192.168.100.163 console-openshift-console.apps.okd.test
192.168.100.163 oauth-openshift.apps.okd.test
2. OC client
- oc client는 완료 로그를 참고해서 KUBECONFIG 를 export 한 뒤, 사용할 수 있다.
DEBUG Cluster is initialized
INFO Checking to see if there is a route at openshift-console/console...
DEBUG Route found in openshift-console namespace: console
DEBUG OpenShift console route is admitted
INFO Install complete!
INFO To access the cluster as the system:admin user when using 'oc', run 'export KUBECONFIG=/home/test/okd/install-directory/auth/kubeconfig'
INFO Access the OpenShift web-console here: https://console-openshift-console.apps.okd.test
INFO Login to the console with user: "kubeadmin", and password: "yiQn9-jgxuH-bYbyi-Sj39w"
DEBUG Time elapsed per stage:
DEBUG Bootstrap Destroy: 25s
DEBUG Cluster Operators: 9m21s
INFO Time elapsed: 9m46s
로드
export KUBECONFIG=/home/test/okd/install-directory/auth/kubeconfig
oc 명령어
- 노드가 Ready 상태인지 확인
oc get nodes -w
- 상태 확인
$ oc status
$ oc get clusteroperator
$ oc get clusterversion
- 보류중(Pendign)인 csr 이 있는 지 확인하고 승인
oc get csr
또는
oc get csr | grep Pending
oc get csr -o name | xargs oc adm certificate approve
- 로그인
oc login --username=kubeadmin --password=yiQn9-jgxuH-bYbyi-Sj39w
- 로그인 확인
oc whoami
- 전체 pod 조회
oc get pod -A -o wide
- 기본 수신 라우터 재기동 (필요 시)
oc -n openshift-ingress get pod -o json |
jq -r '.items[].metadata.name' |
xargs oc -n openshift-ingress delete pod
- 노드 로그 확인
oc adm node-logs --role=master -u kubelet | grep Error
5. 삭제
openshift-install destroy cluster --dir ~/okd/install-directory/ --log-level=info
'Container & Orchestration > OKD' 카테고리의 다른 글
OKD - baremetal (0) | 2025.02.11 |
---|---|
OKD Dashboard 이용해서 Helm Release 쉽게 진행하기 (0) | 2025.02.07 |
okd 명령어 (0) | 2025.01.30 |