개발환경은 마스터와 노드가 둘 다 들어갈 수 있고
운영환경에서는 최소한 4개의 서버가 필요하다.
피시 성능을 고려하여 좋지 못하다면 aws 를 이용하는것도 좋은 방법이다.
lightsail 서비스 클릭
os > ubuntu 20.04
wetty라고 웹브라우저에서 터미널을 이용할 수 있는 것을 스크립트에 추가한다
사양은 20 달라!
create instance
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
echo "ubuntu:1q2w3e4r!!" | chpasswd
service sshd reload
curl -sL https://deb.nodesource.com/setup_14.x | bash -
apt-get -y update
DEBIAN_FRONTEND=noninteractive apt-get -y install nodejs build-essential
npm install -g wetty --unsafe
ln -s /usr/bin/wetty /usr/local/bin/wetty
curl https://gist.githubusercontent.com/subicura/9058671c16e2abd36533fea2798886b0/raw/e5d249612711b14c9c8f44798dea1368395e86a9/wetty.service -o /lib/systemd/system/wetty.service
systemctl start wetty
systemctl enable wetty
ubuntu가 펜딩상태에서 Running 상태로 변한다
클릭 후 네트워크에서 Firewall 부분에 20port,80port를 지우고
3000 ~65000까지 모두 오픈해준다 3천번에서 모든 포트로 접속 할 수 있다는 의미
웹 브라우저에:4200을 하면 설치를 한다
Public IP 주소와 4200 port로 접속 (아이디/패스워드 - ubuntu/1q2w3e4r!!)
쿠버네티스 배포를 설치
curl -sfL https://get.k3s.io | sh -
sudo chown ubuntu:ubuntu /etc/rancher/k3s/k3s.yaml
# 확인
kubectl get nodes
# 설정 복사
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
우분투 환경이라면 도커 환경에서 다운 받을 수 있다.
이미 설치 되어있어도 모르면 기다려라.. ㅠ 애먹는다.. 그렇지 않으면start --driver가 되지 않는다..
(passwd: user 'ubuntu' does not exist
root@user:~# pwd
/root
root@user:~# cd /home/hongtae/
root@user:/home/hongtae#
root@user:/home/hongtae#
root@user:/home/hongtae# passwd hongtae
New password:
Retype new password:
passwd: password updated successfully
root@user:/home/hongtae# su hongtae
미니쿠베를 설치 : curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
&& chmod +x minikube
어디에서 사용가능하게 user/bin으로 넣는다
sudo mkdir -p /usr/local/bin/
다운 받은 파일을 bin 안에 넣는다
sudo install minikube /usr/local/bin/
이제 실행 minikube version
6.1 확인
minikube version: v1.20.0
commit: c61663e942ec43b20e8e70839dcca52e44cd85ae
or 도커를 사용할 수 없다면 가상머신으로 해야한다
# docker 사용시 설치 필요, docker를 사용하지 않는 경우 virtual box 설치
curl -fsSL https://get.docker.com/ | sudo sh
sudo usermod -aG docker $USER
# docker 대신 virtual box 설치
sudo apt-get install virtualbox
# install minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
&& chmod +x minikube
sudo mkdir -p /usr/local/bin/
sudo install minikube /usr/local/bin/
minikube version
기본 명령어
# 버전확인
minikube version
# 가상머신 시작
minikube start --driver=docker
# driver 에러가 발생한다면 virtual box를 사용
minikube start --driver=virtualbox
# 특정 k8s 버전 실행
minikube start --kubernetes-version=v1.20.0
# 상태확인
minikube status
# 정지
minikube stop
# 삭제
minikube delete
# ssh 접속
minikube ssh
# ip 확인
minikube ip
(base) hongtae@user:~$ minikube start --driver=docker
😄 Ubuntu 20.04 위의 minikube v1.20.0
✨ 유저 환경 설정 정보에 기반하여 docker 드라이버를 사용하는 중
👍 minikube 클러스터의 minikube 컨트롤 플레인 노드를 시작하는 중
🚜 Pulling base image ...
💾 Downloading Kubernetes v1.20.2 preload ...
> preloaded-images-k8s-v10-v1...: 491.71 MiB / 491.71 MiB 100.00% 25.15 Mi
> gcr.io/k8s-minikube/kicbase...: 358.10 MiB / 358.10 MiB 100.00% 9.14 MiB
> gcr.io/k8s-minikube/kicbase...: 358.10 MiB / 358.10 MiB 100.00% 9.05 MiB
🔥 Creating docker container (CPUs=2, Memory=3900MB) ...
🐳 쿠버네티스 v1.20.2 을 Docker 20.10.6 런타임으로 설치하는 중
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔎 Verifying Kubernetes components...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: storage-provisioner, default-storageclass
💡 kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
(base) hongtae@user:~$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
쿠버네티스 버전을 다른걸 하여 다시설치해보자
(base) hongtae@user:~$ minikube stop
✋ Stopping node "minikube" ...
🛑 Powering off "minikube" via SSH ...
🛑 1개의 노드가 중지되었습니다.
(base) hongtae@user:~$
(base) hongtae@user:~$ minikube delete
🔥 docker 의 "minikube" 를 삭제하는 중 ...
🔥 Deleting container "minikube" ...
🔥 /home/hongtae/.minikube/machines/minikube 제거 중...
💀 "minikube" 클러스터 관련 정보가 모두 삭제되었습니다
(base) hongtae@user:~$ minikube start --kubernetes-version=v1.20.2
😄 Ubuntu 20.04 위의 minikube v1.20.0
✨ 자동적으로 docker 드라이버가 선택되었습니다. 다른 드라이버 목록: none, ssh
👍 minikube 클러스터의 minikube 컨트롤 플레인 노드를 시작하는 중
🚜 Pulling base image ...
🔥 Creating docker container (CPUs=2, Memory=3900MB) ...
🐳 쿠버네티스 v1.20.2 을 Docker 20.10.6 런타임으로 설치하는 중
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔎 Verifying Kubernetes components...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: storage-provisioner, default-storageclass
💡 kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
(base) hongtae@user:~$ minikube start --kubernetes-version=v1.20.0
😄 Ubuntu 20.04 위의 minikube v1.20.0
🙈 Exiting due to K8S_DOWNGRADE_UNSUPPORTED: Unable to safely downgrade existing Kubernetes v1.20.2 cluster to v1.20.0
💡 권장:
1) Recreate the cluster with Kubernetes 1.20.0, by running:
minikube delete
minikube start --kubernetes-version=v1.20.0
2) Create a second cluster with Kubernetes 1.20.0, by running:
minikube start -p minikube2 --kubernetes-version=v1.20.0
3) Use the existing cluster at version Kubernetes 1.20.2, by running:
minikube start --kubernetes-version=v1.20.2
(base) hongtae@user:~$ minikube delete
🔥 docker 의 "minikube" 를 삭제하는 중 ...
🔥 Deleting container "minikube" ...
🔥 /home/hongtae/.minikube/machines/minikube 제거 중...
💀 "minikube" 클러스터 관련 정보가 모두 삭제되었습니다
(base) hongtae@user:~$ minikube start --kubernetes-version=v1.20.0
😄 Ubuntu 20.04 위의 minikube v1.20.0
✨ 자동적으로 docker 드라이버가 선택되었습니다. 다른 드라이버 목록: ssh, none
👍 minikube 클러스터의 minikube 컨트롤 플레인 노드를 시작하는 중
🚜 Pulling base image ...
💾 Downloading Kubernetes v1.20.0 preload ...
> preloaded-images-k8s-v10-v1...: 491.68 MiB / 491.68 MiB 100.00% 28.45 Mi
🔥 Creating docker container (CPUs=2, Memory=3900MB) ...
🐳 쿠버네티스 v1.20.0 을 Docker 20.10.6 런타임으로 설치하는 중
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔎 Verifying Kubernetes components...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: storage-provisioner, default-storageclass
💡 kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
(base) hongtae@user:~$ minikube ssh
docker@minikube:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
43bce5bacaf1 6e38f40d628d "/storage-provisioner" 7 seconds ago Up 6 seconds k8s_storage-provisioner_storage-provisioner_kube-system_89667175-f87f-4b87-8f4d-e283e605e902_1
7a535884f1ed bfe3a36ebd25 "/coredns -conf /etc…" 35 seconds ago Up 34 seconds k8s_coredns_coredns-74ff55c5b-chrdh_kube-system_54b6af28-de0f-466e-8537-01ccce0b8bed_0
864c02d3b303 k8s.gcr.io/pause:3.2 "/pause" 35 seconds ago Up 34 seconds k8s_POD_coredns-74ff55c5b-chrdh_kube-system_54b6af28-de0f-466e-8537-01ccce0b8bed_0
585e52d68f1c 10cc881966cf "/usr/local/bin/kube…" 38 seconds ago Up 37 seconds k8s_kube-proxy_kube-proxy-zlctt_kube-system_37940faf-d1c6-4318-a389-65a5bc1ddde7_0
dc82a44c84ff k8s.gcr.io/pause:3.2 "/pause" 38 seconds ago Up 37 seconds k8s_POD_storage-provisioner_kube-system_89667175-f87f-4b87-8f4d-e283e605e902_0
c9754f66d923 k8s.gcr.io/pause:3.2 "/pause" 38 seconds ago Up 37 seconds k8s_POD_kube-proxy-zlctt_kube-system_37940faf-d1c6-4318-a389-65a5bc1ddde7_0
b13438ecc682 3138b6e3d471 "kube-scheduler --au…" About a minute ago Up About a minute k8s_kube-scheduler_kube-scheduler-minikube_kube-system_3478da2c440ba32fb6c087b3f3b99813_0
073cfc861916 ca9843d3b545 "kube-apiserver --ad…" About a minute ago Up About a minute k8s_kube-apiserver_kube-apiserver-minikube_kube-system_524cecac593a7ad14f29307cb61f56b8_0
cb1ffca44ce2 b9fa1895dcaa "kube-controller-man…" About a minute ago Up About a minute k8s_kube-controller-manager_kube-controller-manager-minikube_kube-system_a3e7be694ef7cf952503c5d331abc0ac_0
1faa1ef70918 0369cf4303ff "etcd --advertise-cl…" About a minute ago Up About a minute k8s_etcd_etcd-minikube_kube-system_c31fe6a5afdd142cf3450ac972274b36_0
d049fcea31b1 k8s.gcr.io/pause:3.2 "/pause" About a minute ago Up About a minute k8s_POD_kube-controller-manager-minikube_kube-system_a3e7be694ef7cf952503c5d331abc0ac_0
49e31924c3c2 k8s.gcr.io/pause:3.2 "/pause" About a minute ago Up About a minute k8s_POD_kube-apiserver-minikube_kube-system_524cecac593a7ad14f29307cb61f56b8_0
63d318c71b91 k8s.gcr.io/pause:3.2 "/pause" About a minute ago Up About a minute k8s_POD_kube-scheduler-minikube_kube-system_3478da2c440ba32fb6c087b3f3b99813_0
014b522ba1cc k8s.gcr.io/pause:3.2 "/pause" About a minute ago Up About a minute k8s_POD_etcd-minikube_kube-system_c31fe6a5afdd142cf3450ac972274b36_0
docker@minikube:~$ minikube ip
-bash: minikube: command not found
docker@minikube:~$ ^C
docker@minikube:~$ logout
ssh: Process exited with status 130
(base) hongtae@user:~$ minikube ip
192.168.49.2
도커말고 버츄얼 박스로 설치하자
sudo apt-get install virtualbox
기존에 만든 미니쿠베를 삭제하자
(base) hongtae@user:~$ minikube delete
(base) minikube start --driver=virtualbox --kubernetes-version=v1.20.0
😄 Ubuntu 20.04 위의 minikube v1.20.0
✨ 유저 환경 설정 정보에 기반하여 virtualbox 드라이버를 사용하는 중
👍 minikube 클러스터의 minikube 컨트롤 플레인 노드를 시작하는 중
🔥 virtualbox VM (CPUs=2, Memory=3900MB, Disk=20000MB) 를 생성하는 중 ...
🤦 StartHost failed, but will try again: creating host: create: precreate: We support Virtualbox starting with version 5. Your VirtualBox install is "WARNING: The character device /dev/vboxdrv does not exist.\n\t Please install the virtualbox-dkms package and the appropriate\n\t headers, most likely linux-headers-oem.\n\n\t You will not be able to start VMs until this problem is fixed.\n6.1.16_Ubuntur140961". Please upgrade at https://www.virtualbox.org
🔥 virtualbox VM (CPUs=2, Memory=3900MB, Disk=20000MB) 를 생성하는 중 ...
😿 Failed to start virtualbox VM. Running "minikube delete" may fix it: creating host: create: precreate: We support Virtualbox starting with version 5. Your VirtualBox install is "WARNING: The character device /dev/vboxdrv does not exist.\n\t Please install the virtualbox-dkms package and the appropriate\n\t headers, most likely linux-headers-oem.\n\n\t You will not be able to start VMs until this problem is fixed.\n6.1.16_Ubuntur140961". Please upgrade at https://www.virtualbox.org
❌ Exiting due to PR_VBOX_DEVICE_MISSING: Failed to start host: creating host: create: precreate: We support Virtualbox starting with version 5. Your VirtualBox install is "WARNING: The character device /dev/vboxdrv does not exist.\n\t Please install the virtualbox-dkms package and the appropriate\n\t headers, most likely linux-headers-oem.\n\n\t You will not be able to start VMs until this problem is fixed.\n6.1.16_Ubuntur140961". Please upgrade at https://www.virtualbox.org
💡 권장: Reinstall VirtualBox and reboot. Alternatively, try the kvm2 driver: https://minikube.sigs.k8s.io/docs/reference/drivers/kvm2/
🍿 관련 이슈: https://github.com/kubernetes/minikube/issues/
에러가 났다.. 원인을 찾아보니
VT -x 나 버츄얼 이 설치가 안되어 있으면 이런 에러가 난다 걍 도커로 하자
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
미니쿠베를 띄어놨으므로 보이는것이라 했다..
대체 이게 뭔 소리들인지.. 서버 버전이 보이지 않는다면 미니쿠베를 실행 후 다시 해봐라
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.1", GitCommit:"5e58841cce77d4bc13713ad2b91fa0d961e69192", GitTreeState:"clean", BuildDate:"2021-05-12T14:18:45Z", GoVersion:"go1.16.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.0", GitCommit:"af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38", GitTreeState:"clean", BuildDate:"2020-12-08T17:51:19Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}