본문 바로가기

리눅스

[kubernetes] minikube를 이용한 kubernetes 클러스터 배포

728x90

minikube를 이용한 kubernetes 클러스터 배포

minikube

 - kubernetes cluster 구성 도구

1. KVM install
https://help.ubuntu.com/community/KVM/Installation

sudo apt-get install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
sudo adduser `id -un` libvirt
sudo adduser `id -un` kvm
sudo adduser `id -un` libvirt-qemu
sudo reboot
systemctl is-active libvirtd

 

2. minikube install
https://minikube.sigs.k8s.io/docs/start/

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
minikube version
$ minikube version
minikube version: v1.27.0
commit: 4243041b7a72319b9be7842a7d34b6767bbdac2b

kubectl 다운로드 및 설치

- https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/

curl -LO https://dl.k8s.io/release/v1.22.10/bin/linux/amd64/kubectl
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl version
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.10", GitCommit:"eae22ba6238096f5dec1ceb62766e97783f0ba2f", GitTreeState:"clean", BuildDate:"2022-05-24T12:56:35Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.10", GitCommit:"eae22ba6238096f5dec1ceb62766e97783f0ba2f", GitTreeState:"clean", BuildDate:"2022-05-24T12:50:52Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}
$ kubectl version --client
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.10", GitCommit:"eae22ba6238096f5dec1ceb62766e97783f0ba2f", GitTreeState:"clean", BuildDate:"2022-05-24T12:56:35Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}

kubectl 자동 완성 활성화(kubectl autocompletion)

echo 'source <(kubectl completion bash)' >>~/.bashrc
exec bash

minikube start

minikube start --driver=kvm2 --cpus=4 --memory=4096 --kubernetes-version=1.22.10

$ minikube node list
minikube	192.168.39.39

minikube node add

minikube node add

$ minikube node list
minikube	192.168.39.39
minikube-m02	192.168.39.167

virsh 명령으로 노드 확인

virsh list --all
$ virsh list --all
 Id   Name           State
------------------------------
 1    minikube       running
 2    minikube-m02   running

kubectl 명령으로 노드 확인

kubectl get nodes
$ kubectl get nodes
NAME           STATUS   ROLES                  AGE   VERSION
minikube       Ready    control-plane,master   30m   v1.22.10
minikube-m02   Ready    <none>                 23m   v1.22.10
kubectl api-versions
kubectl api-resources

 


옵션 추가

- nodes : 4EA

minikube start --driver=kvm2 --cpus=4 --memory=4096 --nodes=4 --cni=calico --kubernetes-version=1.22.10

** 멀티 노드 구성을 시도하였으나 실패하였음 ㅠㅠ

StartHost failed, but will try again: creating host: create: Error creating machine: Error in driver during machine creation: IP not available after waiting: machine minikube-m02 didn't return IP after 1 minute

- nodes : 1EA

minikube start --driver=kvm2 --cpus=4 --memory=4096 --nodes=1 --cni=calico --kubernetes-version=1.22.10

 

참고URL

- https://kubernetes.io/docs/tasks/tools/included/optional-kubectl-configs-bash-linux/

 

728x90