Kubernetes: различия между версиями

Материал из Artem Aleksashkin's Wiki
Перейти к навигации Перейти к поиску
 
(не показано 17 промежуточных версий этого же участника)
Строка 1: Строка 1:
= Installation =
= Installation =
https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#installing-kubeadm-kubelet-and-kubectl
<pre>
<pre>
sudo apt-get update
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
sudo mkdir -p /etc/apt/keyrings
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
sudo echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-get install -y kubelet kubeadm kubectl
Строка 10: Строка 13:
</pre>
</pre>


= Шпаргалка по командам =
<embedvideo service="youtube" dimensions="800x450">https://www.youtube.com/watch?v=X48VuDVv0do</embedvideo>


= Шпаргалка по командам =
* [https://www.youtube.com/watch?v=s_o8dwzRlu4 Kubernetes Crash Course for Absolute Beginners NEW]
* [https://www.youtube.com/watch?v=X48VuDVv0do Kubernetes Tutorial for Beginners FULL COURSE in 4 Hours]
* [https://kubernetes.io/ru/docs/reference/kubectl/cheatsheet/ Шпаргалка по kubectl]
* [https://kubernetes.io/ru/docs/reference/kubectl/cheatsheet/ Шпаргалка по kubectl]
* [https://www.youtube.com/watch?v=kTp5xUtcalw Docker Containers and Kubernetes Fundamentals – Full Hands-On Course]


<pre>
<pre>
minikube start --mount-string="$HOME/go/src/github.com/nginx:/data" --mount --driver=docker
minikube ip
minikube ip
kubectl cluster-info
kubectl cluster-info
Строка 34: Строка 41:
kubectl describe ing mongo-express-ingress -n mongo-admin
kubectl describe ing mongo-express-ingress -n mongo-admin
kubectl describe ingress mongo-express-ingress -n mongo-admin
kubectl describe ingress mongo-express-ingress -n mongo-admin
kubectl rollout restart deployment <deployment_name> -n <namespace>


kubectl delete --all pods --namespace=kubernetes-dashboard
</pre>
System reset
<pre>
minikube stop
minikube delete
rm -rf ~/.minikube
rm -rf ~/.kube
docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
docker system prune
</pre>
Setup cluster
<pre>
sudo su
swapoff -a
kubeadm reset
kubeadm init
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
</pre>
<pre>
sudo systemctl start docker
sudo swapoff -a
sudo mv /etc/containerd/config.toml  /etc/containerd/config222.toml
sudo kubeadm reset --force
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
/run/flannel/subnet.env
FLANNEL_NETWORK=10.244.0.0/16
FLANNEL_SUBNET=10.244.0.1/24
FLANNEL_MTU=1450
FLANNEL_IPMASQ=true
kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml
kubectl taint nodes --all node-role.kubernetes.io/control-plane-
kubectl taint nodes --all node.kubernetes.io/disk-pressure-
kubectl taint nodes --all node.kubernetes.io/not-ready-
</pre>
</pre>


Строка 40: Строка 95:


* https://kubernetes.io/docs/tasks/configure-pod-container/translate-compose-kubernetes/
* https://kubernetes.io/docs/tasks/configure-pod-container/translate-compose-kubernetes/
= Helm =
https://helm.sh/docs/intro/install/
= Clear space / Remove unused images =
<pre>
crictl rmi --prune
docker image prune -a
</pre>

Текущая версия от 22:36, 6 ноября 2024

Installation

https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#installing-kubeadm-kubelet-and-kubectl

sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo mkdir -p /etc/apt/keyrings
sudo curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
sudo echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

Шпаргалка по командам

minikube start --mount-string="$HOME/go/src/github.com/nginx:/data" --mount --driver=docker
minikube ip
kubectl cluster-info
kubectl create deployment nginx-depl --image=nginx
kubectl get pod
kubectl get replicaset
kubectl get pod <POD-ID> -o wide
kubectl get deployment nginx-depl
kubectl get deployment nginx-depl -o yaml
kubectl edit deployment nginx-depl
kubectl logs <POD-ID>
kubectl describe pod <POD-ID>
kubectl exec -it <POD-ID> -- /bin/bash
kubectl apply -f <CONFIG.YML>
kubectl get deployment nginx-deployment -o yaml
# https://kubernetes.github.io/ingress-nginx/troubleshooting/
kubectl get ingress -n mongo-admin
kubectl describe ing mongo-express-ingress -n mongo-admin
kubectl describe ingress mongo-express-ingress -n mongo-admin
kubectl rollout restart deployment <deployment_name> -n <namespace>

kubectl delete --all pods --namespace=kubernetes-dashboard

System reset

minikube stop
minikube delete
rm -rf ~/.minikube
rm -rf ~/.kube
docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
docker system prune

Setup cluster

sudo su
swapoff -a
kubeadm reset
kubeadm init

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
sudo systemctl start docker
sudo swapoff -a
sudo mv /etc/containerd/config.toml  /etc/containerd/config222.toml
sudo kubeadm reset --force
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
/run/flannel/subnet.env

FLANNEL_NETWORK=10.244.0.0/16
FLANNEL_SUBNET=10.244.0.1/24
FLANNEL_MTU=1450
FLANNEL_IPMASQ=true

kubectl apply -f https://github.com/flannel-io/flannel/releases/latest/download/kube-flannel.yml

kubectl taint nodes --all node-role.kubernetes.io/control-plane-
kubectl taint nodes --all node.kubernetes.io/disk-pressure-
kubectl taint nodes --all node.kubernetes.io/not-ready-

Translate a Docker Compose File to Kubernetes Resources

Helm

https://helm.sh/docs/intro/install/

Clear space / Remove unused images

crictl rmi --prune
docker image prune -a