230118

su-mmer·2023년 1월 18일
0

아묻따 도커 공부

목록 보기
18/18

docker-compose version 맞추기

FROM python:3.7-alpine
WORKDIR /code
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0
RUN apk add --no-cache gcc musl-dev linux-headers
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
EXPOSE 5000
COPY . .
CMD ["flask", "run"]

docker-compose로 Django 실행하기

Docker sample site

Github readme

# mysql

version: "3"
services:
  db:
    image: mysql:latest
    container_name: mysql-server
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: root
    command: # 명령어 실행
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_unicode_ci
    volumes:
      - ./data/:/var/lib/mysql

virtual box xshell

관리자
1. NAT Network 생성, 포트 설정

머신
1. 유선 네트워크 설정 > ipv4 설정 > 네트워크 껐다 켜기
2. 인터넷 확인
3. openssh 설치
4. xshell 연결

쿠버네티스 환경 설정

# master, node1, node2 동일
swapoff -a && sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

sysctl params required by setup, params persist across reboots
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables  = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward                 = 1
EOF

sudo apt-get install -y apt-transport-https ca-certificates curl

sudo mkdir /etc/apt/keyrings

sudo curl -fsSLo /etc/apt/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg

sudo curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF | tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/kubernetes-xenial main
EOF

echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  
sudo apt-get update

sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

sudo systemctl status docker
sudo systemctl start docker
sudo systemctl enable docker

sudo apt-get install -y kubelet kubeadm kubectl

# 고정
sudo apt-mark hold kubelet kubeadm kubectl

systemctl start kubelet

systemctl enable kubelet

# master 설정
sudo rm /etc/containerd/config.toml
sudo systemctl restart containerd
kubeadm init
> kubeadm join~으로 시작하는 키 저장해두기

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl get node
kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml

# node1, node2 설정
sudo rm /etc/containerd/config.toml
sudo systemctl restart containerd
kubeadm join~으로 시작하는 키 입력

# master에서 확인
kubectl get node

kubectl
kubelet(->daemon)

0개의 댓글