Minikube: Difference between revisions
Jump to navigation
Jump to search
Line 218: | Line 218: | ||
minikube ip | minikube ip | ||
kubectl edit configmap coredns -n kube-system | kubectl edit configmap coredns -n kube-system | ||
<source lang='properties' line> | |||
apiVersion: v1 | |||
data: | |||
Corefile: | | |||
.:53 { | |||
errors | |||
</source> | |||
---- | |||
<source lang='properties' line start='25' highlight='4-8'> | <source lang='properties' line start='25' highlight='4-8'> | ||
reload | reload | ||
Line 229: | Line 237: | ||
kind: ConfigMap | kind: ConfigMap | ||
metadata: | metadata: | ||
|} | |||
</source> | </source> | ||
==Knowledge== | ==Knowledge== |
Revision as of 23:24, 7 July 2023
sudo mkdir -p /opt/cli/minikube-linux-amd64/bin
sudo wget -cq https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64\
-O /opt/cli/minikube-linux-amd64/bin/minikube
sudo chmod +x /opt/cli/minikube-linux-amd64/bin/minikube
sudo update-alternatives --install /usr/local/bin/minikube minikube\
/opt/cli/minikube-linux-amd64/bin/minikube 1980
Order | Port Type | Internal IP | Internal Port | External IP | External Port |
---|---|---|---|---|---|
1 |
TCP |
0.0.0.0 |
32443 |
127.0.0.1 |
49153
|
2 |
TCP |
0.0.0.0 |
8443 |
127.0.0.1 |
49154
|
3 |
TCP |
0.0.0.0 |
5000 |
127.0.0.1 |
49155
|
4 |
TCP |
0.0.0.0 |
2376 |
127.0.0.1 |
49156
|
5 |
TCP |
0.0.0.0 |
22 |
127.0.0.1 |
49157
|
Kubectl
sudo mkdir -p /etc/apt/keyrings
sudo curl -fsSLo /etc/apt/keyrings/kubernetes-archive-keyring.gpg\
https://packages.cloud.google.com/apt/doc/apt-key.gpg
cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list >/dev/null
deb [arch=$(dpkg --print-architecture)\
signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg]\
https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt update
sudo apt install kubectl
Cluster
minikube start
:'
😄 minikube v1.29.0 on Ubuntu 22.04
✨ Automatically selected the docker driver. Other choices: kvm2, qemu2, none, ssh
📌 Using Docker driver with root privileges
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
💾 Downloading Kubernetes v1.26.1 preload ...
> preloaded-images-k8s-v18-v1...: 397.05 MiB / 397.05 MiB 100.00% 33.42 M
> gcr.io/k8s-minikube/kicbase...: 407.19 MiB / 407.19 MiB 100.00% 7.46 Mi
🔥 Creating docker container (CPUs=2, Memory=5900MB) ...
🐳 Preparing Kubernetes v1.26.1 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
🌟 Enabled addons: storage-provisioner, default-storageclass
🔎 Verifying Kubernetes components...
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
'
kubectl get po -A
minikube kubectl -- get po -A
:'
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-64897985d-thxhw 1/1 Running 0 8m14s
kube-system etcd-minikube 1/1 Running 0 8m26s
kube-system kube-apiserver-minikube 1/1 Running 0 8m26s
kube-system kube-controller-manager-minikube 1/1 Running 0 8m26s
kube-system kube-proxy-xqfl2 1/1 Running 0 8m13s
kube-system kube-scheduler-minikube 1/1 Running 0 8m26s
kube-system storage-provisioner 1/1 Running 1 (7m43s ago) 8m25s
'
Dashboard
minikube addons enable metrics-server
minikube dashboard
:'
🔌 Enabling ...
▪ Using image kubernetesui/metrics-scraper:v1.0.7
▪ Using image kubernetesui/dashboard:v2.3.1
🤔 Verifying dashboard health ...
🚀 Launching proxy ...
🤔 Verifying proxy health ...
🎉 Opening http://127.0.0.1:36403/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser...
Gtk-Message: 17:34:36.652: Failed to load module "canberra-gtk-module"
Gtk-Message: 17:34:36.654: Failed to load module "canberra-gtk-module"
'
Deploy
Deployment/NodePort: kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4 kubectl expose deployment hello-minikube --type=NodePort --port=8080 kubectl port-forward service/hello-minikube 7080:8080 http://localhost:7080/ kubectl get services hello-minikube kubectl delete services hello-minikube kubectl delete deployment hello-minikube
Deployment/LoadBalancer: kubectl create deployment balanced --image=k8s.gcr.io/echoserver:1.4 kubectl expose deployment balanced --type=LoadBalancer --port=8080 kubectl get services balanced kubectl delete services balanced kubectl delete deployment balanced
Example
docker build -t chorke/crawler:1.0.00 -f ./Dockerfile .
docker tag chorke/crawler:1.0.00 reg.chorke.org/chorke/crawler:1.0.00
docker push reg.chorke.org/chorke/crawler:1.0.00
docker pull hub.chorke.org/chorke/crawler:1.0.00
docker tag hub.chorke.org/chorke/crawler:1.0.00 chorke/crawler:1.0.00
minikube image load chorke/crawler:1.0.00
minikube image ls --format table
kubectl run crawler --image=chorke/crawler:1.0.00 --image-pull-policy=Never --restart=Never
kubectl logs crawler
kubectl get pod
kubectl delete pod crawler -n default
kubectl delete pod crawler
Deployment/NodePort: kubectl create deployment crawler --image=chorke/crawler:1.0.00 kubectl expose deployment crawler --type=NodePort --port=1983 kubectl port-forward service/crawler 1983:1983 http://localhost:1983/crawler kubectl get services crawler kubectl delete services crawler kubectl delete deployment crawler
Ingress DNS
minikube start
cat /etc/resolv.conf | grep nameserver
|
minikube addons enable ingress
minikube addons enable ingress-dns
|
nslookup academia.local
nslookup academia.local $(minikube ip)
| |||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
kubectl get configmap coredns -n kube-system -o yaml
kubectl get configmap coredns -n kube-system -o "jsonpath={.data.Corefile}"
| |||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
sudo vim /etc/NetworkManager/NetworkManager.conf [main]
dns=dnsmasq
plugins=ifupdown,keyfile
[ifupdown]
managed=false
[device]
wifi.scan-rand-mac-address=no
cat << EOF | sudo tee /etc/NetworkManager/dnsmasq.d/minikube.conf >/dev/null
server=/local/$(minikube ip)
EOF
| |||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
sudo systemctl restart NetworkManager.service sudo systemctl status NetworkManager.service cat /etc/resolv.conf | grep nameserver | |||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||
minikube ip kubectl edit configmap coredns -n kube-system apiVersion: v1
data:
Corefile: |
.:53 {
errors
reload
loadbalance
}
local:53 {
errors
cache 30
forward . 192.168.49.2
}
kind: ConfigMap
metadata:
|}
Knowledge
References
|