목차 (UPDATE: 2019.08.20)

  • kube 설치 후 pemission 문제 해결
  • kubectl 자동완성
  • 특정 포드 찾아서 한번에 지우는 명령어
  • 네트워크 생성 및 접속 툴
  • Dashboard 접속 Token 확인 명령어
  • CoreDNS 오작동 에러

[ kube 설치 후 pemission 문제 해결 ]

> sudo chown -R $USER $HOME/.kube
혹은
> sudo chown -R $USER $HOME/.minikube

[ kubectl 자동완성 ]

1 > source <(kubectl completion bash)
2> alias kc=kubectl
3 > complete -F __start_kubectl kc
4> source ~/.bashrc

[ 서비스 중 인 주소 ]

kubectl cluster-info

[ 특정 포드 찾아서 한번에 지우는 명령어 ]

kubectl get pods -n kube-system -oname |grep coredns |xargs kubectl delete -n kube-system
kubectl get pods -n istio-system -oname |grep istio |xargs kubectl delete -n kube-system

xargs : 파이프로 건너온 인자를 뒤에 추가해주는 기능 
grep : 특정 검색어에 해당하는 줄만 추출

[ 네트워크 생성 및 접속 툴 ]

> kubectl run nettool -it --image=praqma/network-multitool --generator=run-pod/v1 --rm=true bash

[ Dashboard 접속 Token 확인 명령어 ]

> kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep eks-admin | awk '{print $1}')
+ 접속 시 deployments.apps is forbidden: 이라고 나오면.. 권한문제
>kubectl create clusterrolebinding serviceaccounts-cluster-admin --clusterrole=cluster-admin --group=system:serviceaccounts
(!!This allows any user with read access to secrets or the ability to create a pod to access super-user credentials)

[ CoreDNS 오작동 에러 ]

$ echo -e '[Service]\nEnvironment="KUBELET_EXTRA_ARGS=--resolv-conf=/run/systemd/resolve/resolv.conf"\n' | sudo tee /etc/systemd/system/kubelet.service.d/99-local.conf
$ sudo systemctl daemon-reload
$ sudo systemctl restart kubelet

$ kubectl -n kube-system get deployment coredns -o yaml | 
sed 's/allowPrivilegeEscalation: false/allowPrivilegeEscalation: true/g' | kubectl apply -f -

$ echo -e '[Service]\nEnvironment="KUBELET_EXTRA_ARGS=--resolv-conf=/run/systemd/resolve/resolv.conf"\n' | sudo tee /etc/systemd/system/kubelet.service.d/99-local.conf
$ sudo systemctl daemon-reload
$ sudo systemctl restart kubelet
$ kubectl get pods -n kube-system -oname |grep coredns |xargs kubectl delete -n kube-system

$ iptables -P FORWARD ACCEPT
$ iptables -P INPUT ACCEPT
$ iptables -P OUTPUT ACCEPT


'인프라' 카테고리의 다른 글

[Container] Docker 이미지와 컨테이너  (0) 2021.03.16

+ Recent posts