K8s: Difference between revisions
Jump to navigation
Jump to search
(52 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
==K8s Lens== | |||
<syntaxhighlight lang="bash"> | |||
# install from snapcraft | |||
sudo snap install kontena-lens --classic | |||
# license version | |||
curl -fsSL https://downloads.k8slens.dev/keys/gpg\ | |||
| sudo gpg --dearmor -o /etc/apt/keyrings/k8slens.gpg | |||
cat << EOF | sudo tee /etc/apt/sources.list.d/k8slens.list >/dev/null | |||
deb [arch=$(dpkg --print-architecture)\ | |||
signed-by=/etc/apt/keyrings/k8slens.gpg]\ | |||
https://downloads.k8slens.dev/apt/debian stable main | |||
EOF | |||
sudo apt install lens | |||
lens-desktop | |||
</syntaxhighlight> | |||
==Kind== | ==Kind== | ||
{| | {| | ||
Line 28: | Line 47: | ||
==Volume== | ==Volume== | ||
{| | |||
|valign='top'| | |||
<syntaxhighlight lang="properties"> | |||
cat <<EOF | kubectl apply -f - | |||
apiVersion: v1 | |||
kind: PersistentVolume | |||
metadata: | |||
name: chorke-pv | |||
spec: | |||
capacity: | |||
storage: 10Gi | |||
volumeMode: Filesystem | |||
accessModes: | |||
- ReadWriteOnce | |||
persistentVolumeReclaimPolicy: Retain | |||
storageClassName: chorke-local-storage | |||
hostPath: | |||
path: /home/shahed/.chorke/academia/var/k8s | |||
nodeAffinity: | |||
required: | |||
nodeSelectorTerms: | |||
- matchExpressions: | |||
- key: k8s.io/minikube-hostpath | |||
operator: In | |||
values: | |||
- node-hostname | |||
--- | |||
apiVersion: v1 | |||
kind: PersistentVolumeClaim | |||
metadata: | |||
name: chorke-pvc | |||
spec: | |||
accessModes: | |||
- ReadWriteOnce | |||
resources: | |||
requests: | |||
storage: 10Gi | |||
storageClassName: chorke-local-storage | |||
EOF | |||
</syntaxhighlight> | |||
|valign='top'| | |||
<syntaxhighlight lang="properties"> | |||
cat <<EOF | kubectl delete -f - | |||
apiVersion: v1 | |||
kind: PersistentVolume | |||
metadata: | |||
name: chorke-pv | |||
spec: | |||
capacity: | |||
storage: 10Gi | |||
volumeMode: Filesystem | |||
accessModes: | |||
- ReadWriteOnce | |||
persistentVolumeReclaimPolicy: Retain | |||
storageClassName: chorke-local-storage | |||
hostPath: | |||
path: /home/shahed/.chorke/academia/var/k8s | |||
nodeAffinity: | |||
required: | |||
nodeSelectorTerms: | |||
- matchExpressions: | |||
- key: k8s.io/minikube-hostpath | |||
operator: In | |||
values: | |||
- node-hostname | |||
--- | |||
apiVersion: v1 | |||
kind: PersistentVolumeClaim | |||
metadata: | |||
name: chorke-pvc | |||
spec: | |||
accessModes: | |||
- ReadWriteOnce | |||
resources: | |||
requests: | |||
storage: 10Gi | |||
storageClassName: chorke-local-storage | |||
EOF | |||
</syntaxhighlight> | |||
|- | |||
|colspan='2'| | |||
---- | |||
|- | |||
|valign='top'| | |||
|valign='top'| | |||
|- | |||
|colspan='2'| | |||
---- | |||
|- | |||
|valign='top'| | |||
|valign='top'| | |||
|} | |||
==Storage== | |||
# Ceph RBD | |||
# GlusterFS | |||
# OpenEBS | |||
# Longhorn | |||
# Rook | |||
==Argo CD== | ==Argo CD== | ||
Line 35: | Line 159: | ||
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml | kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml | ||
kubectl get | kubectl get -n=argocd pod | ||
kubectl get service -n argocd | kubectl get -n=argocd service -n argocd | ||
kubectl port-forward -n argocd service/argocd-server 8080:80 | kubectl port-forward -n=argocd service/argocd-server 8080:80 | ||
kubectl get -n=argocd -o=yaml secret argocd-initial-admin-secret | |||
echo RE83Uk81QTU5clZyLTlsdg== | base64 --decode | |||
https://localhost:8080/login | |||
---- | ---- | ||
{| | {| | ||
Line 65: | Line 193: | ||
|} | |} | ||
==Docker Config== | |||
kubectl create secret -n chorke generic image-pull-secret --from-file=.dockerconfigjson=${HOME}/.docker/config.json --type=kubernetes.io/dockerconfigjson | |||
kubectl get secret -n chorke image-pull-secret -o "jsonpath={.data.\.dockerconfigjson}" | base64 --decode | |||
kubectl get secret -n chorke image-pull-secret -o yaml | |||
kubectl delete secret -n chorke image-pull-secret | |||
kubectl get pods -A -o jsonpath='{range .items[*]}{"\n"}{.metadata.name}{":\t"}{range .spec.containers[*]}{.image}{", "}{end}{end}' |sort | |||
kubectl get pods -A -o jsonpath="{.items[*].spec.containers[*].image}" |tr -s '[[:space:]]' '\n' |sort |uniq -c | |||
kubectl delete pod academia-<hash> -n chorke --force --grace-period=0 | |||
kubectl delete pod academia-<hash> -n chorke | |||
kubectl get pod academia-<hash> -n chorke -o yaml | |||
kubectl describe pod academia-<hash> -n chorke | |||
kubectl edit pod academia-<hash> -n chorke | |||
kubectl get pod academia-<hash> -n chorke | |||
kubectl logs academia-<hash> -n chorke | |||
kubectl get events -n chorke | |||
==Knowledge== | ==Knowledge== | ||
Line 74: | Line 221: | ||
|valign="top"| | |valign="top"| | ||
<syntaxhighlight lang='bash'> | |||
minikube addons enable default-storageclass | |||
minikube addons enable metrics-server | |||
minikube addons enable metallb | |||
</syntaxhighlight> | |||
|valign="top"| | |valign="top"| | ||
<syntaxhighlight lang='bash'> | |||
minikube addons configure metallb | |||
minikube addons enable olm | |||
minikube addons list | |||
</syntaxhighlight> | |||
|- | |||
|colspan="3"| | |||
---- | |||
|- | |||
| valign="top" | | |||
kubectl exec -it <pod-nmae-hash> -- bash | |||
kubectl exec -it <pod-name-hash> -n <ns> -- bash | |||
kubectl exec -it <pod-name-hash> -n <ns> -- printenv | |||
| valign="top" | | |||
kubectl logs <pod-nmae-hash> | |||
kubectl logs <pod-nmae-hash> -n <ns> | |||
kubectl logs <pod-nmae-hash> -n <ns> -p | |||
| valign="top" | | |||
minikube addons enable ingress | |||
kubectl get pods -n ingress-nginx | |||
kubectl logs <pod-nmae-hash> -c <image-name> -n <ns> | |||
|- | |- | ||
Line 82: | Line 258: | ||
|- | |- | ||
| valign="top" | | | valign="top" | | ||
minikube addons enable ingress-dns | |||
nslookup academia.local $(minikube ip) | |||
kubectl get configmap coredns -n kube-system -o yaml | |||
| valign="top" | | | valign="top" | | ||
Line 92: | Line 271: | ||
{| | {| | ||
| valign="top" | | | valign="top" | | ||
* [https://foxutech.medium.com/kubernetes-crashloopbackoff-how-to-troubleshoot-940dbb16bc84 K8s » CrashLoopBackOff » Medium] | |||
* [https://devopscube.com/setup-kubernetes-cluster-kubeadm/ K8s » Kubeadm » Setup Cluster] | |||
* [https://docs.openshift.com/container-platform/4.9/applications/deployments/what-deployments-are.html K8s » What Deployments Are] | * [https://docs.openshift.com/container-platform/4.9/applications/deployments/what-deployments-are.html K8s » What Deployments Are] | ||
* [https://kubernetes.io/docs/concepts/storage/ephemeral-volumes/ K8s » Volumes » Ephemeral] | * [https://kubernetes.io/docs/concepts/storage/ephemeral-volumes/ K8s » Volumes » Ephemeral] | ||
* [https://kubernetes.io/docs/concepts/storage/persistent-volumes/ K8s » Volumes » Persistent] | * [https://kubernetes.io/docs/concepts/storage/persistent-volumes/ K8s » Volumes » Persistent] | ||
* [https://kubernetes.io/docs/concepts/storage/projected-volumes/ K8s » Volumes » Projected] | * [https://kubernetes.io/docs/concepts/storage/projected-volumes/ K8s » Volumes » Projected] | ||
* [https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/ K8s » Minikube » Ingress] | |||
* [https://www.educative.io/answers/how-to-use-volumes-in-kubernetes K8s » Use Volumes] | * [https://www.educative.io/answers/how-to-use-volumes-in-kubernetes K8s » Use Volumes] | ||
* [https://kustomize.io/ K8s » Kustomize] | * [https://kustomize.io/ K8s » Kustomize] | ||
Line 101: | Line 283: | ||
| valign="top" | | | valign="top" | | ||
* [https://www.groundcover.com/blog/crashloopbackoff K8s » CrashLoopBackOff » GroundCover] | |||
* [https://spacelift.io/blog/crashloopbackoff K8s » CrashLoopBackOff » Spacelift] | |||
* [https://www.blinkops.com/blog/troubleshooting-the-crashloopbackoff-error K8s » CrashLoopBackOff » Blinkops] | |||
* [https://kubernetes.io/docs/tasks/administer-cluster/dns-custom-nameservers/ K8s » DNS Service » Customizing] | |||
* [https://medium.com/kubernetes-tutorials/kubernetes-dns-for-services-and-pods-664804211501 K8s » DNS for Services and Pods] | |||
* [https://stackoverflow.com/questions/50952240/ K8s » Connect to Host Database] | |||
* [https://minikube.sigs.k8s.io/docs/handbook/addons/ingress-dns/ K8s » Minikube » Ingress DNS] | |||
* [https://www.keycloak.org/server/hostname K8s » Keycloak » Hostname] | |||
* [https://medium.com/@pczarkowski/kubernetes-tip-run-an-interactive-pod-d701766a12 K8s » Interactive Pod] | |||
* [https://spacelift.io/blog/restart-kubernetes-pods-with-kubectl K8s » Restart Pods] | |||
| valign="top" | | |||
* [https://microk8s.io/compare K8s » MicroK8s vs K3s vs Minikube] | |||
* [https://georgepaw.medium.com/how-to-run-the-cheapest-kubernetes-cluster-at-1-per-day-9287abb90cee K8s » Cheapest Cluster $1/Day] | |||
* [https://cert-manager.io/docs/ K8s » Ingress » Cert Manager] | |||
* [https://docs.k8slens.dev/getting-started/install-lens/ K8s » Lens » Getting Started] | |||
* [https://getbetterdevops.io/k8s-ingress-with-letsencrypt/ K8s » Ingress » Letsencrypt] | |||
* [https://github.com/MuhammedKalkan/OpenLens/releases K8s » OpenLens] | |||
* [https://microk8s.io/docs/getting-started K8s » MicroK8s] | |||
* [https://www.rancher.com/quick-start K8s » Rancher] | |||
* [https://min.io/docs/minio/kubernetes/upstream/index.html K8s » MinIO] | |||
* [https://github.com/lensapp/lens K8s » Lens] | |||
|- | |||
| colspan="3" | | |||
---- | |||
|- | |||
| valign="top" | | |||
* [https://itnext.io/deciphering-the-kubernetes-networking-maze-navigating-load-balance-bgp-ipvs-and-beyond-7123ef428572 K8s » Deciphering the Networking Maze] | |||
* [https://www.hostafrica.com/blog/new-technologies/install-kubernetes-cluster-windows-server-worker-nodes/ K8s » Windows Server Worker Nodes] | |||
* [https://aws.amazon.com/blogs/aws/introducing-karpenter-an-open-source-high-performance-kubernetes-cluster-autoscaler/ K8s » Introducing Karpenter] | |||
* [https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands K8s » Kubectl Command] | |||
* [https://kubernetes.io/docs/reference/kubectl/#resource-types K8s » Resource types] | |||
* [https://kubernetes.io/docs/reference/setup-tools/kubeadm/ K8s » Kubeadm] | |||
* [https://kubernetes.io/docs/reference/kubectl/ K8s » Kubeactl] | |||
* [https://kubernetes.io/docs/reference/networking/virtual-ips/ K8s » IPVS] | |||
* [https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/ K8s » CNI] | |||
| valign="top" | | |||
* [[K8s/CSI Hostpath Driver|K8s » CSI Hostpath Driver]] | |||
| valign="top" | | | valign="top" | | ||
Line 133: | Line 355: | ||
| valign="top" | | | valign="top" | | ||
* [https://medium.com/sysmap-labs/how-to-reset-argocd-password-b381505c92af GitOps » ArgoCD » Reset password] | |||
* [https://argo-cd.readthedocs.io/en/stable/ GitOps » Argo CD » Overview] | * [https://argo-cd.readthedocs.io/en/stable/ GitOps » Argo CD » Overview] | ||
* [https://jenkins-x.io/ GitOps » Jenkins X] | * [https://jenkins-x.io/ GitOps » Jenkins X] | ||
Line 142: | Line 365: | ||
* [[Hadoop]] | * [[Hadoop]] | ||
* [[WildFly]] | * [[WildFly]] | ||
|- | |- | ||
Line 153: | Line 375: | ||
* [https://docs.gitlab.com/ee/ci/chatops/ ChatOps » GitLab] | * [https://docs.gitlab.com/ee/ci/chatops/ ChatOps » GitLab] | ||
* [https://www.gitops.tech/ GitOps] | * [https://www.gitops.tech/ GitOps] | ||
* [[Spark]] | |||
| valign="top" | | | valign="top" | |
Latest revision as of 09:01, 1 August 2024
K8s Lens
# install from snapcraft
sudo snap install kontena-lens --classic
# license version
curl -fsSL https://downloads.k8slens.dev/keys/gpg\
| sudo gpg --dearmor -o /etc/apt/keyrings/k8slens.gpg
cat << EOF | sudo tee /etc/apt/sources.list.d/k8slens.list >/dev/null
deb [arch=$(dpkg --print-architecture)\
signed-by=/etc/apt/keyrings/k8slens.gpg]\
https://downloads.k8slens.dev/apt/debian stable main
EOF
sudo apt install lens
lens-desktop
Kind
|
||
| ||
Volume
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: PersistentVolume
metadata:
name: chorke-pv
spec:
capacity:
storage: 10Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: chorke-local-storage
hostPath:
path: /home/shahed/.chorke/academia/var/k8s
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: k8s.io/minikube-hostpath
operator: In
values:
- node-hostname
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: chorke-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: chorke-local-storage
EOF
|
cat <<EOF | kubectl delete -f -
apiVersion: v1
kind: PersistentVolume
metadata:
name: chorke-pv
spec:
capacity:
storage: 10Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: chorke-local-storage
hostPath:
path: /home/shahed/.chorke/academia/var/k8s
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: k8s.io/minikube-hostpath
operator: In
values:
- node-hostname
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: chorke-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: chorke-local-storage
EOF
|
| |
| |
Storage
- Ceph RBD
- GlusterFS
- OpenEBS
- Longhorn
- Rook
Argo CD
kubectl create namespace argocd kubectl get namespace -A kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml kubectl get -n=argocd pod kubectl get -n=argocd service -n argocd kubectl port-forward -n=argocd service/argocd-server 8080:80 kubectl get -n=argocd -o=yaml secret argocd-initial-admin-secret echo RE83Uk81QTU5clZyLTlsdg== | base64 --decode https://localhost:8080/login
kubectl get -n=argocd configmap kubectl get -n=argocd deployment kubectl get -n=argocd service kubectl get -n=argocd secret kubectl get -n=argocd event kubectl get -n=argocd pod |
kubectl edit -n=argocd configmap argocd-rbac-cm kubectl edit -n=argocd configmap argocd-cm kubectl edit -n=argocd deployment argocd-redis kubectl edit -n=argocd service argocd-redis kubectl edit -n=argocd secret argocd-secret kubectl edit -n=argocd pod argocd-app-ctrl-0 |
kubectl get -n=argocd -o=yaml configmap argocd-rbac-cm kubectl get -n=argocd -o=yaml configmap argocd-cm kubectl get -n=argocd -o=yaml deployment argocd-redis kubectl get -n=argocd -o=yaml service argocd-redis kubectl get -n=argocd -o=yaml secret argocd-secret kubectl get -n=argocd -o=yaml pod argocd-app-ctrl-0 |
Docker Config
kubectl create secret -n chorke generic image-pull-secret --from-file=.dockerconfigjson=${HOME}/.docker/config.json --type=kubernetes.io/dockerconfigjson kubectl get secret -n chorke image-pull-secret -o "jsonpath={.data.\.dockerconfigjson}" | base64 --decode kubectl get secret -n chorke image-pull-secret -o yaml kubectl delete secret -n chorke image-pull-secret
kubectl get pods -A -o jsonpath='{range .items[*]}{"\n"}{.metadata.name}{":\t"}{range .spec.containers[*]}{.image}{", "}{end}{end}' |sort kubectl get pods -A -o jsonpath="{.items[*].spec.containers[*].image}" |tr -s 'space:' '\n' |sort |uniq -c
kubectl delete pod academia-<hash> -n chorke --force --grace-period=0 kubectl delete pod academia-<hash> -n chorke
kubectl get pod academia-<hash> -n chorke -o yaml kubectl describe pod academia-<hash> -n chorke kubectl edit pod academia-<hash> -n chorke kubectl get pod academia-<hash> -n chorke kubectl logs academia-<hash> -n chorke kubectl get events -n chorke
Knowledge
snap services maas snap services juju snap services lxd |
minikube addons enable default-storageclass
minikube addons enable metrics-server
minikube addons enable metallb
|
minikube addons configure metallb
minikube addons enable olm
minikube addons list
|
| ||
kubectl exec -it <pod-nmae-hash> -- bash kubectl exec -it <pod-name-hash> -n <ns> -- bash kubectl exec -it <pod-name-hash> -n <ns> -- printenv |
kubectl logs <pod-nmae-hash> kubectl logs <pod-nmae-hash> -n <ns> kubectl logs <pod-nmae-hash> -n <ns> -p |
minikube addons enable ingress kubectl get pods -n ingress-nginx kubectl logs <pod-nmae-hash> -c <image-name> -n <ns> |
| ||
minikube addons enable ingress-dns nslookup academia.local $(minikube ip) kubectl get configmap coredns -n kube-system -o yaml |
References
| ||
| ||
| ||