본문 바로가기

백앤드/Kubernetes

[Kubernetes] 설치하고, 실행하고, 종료하기

반응형

1. 설치 환경

  • OS : Ubuntu 20.04.5 LTS
  • CPU : Intel(R) Xeon(R) CPU E3-1230 V2
  • Memory : 8GB
  • Disk : 256 GB

 

2. 다운로드

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

위에 있는 curl 명령어를 통해 minikube 리눅스 버전을 설치합시다. 설치가 되면 아래 사진처럼 minikube-linux-amd64 라는 바이너리가 생긴 것을 확인할 수 있어요.

 

3. 설치

sudo install minikube-linux-amd64 /usr/local/bin/minikube

이번엔 install 명령어를 통해서 방금 다운받은 minikube-linux-amd64를 설치합니다. 설치하게되면 sudo 명령에 의해서 관리자 권한을 획득하기 위한 비밀번호를 입력하게 되고, 이후에는 아래 사진처럼 별다른 알림 없이 설치가 완료됩니다.

 

minikube가 설치된 것을 확인하려면 위에 입력한 경로를 통해 파일 목록을 확인할 수 있고, 파일 확인은 아래 명령어를 통해 쉽게 확인할 수 있습니다.

ls /usr/local/bin

명령어를 입력하면 아래 사진처럼 minikube 실행파일이 있는 것을 확인할 수 있습니다.

 

4. 실행

minikube start

위 명령어를 입력하면 minikube가 실행됩니다. 그러면 이렇게 실행이 되어야됩니다만...

하지만, 아래 사진처럼 에러가 났다. 그래서 에러 해결부터 진행해보겠습니다.

* minikube v1.30.1 on Ubuntu 20.04
* Unable to pick a default driver. Here is what was considered, in preference order:
  - docker: Not healthy: "docker version --format {{.Server.Os}}-{{.Server.Version}}:{{.Server.Platform.Name}}" exit status 1: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/version": dial unix /var/run/docker.sock: connect: permission denied
  - docker: Suggestion: Add your user to the 'docker' group: 'sudo usermod -aG docker $USER && newgrp docker' <https://docs.docker.com/engine/install/linux-postinstall/>
* Alternatively you could install one of these drivers:
  - kvm2: Not installed: exec: "virsh": executable file not found in $PATH
  - podman: Not installed: exec: "podman": executable file not found in $PATH
  - qemu2: Not installed: exec: "qemu-system-x86_64": executable file not found in $PATH
  - virtualbox: Not installed: unable to find VBoxManage in $PATH

X Exiting due to DRV_NOT_HEALTHY: Found driver(s) but none were healthy. See above for suggestions how to fix installed drivers.

 

5. 실행 에러 첫번째 시도

실행에서 에러가 안난 분들은 이번 순서는 건너띄어도 됩니다. 하지만 필자는 에러나서 에러 해결부터 설명 드릴게요.

같은 에러가 발생하신 분은 이 글을 통해 해결되셨으면 좋겠습니다.

 

에러 문구를 자세히 살펴보면 permission denied 라는 문구가 눈에 띄었는데, 그래서 아래 명령어로 다시 실행해봤습니다.

sudo minikube start

 

6. 실행 에러 두번째 시도

하지만, 이번엔 에러 문구가 좀 짧아졌고, permission denied 라더니 sudo 권한을 주니 권한 문제는 사라졌습니다

* minikube v1.30.1 on Ubuntu 20.04
* Automatically selected the docker driver. Other choices: none, ssh
* The "docker" driver should not be used with root privileges. If you wish to continue as root, use --force.
* If you are running minikube within a VM, consider using --driver=none:
*   https://minikube.sigs.k8s.io/docs/reference/drivers/none/

X Exiting due to DRV_AS_ROOT: The "docker" driver should not be used with root privileges.

 

그런데 이번에는 root로 계속 할거면, --force 옵션을 사용하라는 문구가 보여서 그 옵션을 붙이고 다시 실행해봤습니다.

