비어있는 디바이스 혹은 파티션이 최소 하나가 존재해야 한다.
sudo cfdisk /dev/sdX
sudo swapoff -a
sudo vim /etc/fstab # swap 기능을 제거한다.
# (Install Docker CE)
## Set up the repository:
### Install packages to allow apt to use a repository over HTTPS
sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common gnupg2
# Add Docker's official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key --keyring /etc/apt/trusted.gpg.d/docker.gpg add -
# Add the Docker apt repository:
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
# Install Docker CE
sudo apt-get update && sudo apt-get install -y \
containerd.io=1.2.13-2 \
docker-ce=5:19.03.11~3-0~ubuntu-$(lsb_release -cs) \
docker-ce-cli=5:19.03.11~3-0~ubuntu-$(lsb_release -cs)
## Create /etc/docker
sudo mkdir /etc/docker
# Set up the Docker daemon
cat <<EOF | sudo tee /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
# Create /etc/systemd/system/docker.service.d
sudo mkdir -p /etc/systemd/system/docker.service.d
# Create /etc/systemd/system/docker.service.d
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo systemctl daemon-reload
sudo systemctl enable docker
sudo systemctl restart docker
sudo systemctl restart docker.socket
# Install kubernetes
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
http://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt-get install && sudo apt-get install -y kubelet kubeadm kubectl
https://kubernetes.io/docs/setup/production-environment/container-runtimes/#docker
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl restart docker.socket
sudo kubeadm reset
sudo rm -r /etc/cni/net.d
sudo ipvsadm --clear # ipvsadm 가 없다면 설치할 것
# Cleanup Rook configuration
sudo rm -rf /var/lib/rook
sudo kubeadm init
rm -r $HOME/.kube
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
# Schedule master node (=control plane node)
kubectl taint nodes --all node-role.kubernetes.io/master-
# kubeadm join 관련 함수는 기억할 것
sudo kubeadm reset
sudo rm -r /etc/cni/net.d
sudo ipvsadm --clear # ipvsadm 가 없다면 설치할 것
# Cleanup Rook configuration
sudo rm -rf /var/lib/rook
# kubeadm join ...
cni 관련 문제로 잘 작동되지 않을 땐, kube-flunnel 사용을 권장한다.
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
watch kubectl get pod -n kube-system
2020-02-20 현재, ceph:v15 버전에서 싱글 파티션을 인식하지 못하는 문제가 발생했다.
때문에 여기서는 ceph:v14 버전을 사용하는, rook:v1.2 버전을 사용하도록 하겠다.
cd $HOME
git clone --single-branch --branch release-1.2 https://github.com/rook/rook.git
cd $HOME/rook/cluster/examples/kubernetes/ceph
kubectl create -f common.yaml
kubectl create -f operator.yaml
# 선택
kubectl create -f cluster.yaml # production 용. 3개 nodes가 연결되어야 한다.
kubectl create -f cluster-test.yaml # dev 용. 1개 node만 연결되어도 좋다.
rook-ceph-osd
pod이 제대로 준비되어야 한다. 여기까지 오는데에 많은 시도가 필요할 것이다...
watch kubectl get pod -n rook-ceph
cd $HOME/rook/cluster/examples/kubernetes/ceph
kubectl create -f toolbox.yaml
kubectl -n rook-ceph rollout status deploy/rook-ceph-tools
kubectl -n rook-ceph exec -it deploy/rook-ceph-tools -- bash
# In the toolbox,
watch ceph status
# 선택
kubectl apply -f csi/rbd/storageclass.yaml # production
kubectl apply -f csi/rbd/storageclass-test.yaml # dev
kubectl create -f $HOME/rook/cluster/examples/kubernetes/mysql.yaml
kubectl create -f $HOME/rook/cluster/examples/kubernetes/wordpress.yaml
watch kubectl get pod
아래의 출력 결과물 URL로 접속한다.
WORDPRESS_IP=$(ip addr | grep "inet " | grep "dynamic" | sed -n -e "s/.*inet \([0-9.]\+\).*/\1/p")
WORDPRESS_PORT=$(kubectl get svc | grep "wordpress " | sed -n -e "s/.*80:\([0-9]\+\).*/\1/p")
echo "http://$WORDPRESS_IP:$WORDPRESS_PORT"
kubectl delete -f $HOME/rook/cluster/examples/kubernetes/mysql.yaml
kubectl delete -f $HOME/rook/cluster/examples/kubernetes/wordpress.yaml