Kubernetes: различия между версиями
Перейти к навигации
Перейти к поиску
Artem (обсуждение | вклад) |
Artem (обсуждение | вклад) |
||
(не показано 11 промежуточных версий этого же участника) | |||
Строка 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 | sudo mkdir -p /etc/apt/keyrings | ||
echo | 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 | ||
Строка 16: | Строка 19: | ||
* [https://www.youtube.com/watch?v=s_o8dwzRlu4 Kubernetes Crash Course for Absolute Beginners NEW] | * [https://www.youtube.com/watch?v=s_o8dwzRlu4 Kubernetes Crash Course for Absolute Beginners NEW] | ||
* [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 | ||
Строка 36: | Строка 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> | </pre> | ||
Строка 49: | Строка 57: | ||
docker rmi $(docker images -q) | docker rmi $(docker images -q) | ||
docker system prune | 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> | ||
Строка 54: | Строка 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
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
Шпаргалка по командам
- Kubernetes Crash Course for Absolute Beginners NEW
- Шпаргалка по kubectl
- Docker Containers and Kubernetes Fundamentals – Full Hands-On Course
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