sudo minikube start --force

솔직히 말하면, --force 옵션 붙이는 순간 이게 맞나 싶었음.....

 

* minikube v1.30.1 on Ubuntu 20.04
* Automatically selected the docker driver. Other choices: none, ssh
* The "docker" driver should not be used with root privileges. If you wish to continue as root, use --force.
* If you are running minikube within a VM, consider using --driver=none:
*   https://minikube.sigs.k8s.io/docs/reference/drivers/none/

X Exiting due to DRV_AS_ROOT: The "docker" driver should not be used with root privileges.

jskang@jskang-linux01:~/utils/minikube$ sudo minikube start --force
* minikube v1.30.1 on Ubuntu 20.04
! minikube skips various validations when --force is supplied; this may lead to unexpected behavior
* Automatically selected the docker driver. Other choices: ssh, none
* The "docker" driver should not be used with root privileges. If you wish to continue as root, use --force.
* If you are running minikube within a VM, consider using --driver=none:
*   https://minikube.sigs.k8s.io/docs/reference/drivers/none/
* Using Docker driver with root privileges
* Starting control plane node minikube in cluster minikube
* Pulling base image ...
* Downloading Kubernetes v1.26.3 preload ...
    > preloaded-images-k8s-v18-v1...:  397.02 MiB / 397.02 MiB  100.00% 39.96 M
    > gcr.io/k8s-minikube/kicbase...:  373.53 MiB / 373.53 MiB  100.00% 19.38 M

* Creating docker container (CPUs=2, Memory=2200MB) ...
* Preparing Kubernetes v1.26.3 on Docker 23.0.2 ...
  - Generating certificates and keys ...
  - Booting up control plane ...
  - Configuring RBAC rules ...
* Configuring bridge CNI (Container Networking Interface) ...
  - Using image gcr.io/k8s-minikube/storage-provisioner:v5
* Verifying Kubernetes components...
* 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

 

그런데 됬다. 마지막줄에 Done!  완료되었다네요. 

sudo minikube status

그래서 확실하게 실행됬는지 확인차 상태를 확인 해보려고 위에 명령어를 통해서 상태를 확인했는데요.

아래처럼 모두 Running 로 실행된 것 확인 완료! 탕탕..!

minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

 

7. 종료

열심히 실행해봤으니, 이제 끄는 법도 알아야겠죠.

종료하는 방법은 매우 간단합니다.

 

sudo minikube stop

이렇게 명령어를 입력하면 종료됩니다.

 

근데... 저는 아래처럼 이상한 에러가 같이 떴네요....

* Stopping node "minikube"  ...
* Powering off "minikube" via SSH ...

X Exiting due to HOST_JUJU_LOCK_PERMISSION: writing kubeconfig: Error writing file /root/.kube/config: failed to acquire lock for /root/.kube/config: {Name:mk72a1487fd2da23da9e8181e16f352a6105bd56 Clock:{} Delay:500ms Timeout:1m0s Cancel:<nil>}: unable to open /tmp/juju-mk72a1487fd2da23da9e8181e16f352a6105bd56: permission denied
* Suggestion: Run 'sudo sysctl fs.protected_regular=0', or try a driver which does not require root, such as '--driver=docker'
* Related issue: https://github.com/kubernetes/minikube/issues/6391

아직 무슨 에러인지는 정확하게 몰라서,,, 나중에 혹시라도 알게되면 내용 추가로 작성하겠습니다.

 

sudo minikube status

그래서 확실하게 꺼져있는지 확인차 상태를 확인 해보려고 위에 명령어를 통해서 상태를 확인했는데요.

아래처럼 모두 Stopped 으로 종료된 것 확인 완료! 탕탕..!

minikube
type: Control Plane
host: Stopped
kubelet: Stopped
apiserver: Stopped
kubeconfig: Stopped
반응형

'백앤드 > Kubernetes' 카테고리의 다른 글

[Kubernetes] GitLab Container Registry와 연동  (0) 2023.03.10