# 1. Use k8s inside Minikube
- ## issue
```sh
Error: INSTALLATION FAILED: Kubernetes cluster unreachable: Get "https://kubernetes.docker.internal:6443/version": dial tcp 127.0.0.1:6443: connect: connection refused
```
or
```sh
I0512 09:50:11.168857 94624 versioner.go:58] Get "https://kubernetes.docker.internal:6443/version?timeout=5s": dial tcp 127.0.0.1:6443: connect: connection refused
```
or
```sh
$ kubectl get pod
I0512 09:45:27.254675 94077 versioner.go:58] Get "https://kubernetes.docker.internal:6443/version?timeout=5s": dial tcp 127.0.0.1:6443: connect: connection refused
E0512 09:45:27.703949 94077 memcache.go:265] couldn't get current server API group list: Get "https://kubernetes.docker.internal:6443/api?timeout=32s": dial tcp 127.0.0.1:6443: connect: connection refused
E0512 09:45:27.707127 94077 memcache.go:265] couldn't get current server API group list: Get "https://kubernetes.docker.internal:6443/api?timeout=32s": dial tcp 127.0.0.1:6443: connect: connection refused
E0512 09:45:27.708628 94077 memcache.go:265] couldn't get current server API group list: Get "https://kubernetes.docker.internal:6443/api?timeout=32s": dial tcp 127.0.0.1:6443: connect: connection refused
E0512 09:45:27.710322 94077 memcache.go:265] couldn't get current server API group list: Get "https://kubernetes.docker.internal:6443/api?timeout=32s": dial tcp 127.0.0.1:6443: connect: connection refused
E0512 09:45:27.711565 94077 memcache.go:265] couldn't get current server API group list: Get "https://kubernetes.docker.internal:6443/api?timeout=32s": dial tcp 127.0.0.1:6443: connect: connection refused
The connection to the server kubernetes.docker.internal:6443 was refused - did you specify the right host or port?
```
---
- ## fix
- install minikube + hyperkit
- `brew install minikube`
- `brew install hyperkit`
- start minikube using hyperkit (it will start kubeclt cluster inside minikube)
- `minikube start --driver=hyperkit`
- if error , then delete and start `minikube delete` -> `minikube start --driver=hyperkit`
- check minikube status
```sh
$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
```
- set kubectl to use minikube
- `kubectl config use-context minikube`
- `minikube update-context`
- run kubectl command
- `kubectl get pod`
- `kubectl get pod --context legacy-prod --namespace fk-sp-slm-legacy-adapter`
<details>
<summary>fix error - Remote kubernetes server unreachable</summary>
- error : because minikube not started
```sh
$ kubectl get pod --context legacy-prod --namespace fk-sp-slm-legacy-adapter
I0515 10:02:18.380226 20050 versioner.go:56] Remote kubernetes server unreachable
I0515 10:02:23.582148 20051 versioner.go:56] Remote kubernetes server unreachable
```
- fix : start minikube
```sh
$ minikube status
minikube
type: Control Plane
host: Stopped
kubelet: Stopped
apiserver: Stopped
kubeconfig: Stopped
$ minikube start --driver=hyperkit
😄 minikube v1.30.1 on Darwin 12.6.5
✨ Using the hyperkit driver based on existing profile
👍 Starting control plane node minikube in cluster minikube
🔄 Restarting existing hyperkit VM for "minikube" ...
🐳 Preparing Kubernetes v1.26.3 on Docker 20.10.23 ...
🔗 Configuring bridge CNI (Container Networking Interface) ...
🔎 Verifying Kubernetes components...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟 Enabled addons: storage-provisioner, default-storageclass
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
```
</details>
---
# 2. Use Docker inside Minikube
- ## optinal step: to work with docker
- `brew install docker` (this will install docker engine not docker desktop)
- `eval $(minikube docker-env)`
- Minikube includes a Docker daemon inside its VM
- Now our local terminal Docker CLI will interact with the Docker daemon inside the Minikube VM
- run `docker images` or `docker ps -a` ✅
---
<details>
<summary> my mac commands output </summary>
```sh
$ brew install minikube
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 4 taps (derailed/k9s, homebrew/cask-fonts, homebrew/core and homebrew/cask).
==> New Formulae
jet lpeg nerdfix quantum++ ssocr staq svlint svls
==> New Casks
1kc-razer genesys-cloud music-remote shureplus-motiv
asix-ax88179 hdhomerun music-widget synology-cloud-station-backup
bose-updater hp-easy-start nordic-nrf-command-line-tools synology-photo-station-uploader
caldigit-docking-utility huiontablet obsbot-webcam synology-surveillance-station-client
caldigit-thunderbolt-charging insta360-studio opal synologyassistant
concept2-utility jabra-direct pallotron-yubiswitch tiptoi-manager
creative konica-minolta-bizhub-c759-c658-c368-c287-c3851-driver philips-hue-sync volta
eobcanka lg-onscreen-control pololu-avr-programmer-v2 wacom-tablet
focusrite-control linn-konfig qflipper zsa-wally
font-noto-sans-chorasmian logitune saleae-logic
fractal-bot music-miniplayer samsung-portable-ssd-t7
You have 27 outdated formulae and 2 outdated casks installed.
Warning: minikube 1.30.1 is already installed and up-to-date.
To reinstall 1.30.1, run:
brew reinstall minikube
# yadav.hariom @ BLRETV-C02F52AP in ~/git_code/async-profiler-2.9-macos [9:39:49]
$ minikube start
😄 minikube v1.30.1 on Darwin 12.6.5
🆕 Kubernetes 1.26.3 is now available. If you would like to upgrade, specify: --kubernetes-version=v1.26.3
✨ Using the hyperkit driver based on existing profile
🤷 Exiting due to PROVIDER_HYPERKIT_NOT_FOUND: The 'hyperkit' provider was not found: exec: "hyperkit": executable file not found in $PATH
💡 Suggestion: Run 'brew install hyperkit'
📘 Documentation: https://minikube.sigs.k8s.io/docs/reference/drivers/hyperkit/
# yadav.hariom @ BLRETV-C02F52AP in ~/git_code/async-profiler-2.9-macos [9:40:14] C:65
$ brew install hyperkit
==> Fetching dependencies for hyperkit: libev
==> Fetching libev
==> Downloading https://ghcr.io/v2/homebrew/core/libev/manifests/4.33
#=#=- # # #=O#- # ######################################################################################################################################################################################################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libev/blobs/sha256:de9342ba34cfa8c2f8863a92eb7aced34652c302328f8a593a449d183c9fe1e0
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:de9342ba34cfa8c2f8863a92eb7aced34652c302328f8a593a449d183c9fe1e0?se=2023-05-12T04%3A20%3A00Z&sig=sT2gjt9rN6bQyy3cqXJhJCg%2BUPCyn0vSj42YAvQQE0o%3D&sp=r&spr=https&sr=b&sv=2019-12-12
#=#=- # # #=O#- # ######################################################################################################################################################################################################################################################### 100.0%
==> Fetching hyperkit
==> Downloading https://ghcr.io/v2/homebrew/core/hyperkit/manifests/0.20210107
#=#=- # # #=O#- # # -#O=- # # # ######################################################################################################################################################################################################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/hyperkit/blobs/sha256:da3b0d0374a85af5c649c86fb7796c1eecae468f5783bbb994a96d807e60712a
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:da3b0d0374a85af5c649c86fb7796c1eecae468f5783bbb994a96d807e60712a?se=2023-05-12T04%3A20%3A00Z&sig=a4rXkQqSisGvbaXHvr1nBbM4aVJVr69wrKxhMsvq0MY%3D&sp=r&spr=https&sr=b&sv=2019-12-12
######################################################################################################################################################################################################################################################### 100.0%
==> Installing dependencies for hyperkit: libev
==> Installing hyperkit dependency: libev
==> Pouring libev--4.33.monterey.bottle.tar.gz
🍺 /usr/local/Cellar/libev/4.33: 12 files, 483.4KB
==> Installing hyperkit
==> Pouring hyperkit--0.20210107.monterey.bottle.tar.gz
🍺 /usr/local/Cellar/hyperkit/0.20210107: 5 files, 4.6MB
==> Running `brew cleanup hyperkit`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
# yadav.hariom @ BLRETV-C02F52AP in ~/git_code/async-profiler-2.9-macos [9:41:11]
$ minikube start --driver=hyperkit
😄 minikube v1.30.1 on Darwin 12.6.5
🆕 Kubernetes 1.26.3 is now available. If you would like to upgrade, specify: --kubernetes-version=v1.26.3
✨ Using the hyperkit driver based on existing profile
💿 Downloading VM boot image ...
> minikube-v1.30.1-amd64.iso....: 65 B / 65 B [---------] 100.00% ? p/s 0s
> minikube-v1.30.1-amd64.iso: 282.84 MiB / 282.84 MiB 100.00% 7.98 MiB p/
👍 Starting control plane node minikube in cluster minikube
💾 Downloading Kubernetes v1.22.1 preload ...
> preloaded-images-k8s-v18-v1...: 406.64 MiB / 406.64 MiB 100.00% 4.39 Mi
🔄 Restarting existing hyperkit VM for "minikube" ...
^C
# yadav.hariom @ BLRETV-C02F52AP in ~/git_code/async-profiler-2.9-macos [9:48:48] C:130
$ minikube start --driver=hyperkit
😄 minikube v1.30.1 on Darwin 12.6.5
🆕 Kubernetes 1.26.3 is now available. If you would like to upgrade, specify: --kubernetes-version=v1.26.3
✨ Using the hyperkit driver based on existing profile
👍 Starting control plane node minikube in cluster minikube
🔄 Restarting existing hyperkit VM for "minikube" ...
❌ Exiting due to RUNTIME_ENABLE: Failed to enable container runtime: sudo systemctl restart docker: Process exited with status 1
stdout:
stderr:
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.
╭───────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ 😿 If the above advice does not help, please let us know: │
│ 👉 https://github.com/kubernetes/minikube/issues/new/choose │
│ │
│ Please run `minikube logs --file=logs.txt` and attach logs.txt to the GitHub issue. │
│ │
╰───────────────────────────────────────────────────────────────────────────────────────────╯
# yadav.hariom @ BLRETV-C02F52AP in ~/git_code/async-profiler-2.9-macos [9:50:41] C:90
$ docker --version
Docker version 23.0.3-rd, build d2f4735
# yadav.hariom @ BLRETV-C02F52AP in ~/git_code/async-profiler-2.9-macos [9:52:31]
$ minikube delete
🔥 Deleting "minikube" in hyperkit ...
💀 Removed all traces of the "minikube" cluster.
# yadav.hariom @ BLRETV-C02F52AP in ~/git_code/async-profiler-2.9-macos [9:53:43]
$ minikube start --driver=hyperkit
😄 minikube v1.30.1 on Darwin 12.6.5
✨ Using the hyperkit driver based on user configuration
👍 Starting control plane node minikube in cluster minikube
💾 Downloading Kubernetes v1.26.3 preload ...
> preloaded-images-k8s-v18-v1...: 397.02 MiB / 397.02 MiB 100.00% 11.48 M
🔥 Creating hyperkit VM (CPUs=2, Memory=4000MB, Disk=20000MB) ...
🐳 Preparing Kubernetes v1.26.3 on Docker 20.10.23 ...
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔗 Configuring bridge CNI (Container Networking Interface) ...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🔎 Verifying Kubernetes components...
🌟 Enabled addons: default-storageclass, storage-provisioner
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
# yadav.hariom @ BLRETV-C02F52AP in ~/git_code/async-profiler-2.9-macos [9:58:15]
$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
```
---
```sh
kubectl config use-context minikube
$ minikube update-context
🎉 "minikube" context has been updated to point to 192.168.205.3:8443
💗 Current context is "minikube"
$ which hyperkit
/usr/local/bin/hyperkit
```
</details>