Skip to content

Infrastructure as Code to Install Kubernetes using Vagrant, Ansible and Kubespray for dev, learning or lecture

License

Notifications You must be signed in to change notification settings

rayshoo/vansible_with_kubespray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

91 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Vansible with Kubespray

์ด ํ”„๋กœ์ ํŠธ๋Š” ๋”์ด์ƒ ๊ด€๋ฆฌ ๋˜์ง€ ์•Š๊ธฐ์— ์ถ”์ฒœ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋Œ€์‹  Vansinetes ํ”„๋กœ์ ํŠธ๋ฅผ ์‚ฌ์šฉํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.(21.06.23)
This project is not recommended as it is no longer maintained. Use the Vansinetes project instead.(21.06.23)


์†Œ๊ฐœ

์‰ฝ๊ณ  ๋น ๋ฅธ Docker+Kubernetes ๊ฐœ๋ฐœ, ํ•™์Šต ๋ฐ ๊ฐ•์˜ ํ™˜๊ฒฝ ๊ตฌ์ถ•์„ ์œ„ํ•ด ์„ค๊ณ„๋œ
Vagrant, Ansible, Kubespray๋ฅผ ์‚ฌ์šฉํ•œ IaC(Infra as Code) ๋„๊ตฌ

์‚ฌ์šฉ ์ „ ํ•„์š” ์กฐ๊ฑด

์‚ฌ์šฉ์ž์˜ ํ™˜๊ฒฝ์— Vagrant์™€ VirtualBox๊ฐ€ ๋ฏธ๋ฆฌ ์„ค์น˜๋˜์žˆ์–ด์•ผ ํ•œ๋‹ค.

์‚ฌ์šฉ ๋ฐฉ๋ฒ•

1. .env ํŒŒ์ผ์„ ๊ตฌ์„ฑํ•œ๋‹ค.

2. kubespray๋ฅผ ์ˆ˜๋™์œผ๋กœ ๊ตฌ์„ฑํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด, CLUSTER_STRUCTURE_AUTO_CREATE=no์œผ๋กœ ์˜ต์…˜์„ ์„ค์ •ํ•˜๊ณ , cluster folder ๋ฅผ ๋ชฉ์ ์— ๋งž๊ฒŒ ๊ตฌ์„ฑํ•œ๋‹ค.

3. Vagrantfile์ด ์œ„์น˜ํ•œ ๊ฒฝ๋กœ์—์„œ ํ•˜๋‹จ์˜ ๋ช…๋ น์–ด๋ฅผ bash ์‰˜์— ์ž…๋ ฅํ•œ๋‹ค.

$ vagrant plugin install vagrant-env
$ vagrant up --color
$ vagrant ssh $(vagrant status | tail -5 | sed -n '1p' | awk '{ print $1}') // ๊ธฐ๋ณธ ์„ค์ • $ vagrant ssh m1

์ฐธ๊ณ  ์‚ฌํ•ญ

๋ช‡ ๊ฐ€์ง€ alias๊ฐ€ ์ž๋™ ๋“ฑ๋ก๋œ๋‹ค.

alias ans='ansible'
alias anp='ansible-playbook'
alias k='kubectl'

๋ฌธ์ œ ํ•ด๊ฒฐ

1. ํ”„๋กœ๋น„์ „์ด ์‹คํŒจํ•œ ๊ฒฝ์šฐ vagrant provision ๋ช…๋ น์–ด๋กœ ์ด๋ฅผ ๋‹ค์‹œ ์‹œ๋„ํ•œ๋‹ค.

2. vagrant destroy --force && vagrant up ์™€ ๊ฐ™์ด ๊ฐ€์ƒ๋จธ์‹ ์„ ์‚ญ์ œํ•˜๊ณ  ๋‹ค์‹œ ์ƒ์„ฑํ• ๋•Œ,
๊ฐ„ํ˜น ์ •์ƒ์ ์œผ๋กœ ์‚ญ์ œ๋œ ๊ฒƒ์œผ๋กœ ๋ณด์ด์ง€๋งŒ ์‹ค์ œ๋กœ๋Š” ์‚ญ์ œ๋˜์ง€ ์•Š์•„์„œ ์‹คํŒจํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์œผ๋ฏ€๋กœ ๋ฒ„์ถ”์–ผ ๋จธ์‹  ํ™˜๊ฒฝ์„ค์ •์˜ ๊ฐ€์ƒ๋จธ์‹  ํŒŒ์ผ ์ €์žฅ ๊ฒฝ๋กœ์—์„œ ์ด๋ฅผ ์ง์ ‘ ํ™•์ธํ•ด์„œ ์‚ญ์ œ ํ›„ ๋‹ค์‹œ ์‹œ๋„ํ•œ๋‹ค.

3. kubernetes ํ”„๋กœ๋น„์ „์ด ๊ณ„์† ์‹คํŒจํ•˜๋Š” ๊ฒฝ์šฐ, ๋‹ค์Œ์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•˜์—ฌ ๋‹ค์‹œ ์‹œ๋„ํ•œ๋‹ค.

// host machine
$ vagrant ssh $(vagrant status | tail -5 | sed -n '1p' | awk '{ print $1}') // ๊ธฐ๋ณธ ์„ค์ •, $ vagrant ssh m1

// guest machine
$ cd environment/kubernetes && ansible-playbook -i inventory.ini kubespray/reset.yml -v --become --become-user=root
$ yes
$ exit

