[DevOps] 2. 파일 배포 (스크립트)

GisangLee·2025년 7월 8일
0

devops

목록 보기
2/11

정기적으로 서버에 파일을 배포해야하는 업무가 있다고 가정.

동일한 명령어를 여러번 입력하지 않고, 스크립트 하나로 해결하자

주요 명령어

  • json (Javascript Object Notation)
    • 구조화된 데이터를 간결하게 표현가능한 방식
  • jq (json query)
    • 툴, CLI 유틸리티
  • tr (translate or delete) -d (--delete)
  • For 반복문
    for 변수 in 범위
     do 
     // 명령
     done

스크립트

#!/bin/bash

SERVERS=$(kubectl get no -o json | jq '.items[] | .status .addresses[] | select(.type=="ExternalIP") .address' | tr -d '"')
for server in $SERVERS
do
  scp -i <file> user@$server:/<dir>
done
profile
포폴 및 이력서 : https://upbeat-suede-20b.notion.site/2265782662ce8071aeb7f67163e63467?source=copy_link

0개의 댓글