AWS CLI로 EKS 클러스터 접근하는 예시
2021-12-11
.
Data_Engineering_TIL(20211210)
$ aws eks --region us-east-1 update-kubeconfig --name minman-cluster
Updated context arn:aws:eks:us-east-1:111111111111:cluster/minman-cluster in /Users/minman/.kube/config
$ aws eks update-kubeconfig --name minman-cluster --region us-east-1 --role-arn arn:aws:iam::111111111111:role/eksctl-minman-cluster-cluster-ServiceRole-qwecqwexasdnka
Updated context arn:aws:eks:us-east-1:111111111111:cluster/minman-cluster in /Users/minman/.kube/config
$ cat /Users/minman/.kube/config
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: ************************
server: https://qwecqwexasdnka.yl4.us-east-1.eks.amazonaws.com
name: arn:aws:eks:us-east-1:111111111111:cluster/minman-cluster
contexts:
- context:
cluster: arn:aws:eks:us-east-1:111111111111:cluster/minman-cluster
user: arn:aws:eks:us-east-1:111111111111:cluster/minman-cluster
name: arn:aws:eks:us-east-1:111111111111:cluster/minman-cluster
current-context: arn:aws:eks:us-east-1:111111111111:cluster/minman-cluster
kind: Config
preferences: {}
users:
- name: arn:aws:eks:us-east-1:111111111111:cluster/minman-cluster
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
args:
- --region
- us-east-1
- eks
- get-token
- --cluster-name
- minman-cluster
command: aws
- name: arn:aws:eks:us-east-1:111111111111:cluster/minman-cluster
user:
exec:
apiVersion: client.authentication.k8s.io/v1alpha1
args:
- --region
- us-east-1
- eks
- get-token
- --cluster-name
- minman-cluster
- --role
- arn:aws:iam::111111111111:role/eksctl-minman-cluster-ServiceRole-qwecqwexasdnka
command: aws
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
minman-cluster-redash-dev-scheduler-0 1/1 Running 0 6d2h
minman-cluster-redash-dev-server-0 1/1 Running 0 38h
minman-cluster-redash-dev-worker-0 1/1 Running 0 38h
$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/minman-cluster-redash-dev-scheduler-0 1/1 Running 0 6d2h
pod/minman-cluster-redash-dev-server-0 1/1 Running 0 38h
pod/minman-cluster-redash-dev-worker-0 1/1 Running 0 38h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/minman-cluster-redash-dev NodePort 10.100.112.216 <none> 80:32440/TCP 646d
service/kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 447d
NAME READY AGE
statefulset.apps/minman-cluster-redash-dev-scheduler 1/1 559d
statefulset.apps/minman-cluster-redash-dev-server 1/1 559d
statefulset.apps/minman-cluster-redash-dev-worker 1/1 559d
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
horizontalpodautoscaler.autoscaling/minman-cluster-redash-dev-scheduler StatefulSet/minman-cluster-redash-dev-scheduler 40%/90% 1 2 1 618d
horizontalpodautoscaler.autoscaling/minman-cluster-redash-dev-server StatefulSet/minman-cluster-redash-dev-server 36%/90% 1 2 1 618d
horizontalpodautoscaler.autoscaling/minman-cluster-redash-dev-worker StatefulSet/minman-cluster-redash-dev-worker 46%/90% 1 2 1 578d
$ kubectl get namespaces
NAME STATUS AGE
argo Active 394d
aws-observability Active 201d
default Active 676d
grafana Active 639d
kube-node-lease Active 640d
kube-public Active 676d
kube-system Active 676d
nifi Active 394d
prometheus Active 637d
redash-prod Active 646d
$ kubectl config set-context --current --namespace=nifi
Context "arn:aws:eks:us-east-1:111111111111:cluster/minman-cluster" modified.
$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/nifi-0 1/1 Running 0 41h
pod/nifi-1 1/1 Running 0 42h
pod/nifi-2 1/1 Running 0 42h
pod/nifi-3 1/1 Running 0 41h
pod/nifi-4 1/1 Running 0 41h
pod/nifi-dev-0 1/1 Running 0 2d9h
pod/nifi-dev-1 1/1 Running 0 2d10h
pod/nifi-dev-2 1/1 Running 0 2d9h
pod/nifi-registry-0 1/1 Running 0 41h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/nifi-dev-http NodePort 10.100.202.255 <none> 8080:30388/TCP 386d
service/nifi-http NodePort 10.100.191.220 <none> 8080:30366/TCP 388d
service/nifi-registry-http NodePort 10.100.47.19 <none> 18080:31339/TCP 393d
NAME READY AGE
statefulset.apps/nifi 5/5 288d
statefulset.apps/nifi-dev 3/3 290d
statefulset.apps/nifi-registry 1/1 393d
NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE
horizontalpodautoscaler.autoscaling/nifi StatefulSet/nifi 61%/90% 5 10 5 303d
horizontalpodautoscaler.autoscaling/nifi-dev StatefulSet/nifi-dev 46%/90% 3 5 3 386d