// host machine
$ vagrant provision $(vagrant status | tail -5 | sed -n '1p' | awk '{ print $1}') // ๊ธฐ๋ณธ ์„ค์ •, $ vagrant provision m1

Introduce

IaC (Infra as Code) tool designed for easy and fast Docker + Kubernetes development, learning, and lecture environment construction
with using Vagrant, Ansible, Kubespray.

Requirements before use

Vagrant and VirtualBox must be installed in the user's environment in advance.

How to Use

1. Configure the .env file.

2. If you want to configure kubespray with manually, set CLUSTER_STRUCTURE_AUTO_CREATE=no then configure the cluster folder.

3. Type the following command into the bash shell in the path where the Vagrantfile is located.

$ vagrant plugin install vagrant-env
$ vagrant up --color
$ vagrant ssh $(vagrant status | tail -5 | sed -n '1p' | awk '{ print $1}') // By default, $ vagrant ssh m1

Note

Several aliases are automatically registered.

alias ans='ansible'
alias anp='ansible-playbook'
alias k='kubectl'

Trouble Shooting

1. If provisioning fails, try again with the vagrant provision command.

2. When deleting and recreating a virtual machine like vagrant destroy --force && vagrant up,
it appears to have been deleted normally, but it is not actually deleted once at a time. Check it yourself, delete it, and try again.

3. If kubernetes provisioning continues to fail, try again by entering the following command.

// host machine
$ vagrant ssh $(vagrant status | tail -5 | sed -n '1p' | awk '{ print $1}') // By default, $ vagrant ssh m1

// guest machine
$ cd environment/kubernetes && ansible-playbook -i inventory.ini kubespray/reset.yml -v --become --become-user=root
$ yes
$ exit

// host machine
$ vagrant provision $(vagrant status | tail -5 | sed -n '1p' | awk '{ print $1}') // By default, $ vagrant provision m1

๋ผ์ด์„ผ์Šค, License


๊ฐœ์ธ ๋ธ”๋กœ๊ทธ, Personal Blog


๊ณต์‹ ๋ฌธ์„œ, Official Documents


์ฐธ๊ณ ํ•œ ์ฑ…, Book referenced

์นด์™€๋ฌด๋ผ ์„ธ์ด๊ณ ,๊ธฐํƒ€๋…ธ ํƒ€๋กœ์˜ค,๋‚˜์นด์•ผ๋งˆ ํƒ€์นดํžˆ๋กœ,๊ตฌ์‚ฌ์นด๋ฒ  ํƒ€์นด์•„ํ‚ค,๋ฆฌ์ฟ ๋ฅดํŠธ ํ…Œํฌ๋†€๋กœ์ง€
๋ฒˆ์—ญ ์–‘์„ฑ๊ฑด,์˜์ง„๋‹ท์ปด(2020),IT ์šด์šฉ ์ฒด์ œ ๋ณ€ํ™”๋ฅผ ์œ„ํ•œ ๋ฐ๋ธŒ์˜ต์Šค

์ •์›์ฒœ,๊ณต์šฉ์ค€,ํ™์„์šฉ,์ •๊ฒฝ๋ก,๋™์–‘๋ถ์Šค(2020),์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ์ž…๋ฌธ


์ฐธ๊ณ ํ•œ ๊ณณ, Site referenced

Shell script

ํ•ธ๋“œ์˜ค๋ฒ„,์ผ์ƒ ๋ฉ”๋ชจ์žฅ
์–‘ํ–„์ฐŒ๊ฐ€ ๋งŒ๋“œ๋Š” ์„ธ์ƒ

ruby

์กฐ๋ฌตํ—Œ,Ruby ์ฒ˜์Œ ๋ฐฐ์šฐ๊ธฐ:๋ฐ์ดํ„ฐํƒ€์ž…
yundream,Joinc

vagrant

asdf,๋…ธ๋ ฅ ์ด๊ธฐ๋Š” ์žฌ๋Šฅ ์—†๊ณ  ๋…ธ๋ ฅ ์™ธ๋ฉดํ•˜๋Š” ๊ฒฐ๊ณผ๋„ ์—†๋‹ค
YOUNG.K

ansible

์„ธ๋ชจ๋ฐ
Sentimental Programmer
๋ถ€๋“ค์žŽ์˜ ์ด๊ฒƒ์ €๊ฒƒ
mydailytutorials,Working with Environmentโ€‹ Variables in Ansible
How to create a file in ansible

python j2 template

Python2.net

kubespray

๋ธŒ๋žœ๋“ ์˜ ๋ธ”๋กœ๊ทธ
alice_k106๋‹˜์˜ ๋ธ”๋กœ๊ทธ
teamsmiley ๋ธ”๋กœ๊ทธ

serverspec

Tunelinux home
Daegwon Nacyot Kim,44BITS

lecture

์กฐํ›ˆ,๋‹ค์–‘ํ•œ ํ™˜๊ฒฝ์„ ์•ค์„œ๋ธ”(Ansible)๋กœ ๊ด€๋ฆฌํ•˜๊ธฐ with ๋ฒ ์ด๊ทธ๋ŸฐํŠธ(Vagrant)

git repository

kairen/kubeadm-ansible
kubernetes-sigs/kubespray
junegunn/vim-plug
pearofducks/ansible-vim
tpope/vim-pathogen
chase/vim-ansible-yaml
telus/ansible-motd

About

Infrastructure as Code to Install Kubernetes using Vagrant, Ansible and Kubespray for dev, learning or lecture

Topics

Resources

License

Stars

Watchers

Forks