GGAMI.NET

AWS kubectl 설치 및 명령어

Updated on

목차

Windows 필요 라이브러리 설치하기#

msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi curl -LO "https://dl.k8s.io/release/v1.27.4/bin/windows/amd64/kubectl.exe" choco install k9s choco install kubectx

AWS Configure (AWS API KEY)#

aws configure Access key ID 입력 Secret access key 입력 ap-northeast-2 입력 None 입력 aws configure list aws configure --profile testUser aws s3 ls --profile testUser

AWS kubeconfig EKS 세팅#

aws eks update-kubeconfig --name svc-seoul-v2 --alias svc-seoul-v2 --region ap-northeast-2

쉘 스크립트 상에서 AWS ECR 로그인#

aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 123456789.dkr.ecr.ap-northeast-2.amazonaws.com

Kubectl 명령어#

# 네임스페이스 생성 kubectl create namespace manager # pod 검색 kubectl get pod -A # port forward kubectl port-forward services/postgresql 5432:5432 -n manager # apply kubectl apply -f ingress.yml --namespace=manager # ctx 변경 kubectx dev-seoul-v2 kubectx -c

그런데 kubectl 명령어 보다는 k9s 를 사용하기 때문에 명령어는 잘 사용 안하게 됨.

kubectl ctx remove#

kubectl config unset users.gke_project_zone_name kubectl config unset contexts.aws_cluster1-kubernetes kubectl config unset clusters.foobar-baz

이거 생각보다 중요하긴한데, config 에 저장된 ctx 리스트를 제거할때 쓰는 명령어임. (ctx 주소 바뀐다거나 할때 사용)

k9s 에서 서비스 삭제할때 순서#

:deploy 삭제 :service 삭제 :pods 를 삭제 해야지만, 컨테이너가 되살아나지 않는다.

이제는 당연한거... (이거 메모장에 적어둘때에는 몰랐음)

terraform 명령어#

terraform init terraform apply terraform apply -f ~~~~ terraform destroy -approve terraform refresh

다른 글