Kubernetes_1 (2023.01.27)

최시열·2023년 1월 27일
1
  • k8s는 Layer 5에 있다.
    (Layer 3에는 OS
    Layer 4에는 컨테이너 엔진)

  • k8s 자동완성

source <(kubectl completion bash)
echo "source <(kubectl completion bash)" >> ~/.bashrc
  • 자세한 내용을 보여줄 때(-o wide)
kubectl get nodes -o wide
  • pod 생성 및 시작
kubectl run webserver --image=nginx:1.14 --port 80
  • pod 전체 조회
kubectl get pods
  • pod 상세내용 조회(describe)
kubectl describe pod webserver
  • 복제
kubectl create deployment mainui --image=httpd:latest --replicas=3

kubectl describe deployments.apps mainui
  • webserver linux로 접속
kubectl exec webserver -it -- /bin/bash

	(index.html을 수정)

cd usr/share/nginx/html/
vim index.html
exit

curl [ip주소]
  • log 확인
kubectl logs webserver
  • vi 모드로 진입
kubectl edit deployments.apps mainui

	(replicas 내용 바꿔주면 실행 숫자 바뀜)
  • delete
kubectl delete pod webserver
  • 실험 시작
맞는지 검사해봐
kubectl run webserver --image=nginx:1.14 --port 80 --dry-run

pod를 만드는 yaml 보여줘
kubectl run webserver --image=nginx:1.14 --port 80 --dry-run -o yaml


활용해서 pod 만들기
kubectl run webserver --image=nginx:1.14 --port 80 --dry-run -o yaml > webserver-pod.yaml
vim webserver-pod.yaml (필요없는 내용 지워주기)
kubectl create -f webserver-pod.yaml
kubectl get pods
profile
최시열

0개의 댓글