Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

Minikubeをubuntu19.04にインストールした話[kvm2利用・BIOS画面でVirtualization有効化]

More than 1 year has passed since last update.

はじめに

Kubernatesを扱っていく可能性が出てきたので、kubectlコマンドくらいはサラッと触っておきたいと思い、Minikubeをローカルpcに入れることにしました。

Minikubeのインストールについて調べていくと、BIOS周りの設定をする必要があることが分かります。
ビクビクしながら、インストールすることのないように備忘録として残しておきます笑。

環境/バージョン情報

  • Dell xps13 9380
  • Ubuntu19.04 (Disco Dingo)
  • kvm QEMU emulator version 3.1.0 (Debian 1:3.1+dfsg-2ubuntu3.5)
  • minikube version: v1.5.2
  • kubectl Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2"

お話すること

下準備(Virtualizationの有効化)

  • 電源ボタンを押す
  • Dellのロゴが出たら、画面が変わるるまでF2キーを繰り返し押す
  • BIOS設定画面で下記の Virtualization にチェックがついているか確認 vt.jpg

kvm driverをインストール

gkz@localhost ~ $ sudo apt install cpu-checker && sudo kvm-ok
Reading package lists... Done
Building dependency tree       
Reading state information... Done
cpu-checker is already the newest version (0.7-1.1).
cpu-checker set to manually installed.
gkz@localhost ~ $ sudo kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
gkz@localhost ~ $ sudo apt install libvirt-clients libvirt-daemon-system qemu-kvm \
>     && sudo usermod -a -G libvirt $(whoami) \
>     && newgrp libvirt
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libvirt-clients is already the newest version (5.0.0-1ubuntu2.5).
libvirt-daemon-system is already the newest version (5.0.0-1ubuntu2.5).
qemu-kvm is already the newest version (1:3.1+dfsg-2ubuntu3.5).
0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
gkz@localhost ~ $ sudo virt-host-validate
  QEMU: Checking for hardware virtualization                                 : PASS
  QEMU: Checking if device /dev/kvm exists                                   : PASS
  QEMU: Checking if device /dev/kvm is accessible                            : PASS
  QEMU: Checking if device /dev/vhost-net exists                             : PASS

(略)

gkz@localhost ~ $ kvm --version
QEMU emulator version 3.1.0 (Debian 1:3.1+dfsg-2ubuntu3.5)
Copyright (c) 2003-2018 Fabrice Bellard and the QEMU Project developers

Minikubeをインストール

gkz@localhost ~ $ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
>    && sudo install minikube-linux-amd64 /usr/local/bin/minikube
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 46.3M  100 46.3M    0     0  5699k      0  0:00:08  0:00:08 --:--:-- 7973k

Minikubeを立ち上げる

gkz@localhost ~ $ minikube start --vm-driver=kvm2
😄  minikube v1.5.2 on Ubuntu 19.04
✨  Automatically selected the 'kvm2' driver (alternates: [none])
🔥  Creating kvm2 VM (CPUs=2, Memory=2000MB, Disk=20000MB) ...
🌐  Found network options:
    ▪ NO_PROXY=localhost,127.0.0.0/8,::1
    ▪ no_proxy=localhost,127.0.0.0/8,::1
🐳  Preparing Kubernetes v1.16.2 on Docker '18.09.9' ...
    ▪ env NO_PROXY=localhost,127.0.0.0/8,::1
    ▪ env NO_PROXY=localhost,127.0.0.0/8,::1
💾  Downloading kubeadm v1.16.2
💾  Downloading kubelet v1.16.2
🚜  Pulling images ...
🚀  Launching Kubernetes ... 
⌛  Waiting for: apiserver
🏄  Done! kubectl is now configured to use "minikube"

ダッシュボードを開く

gkz@localhost ~ $ minikube dashboard
🤔  Verifying dashboard health ...
🚀  Launching proxy ...
🤔  Verifying proxy health ...
🎉  Opening http://127.0.0.1:43933/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...
Opening in existing browser session. 

ブラウザが下記のように立ち上がります

minikube_dashboard.png

Minikubeのステータスの確認

# Minikubeを立ち上げる前
gkz@localhost ~ $ minikube status
host: 
kubelet: 
apiserver: 
kubeconfig: 

# Minikubeを立ち上げた後
gkz@localhost ~ $ minikube status
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

Minikubeを停止・削除

gkz@localhost ~ $ minikube stop
✋  Stopping "minikube" in kvm2 ...
🛑  "minikube" stopped.
gkz@localhost ~ $ minikube delete
🔥  Deleting "minikube" in kvm2 ...
💔  The "minikube" cluster has been deleted.
🔥  Successfully deleted profile "minikube"

# まとめて消す方法
gkz@localhost ~ $ minikube stop; minikube delete

# Minikubeのステータスの確認
gkz@localhost ~ $ minikube status
host: 
kubelet: 
apiserver: 
kubeconfig: 

Minikubeを完全に削除

gkz@localhost ~ $ sudo rm /usr/local/bin/minikube 
[sudo] password for gkz: 
gkz@localhost ~ $ rm -rf ~/.minikube

# 削除できているか確認
gkz@localhost ~ $ minikube start -vm-driver=kvm2
bash: /usr/local/bin/minikube: No such file or directory
gkz@localhost ~ $ kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.2", GitCommit:"c97fe5036ef3df2967d086711e6c0c405941e14b", GitTreeState:"clean", BuildDate:"2019-10-15T19:18:23Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}
Error from server (NotFound): the server could not find the requested resource
gkz@localhost ~ $ minikube version
bash: /usr/local/bin/minikube: No such file or directory

Minikubeを再インストール

gkz@localhost ~ $ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
>     && sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 46.3M  100 46.3M    0     0  5463k      0  0:00:08  0:00:08 --:--:-- 5424k
gkz@localhost ~ $ minikube version
minikube version: v1.5.2
commit: 792dbf92a1de583fcee76f8791cff12e0c9440ad-dirty

参考

P.S. Twitterもやってるのでフォローしていただけると泣いて喜びます:)

@gkzvoice

#gkz

gkzz
お引越ししました。https://zenn.dev/gkz
https://github.com/gkzz
ap-com
エーピーコミュニケーションズは「エンジニアから時間を奪うものをなくす」ため、ITインフラ自動化のプロフェッショナルとして、クラウドも含めたインフラ自動化技術で顧客の課題を解決すると同時に、SI業務の課題を解決するプロダクト・サービスを提供するNeoSIer(ネオエスアイヤー)です。
https://www.ap-com.co.jp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away