Restart ์คํฏ์ ๋ณด๋ฉด ๋ช๋ฒ์ด๋ ์ฌ ์์ํ๊ฒ์ ๋ณผ ์๊ฐ ์๋ค..
๋๋์ฒด ๋ญ๊ฐ ๋ฌธ์ ์ธ์ง๋ ๋ชจ๋ฅด๊ฒ ๊ณ .. ํด๋ฌ์คํฐ๋ฅผ ๊ตฌ์ฑํ๋ ๋ง์คํฐ ๋ ธ๋์ ๋ฉ๋ชจ๋ฆฌ๊ฐ ๋ถ์กฑํ๊ฑด๊ฐ ์ถ๊ธฐ๋ํ์..
ec2์ธ์คํด์ค๋ฅผ t3.small๋ก ์ฒ์์ ์ง์ ํ๋ค๊ฐ t2.meduim์ผ๋ก ๋ณ๊ฒฝํด์ ์ธ์คํด์ค๋ฅผ ์์ฑํ์๋ค.
๋ด๊ฐ ๊ณต๋ถํ๋ฉด์ GKEํ๊ฒฝ์์ ๊ตฌ์ถํ๋ ํด๋ฌ์คํฐ ํ๊ฒฝ๊ณผ
https://velog.io/@99_insung/GKE-VM
๐ํด์ธ ์ฌ์ดํธ์ ๋ฐ๊ฒฌํ EC2 ์ธ์คํด์ค๋ก ํด๋ฌ์คํฐ ํ๊ฒฝ์ ๊ตฌ์ถํ ๋ธ๋ก๊ทธ๋ฅผ ๋๋ค ์ด์ฉํ์์.
https://nvtienanh.info/blog/cai-dat-kubernetes-cluster-tren-ubuntu-server-22-04
๊ตญ๋ด ๋ธ๋ก๊ทธ(ํฌํธ ๊ฐ๋ฐฉํ์ธ, ์ฌ๊ธฐ์๋ systemd๋ฅผ ์ฌ์ฉํจ)
EC2 HA ๋ฅผ ํ์ฉ
https://blog.zooneon.dev/kubeadm-cloud-provider-aws/
sudo apt update
sudo apt upgrade -y
๋ง์ ec2 ํด๋ฌ์คํฐ ํ๊ฒฝ ๊ตฌ์ถ์์ ํธ์คํธ ์ด๋ฆ์ ์ค์ ํ๋๋ฐ ๋๋ ํ์ง ์์๋ค.
sudo hostnamectl set-hostname <ํธ์คํธ์ด๋ฆ>
# ํ์ฌ ์์คํ ์ ์ ์ฉ(๋ฆฌ๋ถํ ํ๋ฉด ์ฌ ์ค์ ํ์) sudo swapoff -a # ๋ฆฌ๋ถํ ํ์ sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
free -h
๋ฅผ ํตํด์ ํ์ธtotal used free shared buff/cache available Mem: 7.7Gi 167Mi 7.1Gi 1.0Mi 437Mi 7.3Gi Swap: 0B 0B 0B
sudo tee /etc/modules-load.d/containerd.conf <<EOF overlay br_netfilter EOF
- overlay : Overlay ํ์ผ ์์คํ ๋ชจ๋ ๋ก๋.
- ์ปจํ ์ด๋ ๋ฐํ์ (Docker, containerd) ์์ ์ฌ์ฉ ๋๋ ๋ ์ด์ด๋ ํ์ผ ์์คํ ์ค ํ๋
- ์ปจํ ์ด๋ ์ด๋ฏธ์ง์ ํ์ผ ์์คํ ๊ด๋ฆฌ์ ์ฌ์ฉ
- br_netfilter: ๋ธ๋ฆฌ์ง ๋ทํํฐ ๋ชจ๋ ๋ก๋
- Linux ๋ธ๋ฆฌ์ง ๋คํธ์ํฌ์ ๋คํธ์ํฌ ํจํท ํํฐ๋ง ์ง์
- ์ปจํ ์ด๋ ๋คํธ์ํฌ ์ค์ ์ ์ฌ์ฉ
sudo modprobe overlay
sudo modprobe br_netfilter
sudo tee /etc/sysctl.d/kubernetes.conf <<EOF net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 net.ipv4.ip_forward = 1 EOF
sudo sysctl --system
sudo apt install -y curl gnupg2 software-properties-common apt-transport-https ca-certificates
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/docker.gpg
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install -y containerd.io
containerd config default | sudo tee /etc/containerd/config.toml >/dev/null 2>&1
sudo sed -i 's/SystemdCgroup \= false/SystemdCgroup \= true/g' /etc/containerd/config.toml
sudo systemctl restart containerd
sudo systemctl enable containerd
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-add-repository "deb http://apt.kubernetes.io/ kubernetes-xenial main"
sudo apt update
sudo apt install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
sudo kubeadm init \
--pod-network-cidr=10.10.0.0/16 \
--control-plane-endpoint=ํธ์คํธ๋ค์ # ํด๋น ๋ถ๋ถ์ ์ ์ธํจ
์ฌ๊ธฐ์ ๋ง์คํฐ ๋ ธ๋ ์ค์ ์ด ์ ๋๋ก ๋์ง ์์๊ณ , ํธ๋ฌ๋ธ ์ํ ํ๋๋ผ ์ค๋ ๊ฑธ๋ฆผ (ํฌํธ ๊ฐ๋ฐฉ์ด ํ์)
ํฌ์คํ : https://velog.io/@99_insung/EC2-%ED%81%B4%EB%9F%AC%EC%8A%A4%ED%84%B0-%EA%B5%AC%EC%B6%95
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl cluster-info
kubectl get nodes
kubectl get nodes
์ฒ์์ ๋ชจ๋ NotReady ์ํ๋ก ๋ ธ๋๋ฆฌ์คํธ ์ํ๊ฐ ์กด์ฌํ๋ค.
curl https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/calico.yaml -O
---
# The default IPv4 pool to create on startup if none exists. Pod IPs will be
# chosen from this range. Changing this value after installation will have
# no effect. This should fall within `--cluster-cidr`.
- name: CALICO_IPV4POOL_CIDR
value: '10.10.0.0/16'
# Disable file logging so `kubectl logs` works.
- name: CALICO_DISABLE_FILE_LOGGING
value: 'true'
kubectl apply -f calico.yaml
: ์ ์ฉํ์ฌ ๋คํธ์ํฌ ํ๋ฌ๊ทธ์ธ ์คํ
์คํ ์๋ฃ ํ
kubectl get nodes
๋ฅผ ๋ค์ ํด๋ณด๋ฉด ๊ฐ ๋ ธ๋๋ค์ด ์ ์ ๋์ํ์๋ค.NAME STATUS ROLES AGE VERSION worker-2 Ready <none> 8h v1.28.2 worker-1 Ready <none> 8h v1.28.2 master-1 Ready control-plane 8h v1.28.2
calico-node๊ฐ ๊ณ์ 0/1 READY ์ํ๋ผ์ ํธ๋ฌ๋ธ ์ํ ํ๋๋ฐ ๋ง์ด ์ ๋จน์์๋ค.
ํฌ์คํ : https://velog.io/@99_insung/Calico-BGP-%ED%8A%B8%EB%9F%AC%EB%B8%94-%EC%8A%88%ED%8C%85
git clone https://github.com/kubernetes/ingress-nginx/
kubectl apply -k `pwd`/ingress-nginx/deploy/static/provider/baremetal/
kubectl get pod -n ingress-nginx
: ์ค์น ํ์ธ
kubectl delete validatingwebhookconfigurations.admissionregistration.k8s.io ingress-nginx-admission
: ํ์ฌ ์ค๋ฅ๋๋ ๊ธฐ๋ฅ ์ ๊ฑฐ
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: jpapractice-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: "/"
spec:
rules:
- host: insung-jpadocker.store # ์ค์ ๋๋ฉ์ธ ์ค์
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: jpapractice-service
port:
number: 80
apiVersion: apps/v1
kind: Deployment
metadata:
name: jpapractice-deployment
spec:
replicas: 3
selector:
matchLabels:
app: jpapractice
template:
metadata:
labels:
app: jpapractice
spec:
containers:
- name: jpapractice
image: adultkim/jpapractice:latest
env:
- name: active
value: "prod"
ports:
- containerPort: 8081
apiVersion: v1
kind: Service
metadata:
name: jpapractice-service
spec:
selector:
app: jpapractice
ports:
- protocol: TCP
port: 80
targetPort: 8081 # Port your Spring Boot application is running on
type: LoadBalancer # ๋ก๋๋ฐธ๋ฐ์๋ฅผ ์์ง ํ ๋น์ํด์ ์คํ ํ์ NodePort๋ก ๋ณ๊ฒฝํจ
์ด๋ ๊ฒ ๊ฐ๋จํ๊ฒ ์น ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ฐฐํฌํ์๊ณ ,
$ kubectl get all -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/jpapractice-deployment-5b4596d8d9-27nv5 1/1 Running 0 7h33m 10.10.32.132 ip-172-31-31-33 <none> <none>
pod/jpapractice-deployment-5b4596d8d9-cdwhr 1/1 Running 0 7h33m 10.10.32.133 ip-172-31-31-33 <none> <none>
pod/jpapractice-deployment-5b4596d8d9-lb9mx 1/1 Running 0 7h33m 10.10.120.68 ip-172-31-16-104 <none> <none>
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/jpapractice-service NodePort 10.99.56.67 <none> 80:30353/TCP 7h33m app=jpapractice
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 9h <none>
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
deployment.apps/jpapractice-deployment 3/3 3 3 7h33m jpapractice adultkim/jpapractice:latest app=jpapractice
NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR
replicaset.apps/jpapractice-deployment-5b4596d8d9 3 3 3 7h33m jpapractice adultkim/jpapractice:latest app=jpapractice,pod-template-hash=5b4596d8d9
์๋น์ค๋ฅผ LoadBalancer๋ฅผ ์ฌ์ฉํ๋ฉด ๋ฐฐํฌํ service์ ์ธ๋ถ IP๊ฐ ๊ณ์ Pending ์ํ์๋ค.
NodePort๋ก ๋ณ๊ฒฝ ํ์ ๋ด๋ถ ํ๊ฒฝ์์ ์ ์์ด ๋๋์ง ํ์ธํจ.
-> ํด๋ฌ์คํฐ ๋ด๋ถ์์ ์์ฒญ์ ๋ ธ์ถํ์ฌ ํ์ธ