본문 바로가기

카테고리 없음

Rocky에 Kubernetes 설치하기 (kubeadm)

반응형

 

Rocky가 깔려있는 버츄얼 머신이 있다고 가정한 다음 진행함

Virtual Box에 Rocky version 8이 이미 설치되어있음. 이를 복제하여 가상 서버를 구성할 예정임

 

 

1. Rocky 우클릭 -> 복제 -> MAC Address Policy = 모든 네트워크 어댑터의 새 MAC 주소 생성 -> 다음 -> 완전한 복제

2. 아래처럼 복제가 완료됨을 알 수 있음

 

3. 복제 되었으면 서버를 실행시키자.
master 및 worker 에 공통적으로 설정되어 있어야 하는 부분을 한번에 설정한 다음,
해당 서버를 다시 복제하여 다른 서버를 생성할 것이다.

우리가 공통적으로 설정해줘야 하는 부분은 다음과 같다.
- 방화벽 및 리눅스 보안 프로그램 종료 (보안 프로그램이 쿠버 실행을 차단하여 정상적으로 작동하지 않음을 미연에 방지)
- 메모리 스왑 종료 (idle한 자원을 활용하기 위한 방법이지만 ,쿠버에선 정상작동 안될 가능성이 있어서 꺼놓음)
- 도메인 및 라우팅 설정 ( node끼리 통신하기 위해서 서로 알고있어야하며 iptable 라우팅 설정을 따르도록 해야함)
- 쿠버네티스 repository 추가 (yum으로 쿠버네티스 파일을 다운로드받을 때, 해당 파일을 들고 있는 저장소를 추가해줌)
- yum update (yum의 정상동작을 위해 update)

 

4. root로 접속 (시스템 설정을 건드려야 하므로 root)

[kcy@k8s-orche ~]$ su - root
Password: 

5. selinux 종료
[root@k8s-orche ~]# sudo setenforce 0
[root@k8s-orche ~]# sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
[root@k8s-orche ~]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted



6. 방화벽 종료 (실제 보안이 중요한 서버에선 종료가 아닌, 방화벽 정책을 일일이 지정해줘야 한다. 나는 학습용이라 패스)
[root@k8s-orche ~]# systemctl stop firewalld && sudo systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

7. SWAP 종료
[root@k8s-orche ~]# swapoff -a
[root@k8s-orche ~]# sed -i -e '/swap/d' /etc/fstab
[root@k8s-orche ~]# 
[root@k8s-orche ~]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Tue May 16 14:19:29 2023
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/rl-root     /                       xfs     defaults        0 0
UUID=c3308589-0f75-4150-90e3-efef2a77f27e /boot                   xfs     defaults        0 0

8. 도메인 설정
- 쿠버네티스는 각 노드들끼리 통신을 해야한다.
- 미리 노드의 이름과 IP를 이 곳에서 지정시켜줌
[root@k8s-orche etc]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.56.101 k8s-orche
192.168.56.110 k8s-work1
192.168.56.111 k8s-work2
192.168.56.112 k8s-work3

 

8. 쿠버네티스 repository 추가하기
[root@k8s-orche sysconfig]# vi /etc/yum.repos.d/kubernetes.repo
[root@k8s-orche sysconfig]# cat /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl= https://packages.cloud.google.com/yum/repos/kubernetes-el7-$basearch 
enabled=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpghttps://packages.cloud.google.com/yum/doc/rpm-package-key.gpg 
EOF

 

9. yum 업데이트

[root@k8s-orche sysconfig]# yum update
... 여러가지 막 업데이트 됨 ...
Complete!

 

 

 

반응형