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

Материал из Artem Aleksashkin's Wiki
Перейти к навигации Перейти к поиску
Строка 18: Строка 18:


<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

Версия от 02:54, 21 ноября 2023

Installation

sudo apt-get update
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
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 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>

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

Translate a Docker Compose File to Kubernetes Resources