2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

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

Last updated at Posted at 2019-11-08

はじめに

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

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?