Minikube Operations: Difference between revisions
(→Status) |
|||
(56 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=External= | =External= | ||
* https://minikube.sigs.k8s.io/docs/start/ | * https://minikube.sigs.k8s.io/docs/start/ | ||
* https://minikube.sigs.k8s.io/docs/commands/ | |||
=Internal= | =Internal= | ||
Line 9: | Line 10: | ||
Administration is done with <code>minikube</code>. | Administration is done with <code>minikube</code>. | ||
=Addons= | |||
minikube instance must be running for "addons" to work. | |||
<syntaxhighlight lang='text'> | |||
minikube addons list | |||
</syntaxhighlight> | |||
<syntaxhighlight lang='text'> | |||
minikube addons enable <addon-name> | |||
</syntaxhighlight> | |||
=Start= | =Start= | ||
{{External|https://minikube.sigs.k8s.io/docs/commands/start/}} | |||
==Start Overview== | |||
==Start Example== | |||
<syntaxhighlight lang='bash'> | |||
minikube start [-v=10] [--driver=none] [--kubernetes-version "v1.19.1"] | |||
minikube v1.12.3 on Darwin 10.14.6 | |||
✨ Automatically selected the docker driver | |||
👍 Starting control plane node minikube in cluster minikube | |||
🚜 Pulling base image ... | |||
💾 Downloading Kubernetes v1.18.3 preload ... | |||
> preloaded-images-k8s-v5-v1.18.3-docker-overlay2-amd64.tar.lz4: 510.91 MiB | |||
🔥 Creating docker container (CPUs=2, Memory=8100MB) ... | |||
🐳 Preparing Kubernetes v1.18.3 on Docker 19.03.8 ... | |||
🔎 Verifying Kubernetes components... | |||
🌟 Enabled addons: default-storageclass, storage-provisioner | |||
🏄 Done! kubectl is now configured to use "minikube" | |||
❗ /usr/local/bin/kubectl is version 1.16.6-beta.0, which may be incompatible with Kubernetes 1.18.3. | |||
💡 You can also use 'minikube kubectl -- get pods' to invoke a matching version | |||
</syntaxhighlight> | |||
--driver=none option is relevant to accessing host-level directories from pods and exposing them as hostPaths. Also see {{Internal|Minikube Concepts#Drivers|Minikube Concepts &124; Drivers}} | |||
==Kubernetes Configuration at Startup== | |||
{{External|https://minikube.sigs.k8s.io/docs/handbook/config/#modifying-kubernetes-defaults}} | |||
<syntaxhighlight lang='bash'> | |||
minikube start --extra-config=.... --extra-config=... | |||
</syntaxhighlight> | |||
<syntaxhighlight lang='bash'> | |||
minikube start --extra-config=apiserver.enable-admission-plugins=PodSecurityPolicy | |||
</syntaxhighlight> | |||
===Custom Configuration Files=== | |||
Files placed in ~/.minikube/files (including recursive directories) are transferred into minikube VM. A file placed in ~/.minikube/files/etc/tokens.csv is copied in the VM as /etc/token.csv. That can actually be verified by <code>minikube ssh</code> into the VM after boot. | |||
===Start with Admission Controller Enabled=== | |||
See [[#Enable_Pod_Security_Policies|Enable Pod Security Policies]] below for an example how to start with a PodSecurityPolicy admission controller. | |||
=Status= | |||
<syntaxhighlight lang='bash'> | |||
minikube status | |||
minikube | |||
type: Control Plane | |||
host: Running | |||
kubelet: Running | |||
apiserver: Running | |||
kubeconfig: Configured | |||
</syntaxhighlight> | |||
=Stop= | |||
{{External|https://minikube.sigs.k8s.io/docs/commands/stop/}} | |||
Stop the local Kubernetes cluster. This command stops the underlying VM or container, but keeps [[Minikube_Concepts#User_Data|user data]] intact. The cluster can be started again with the [[#Start|start]] command. | |||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
minikube | minikube stop | ||
✋ Stopping node "minikube" ... | |||
🛑 Powering off "minikube" via SSH ... | |||
🛑 1 nodes stopped. | |||
</syntaxhighlight> | </syntaxhighlight> | ||
= | =Delete= | ||
{{External|https://minikube.sigs.k8s.io/docs/commands/delete/}} | |||
Deletes a local Kubernetes cluster. This command deletes the VM, and removes all associated files. | |||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
minikube | minikube delete --all --purge | ||
</syntaxhighlight> | </syntaxhighlight> | ||
--all deletes all profiles. | |||
--purge deletes delete the '.minikube' folder from the user directory. | |||
=Dashboard= | =Dashboard= | ||
Line 26: | Line 108: | ||
=Version= | =Version= | ||
<syntaxhighlight lang='bash'> | |||
minikube version | |||
</syntaxhighlight> | |||
==Kubernetes Version== | |||
After minikube starts: | |||
<syntaxhighlight lang='bash'> | |||
kubectl version | |||
</syntaxhighlight> | |||
Also, nodes report their Kubernetes version: | |||
<syntaxhighlight lang='bash'> | |||
kubectl get nodes | |||
</syntaxhighlight> | |||
Also see: {{Internal|Minikube_Configuration#Configure_Kubernetes_Version|Minikube Configuration}} | |||
=Node Operations= | |||
{{External|https://minikube.sigs.k8s.io/docs/commands/node/}} | |||
=Enable Pod Security Policies= | |||
{{External|https://minikube.sigs.k8s.io/docs/tutorials/using_psp/}} | |||
<syntaxhighlight lang='bash'> | |||
minikube stop | |||
minikube start --extra-config=apiserver.enable-admission-plugins=PodSecurityPolicy --addons=pod-security-policy | |||
</syntaxhighlight> | |||
=CRI-O= | |||
{{Internal|CRI-O minikube|CRI-O Support on minikube}} | |||
=Mount= | |||
{{External|https://minikube.sigs.k8s.io/docs/handbook/mount/}} | |||
If minikube runs in its own VM, host directories can be exposed as hostPath only if they are mounted in the VM. This issue does not exist if minikube does not use a VM and runs in "bare-metal" configuration. See minikube start --driver=none option. Also see {{Internal|Minikube Concepts#Drivers|Minikube Concepts | Drivers}} | |||
Also see: {{Internal|Kubernetes_Storage_Concepts#hostPath_on_single-node_Kubernetes_Clusters_.28minikube.2C_Docker_Desktop_Kubernetes.29|hostPath on single-node Kubernetes Clusters (minikube, Docker_Desktop_Kubernetes)}} | |||
=Configuration= | |||
{{Internal|Minikube Configuration|Minikube Configuration}} | |||
=Troubleshooting= | |||
{{External|https://minikube.sigs.k8s.io/docs/handbook/troubleshooting/}} | |||
<syntaxhighlight lang='bash'> | |||
minikube logs | |||
</syntaxhighlight> | |||
<syntaxhighlight lang='bash'> | |||
minikube start --alsologtostderr --v=2 | |||
</syntaxhighlight> | |||
Obtaining details about kube-apiserver startup arguments: | |||
<syntaxhighlight lang='bash'> | |||
kubectl -n kube-system describe pod kube-apiserver-minikube | |||
</syntaxhighlight> | |||
SSH into the minikube VM: | |||
<syntaxhighlight lang='bash'> | |||
minikube ssh | |||
</syntaxhighlight> | |||
To get more details about IP and port: | |||
<syntaxhighlight lang='bash'> | |||
minikube ssh --v=2 --alsologtostderr | |||
</syntaxhighlight> | |||
Then you can use the IP address (127.0.0.1) and the port to connect via native SSH: | |||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
minikube | ssh docker@127.0.0.1 -p 32799 -i ~/.minikube/machines/minikube/id_rsa | ||
</syntaxhighlight> | |||
For file transfer, a local directory can be mounted into the minikube VM (failed last time I tried it): | |||
<syntaxhighlight lang='bash'> | |||
minikube mount ~/tmp/minikube:/tmp/temporary | |||
</syntaxhighlight> | |||
Files can be transferred back and forth via scp: | |||
<syntaxhighlight lang='bash'> | |||
scp -P 32799 -i ~/.minikube/machines/minikube/id_rsa docker@127.0.0.1:/var/tmp/minikube/kubeadm.yaml . | |||
</syntaxhighlight> | </syntaxhighlight> | ||
= | ==hostPath Mount Troubleshooting== | ||
ssh into the VM: | |||
<syntaxhighlight lang='bash'> | |||
minikube ssh | |||
</syntaxhighlight> | |||
Find the container for the pod in question: | |||
<syntaxhighlight lang='bash'> | |||
docker ps | |||
</syntaxhighlight> | |||
Describe the container: | |||
<syntaxhighlight lang='bash'> | |||
docker inspect <container-id> | |||
</syntaxhighlight> | |||
Look for "Binds". |
Latest revision as of 06:07, 10 June 2021
External
Internal
Overview
Administration is done with minikube
.
Addons
minikube instance must be running for "addons" to work.
minikube addons list
minikube addons enable <addon-name>
Start
Start Overview
Start Example
minikube start [-v=10] [--driver=none] [--kubernetes-version "v1.19.1"]
minikube v1.12.3 on Darwin 10.14.6
✨ Automatically selected the docker driver
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
💾 Downloading Kubernetes v1.18.3 preload ...
> preloaded-images-k8s-v5-v1.18.3-docker-overlay2-amd64.tar.lz4: 510.91 MiB
🔥 Creating docker container (CPUs=2, Memory=8100MB) ...
🐳 Preparing Kubernetes v1.18.3 on Docker 19.03.8 ...
🔎 Verifying Kubernetes components...
🌟 Enabled addons: default-storageclass, storage-provisioner
🏄 Done! kubectl is now configured to use "minikube"
❗ /usr/local/bin/kubectl is version 1.16.6-beta.0, which may be incompatible with Kubernetes 1.18.3.
💡 You can also use 'minikube kubectl -- get pods' to invoke a matching version
--driver=none option is relevant to accessing host-level directories from pods and exposing them as hostPaths. Also see
Kubernetes Configuration at Startup
minikube start --extra-config=.... --extra-config=...
minikube start --extra-config=apiserver.enable-admission-plugins=PodSecurityPolicy
Custom Configuration Files
Files placed in ~/.minikube/files (including recursive directories) are transferred into minikube VM. A file placed in ~/.minikube/files/etc/tokens.csv is copied in the VM as /etc/token.csv. That can actually be verified by minikube ssh
into the VM after boot.
Start with Admission Controller Enabled
See Enable Pod Security Policies below for an example how to start with a PodSecurityPolicy admission controller.
Status
minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
Stop
Stop the local Kubernetes cluster. This command stops the underlying VM or container, but keeps user data intact. The cluster can be started again with the start command.
minikube stop
✋ Stopping node "minikube" ...
🛑 Powering off "minikube" via SSH ...
🛑 1 nodes stopped.
Delete
Deletes a local Kubernetes cluster. This command deletes the VM, and removes all associated files.
minikube delete --all --purge
--all deletes all profiles.
--purge deletes delete the '.minikube' folder from the user directory.
Dashboard
minikube dashboard
Version
minikube version
Kubernetes Version
After minikube starts:
kubectl version
Also, nodes report their Kubernetes version:
kubectl get nodes
Also see:
Node Operations
Enable Pod Security Policies
minikube stop
minikube start --extra-config=apiserver.enable-admission-plugins=PodSecurityPolicy --addons=pod-security-policy
CRI-O
Mount
If minikube runs in its own VM, host directories can be exposed as hostPath only if they are mounted in the VM. This issue does not exist if minikube does not use a VM and runs in "bare-metal" configuration. See minikube start --driver=none option. Also see
Also see:
Configuration
Troubleshooting
minikube logs
minikube start --alsologtostderr --v=2
Obtaining details about kube-apiserver startup arguments:
kubectl -n kube-system describe pod kube-apiserver-minikube
SSH into the minikube VM:
minikube ssh
To get more details about IP and port:
minikube ssh --v=2 --alsologtostderr
Then you can use the IP address (127.0.0.1) and the port to connect via native SSH:
ssh docker@127.0.0.1 -p 32799 -i ~/.minikube/machines/minikube/id_rsa
For file transfer, a local directory can be mounted into the minikube VM (failed last time I tried it):
minikube mount ~/tmp/minikube:/tmp/temporary
Files can be transferred back and forth via scp:
scp -P 32799 -i ~/.minikube/machines/minikube/id_rsa docker@127.0.0.1:/var/tmp/minikube/kubeadm.yaml .
hostPath Mount Troubleshooting
ssh into the VM:
minikube ssh
Find the container for the pod in question:
docker ps
Describe the container:
docker inspect <container-id>
Look for "Binds".