2
0

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導入とエラー対応

Last updated at Posted at 2021-03-08

概要

  • Macローカルにminikubeを導入する際エラーに遭遇する
  • 解決したエラーと方法をメモしておく

詳細

minikube導入

$ brew cask install virtualbox

$ brew install minikube
or
$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.23.0/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

$ brew unlink minikube
Unlinking /usr/local/Cellar/minikube/1.18.1... 3 symlinks removed.
$ brew link minikube
Linking /usr/local/Cellar/minikube/1.18.1... 3 symlinks created.
$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64

$ sudo install minikube-darwin-amd64 /usr/local/bin/minikube
$ ls -l /usr/local/bin/minikube
-rwxr-xr-x  1 root  admin  59174304 Mar  8 15:32 /usr/local/bin/minikube

kubectl導入

  • brewの場合
$ brew install kubectl

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.4", GitCommit:"e87da0bd6e03ec3fea7933c4b5263d151aafd07c", GitTreeState:"clean", BuildDate:"2021-02-21T20:23:45Z", GoVersion:"go1.15.8", Compiler:"gc", Platform:"darwin/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?
  • curlの場合
最新版
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl"

バージョン指定
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.20.0/bin/darwin/amd64/kubectl
  • 実行権と$PATH以下へ移動
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
  • minikube起動
$ minikube start
$ kubectl get node
NAME       STATUS    ROLES     AGE       VERSION
minikube   Ready     <none>    6h        v1.8.0

エラー参考集

エラー参考:Startup with virtualbox driver failed

$ minikube start
E0308 16:27:22.254249   22591 cloud_events.go:60] unable to write to /Users/username/.minikube/profiles/minikube/events.json: open /Users/username/.minikube/profiles/minikube/events.json: permission denied
😄  minikube v1.18.1 on Darwin 11.1
✨  Automatically selected the virtualbox driver
👍  Starting control plane node minikube in cluster minikube
❗  Startup with virtualbox driver failed, trying with alternate driver ssh: Failed to save config: open /Users/username/.minikube/profiles/minikube/config.json: permission denied
❗  Failed to delete cluster minikube, proceeding with retry anyway.
❌  Exiting due to MK_USAGE: No IP address provided. Try specifying --ssh-ip-address, or see https://minikube.sigs.k8s.io/docs/drivers/ssh/

エラー参考:Error starting host: Error creating host: Error executing step: Creating VM.

Error starting host: Error creating host: Error executing step: Creating VM.
: Error setting up host only network on machine start: The host-only adapter we just created is not visible. This is a well known VirtualBox bug. You might want to uninstall it and reinstall at least version 5.0.12 that is is supposed to fix this issue.
  • ハイパーバイザ(VirtualBoxなど)が入ってない場合は以下のエラー
  • もしくはVirtualBoxにエラーがある
  • この場合VirtualBoxのバグでVM作成できないとのメッセージ
  • ステーブルバージョンを入れ直す
  • VirtualBoxのdmg内にアンインストールツールがある
  • MacごとOS再起動する
  • 起動できるようになる

問題を取り除いた後再度起動

$ minikube start
Starting local Kubernetes v1.8.0 cluster...
Starting VM...
:
Starting cluster components...
Kubectl is now configured to use the cluster.

$ minikube status
minikube: Running
cluster: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100

エラー参考:Error from server (NotAcceptable)

  • minikube(kubernetes)本体とkubectlのバージョンが合っていない可能性がある
  • 本体は変更は困難なケースが多い。kubectlを違うバージョンにしてみる事を推奨
  • Kubectl 1.11はKubernetesのバージョンがv1.9以上必要。このケースではKubernetesがv1.8.0。
  • kubectlを1.10に下げてみる
$ kubectl cluster-info
Kubernetes control plane is running at https://192.168.99.103:8443

$ kubectl get node
Error from server (NotAcceptable): the server was unable to respond with a content type that the client supports (get nodes)
$ minikube version
minikube version: v0.23.0

エラー参考 kubectl: cannot execute binary file

  • kubectlが実行できない場合
  • MacでLinuxのバイナリをダウンロードしてきた等の可能性がある
  • ダウンロードをし直してみる
誤
$ curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.10.0/bin/linux/amd64/kubectl

正
$ curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.10.0/bin/darwin/amd64/kubectl

MacにLinuxのkubectlを導入した場合
$ /usr/local/bin/kubectl
/usr/local/bin/kubectl: /usr/local/bin/kubectl: cannot execute binary file

その他に32bit用と64bit用を間違えるなど
  • 正しいバイナリを再配置
$ chmod +x ./kubectl
$ sudo mv ./kubectl /usr/local/bin/kubectl

参考リンク

https://kubernetes.io/ja/docs/tasks/tools/install-kubectl/
https://kubernetes.io/ja/docs/setup/learning-environment/minikube/
https://kubernetes.io/ja/docs/tutorials/hello-minikube/
https://github.com/kubernetes/kubernetes/issues/65575#issuecomment-401319830

2
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?