1
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?

【Kubernetes】Minikubeインストール手順

Last updated at Posted at 2024-03-12

minikubeとは

ローカル環境でKubernetesを簡単に実行するためのツールです。
Kubernetesを触ってみたい!という方のために、PC上のVM内でシングルノードのKubernetesクラスターを実行することができます。
参考:minikube - 公式ドキュメント

インストール手順

システムの更新

システムを最新バージョンに更新します。

$ sudo apt update -y
$ sudo apt upgrade -y

minikubeのインストール

公式サイトからMinikubeのバイナリファイルをダウンロードします。

$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
% Total    % Received % Xferd  Average Speed   Time    Time     Time     Current
                               Dload  Upload   Total   Spent    Left     Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
:
100 89.3M  100 89.3M    0     0  3985k      0  0:00:22  0:00:22 --:--:-- 3844k

ダウンロードしたバイナリファイルをインストールします。

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

確認のため、バージョンを確認してみましょう。以下のように出力されればインストール完了です。

$ minikube version
minikube version: v1.32.0
commit: adfjoefhir774wfiuieuwhr4rgdslvsxljxpuw9u

動作確認

minikubeの起動

minikube startで開始できます。

$ minikube start
* minikube v1.32.0 on Ubuntu 22.04 (kvm/amd64)
* Using the docker driver based on existing profile
* Starting control plane node minikube in cluster minikube
* Pulling base image ...

:

* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

minikubeが正しく起動できていると、minikube statusを実行した際以下のように出力されます。

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

エラーが発生した場合
環境変数にプロキシが設定されていない場合は、minikube start実行時に以下のようなエラーが出力されます。

$ minikube start
* minikube v1.32.0 on Ubuntu 22.04 (kvm/amd64)
* Automatically selected the docker driver. Other choices: none, ssh
* Using Docker driver with root privileges
* Starting control plane node minikube in cluster minikube
* Pulling base image ...
! The image 'registry.k8s.io/kube-scheduler:v1.28.3' was not found; unable to add it to cache.
! The image 'registry.k8s.io/kube-controller-manager:v1.28.3' was not found; unable to add it to cache.
! The image 'registry.k8s.io/kube-apiserver:v1.28.3' was not found; unable to add it to cache.
! The image 'gcr.io/k8s-minikube/storage-provisioner:v5' was not found; unable to add it to cache.
! The image 'registry.k8s.io/kube-proxy:v1.28.3' was not found; unable to add it to cache.
! The image 'registry.k8s.io/pause:3.9' was not found; unable to add it to cache.
! The image 'registry.k8s.io/coredns/coredns:v1.10.1' was not found; unable to add it to cache.
! The image 'registry.k8s.io/etcd:3.5.9-0' was not found; unable to add it to cache.
E0221 11:54:20.746072  155171 cache.go:189] Error downloading kic artifacts:  failed to download kic base image or any fallback image
* Creating docker container (CPUs=2, Memory=2200MB) ...
! This container is having trouble accessing https://registry.k8s.io
* To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/
* Preparing Kubernetes v1.28.3 on Docker 24.0.7 ...
X Unable to load cached images: loading cached images: stat /home/.minikube/cache/images/amd64/registry.k8s.io/coredns/coredns_v1.10.1: no such file or directory

X Exiting due to INET_LOOKUP_HOST: updating control plane: downloading binaries: downloading kubectl: download failed: https://dl.k8s.io/release/v1.28.3/bin/linux/amd64/kubectl?checksum=file:https://dl.k8s.io/release/v1.28.3/bin/linux/amd64/kubectl.sha256: getter: &{Ctx:context.Background Src:https://dl.k8s.io/release/v1.28.3/bin/linux/amd64/kubectl?checksum=file:https://dl.k8s.io/release/v1.28.3/bin/linux/amd64/kubectl.sha256 Dst:/home/.minikube/cache/linux/amd64/v1.28.3/kubectl.download Pwd: Mode:2 Umask:---------- Detectors:[0x46177c0 0x46177c0 0x46177c0 0x46177c0 0x46177c0 0x46177c0 0x46177c0] Decompressors:map[bz2:0xc00059e5e0 gz:0xc00059e5e8 tar:0xc00059e590 tar.bz2:0xc00059e5a0 tar.gz:0xc00059e5b0 tar.xz:0xc00059e5c0 tar.zst:0xc00059e5d0 tbz2:0xc00059e5a0 tgz:0xc00059e5b0 txz:0xc00059e5c0 tzst:0xc00059e5d0 xz:0xc00059e5f0 zip:0xc00059e600 zst:0xc00059e5f8] Getters:map[file:0xc002cb5950 http:0xc000659180 https:0xc0006591d0] Dir:false ProgressListener:0x45d7ae0 Insecure:false DisableSymlinks:false Options:[0x120d740]}: invalid checksum: Error downloading checksum file: Get "https://dl.k8s.io/release/v1.28.3/bin/linux/amd64/kubectl.sha256": dial tcp: lookup dl.k8s.io on 127.0.0.53:53: no such host
* Suggestion: Verify that your HTTP_PROXY and HTTPS_PROXY environment variables are set correctly.
* Documentation: https://minikube.sigs.k8s.io/docs/handbook/vpn_and_proxy/
  • Suggestion: Verify that your HTTP_PROXY and HTTPS_PROXY environment variables are set correctly.
    (提案:HTTP_PROXY および HTTPS_PROXY 環境変数が正しく設定されていることを確認してください。)

提案通り、プロキシを設定しましょう。

$ export HTTP_PROXY=http://proxy.co.jp:xxxx
$ export HTTP_PROXY=http://proxy.co.jp:xxxx
# 設定の確認
$ printenv HTTP_PROXY
http://proxy.co.jp:xxxx
$ printenv HTTPS_PROXY
http://proxy.co.jp:xxxx

minikubeの停止

minikube stopで停止できます。

$ minikube stop
* Stopping node "minikube"  ...
* Powering off "minikube" via SSH ...
* 1 node stopped.

minikubeの削除

不要になったminikubeクラスタは、minikube deleteで削除できます。

$ minikube delete
* Deleting "minikube" in docker ...
* Deleting container "minikube" ...
* Removing /home/.minikube/machines/minikube ...
* Removed all traces of the "minikube" cluster.

参考:

1
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
1
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?