이세개발
article thumbnail

 

기본적인 ansible이 구현이 되었으면 kubespray를 설치해보도록 한다.

python, pip, git

sudo apt update
sudo apt install -y python3 python3-pip git

git clone

적당한 장소에 kubespray git을 clone 해오도록 한다.

git clone -b v2.21.0 https://github.com/kubernetes-sigs/kubespray.git

## 현재 릴리즈 최신버전인 2.21.0 으로 진행하는데 관련한 요구사항들은 

https://github.com/kubernetes-sigs/kubespray/tree/v2.21.0

 

GitHub - kubernetes-sigs/kubespray: Deploy a Production Ready Kubernetes Cluster

Deploy a Production Ready Kubernetes Cluster. Contribute to kubernetes-sigs/kubespray development by creating an account on GitHub.

github.com

에서 확인해 볼 수 있다.

마음같아선 kubernetes v1.26.3 까지 지원하는 master브랜치의 코드를 사용하고싶지만 꼬이거나해서 인스턴스를 삭제하고 다시만드는것도 꽤 일이므로 제일 최신의 릴리즈 버전을 사용하기로 하였다.

kubespray 설치

기본 설치

cd kubespray

## 왜인지 모르겠지만 앤서블을 pip로 한번 더 설치해주어야한다.
sudo pip install --upgrade pip
sudo pip install --force-reinstall ansible ansible-core
sudo pip install --upgrade jinja2
sudo pip install -r requirements.txt

인벤토리 복사 및 수정

cp -rfp inventory/sample inventory/mycluster
vi inventory/mycluster/inventory.ini
[all]
control_plane ansible_host=152.67.196.205 ip=10.0.0.144 etcd_member_name=etcd1
node1 ansible_host=138.2.113.197 ip={내부ip} etcd_member_name=etcd2
node2 ansible_host=138.2.112.219 ip=10.0.0.242 etcd_member_name=etcd3

# ## configure a bastion host if your nodes are not directly reachable
# [bastion]
# bastion ansible_host=x.x.x.x ansible_user=some_user

[kube_control_plane]
control_plane
# node1
# node2
# node3

[etcd]
control_plane
node1
node2
# node1
# node2
# node3

[kube_node]
node1
node2
# node2
# node3
# node4
# node5
# node6

[calico_rr]

[k8s_cluster:children]
kube_control_plane
kube_node
calico_rr

 

ansible-playbook -i inventory/mycluster/inventory.ini -become --become-user={user} cluster.yml

 

profile

이세개발

@print(name)

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!