๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ’ปTech/๐Ÿณdocker, kubernetes

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ๋ช…๋ น์–ด (with CDSW)

by _viper_ 2020. 10. 13.
๋ฐ˜์‘ํ˜•

โ—พ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค pod ๋ฆฌ์ŠคํŠธ ์กฐํšŒ

kubectl get pods --all-namespaces -o wide

 

โ—พ pod ์ ‘์†

kubectl exec -it ํŒŸ์ด๋ฆ„ -n ๋„ค์ž„์ŠคํŽ˜์ด์Šค /bin/bash 
ex) kubectl exec -it 5w1ixw5q39iqvcfi -n default-user-1 /bin/bash

 

โ—พ pod ๋กœ๊ทธ ํ™•์ธ ๋ฐฉ๋ฒ•

## f ์˜ต์…˜์€ ์‹ค์‹œ๊ฐ„ ํ™•์ธ
kubectl logs -f 5w1ixw5q39iqvcfi -n default-user-1

## pod init ๋กœ๊ทธ ํ™•์ธ (Init:CrashLoopBackOff, Init:Error ๋ฐœ์ƒํ•  ๋•Œ ํ™•์ธ)
## init-container name์€ describe ๋ช…๋ น์–ด ์‹คํ–‰์œผ๋กœ ํ™•์ธ ๊ฐ€๋Šฅ
kubectl logs 5w1ixw5q39iqvcfi -n default-user-1 -c init-container

 

โ—พ pod ์ƒ์„ธ ์ •๋ณด ํ™•์ธ

kubectl describe pod 5w1ixw5q39iqvcfi -n default-user-1

 

โ—พ pod ์ ‘์†ํ•˜์ง€ ์•Š๊ณ  /etc/hosts ์ˆ˜์ •

kubectl exec -it msqylt1wj85wqkxl -n default-user-1 -- bash -c "echo 'xxx.xxx.xxx.xxx  hostname' >> /etc/hosts"

 

โ—พ CDSW Master,Worker ์ƒํƒœ ํ™•์ธ

kubectl get node --show-labels

 

 

โ—พ show-labels STATUS๊ฐ€ SchedulingDisabled ์ƒํƒœ์ด๋ฉด CDSW worker๋กœ ๋™์ž‘ํ•˜์ง€ ์•Š์Œ

  • ์•„๋ž˜ ๋ช…๋ น์–ด๋กœ SchedulingDisabled ์ƒํƒœ ํ•ด์ œ
kubectl uncordon ${NODE_NAME}

 

โ—พ [Cloudera Manager] Spark - CDSW Python3 ์„ค์ • ํ›„ CDSW ์žฌ๊ธฐ๋™

Spark Client Advanced Configuration Snippet (Safety Valve) for spark-conf/spark-env.sh
export PYSPARK_PYTHON=/usr/bin/python3

 

โ—พ CDSW code์—์„œ python3 ์„ค์ •

  • ์ฝ”๋“œ ์ €์žฅ ํ›„ ์„ธ์…˜ ์žฌ์‹œ์ž‘
import os 
os.environ["PYSPARK_PYTHON"]="/usr/bin/python3"

 

โ—พ CDSW์˜ postgresql DB์— ์ฟผ๋ฆฌ ์‹คํ–‰

// ํ…Œ์ด๋ธ” ๋ชฉ๋ก ํ™•์ธ
kubectl exec $(kubectl get pods -l role=db --no-headers=true -o custom-columns=NAME:.metadata.name) -ti -- psql -U sense -c "\dt"

// select ์ฟผ๋ฆฌ ์‹คํ–‰
kubectl exec $(kubectl get pods -l role=db --no-headers=true -o custom-columns=NAME:.metadata.name) -ti -- psql -U sense -c "select * from jobs"

// project id์™€ name ๋งคํ•‘ ๊ฒฐ๊ณผ
kubectl exec $(kubectl get pods -l role=db --no-headers=true -o custom-columns=NAME:.metadata.name) -ti -- psql -U sense -c 'select id,name from projects'