AlanGreene / starter

Dotfiles starter project for new machines
1 stars 1 forks source link

Kubernetes #58

Open AlanGreene opened 2 years ago

AlanGreene commented 2 years ago

To test / review / consider:

The following may be more suited to a homelab repo, ref. https://github.com/AlanGreene/starter/discussions/50

AlanGreene commented 1 year ago

Get the name of the all the nodes’ name, os image, os architecture, pod cidrs, internal and external ip address

kubectl get nodes -o custom-columns='NODE-NAME:.metadata.name,OS-IMAGE:.status.nodeInfo.osImage,OS-ARCH:.status.nodeInfo.architecture,POD-CIDRs:.spec.podCIDRs[*],INTERNAL-IP:.status.addresses[?(@.type=="InternalIP")].address,EXTERNAL-IP:.status.addresses[?(@.type=="ExternalIP")].address'

which shows:

NODE-NAME               OS-IMAGE             OS-ARCH   POD-CIDRs       INTERNAL-IP    EXTERNAL-IP
sideling1.example.com   Ubuntu 20.04.2 LTS   amd64     10.244.0.0/24   10.51.10.109   <none>
sideling2.example.com   Ubuntu 20.04.2 LTS   amd64     10.244.1.0/24   10.51.12.45    <none>

Get all the pods that are using specific configmap. Change the configmap name according to your requirement in @.spec.volumes[*].configMap.name=="test-config"

which worked for me using the coredns configMap.

First I queried for configMaps on my cluster: -

kubectl get configmaps -A

NAMESPACE         NAME                                 DATA   AGE
default           kube-root-ca.crt                     1      57d
kube-node-lease   kube-root-ca.crt                     1      57d
kube-public       cluster-info                         1      57d
kube-public       kube-root-ca.crt                     1      57d
kube-system       calico-config                        4      57d
kube-system       coredns                              1      57d
kube-system       extension-apiserver-authentication   6      57d
kube-system       kube-proxy                           2      57d
kube-system       kube-root-ca.crt                     1      57d
kube-system       kubeadm-config                       2      57d
kube-system       kubelet-config-1.21                  1      57d

and then for Pods using that particular configMap: -

kubectl get pods --all-namespaces -o jsonpath='{range $.items[?(@.spec.volumes[*].configMap.name=="coredns")]}{.metadata.name}{"\t"}{.spec.volumes[*].configMap.name}{"\n"}{end}'

coredns-558bd4d5db-dmnnc    coredns
coredns-558bd4d5db-t8xnm    coredns

Get the name of the all the nodes and their corresponding InternalIP address.

kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.addresses[?(@.type=="InternalIP")].address}{"\n"}{end}'

sideling1.example.com   10.51.10.109
sideling2.example.com   10.51.12.45

Get all the pods that are on specific node. Change the node name accordingly

kubectl get pods --all-namespaces -o jsonpath='{range $.items[?(@.spec.nodeName=="sideling1.example.com")]}{.metadata.name}{"\t"}{.spec.nodeName}{"\n"}{end}'

calico-kube-controllers-cc8959d7f-9qhh4 sideling1.example.com
calico-node-kwj42   sideling1.example.com
coredns-558bd4d5db-dmnnc    sideling1.example.com
coredns-558bd4d5db-t8xnm    sideling1.example.com
etcd-sideling1.example.com  sideling1.example.com
kube-apiserver-sideling1.example.com    sideling1.example.com
kube-controller-manager-sideling1.example.com   sideling1.example.com
kube-proxy-kz2cm    sideling1.example.com
kube-scheduler-sideling1.example.com    sideling1.example.com

kubectl get pods --all-namespaces -o jsonpath='{range $.items[?(@.spec.nodeName=="sideling2.example.com")]}{.metadata.name}{"\t"}{.spec.nodeName}{"\n"}{end}'

calico-node-jd867   sideling2.example.com
kube-proxy-bc897    sideling2.example.com
AlanGreene commented 9 months ago

Including colima as replacement for Docker Desktop, and additional steps for docker CLI here too…

brew install colima docker docker-buildx
mkdir -p ~/.docker/cli-plugins
ln -sfn $HOMEBREW_PREFIX/opt/docker-buildx/bin/docker-buildx ~/.docker/cli-plugins/docker-buildx

colima start --cpu 2 --memory 4

Should be sufficient for a basic working environment in which to run kind etc.

colima start --edit to save changes to a config file

brew services start colima to run on system startup

AlanGreene commented 3 months ago

https://headlamp.dev/ in particular see https://headlamp.dev/docs/latest/development/plugins/functionality (similar approach could also be useful for resurrecting some of the previous Dashboard extension functionality)