Minikube Ingress DNS: Difference between revisions
Jump to navigation
Jump to search
| (40 intermediate revisions by the same user not shown) | |||
| Line 54: | Line 54: | ||
|} | |} | ||
== | ==CoreDNS== | ||
{| | {|class='wikitable mw-collapsible' | ||
| | !scope='col' style='width:600px'| | ||
'''Kube-System » ConfigMap » CoreDNS''' | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="yaml"> | |||
cat <<'YML'|kubectl apply -n kube-system -f - | |||
--- | |||
apiVersion: v1 | apiVersion: v1 | ||
kind: ConfigMap | |||
metadata: | |||
name: coredns | |||
namespace: kube-system | |||
data: | data: | ||
Corefile: | | Corefile: | | ||
| Line 65: | Line 73: | ||
log | log | ||
errors | errors | ||
health { | |||
-- | lameduck 5s | ||
} | |||
ready | |||
kubernetes cluster.local in-addr.arpa ip6.arpa { | |||
pods insecure | |||
fallthrough in-addr.arpa ip6.arpa | |||
ttl 30 | |||
} | |||
prometheus :9153 | |||
hosts { | |||
192.168.49.1 host.minikube.internal | |||
fallthrough | |||
} | |||
forward . /etc/resolv.conf { | |||
max_concurrent 1000 | |||
} | |||
cache 30 { | |||
disable success cluster.local | |||
disable denial cluster.local | |||
} | |||
loop | |||
reload | reload | ||
loadbalance | loadbalance | ||
} | } | ||
chorke.com:53 { | |||
errors | |||
cache 30 | |||
forward . 1.1.1.1 8.8.8.8 | |||
} | |||
chorke.org:53 { | |||
errors | |||
cache 30 | |||
forward . 1.1.1.1 8.8.8.8 | |||
} | |||
shahed.biz:53 { | |||
errors | |||
cache 30 | |||
forward . 1.1.1.1 8.8.8.8 | |||
} | |||
group.ops:53 { | |||
errors | |||
cache 30 | |||
forward . 192.168.49.2 | |||
} | |||
biz.ops:53 { | |||
errors | errors | ||
cache 30 | cache 30 | ||
forward . 192.168.49.2 | forward . 192.168.49.2 | ||
} | } | ||
com.ops:53 { | |||
errors | errors | ||
cache 30 | cache 30 | ||
forward . 192.168.49.2 | forward . 192.168.49.2 | ||
} | } | ||
k8s.ops:53 { | |||
errors | |||
cache 30 | |||
forward . 192.168.49.2 | |||
} | |||
org.ops:53 { | |||
errors | |||
cache 30 | |||
forward . 192.168.49.2 | |||
} | |||
bd.ops:53 { | |||
errors | |||
cache 30 | |||
forward . 192.168.49.2 | |||
} | |||
io.ops:53 { | |||
errors | |||
cache 30 | |||
forward . 192.168.49.2 | |||
} | |||
my.ops:53 { | |||
errors | |||
cache 30 | |||
forward . 192.168.49.2 | |||
} | |||
YML | |||
kubectl -n kube-system rollout restart deploy/coredns | |||
</syntaxhighlight> | |||
|} | |||
==Ingress DNS== | |||
{| | |||
|colspan="2"| | |||
<syntaxhighlight lang="bash"> | |||
# minikube nameserver ip | |||
printf -v MINIKUBE_NSLOOKUP '%s' $(minikube ip) | |||
</syntaxhighlight> | |||
|- | |||
|colspan="2"| | |||
---- | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang='bash' line> | |||
# minikube find coredns last entry | |||
CONFIGMAP_COREDNS_FIND=$(cat <<QRY | |||
}\n\ | |||
cache 30\n\ | |||
loop\n\ | |||
reload\n\ | |||
loadbalance\n\ | |||
} | |||
QRY | |||
) | |||
</syntaxhighlight> | |||
|valign='top'| | |||
<syntaxhighlight lang='bash' line> | |||
# minikube fill coredns last entry | |||
CONFIGMAP_COREDNS_FILL=$(cat <<UPD | |||
${CONFIGMAP_COREDNS_FIND}\n\ | |||
k8s.ops:53 {\n\ | |||
errors\n\ | |||
cache 30\n\ | |||
forward . ${MINIKUBE_NSLOOKUP}\n\ | |||
} | |||
UPD | |||
) | |||
</syntaxhighlight> | |||
|- | |||
|colspan="2"| | |||
---- | |||
'''K8s » CoreDNS''' | |||
---- | |||
|- | |||
|colspan="2"| | |||
<syntaxhighlight lang='bash'> | |||
# minikube update coredns entry for k8s.ops | |||
kubectl get configmap coredns -n kube-system -o yaml \ | |||
| sed -z "s|${CONFIGMAP_COREDNS_FIND}|$(echo "${CONFIGMAP_COREDNS_FILL}")|" \ | |||
| kubectl apply -n kube-system -f - | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 97: | Line 220: | ||
|- | |- | ||
|valign='top'| | |valign='top'| | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="yaml"> | ||
cat << | cat << YML | kubectl apply -n kubernetes-dashboard -f - | ||
--- | |||
apiVersion: networking.k8s.io/v1 | apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | kind: Ingress | ||
metadata: | metadata: | ||
name: kubernetes-dashboard | name: kubernetes-dashboard | ||
namespace: kubernetes-dashboard | |||
labels: | labels: | ||
app.kubernetes.io/version: 1.0.0 | |||
app.kubernetes.io/managed-by: kubectl | |||
app.kubernetes.io/name: kubernetes-dashboard | app.kubernetes.io/name: kubernetes-dashboard | ||
app.kubernetes.io/instance: kubernetes-dashboard | app.kubernetes.io/instance: kubernetes-dashboard | ||
spec: | spec: | ||
ingressClassName: nginx | ingressClassName: nginx | ||
rules: | rules: | ||
- host: "www.k8s. | - host: "www.k8s.ops" | ||
http: | http: | ||
paths: | paths: | ||
| Line 122: | Line 246: | ||
port: | port: | ||
number: 80 | number: 80 | ||
YML | |||
</syntaxhighlight> | </syntaxhighlight> | ||
|valign='top'| | |valign='top'| | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="yaml"> | ||
cat << | cat <<YML | kubectl delete -n kubernetes-dashboard -f - | ||
--- | |||
apiVersion: networking.k8s.io/v1 | apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | kind: Ingress | ||
metadata: | metadata: | ||
name: kubernetes-dashboard | name: kubernetes-dashboard | ||
namespace: kubernetes-dashboard | |||
labels: | labels: | ||
app.kubernetes.io/version: 1.0.0 | |||
app.kubernetes.io/managed-by: kubectl | |||
app.kubernetes.io/name: kubernetes-dashboard | app.kubernetes.io/name: kubernetes-dashboard | ||
app.kubernetes.io/instance: kubernetes-dashboard | app.kubernetes.io/instance: kubernetes-dashboard | ||
spec: | spec: | ||
ingressClassName: nginx | ingressClassName: nginx | ||
rules: | rules: | ||
- host: "www.k8s. | - host: "www.k8s.ops" | ||
http: | http: | ||
paths: | paths: | ||
| Line 151: | Line 276: | ||
port: | port: | ||
number: 80 | number: 80 | ||
YML | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 160: | Line 285: | ||
|colspan="2"| | |colspan="2"| | ||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
kubectl run -i --tty --rm debug --image=alpine --restart=Never -- nslookup www.k8s. | kubectl run -i --tty --rm debug --image=alpine --restart=Never -- nslookup www.k8s.ops | ||
kubectl run -i --tty --rm debug --image=alpine --restart=Never -- ping www.k8s. | kubectl run -i --tty --rm debug --image=alpine --restart=Never -- ping www.k8s.ops | ||
nslookup www.k8s. | nslookup www.k8s.ops $(minikube ip) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 172: | Line 297: | ||
|- | |- | ||
|colspan="2"| | |colspan="2"| | ||
<syntaxhighlight lang='bash'> | |||
sudo vim /etc/systemd/resolved.conf | |||
:' | |||
[Resolve] | |||
DNS=192.168.49.110 192.168.49.2 10.19.83.100 1.1.1.1 8.8.8.8 | |||
FallbackDNS=1.1.1.1 8.8.8.8 | |||
DNSStubListener=yes | |||
Domains=~. | |||
' | |||
sudo systemctl restart systemd-resolved | |||
resolvectl status | |||
</syntaxhighlight> | |||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
RESOLVE='/etc/resolv.conf';\ | RESOLVE='/etc/resolv.conf';\ | ||
| Line 190: | Line 327: | ||
|valign='top'| | |valign='top'| | ||
<syntaxhighlight lang="properties"> | <syntaxhighlight lang="properties"> | ||
nslookup www.k8s. | nslookup www.k8s.ops | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|valign='top'| | |valign='top'| | ||
<syntaxhighlight lang="properties"> | <syntaxhighlight lang="properties"> | ||
ping www.k8s. | ping www.k8s.ops | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 204: | Line 341: | ||
|valign='top'| | |valign='top'| | ||
<syntaxhighlight lang="properties"> | <syntaxhighlight lang="properties"> | ||
xdg-open http://www.k8s. | xdg-open http://www.k8s.ops &>/dev/null & | ||
gnome-open http://www.k8s. | gnome-open http://www.k8s.ops &>/dev/null & | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|valign='top'| | |valign='top'| | ||
<syntaxhighlight lang="properties"> | <syntaxhighlight lang="properties"> | ||
x-www-browser http://www.k8s. | x-www-browser http://www.k8s.ops &>/dev/null & | ||
sensible-browser http://www.k8s. | sensible-browser http://www.k8s.ops &>/dev/null & | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 217: | Line 354: | ||
==Dynamic DNS Script== | ==Dynamic DNS Script== | ||
<syntaxhighlight lang="bash" highlight="1, | <syntaxhighlight lang="bash" highlight="1,26-29,62-80,97" line> | ||
cat << EXE | sudo tee /etc/ | cat << EXE | sudo tee /etc/NetworkManager/dispatcher.d/minikube-ifupdown >/dev/null | ||
#!/bin/bash | #!/bin/bash | ||
: ' | : ' | ||
| Line 227: | Line 364: | ||
' | ' | ||
USER_TARGET="${ | USER_TARGET="minikube" | ||
IFACE="\${1}" | |||
ACTION="\${2}" | |||
function silent_exit(){ | function silent_exit(){ | ||
| Line 266: | Line 405: | ||
function verify_mode(){ | function verify_mode(){ | ||
if [[ "\${ | if [[ "\${ACTION}" == 'up' ]]; then verify_link; else verify_mini; fi | ||
} | } | ||
| Line 276: | Line 415: | ||
RESOLV_CONF='/etc/resolv.conf' | RESOLV_CONF='/etc/resolv.conf' | ||
if [[ -f \${RESOLV_CONF} ]]&&[[ "\$(grep -c \${DNS_HOST} \${RESOLV_CONF})" == 0 ]];then | if [[ -f \${RESOLV_CONF} ]]&&[[ "\$(grep -c \${DNS_HOST} \${RESOLV_CONF})" == 0 ]];then | ||
cat << CON | sudo tee | cat << CON | sudo tee \${RESOLV_CONF} >/dev/null | ||
# /etc/resolv.conf replaced by the minikube dispatcher | |||
# /etc/NetworkManager/dispatcher.d/minikube-ifupdown | |||
# | |||
# Dynamic resolv.conf (using network dispatch) | |||
# Primary DNS: Pi-Hole (192.168.49.110) | |||
# Secondary DNS: Minikube (192.168.49.2 ) | |||
# Backup DNS: Office DNS (10.19.83.100 ) | |||
# Loopback DNS: hostnamectl (127.0.0.53 ) | |||
# Public DNS fallback: Cloudflare + Google | |||
nameserver 192.168.49.110 | |||
nameserver 192.168.49.2 | |||
nameserver 10.19.83.100 | |||
nameserver 127.0.0.53 | |||
nameserver 1.1.1.1 | |||
nameserver 8.8.8.8 | |||
search ops local . | |||
options edns0 trust-ad | |||
CON | CON | ||
else silent_exit; fi | else silent_exit; fi | ||
| Line 295: | Line 451: | ||
init | init | ||
EXE | EXE | ||
sudo chmod +x /etc/ | sudo chmod +x /etc/NetworkManager/dispatcher.d/minikube-ifupdown | ||
</syntaxhighlight> | |||
==Swiss Knife== | |||
<syntaxhighlight lang="bash"> | |||
kubectl -n kube-system run -i --tty --rm nslookup-cli --image=alpine --restart=Never -- sh | |||
apk --update add inetutils-telnet | |||
nslookup kubernetes-dashboard.kubernetes-dashboard.svc.cluster.local | |||
nslookup postgresql-hl.postgresql.svc.cluster.local | |||
nslookup minikube-host.internal.svc.cluster.local | |||
nslookup postgresql.postgresql.svc.cluster.local | |||
nslookup redis-headless.redis.svc.cluster.local | |||
nslookup www.k8s.ops | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 396: | Line 565: | ||
| valign="top" | | | valign="top" | | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
CONFIGMAP_COREDNS_FIND=$(cat << | CONFIGMAP_COREDNS_FIND=$(cat <<QRY | ||
}\n\ | }\n\ | ||
cache 30\n\ | cache 30\n\ | ||
| Line 403: | Line 572: | ||
loadbalance\n\ | loadbalance\n\ | ||
} | } | ||
QRY | |||
) | ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 409: | Line 578: | ||
| valign="top" colspan="2" | | | valign="top" colspan="2" | | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
CONFIGMAP_COREDNS_FILL=$(cat << | CONFIGMAP_COREDNS_FILL=$(cat <<UPD | ||
${CONFIGMAP_COREDNS_FIND}\n\ | ${CONFIGMAP_COREDNS_FIND}\n\ | ||
k8s. | k8s.ops:53 {\n\ | ||
errors\n\ | errors\n\ | ||
cache 30\n\ | cache 30\n\ | ||
forward . 192.168.49.2\n\ | forward . 192.168.49.2\n\ | ||
} | } | ||
UPD | |||
) | ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 426: | Line 595: | ||
| valign="top" colspan="3" | | | valign="top" colspan="3" | | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
kubectl get configmap coredns -n kube-system -o yaml|sed -z "s|${CONFIGMAP_COREDNS_FIND}|$(echo "${CONFIGMAP_COREDNS_FILL}")|" | kubectl get configmap coredns -n kube-system -o yaml\ | ||
| sed -z "s|${CONFIGMAP_COREDNS_FIND}|$(echo "${CONFIGMAP_COREDNS_FILL}")|" | |||
</syntaxhighlight> | |||
|- | |||
| colspan="3" | | |||
---- | |||
|- | |||
| valign="top" colspan="3" | | |||
<syntaxhighlight lang="bash"> | |||
cat << ENV | kubectl -n=kubernetes-dashboard create secret generic kubernetes-dashboard-auth --from-file=auth=/dev/stdin | |||
$(htpasswd -nbB shahed 'sadaqah!') | |||
$(htpasswd -nbB chorke 'sadaqah!') | |||
ENV | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 458: | Line 640: | ||
| valign="top" | | | valign="top" | | ||
* [[Minikube Tunnel|Minikube » Tunnel]] | |||
|- | |- | ||
| Line 476: | Line 659: | ||
| valign="top" | | | valign="top" | | ||
* [https://github.com/coredns/coredns/issues/2347 K8s » CoreDNS » Configure » Rewrite » Custom DNS] | |||
* [https://audun-nes.medium.com/configure-coredns-as-basic-dns-server-on-your-local-area-network-at-home-e67463b83ba3 CoreDNS » Configure as basic DNS server at Home] | |||
* [https://askubuntu.com/questions/1512141/ Ubuntu » 24.04 » <code>if-up.d</code> doesn't executed] | * [https://askubuntu.com/questions/1512141/ Ubuntu » 24.04 » <code>if-up.d</code> doesn't executed] | ||
* [https://stackoverflow.com/questions/19075671/ Bash » Use Shell Variables In An <code>awk</code> Script] | * [https://stackoverflow.com/questions/19075671/ Bash » Use Shell Variables In An <code>awk</code> Script] | ||
* [https://www.alibabacloud.com/help/en/ack/ack-managed-and-ack-dedicated/user-guide/configure-coredns#:~:text=rewrite%20stop K8s » CoreDNS » Configure » Rewrite] | |||
* [https://coredns.io/plugins/rewrite/ CoreDNS » Plugins » Rewrite] | |||
* [https://www.hostinger.my/tutorials/cron-job Understanding Cron Syntax] | * [https://www.hostinger.my/tutorials/cron-job Understanding Cron Syntax] | ||
* [[Google Cloud CLI]] | * [[Google Cloud CLI]] | ||
* [[Free Up RAM|Free Up RAM]] | |||
* [[AWS CLI]] | * [[AWS CLI]] | ||
| valign="top" | | | valign="top" | | ||
* [https://stackoverflow.com/questions/54509142/ K8s » CoreDNS » Rewrite » Return the rewritten name] | |||
* [https://kubernetes.io/docs/tasks/administer-cluster/dns-custom-nameservers/ K8s » CoreDNS » Customizing DNS Service] | |||
* [https://github.com/coredns/coredns/blob/master/plugin/rewrite/README.md CoreDNS » Plugins » Rewrite » README] | |||
* [[Swap Space]] | |||
|} | |} | ||
Latest revision as of 16:40, 23 October 2025
minikube stop
minikube delete --all
rm -rf ${HOME}/.minikube/*
|
minikube start
minikube docker-env
minikube addons list
|
minikube addons enable ingress
minikube addons enable ingress-dns
minikube addons enable metrics-server
|
|
| ||
kubectl get ns
kubectl get all
kubectl get all -A
kubectl get pods -A
kubectl get namespaces
|
minikube kubectl -- get ns
minikube kubectl -- get all
minikube kubectl -- get all -A
minikube kubectl -- get pods -A
minikube kubectl -- get namespaces
|
kubectl get all -n kube-system
kubectl get configmap -n kube-system
kubectl get configmap coredns -n kube-system
kubectl edit configmap coredns -n kube-system
kubectl get configmap coredns -n kube-system -o yaml
|
CoreDNS
|
Kube-System » ConfigMap » CoreDNS |
|---|
cat <<'YML'|kubectl apply -n kube-system -f -
---
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns
namespace: kube-system
data:
Corefile: |
.:53 {
log
errors
health {
lameduck 5s
}
ready
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
prometheus :9153
hosts {
192.168.49.1 host.minikube.internal
fallthrough
}
forward . /etc/resolv.conf {
max_concurrent 1000
}
cache 30 {
disable success cluster.local
disable denial cluster.local
}
loop
reload
loadbalance
}
chorke.com:53 {
errors
cache 30
forward . 1.1.1.1 8.8.8.8
}
chorke.org:53 {
errors
cache 30
forward . 1.1.1.1 8.8.8.8
}
shahed.biz:53 {
errors
cache 30
forward . 1.1.1.1 8.8.8.8
}
group.ops:53 {
errors
cache 30
forward . 192.168.49.2
}
biz.ops:53 {
errors
cache 30
forward . 192.168.49.2
}
com.ops:53 {
errors
cache 30
forward . 192.168.49.2
}
k8s.ops:53 {
errors
cache 30
forward . 192.168.49.2
}
org.ops:53 {
errors
cache 30
forward . 192.168.49.2
}
bd.ops:53 {
errors
cache 30
forward . 192.168.49.2
}
io.ops:53 {
errors
cache 30
forward . 192.168.49.2
}
my.ops:53 {
errors
cache 30
forward . 192.168.49.2
}
YML
kubectl -n kube-system rollout restart deploy/coredns
|
Ingress DNS
# minikube nameserver ip
printf -v MINIKUBE_NSLOOKUP '%s' $(minikube ip)
| |
|
| |
# minikube find coredns last entry
CONFIGMAP_COREDNS_FIND=$(cat <<QRY
}\n\
cache 30\n\
loop\n\
reload\n\
loadbalance\n\
}
QRY
)
|
# minikube fill coredns last entry
CONFIGMAP_COREDNS_FILL=$(cat <<UPD
${CONFIGMAP_COREDNS_FIND}\n\
k8s.ops:53 {\n\
errors\n\
cache 30\n\
forward . ${MINIKUBE_NSLOOKUP}\n\
}
UPD
)
|
|
K8s » CoreDNS | |
# minikube update coredns entry for k8s.ops
kubectl get configmap coredns -n kube-system -o yaml \
| sed -z "s|${CONFIGMAP_COREDNS_FIND}|$(echo "${CONFIGMAP_COREDNS_FILL}")|" \
| kubectl apply -n kube-system -f -
| |
|
K8s » Dashboard | |
cat << YML | kubectl apply -n kubernetes-dashboard -f -
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: kubernetes-dashboard
namespace: kubernetes-dashboard
labels:
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/managed-by: kubectl
app.kubernetes.io/name: kubernetes-dashboard
app.kubernetes.io/instance: kubernetes-dashboard
spec:
ingressClassName: nginx
rules:
- host: "www.k8s.ops"
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: kubernetes-dashboard
port:
number: 80
YML
|
cat <<YML | kubectl delete -n kubernetes-dashboard -f -
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: kubernetes-dashboard
namespace: kubernetes-dashboard
labels:
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/managed-by: kubectl
app.kubernetes.io/name: kubernetes-dashboard
app.kubernetes.io/instance: kubernetes-dashboard
spec:
ingressClassName: nginx
rules:
- host: "www.k8s.ops"
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: kubernetes-dashboard
port:
number: 80
YML
|
|
| |
kubectl run -i --tty --rm debug --image=alpine --restart=Never -- nslookup www.k8s.ops
kubectl run -i --tty --rm debug --image=alpine --restart=Never -- ping www.k8s.ops
nslookup www.k8s.ops $(minikube ip)
| |
|
K8s » DNS Config | |
sudo vim /etc/systemd/resolved.conf
:'
[Resolve]
DNS=192.168.49.110 192.168.49.2 10.19.83.100 1.1.1.1 8.8.8.8
FallbackDNS=1.1.1.1 8.8.8.8
DNSStubListener=yes
Domains=~.
'
sudo systemctl restart systemd-resolved
resolvectl status
RESOLVE='/etc/resolv.conf';\
printf -v K8S_DNS '%s' $(minikube ip);\
if [ -f ${RESOLVE} ]&&[ "$(grep -c ${K8S_DNS} ${RESOLVE})" == 0 ];then\
cat << EOF | sudo tee -a ${RESOLVE} >/dev/null
nameserver ${K8S_DNS}
EOF
fi;\
cat ${RESOLVE}
| |
|
| |
nslookup www.k8s.ops
|
ping www.k8s.ops
|
|
| |
xdg-open http://www.k8s.ops &>/dev/null &
gnome-open http://www.k8s.ops &>/dev/null &
|
x-www-browser http://www.k8s.ops &>/dev/null &
sensible-browser http://www.k8s.ops &>/dev/null &
|
Dynamic DNS Script
cat << EXE | sudo tee /etc/NetworkManager/dispatcher.d/minikube-ifupdown >/dev/null
#!/bin/bash
: '
@vendor Chorke Academia, Inc.
@web https://cdn.chorke.org/docs/academia
@version 1.0.00
@since 1.0.00
'
USER_TARGET="minikube"
IFACE="\${1}"
ACTION="\${2}"
function silent_exit(){
exit 0
}
function verify_addr(){
printf -v DNS_HOST '%s' \$(sudo -u \${USER_TARGET} minikube ip)
if [[ "\${DNS_HOST}" =~ ^(([1-9]?[0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))\.){3}([1-9]?[0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))$ ]]; then
if [[ "\${DNS_HOST}" == '127.0.0.1' ]]; then silent_exit; fi
else silent_exit; fi
}
function verify_kube(){
printf -v K8S_JSON '%s' \$(sudo -u \${USER_TARGET} minikube status -o 'json')
printf -v K8S_REST '%s' \$(echo \${K8S_JSON} | jq -r '.APIServer')
printf -v K8S_KUBE '%s' \$(echo \${K8S_JSON} | jq -r '.Kubelet')
printf -v K8S_HOST '%s' \$(echo \${K8S_JSON} | jq -r '.Host')
if [[ "\${K8S_HOST}" == 'Running' ]]&&
[[ "\${K8S_KUBE}" == 'Running' ]]&&
[[ "\${K8S_REST}" == 'Running' ]]; then verify_addr
else silent_exit; fi
}
function verify_tool(){
if [[ -x "\$(command -v jq)" ]]; then verify_kube; else silent_exit; fi
}
function verify_mini(){
if [[ -x "\$(command -v minikube)" ]]; then verify_tool; else silent_exit; fi
}
function verify_link(){
HOST_ETHERS="\$(ip -j link show | jq -r '.[].ifname'| paste -sd' ' -)"
if [[ "\${HOST_ETHERS}" =~ "\${IFACE}" ]]; then verify_mini; else silent_exit; fi
}
function verify_mode(){
if [[ "\${ACTION}" == 'up' ]]; then verify_link; else verify_mini; fi
}
function verify(){
verify_mode
}
function amend_nameserver(){
RESOLV_CONF='/etc/resolv.conf'
if [[ -f \${RESOLV_CONF} ]]&&[[ "\$(grep -c \${DNS_HOST} \${RESOLV_CONF})" == 0 ]];then
cat << CON | sudo tee \${RESOLV_CONF} >/dev/null
# /etc/resolv.conf replaced by the minikube dispatcher
# /etc/NetworkManager/dispatcher.d/minikube-ifupdown
#
# Dynamic resolv.conf (using network dispatch)
# Primary DNS: Pi-Hole (192.168.49.110)
# Secondary DNS: Minikube (192.168.49.2 )
# Backup DNS: Office DNS (10.19.83.100 )
# Loopback DNS: hostnamectl (127.0.0.53 )
# Public DNS fallback: Cloudflare + Google
nameserver 192.168.49.110
nameserver 192.168.49.2
nameserver 10.19.83.100
nameserver 127.0.0.53
nameserver 1.1.1.1
nameserver 8.8.8.8
search ops local .
options edns0 trust-ad
CON
else silent_exit; fi
}
function handle(){
amend_nameserver
}
function init(){
verify
handle
}
init
EXE
sudo chmod +x /etc/NetworkManager/dispatcher.d/minikube-ifupdown
Swiss Knife
kubectl -n kube-system run -i --tty --rm nslookup-cli --image=alpine --restart=Never -- sh
apk --update add inetutils-telnet
nslookup kubernetes-dashboard.kubernetes-dashboard.svc.cluster.local
nslookup postgresql-hl.postgresql.svc.cluster.local
nslookup minikube-host.internal.svc.cluster.local
nslookup postgresql.postgresql.svc.cluster.local
nslookup redis-headless.redis.svc.cluster.local
nslookup www.k8s.ops
Playground
minikube status -f '{{.Kubeconfig}}'
minikube status -f '{{.APIServer}}'
minikube status -f '{{.Kubelet}}'
minikube status -f '{{.Worker}}'
minikube status -f '{{.Host}}'
|
minikube status -o 'json' | jq -r '.Kubeconfig'
minikube status -o 'json' | jq -r '.APIServer'
minikube status -o 'json' | jq -r '.Kubelet'
minikube status -o 'json' | jq -r '.Worker'
minikube status -o 'json' | jq -r '.Host'
|
ip -j link show | jq -r '.[].ifname'| paste -sd' ' -
ip -j link show type bridge | jq -r '.[].ifname'
ip -o link show | awk -F': ' '{print $2}'
ip -j link show | jq -r '.[].ifname'
ls /sys/class/net
|
|
| ||
minikube status -f '{{- if .TimeToStop }} timeToStop: {{.TimeToStop}} {{- end }}'
minikube status -f '{{- if .DockerEnv }} docker-env: {{.DockerEnv}} {{- end }}'
minikube status -o 'json' | jq
|
ip -j link show | jq -r '.[]|select(.link_type=="loopback")'
ip -j link show | jq -r '.[]|select(.link_type=="ether")'
ip -j link show | jq -r '.[]|select(.link_type==null)'
| |
|
| ||
export SYSTEM_RAM_QUOTA=$((3*1024))
export SYSTEM_RAM_LIMIT=$(awk '/^MemTotal:/ {print int($2/1024-3*1024);}' /proc/meminfo)
export SYSTEM_RAM_LIMIT=$(awk -v QUOTA="${SYSTEM_RAM_QUOTA}" '/^MemTotal:/ {print int($2/1024-QUOTA);}' /proc/meminfo)
| ||
|
| ||
bash <(curl -s 'https://cdn.chorke.org/exec/cli/bash/install/minikube/network/ifupdown/1.0.0-ubuntu-22.04.sh.txt')
sudo su -c 'export IFACE=lo;export MODE=stop; /etc/network/if-post-down.d/minikube-ifupdown'
sudo su -c 'export IFACE=lo;export MODE=start;/etc/network/if-up.d/minikube-ifupdown'
| ||
|
| ||
echo 'export IFACE=lo;export MODE=stop; /etc/network/if-post-down.d/minikube-ifupdown'|sudo su
echo 'export IFACE=lo;export MODE=start;/etc/network/if-up.d/minikube-ifupdown'|sudo su
ls -lah /etc/network/if-{up,post-down}.d/minikube-ifupdown
sudo rm -f /etc/network/if-{up,post-down}.d/minikube-ifupdown
| ||
|
| ||
bash <(curl -s 'https://cdn.chorke.org/exec/cli/bash/install/minikube/network/ifupdown/1.0.0-ubuntu-24.04.sh.txt')
sudo /etc/NetworkManager/dispatcher.d/minikube-ifupdown lo down
sudo /etc/NetworkManager/dispatcher.d/minikube-ifupdown lo up
| ||
|
| ||
CONFIGMAP_COREDNS_FIND=$(cat <<QRY
}\n\
cache 30\n\
loop\n\
reload\n\
loadbalance\n\
}
QRY
)
|
CONFIGMAP_COREDNS_FILL=$(cat <<UPD
${CONFIGMAP_COREDNS_FIND}\n\
k8s.ops:53 {\n\
errors\n\
cache 30\n\
forward . 192.168.49.2\n\
}
UPD
)
| |
|
| ||
kubectl get configmap coredns -n kube-system -o yaml\
| sed -z "s|${CONFIGMAP_COREDNS_FIND}|$(echo "${CONFIGMAP_COREDNS_FILL}")|"
| ||
|
| ||
cat << ENV | kubectl -n=kubernetes-dashboard create secret generic kubernetes-dashboard-auth --from-file=auth=/dev/stdin
$(htpasswd -nbB shahed 'sadaqah!')
$(htpasswd -nbB chorke 'sadaqah!')
ENV
| ||