Minikube 클러스터와 도구준비

OS별 설치방법은 아래 문서를 참고하고 MacOS 기준으로 설명합니다.

minikube start
minikube is local Kubernetes

설치

$ brew install minikube

클러스터 시작

최신 릴리즈 참고

Releases · kubernetes/kubernetes
Production-Grade Container Scheduling and Management - kubernetes/kubernetes
# 최신 버전 설치: --kubernetes-version=latest
$ minikube start --cpus 4 --memory 8192 --kubernetes-version=v1.21.1

😄  minikube v1.20.0 on Darwin 11.3.1
❗  Kubernetes 1.21.1 has a known performance issue on cluster startup. It might take 2 to 3 minutes for a cluster to start.
❗  For more information, see: https://github.com/kubernetes/kubeadm/issues/2395
✨  Automatically selected the hyperkit driver
💾  Downloading driver docker-machine-driver-hyperkit:
    > docker-machine-driver-hyper...: 65 B / 65 B [----------] 100.00% ? p/s 0s
    > docker-machine-driver-hyper...: 10.52 MiB / 10.52 MiB  100.00% 5.87 MiB p
🔑  The 'hyperkit' driver requires elevated permissions. The following commands will be executed:

    $ sudo chown root:wheel /Users/hibuz/.minikube/bin/docker-machine-driver-hyperkit
    $ sudo chmod u+s /Users/hibuz/.minikube/bin/docker-machine-driver-hyperkit


Password:
💿  Downloading VM boot image ...
    > minikube-v1.20.0.iso.sha256: 65 B / 65 B [-------------] 100.00% ? p/s 0s
    > minikube-v1.20.0.iso: 245.40 MiB / 245.40 MiB  100.00% 49.56 MiB p/s 5.2s
👍  Starting control plane node minikube in cluster minikube
💾  Downloading Kubernetes v1.21.1 preload ...
    > preloaded-images-k8s-v10-v1...: 504.74 MiB / 504.74 MiB  100.00% 38.08 Mi
🔥  Creating hyperkit VM (CPUs=4, Memory=8192MB, Disk=20000MB) ...
🐳  Preparing Kubernetes v1.21.1 on Docker 20.10.6 ...
    ▪ Generating certificates and keys ...
    ▪ Booting up control plane ...
    ▪ Configuring RBAC rules ...
🔎  Verifying Kubernetes components...
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟  Enabled addons: storage-provisioner, default-storageclass

❗  /usr/local/bin/kubectl is version 1.19.7, which may have incompatibilites with Kubernetes 1.21.1.
    ▪ Want kubectl v1.21.1? Try 'minikube kubectl -- get pods -A'
🏄  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
~ 1m 46s

$ minikube node list
minikube	192.168.66.5

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

$ minikube ssh
                         _             _
            _         _ ( )           ( )
  ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __
/' _ ` _ `\| |/' _ `\| || , <  ( ) ( )| '_`\  /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)

$ uname -a
Linux minikube 4.19.182 #1 SMP Wed May 5 21:20:39 UTC 2021 x86_64 GNU/Linux
$ exit
logout

관리도구 설치

  1. Web Dashboard
# 참고: https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/

# Install Kubernetes Dashboard
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml

namespace/kubernetes-dashboard created
serviceaccount/kubernetes-dashboard created
service/kubernetes-dashboard created
secret/kubernetes-dashboard-certs created
secret/kubernetes-dashboard-csrf created
secret/kubernetes-dashboard-key-holder created
configmap/kubernetes-dashboard-settings created
role.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
deployment.apps/kubernetes-dashboard created
service/dashboard-metrics-scraper created
deployment.apps/dashboard-metrics-scraper created

# Patch the dashboard to allow skipping login
$ kubectl patch deployment kubernetes-dashboard -n kubernetes-dashboard --type 'json' -p '[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--enable-skip-login"}]'

deployment.apps/kubernetes-dashboard patched

$ kubectl proxy

Starting to serve on 127.0.0.1:8001

브라우져에서 접속 (생략으로 로그인)

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

2. Metrics server

$ kubectl top node
error: Metrics API not available

# 참고: https://github.com/kubernetes-sigs/metrics-server
# Install Metrics Server
$ kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml

serviceaccount/metrics-server created
clusterrole.rbac.authorization.k8s.io/system:aggregated-metrics-reader created
clusterrole.rbac.authorization.k8s.io/system:metrics-server created
rolebinding.rbac.authorization.k8s.io/metrics-server-auth-reader created
clusterrolebinding.rbac.authorization.k8s.io/metrics-server:system:auth-delegator created
clusterrolebinding.rbac.authorization.k8s.io/system:metrics-server created
service/metrics-server created
deployment.apps/metrics-server created
apiservice.apiregistration.k8s.io/v1beta1.metrics.k8s.io created

# Patch the metrisc server to work with insecure TLS
$ kubectl patch deployment metrics-server -n kube-system --type 'json' -p '[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--kubelet-insecure-tls"}]'

deployment.apps/metrics-server patched

$ kubectl top node
NAME       CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%
minikube   204m         5%     1463Mi          18%

3. K9s

# 참고: https://github.com/derailed/k9s
$ brew install k9s

$ k9s

4. Lens 설치

Lens | The Kubernetes IDE
Lens IDE for Kubernetes. The only system you’ll ever need to take control of your Kubernetes clusters. It’s open source and free. Download it today!

삭제

$ minikube delete --all

🔥  Deleting "minikube" in hyperkit ...
💀  Removed all traces of the "minikube" cluster.
🔥  Successfully deleted all profiles