SAML for using Amazon Managed Grafana Workspace (To-Do)
- kkumtree
2024-11-02T21:43:00+09:00
Organizationμ μ΄μκ° μμ΄
Amazon Managed Grafana Workspaceλ₯Ό μ¬μ©νλ €λ©΄ SAML μΈμ¦μ ꡬμ±ν΄μΌνλλ°, SAML μΈμ¦ μ μ΄κ° λλ©΄ κ²ν ν΄λ³΄κ² μ΅λλ€.
λΉμ°ν κ±°μ 4λ μ΄ λ€λκ°λ Amazon Managed Grafana β Getting Startedμλ λ€λ₯Έ μΈν°νμ΄μ€λ₯Ό νμΈν μ μμμ΅λλ€.
νμ¬ μ κΆνμΌλ‘λ Organizationμ μμ±ν μ μμ΄μ, Workspaceλ§ μμ±ν΄λ³΄μμ΅λλ€.
μ¦, λ§€μ° λμ¨ν κΆνμΌλ‘ Workspaceλ₯Ό λ§λ€μ΄μ£Όκ² λ€ μ΄κ²μ
λλ€.
1. ‘λΈκΉ’μΌλ‘ μμνκΈ°
- Getting Started with
λΈκΉ

- μ΄λ¦λ§ μ§κ³ , λμ΄κ° λ³΄κ² μ΅λλ€.

TFC(Terraform Cloud) drift μλ¦Ό μ€μ
- kkumtree
2023-10-15T00:10:33+09:00
CloudNet@μμμ Terraform μ€ν°λκ° λλκ³ λμ,
ν
λΌνΌμ μ€μ μ΄μ μν©μ λμ
νλ©΄μ λ§μ£Όν μ λ°μ μλ λ리ννΈ(drift) μν©μ λν΄
μ΄ν΄ν΄λ³΄λ μκ°μ κ°μ‘μ΅λλ€.
μ°Έκ³ ) TFCμμμ Drift Detection κΈ°λ₯μ νμ¬ TFC Plus μλμ
μμ μ§μλ©λλ€.
1. μ©μ΄ μ΄ν΄ν΄λ³΄κΈ°
μ¬μ€μ μλ
λΆν° ν
λΌνΌμ μ νκ³ λμ, IaCλΌλ κ°λ
μ κ½νκΈ°λ§ νμ§
μ΄μ μ
μ₯μμ λ§μ£Όνμλ μλ§μ μνμ°©μ€λ€μ νν μ μ μλ¬λ‘λ§ μκ°ν΄μμμ΅λλ€.
μ€ν°λμ μ°Έμ¬νλ©΄μ μ’
μ’
‘λ리ννΈ’λΌλ λ¨μ΄λ₯Ό λ£κ³ , μ°Ύμ보λ
μλΉλΆλΆμ΄ μ΄μ μνλ μν©μ΄λΌλ κ²μ μ μ μμμ΅λλ€.
(1) Drift?
κΈ μμ±μ μν΄ μ°Ύμλ³Έ κΈ°μ μ Driftλ λ³Έλ μ£Όνμ μμ΄μμ κ·Έκ²κ³Ό
ν¬κ² μ°¨μ΄κ° μμμ μ μ μμμ΅λλ€.
Understanding terraform module
- kkumtree
2023-10-04T11:24:13+09:00
This week is last week of CloudNet@ group study about terraform.
In this study, my personal goal is making AWS architecture only with terraform and one tfstate file.
- Basic knowledge about AWS resources is required.
1. Terraform without Module
Before, I already met terraform for maintaining AWS in production level.
But at that time, our team maintain them as folder structure which is used by terraformer
# example structure
$ tree
.
βββ alb
β βββ lb.tf
β βββ lb_listener.tf
β βββ lb_target_group.tf
β βββ lb_target_group_attachment.tf
β βββ outputs.tf
β βββ provider.tf
β βββ variables.tf
βββ auto_scaling
β βββ autoscaling_group.tf
β βββ launch_template.tf
β βββ outputs.tf
β βββ provider.tf
β βββ variables.tf
βββ ec2_instance
β βββ instance.tf
β βββ outputs.tf
β βββ provider.tf
β βββ variables.tf
βββ eni
β βββ network_interface.tf
β βββ outputs.tf
β βββ provider.tf
βββ igw
β βββ internet_gateway.tf
β βββ outputs.tf
β βββ provider.tf
β βββ variables.tf
βββ nacl
β βββ default_network_acl.tf
β βββ outputs.tf
β βββ provider.tf
β βββ variables.tf
βββ route_table
β βββ main_route_table_association.tf
β βββ outputs.tf
β βββ provider.tf
β βββ route_table.tf
β βββ route_table_association.tf
β βββ variables.tf
βββ s3
β βββ outputs.tf
β βββ provider.tf
β βββ s3_bucket.tf
βββ sg
β βββ outputs.tf
β βββ provider.tf
β βββ security_group.tf
β βββ variables.tf
βββ subnet
β βββ outputs.tf
β βββ provider.tf
β βββ subnet.tf
β βββ variables.tf
βββ vpc
βββ outputs.tf
βββ provider.tf
βββ vpc.tf
At glance, this solution looks like cool.
But, problems were enough critical to think ‘why we have to use terraform?’.
IAM STSλ₯Ό μ΄μ©ν Terraform Cloud κΆν λΆμ¬
- kkumtree
2023-09-13T20:54:28+09:00
μ΄λ²μλ Terraform Cloudκ° μΌλ§λ μ’μμ§ λ μμ보기 μν΄,
μ€ν°λμμ μ§μμ μΌλ‘ μ₯μ μ΄ κ°μ‘°λμ΄ μλ Terraform Cloudμ
IAM STSλ₯Ό μ΄μ©ν κΆν λΆμ¬ λμ λ° μ μ© μ±κ³΅μ λν΄ μ¨λ³΄λ €κ³ ν©λλ€.
Terraformμ μν μ μ₯μ μν΄ λ³΄ν΅ AWS S3λ₯Ό μ¬μ©νλλ°,
μλ€μνΌ S3 κΈ°λ‘μ 무λ£μ§λ§, λΆλ¬μ€λ κ²μ μ λ£μ
λλ€.
(μ κΈ°λ κ΅μ°μ΄μ§λ§, μλ£λ μμ
μ
λλ€)
κ·Έλμ μ€ν°λμ©μΌλ‘λ Terraformμ λΆλ¬μ¬ λλ§λ€,
μν κ°μ S3λ§κ³ , λ‘컬μ μ μ₯νμλλ°μ.
λ°μμλ λ
ΈνΈλΆ, μ§μμλ λ°μ€ν¬νμΌλ‘ νλ €λ
μ΄κ±Έ GitHubμ Private Repoμ μ μ₯ν κΉ? νλ€κ°
Terraform Cloudλ₯Ό μ¨λ³΄κΈ°λ‘ νμ΅λλ€. (κ³ ν΅μ μμ)
AWS EKS μ€ν°λ 7μ£Όμ°¨ - Automation
- kkumtree
2023-06-10T15:13:19+09:00
EKS μ€ν°λλ λ§μ§λ§ 7μ£Όμ°¨λ₯Ό λ§μ΄νμ΅λλ€.
μ΄λ²μλ AWS Controller for k8s(ACK)μ fluxλ₯Ό κ°λ³κ² μ€μ΅ν΄λ³΄κ³
μλνμ λν΄ λ§λ³΄κΈ°λ₯Ό ν΄λ³΄μμ΅λλ€.
μμ νμ΅ν΄λ³Έ IRSA κ°λ μΈμλ CRD(CustomResourceDefinition)μ νμ©ν©λλ€.
1. μ€μ΅νκ²½ λ°°ν¬
μ€μ΅μ μν YAMLνμΌμ΄ λ³κ²½λκ±° λ§κ³ λ 6μ£Όμ°¨μ μ μ¬ν©λλ€.
curl -O https://s3.ap-northeast-2.amazonaws.com/cloudformation.cloudneta.net/K8S/eks-oneclick6.yaml
# μ΄ν μ€λ΅
# CERT_ARN(ACM)μ κ²½μ°μλ /etc/profileμ νκ²½λ³μ μ μ₯μ μν΄λ¬μ
# μΈμ
μ΄ λ§λ£λλ©΄, λ€μ μ¬μ€μ νμ
CERT_ARN=`aws acm list-certificates --query 'CertificateSummaryList[].CertificateArn[]' --output text`
echo $CERT_ARN
2. ACK(AWS Controller for k8s)
- μΉμ½μμ μ κ·Όνμ§ μκ³ λ, AWS μλΉμ€ 리μμ€λ₯Ό μ§μ k8sμμ μ μ λ° μ¬μ©κ°λ₯
- μμ: ACK 컨νΈλ‘€λ¬ μ€μΉ -> IRSA μ€μ -> AWS 리μμ€ μ»¨νΈλ‘€
- κ°μ ν¨ν΄μΌλ‘ μ΄λ£¨μ΄μ Έμλλ°, Cloudformationμ μ°λ€λ³΄λ μ€κ°μ€κ° λκΈ° μκ° λ°μ
- (23/05/29) GA: 17κ° μλΉμ€, Preview: 10κ° μλΉμ€
2-1. S3
- [ACK S3 Controller μ€μΉ]
# μλΉμ€λͺ
λ³μ μ§μ
export SERVICE=s3
# helm μ°¨νΈ λ€μ΄λ‘λ
export RELEASE_VERSION=$(curl -sL https://api.github.com/repos/aws-controllers-k8s/$SERVICE-controller/releases/latest | grep '"tag_name":' | cut -d'"' -f4 | cut -c 2-)
helm pull oci://public.ecr.aws/aws-controllers-k8s/$SERVICE-chart --version=$RELEASE_VERSION
tar xzvf $SERVICE-chart-$RELEASE_VERSION.tgz
# helm chart νμΈ
tree ~/$SERVICE-chart
# ACK S3 Controller μ€μΉ
export ACK_SYSTEM_NAMESPACE=ack-system
export AWS_REGION=ap-northeast-2
helm install --create-namespace -n $ACK_SYSTEM_NAMESPACE ack-$SERVICE-controller --set aws.region="$AWS_REGION" ~/$SERVICE-chart
# μ€μΉ νμΈ
helm list --namespace $ACK_SYSTEM_NAMESPACE
kubectl -n ack-system get pods
kubectl get crd | grep $SERVICE
kubectl get all -n ack-system
kubectl get-all -n ack-system
kubectl describe sa -n ack-system ack-s3-controller
- [IRSA μ€μ ] AmazonS3FullAccess
- μ€μ νμλ rolloutμΌλ‘ λ°μν΄μ£Όμ΄μΌν¨
# Create an iamserviceaccount - AWS IAM role bound to a Kubernetes service account
eksctl create iamserviceaccount \
--name ack-$SERVICE-controller \
--namespace ack-system \
--cluster $CLUSTER_NAME \
--attach-policy-arn $(aws iam list-policies --query 'Policies[?PolicyName==`AmazonS3FullAccess`].Arn' --output text) \
--override-existing-serviceaccounts --approve
# νμΈ
eksctl get iamserviceaccount --cluster $CLUSTER_NAME
kubectl get sa -n ack-system
kubectl describe sa ack-$SERVICE-controller -n ack-system
# Restart ACK service controller deployment using the following commands.
kubectl -n ack-system rollout restart deploy ack-$SERVICE-controller-$SERVICE-chart
# IRSA μ μ©μΌλ‘ Env, projected Volume μΆκ° νμΈ
kubectl describe pod -n ack-system -l k8s-app=$SERVICE-chart

AWS EKS μ€ν°λ 6μ£Όμ°¨ - Security
- kkumtree
2023-06-04T06:56:52+09:00
μ΄λ²μλ 보μμ μν μΈμ¦ λ° μΈκ°, κ·Έλ¦¬κ³ IRSAλ₯Ό μ€μ¬μΌλ‘ EKSμ 보μμ λν΄ νμ΅ν΄λ³΄μμ΅λλ€.
kops μ€ν°λ λμλ μ λͺ°λλλ°, RBAC λΏλ§ μλλΌ λ³΅κΈ°νλ€λ³΄λ…
- [4-1] projected Volume
- [4-2] AWS Load Balancer Controller IRSA λ° LB Pod mutating
μμ λ κ°μ§κ° μ€μν ννΈλ₯Ό μ°¨μ§νκ³ μμμμ μ μ μμμ΅λλ€.
Network(2μ£Όμ°¨)κ° λ§€λ² λκ° μΌλΆκ° μ리μ‘νμλ€λ©΄
Securityλ 볡기νλ€κ° μ΄λ‘ μ μΌλ‘λ κ°λ¨(κ³Όμ°?)ν΄λ³΄μ¬λ
μ€μ ꡬλλ°©μ μ΄ν΄ μμ²΄κ° μ΄λ°μ μλμ, μ¬ν λ¨μ§ κ±Έλ¦° λμ λ μ΄λ €μ λ κ² κ°μ΅λλ€.
κ·Έ μΈ
- myeks-bastion-2μ μ μ μ, ν¨κ» μ§νν λλ
ssh {Public IP}λ‘ μ μ μλλ κ±Έ λ΄€λλ° μ μ νΌμ ν λ μ μμ΄ λμ§μμμ΅λλ€.- Amazon Linuxμμλ ssh ec2-user@{Public IP}λ‘ μ μν΄μΌν¨
(νμν κ²½μ° sshν€λ ν¬ν¨) - AWS Public AMIμμ μ 곡λλ Ubuntu AMIμ κ²½μ°,
ubuntu@{Public IP}λ‘ μ μκ°λ₯ - μΆμ : 곡μ λ λ¨Έμ μ λ€λ₯Έ μ€μ μ΄ μ΄μκ° λλ κ²μΌλ‘ μΆμ λ©λλ€.

- Amazon Linuxμμλ ssh ec2-user@{Public IP}λ‘ μ μν΄μΌν¨
- IAM User(testuser)λ μΉμ½μμμ μμ νλ κ²μ΄ νΈλ¦¬ν©λλ€.
- μλλ©΄, μλμ²λΌ detach νλ€λ λλμΌλ‘ μμ°¨μ μ€νν©λλ€.
- list-attached-role-policies && detach-role-policy
- list-access-keys && delete-access-key
- delete-user

- μλλ©΄, μλμ²λΌ detach νλ€λ λλμΌλ‘ μμ°¨μ μ€νν©λλ€.
- CLIλ‘ IAM Trust Relationship μ‘°ν
- μΉ μ½μμ κ΅³μ΄ λ€μ΄κ°μΌνλ νκ³ , λ¬Έλ νΈκΈ°μ¬μ μλνλ€κ° μκ°μ΄ λ μκ°μ΅λλ€.
- κ²°λ‘ : νλμ½μ΄ν νμ±..
jq -r '.[].status.roleARN' | rev | cut -d '/' -f1 | rev- chatGPTμκ² μλμ κ°μ΄ κ΅μ λ°μμ§λ§, ννμΉ μμ..
jq -r '.[].status.roleARN' | grep -oE '[^/]+$'

1. μ€μ΅ νκ²½ λ°°ν¬
- λͺ¨μ곡격(?) ν μ€νΈλ₯Ό μν΄ 2κ°μ bastion μλ²κ° ꡬμ±λ νκ²½ λ°°ν¬
- p8s λ° grafanaμ κ²½μ°, μ νμ μΌλ‘ λ°°ν¬ν΄λ λμ κΈ°μ μλ΅
curl -O https://s3.ap-northeast-2.amazonaws.com/cloudformation.cloudneta.net/K8S/eks-oneclick5.yaml
# μ΄ν μ€λ΅
# CERT_ARN(ACM)μ κ²½μ°μλ /etc/profileμ νκ²½λ³μ μ μ₯μ μν΄λ¬μ
# μΈμ
μ΄ λ§λ£λλ©΄, λ€μ μ¬μ€μ νμ
CERT_ARN=`aws acm list-certificates --query 'CertificateSummaryList[].CertificateArn[]' --output text`
echo $CERT_ARN
2. k8s μΈμ¦/μΈκ°
.kube/configνμΌμ κΈ°λ°- cluster: k8s API μλ² μ μμ 보
- users: API μλ²μ μ μνκΈ° μν μ μ μΈμ¦μ 보 λͺ©λ‘
- contexts: clusterλ° userλ₯Ό λ§€ν(μ‘°ν©)ν μ 보

AWS EKS μ€ν°λ 5μ£Όμ°¨ - Autoscaling
- kkumtree
2023-05-22T19:23:37+09:00
μ΄λ² μ£Όμ°¨λ μ€ν μ€μΌμΌλ§μ λ©μΈμΌλ‘ νμ¬, μν/μμ§ νλ‘λΉμ λμ νμ΅ν΄λ³΄μμ΅λλ€.
λ§μ§λ§μλ κ³ μ±λ₯ μ€ν μ€μΌμΌλ¬μΈ Karpenterλ₯Ό λ³λλ‘ μ€μ΅ν΄λ³΄μμ΅λλ€.
νΉν..
-
HPA custom metrics(μ¬μ©μ μ μ λ©νΈλ¦) μ μ©
-
YAML μ€μ κ°μ CPUλ‘ λ§μΆ κ²μ μκ³ , νλ‘λΉμ λμ μλͺ» μμΈ‘ν κ²λ ν¨κ» 곡μ ν©λλ€.
-
AutoScaling
- HPA: Horizontal Pod Autoscaler
- VPA: Vertical Pod Autoscaler
- CA: Cluster Autoscaler
- κ° CSP μμ‘΄μ , μ컀 λ Έλ λ 벨μμμ μ€ν μ€μΌμΌλ§
1. μ€μ΅ νκ²½ λ°°ν¬
- 4μ£Όμ°¨μ μ΄κΈ° λ°°ν¬ λ΄μ©μ p8s λ° Grafanaλ₯Ό μΆκ°νμ¬ λ°°ν¬
- verticalPodAutoscaler νμ±ν
- μΆμ² λμ보λ: 15757, 17900, 15172
curl -O https://s3.ap-northeast-2.amazonaws.com/cloudformation.cloudneta.net/K8S/eks-oneclick4.yaml
# μ΄ν μ€λ΅
## Prometheus & Grafana μ€μΉ
# μΈμ¦μ ARN
CERT_ARN=`aws acm list-certificates --query 'CertificateSummaryList[].CertificateArn[]' --output text`
echo $CERT_ARN
# νλΌλ―Έν° νμΌ μμ± λ° λ°°ν¬
cat <<EOT > monitor-values.yaml
prometheus:
prometheusSpec:
podMonitorSelectorNilUsesHelmValues: false
serviceMonitorSelectorNilUsesHelmValues: false
retention: 5d
retentionSize: "10GiB"
verticalPodAutoscaler:
enabled: true
ingress:
enabled: true
ingressClassName: alb
hosts:
- prometheus.$MyDomain
paths:
- /*
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS":443}, {"HTTP":80}]'
alb.ingress.kubernetes.io/certificate-arn: $CERT_ARN
alb.ingress.kubernetes.io/success-codes: 200-399
alb.ingress.kubernetes.io/load-balancer-name: myeks-ingress-alb
alb.ingress.kubernetes.io/group.name: study
alb.ingress.kubernetes.io/ssl-redirect: '443'
grafana:
defaultDashboardsTimezone: Asia/Seoul
adminPassword: prom-operator
ingress:
enabled: true
ingressClassName: alb
hosts:
- grafana.$MyDomain
paths:
- /*
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/listen-ports: '[{"HTTPS":443}, {"HTTP":80}]'
alb.ingress.kubernetes.io/certificate-arn: $CERT_ARN
alb.ingress.kubernetes.io/success-codes: 200-399
alb.ingress.kubernetes.io/load-balancer-name: myeks-ingress-alb
alb.ingress.kubernetes.io/group.name: study
alb.ingress.kubernetes.io/ssl-redirect: '443'
defaultRules:
create: false
kubeControllerManager:
enabled: false
kubeEtcd:
enabled: false
kubeScheduler:
enabled: false
alertmanager:
enabled: false
EOT
kubectl create ns monitoring
helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack --version 45.27.2 \
--set prometheus.prometheusSpec.scrapeInterval='15s' --set prometheus.prometheusSpec.evaluationInterval='15s' \
-f monitor-values.yaml --namespace monitoring
# metrics-server λ°°ν¬
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
1-1. EKS Node Viewer μ€μΉ
- νλ 리μμ€μ λν μμ² μ 보λ₯Ό νμΈν μ μλ λμ보λ
- ν΄λΉ λ Έλμ ν λΉ κ°λ₯ν μ©λμ μκ°μ μΌλ‘ νμ
- μ€μ μ¬μ©λμ΄ μλλΌ, μμ²λ 리μμ€(CPU, Memory)μ λν νμ
- μ€μ΅ μ€μ± μμμ go μ€μΉ λ° λ·°μ΄ μ€μΉμ λ€μ μκ°μ΄ μμ (μ½ 5λΆ)
- Karpenter μ€μ΅ μμλ μΈκΈλκ² μ§λ§, EKSκ° κ΅¬μΆλ λ€μ μ¬μ©μ΄ κ°λ₯νλ€.
# go λ° EKS Node Viewer μ€μΉ
yum install -y go
go install github.com/awslabs/eks-node-viewer/cmd/eks-node-viewer@latest
# EKS Node Viewer μ€ν
tree ~/go/bin
cd ~/go/bin && ./eks-node-viewer
## EKS Node Viewer λͺ
λ Ή μν
# Display both CPU and Memory Usage
./eks-node-viewer --resources cpu,memory
# Karenter nodes only
./eks-node-viewer --node-selector "karpenter.sh/provisioner-name"
# Display extra labels, i.e. AZ
./eks-node-viewer --extra-labels topology.kubernetes.io/zone
# Specify a particular AWS profile and region
AWS_PROFILE=myprofile AWS_REGION=ap-northeast-2
## κΈ°λ³Έ μ΅μ
νκ²½ λ³μ
# select only Karpenter managed nodes
node-selector=karpenter.sh/provisioner-name
# display both CPU and memory
resources=cpu,memory

AWS EKS μ€ν°λ 4μ£Όμ°¨ - Observability
- kkumtree
2023-05-21T06:13:52+09:00
μ΄λ² μ£Όμ°¨μλ Observabilityμ λν΄ μ€ν°λκ° μ§νλμμ΅λλ€.
μμ λͺ¨λν°λ§ ν΄λ€μ μ μ© λ° μ¬μ©μ΄ μ€μ¬μ
λλ€.
κ·Έλμ λ k8s 1.26μμ metricsμ μΌλΆ λͺ
μΉμ΄ λ°λλ κ±Έ λ³΄κ³ μκ²νμ΅λλ€.
(etcd_db_total_size_bytes λμ , apiserver_storage_db_total_size_in_bytes μΌλ‘ λ³κ²½)
λν kubecostμ κ²½μ°, cloudformation μ€ν μ κ±° νμλ λ³Όλ₯¨ λ°μ΄ν°κ° λ¨μμμ΄μ λ³λλ‘ μμ ν΄μΌ νμ΅λλ€.
1. μ€μ΅νκ²½ λ°°ν¬
- NATκ²μ΄νΈμ¨μ΄, EBS addon, IAM role, ISRA for LB/EFS, PreCommand ν¬ν¨
- λ
Έλ: t3.xlarge
- t3a.xlarge(AMD)λ μμΈ λ¦¬μ b AZ(ap-northeast-2b)μμ λ―Έμ§μ
- λ λ§μ κ°λ€μ΄ μ λ ₯λμ΄μ, μμ± μλ£κΉμ§ λ λ§μ μκ°μ΄ μμ (μ½ 20μ¬λΆ μ΄λ΄)
curl -O https://s3.ap-northeast-2.amazonaws.com/cloudformation.cloudneta.net/K8S/eks-oneclick3.yaml
# μ΄ν μλ΅, 3μ£Όμ°¨ μ°Έκ³

aws-cliλ₯Ό μ΄μ©ν bastion CIDR λ³κ²½
- kkumtree
2023-05-18T21:36:19+09:00
0. μμ½
aws ec2 describe-security-groups
aws ec2 modify-security-group-rules
1. λ°°κ²½

2μ£Ό μ μ λ¬Έλ μ΄λ° μ§λ¬Έμ μ¬λ Έλ μ μ΄ μμλ€.
λ¬Όλ‘ λ°κΎΈλ©΄ μλ μΌμ μμλλ° μ΄λ κ² νλκ² λ§λ νμ μ΄ λͺ¨μλΌμ μ견μ μ¬μ€λ΄€μκ³ ,
μ΄κ² λ§λ€λ νμ μ λ°μλ€.
κ·Έλ¦¬κ³ μ€λ… μΉ΄νλ₯Ό λ κ³³μ΄λ λ€λ¦¬λ©΄μ νλλΌ μ½κ°μ λ²κ±°λ‘μλ μκ³ AWS μΉ μ½μμμ νλ € νλ€.
κ·Έλ°λ°, μ λ
SGμμλ§ νμ΄μ§ λ‘λ©μ΄ timeout κ±Έλ €μ,
λμ ν μμ μ 컀λ
ν΄λΉ IDλ νμ
μ νκΈ° νλ μν©μ΄ λμλ€.
AWS EKS μ€ν°λ 3μ£Όμ°¨ - Storage
- kkumtree
2023-05-12T05:36:38+09:00
μ΄λ² μ£Όμ°¨μλ μ€ν 리μ§μ λν΄ μ€μ΅μ μ§νν΄λ³΄μμ΅λλ€. μ§λλ² kOps μ€ν°λμμ λ€λ£¨μλ λ΄μ©μ΄μ§λ§, λΆμ‘±νλ λ΄μ©μ 보좩νλ©΄μ μμ±μ ν΄λ³΄μμ΅λλ€.
μ£Όμν λ΄μ©μ…
- NodeAffinityλ₯Ό μ΄μ©ν λΌλ²¨λ§
- AWS EBS controllerμ κ²½μ°, AWS managed policyλ₯Ό νμ©
- AWS Volume SnapShots Controllerλ₯Ό ν΅ν λ³Όλ₯¨ λ°±μ
- AWS EFS controllerμμμ λμ νλ‘λΉμ λ
- AWS EKS μ κ· λ Έλκ·Έλ£Ή μμ±
λ³λλ‘ kube-ops-viewμ κ²½μ°, μΉμΌλ‘ νμΈν μ μμ λκΉμ§ μκ°μ΄ μμλλ€λ μ μ΄ μμ΅λλ€.
1. μ€μ΅ νκ²½ λ°°ν¬
- 2μ£Όμ°¨μ μ€μ΅νλ λ΄μ©λ€μ 미리 λ°°ν¬
- AWS LB
- ExternalDNS
- kube-ops-view
- context μ΄λ¦ λ³κ²½
- μ§λ λ²κΉμ§ pkosκ° λ¨λ νμμ΄ μμλλ°, λλ€μμ λ³λ μ§μ ν μ μμ
- EFS μμ± κ΄λ ¨ cloudformationμ΄ μΆκ°λμμ
- EFS FS ID μ‘°νλ₯Ό νκΈ° μν΄ aws-cli νν° νμ© (μΆμ²: AWS Docs)
# μ€μ΅ YAML νμΌ
curl -O https://s3.ap-northeast-2.amazonaws.com/cloudformation.cloudneta.net/K8S/eks-oneclick2.yaml
# cloudformation μ€ν μμ±
aws cloudformation deploy --template-file eks-oneclick2.yaml --stack-name myeks --parameter-overrides KeyName=aews SgIngressSshCidr=$(curl -s ipinfo.io/ip)/32 MyIamUserAccessKeyID=AKIA5... MyIamUserSecretAccessKey=CVNa2... ClusterBaseName=myeks --region ap-northeast-2
ssh -i ~/.ssh/aews.pem ec2-user@$(aws cloudformation describe-stacks --stack-name myeks --query 'Stacks[*].Outputs[0].OutputValue' --output text)
# default λ€μμ€νμ΄μ€ μ μ©
kubectl ns default
# (μ΅μ
) context μ΄λ¦ λ³κ²½
NICK=kkumtree
kubectl ctx
kubectl config rename-context [email protected] $NICK@myeks
# EFS νμΈ : AWS κ΄λ¦¬μ½μ EFS νμΈ
EfsFsId=$(aws efs describe-file-systems --query 'FileSystems[*].FileSystemId' --output text)
echo $EfsFsId
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport $EfsFsId.efs.ap-northeast-2.amazonaws.com:/ /mnt/myefs
df -hT --type nfs4
mount | grep nfs4
echo "Test efs exist with file " > /mnt/myefs/memo.txt
cat /mnt/myefs/memo.txt
rm -f /mnt/myefs/memo.txt
# μ€ν 리μ§ν΄λμ€ λ° CSI λ
Έλ νμΈ
kubectl get sc
kubectl get sc gp2 -o yaml | yh
kubectl get csinodes
# λ
Έλ μ 보 νμΈ
kubectl get node --label-columns=node.kubernetes.io/instance-type,eks.amazonaws.com/capacityType,topology.kubernetes.io/zone
eksctl get iamidentitymapping --cluster myeks
# λ
Έλ IP νμΈ λ° PrivateIP λ³μ μ§μ
N1=$(kubectl get node --label-columns=topology.kubernetes.io/zone --selector=topology.kubernetes.io/zone=ap-northeast-2a -o jsonpath={.items[0].status.addresses[0].address})
N2=$(kubectl get node --label-columns=topology.kubernetes.io/zone --selector=topology.kubernetes.io/zone=ap-northeast-2b -o jsonpath={.items[0].status.addresses[0].address})
N3=$(kubectl get node --label-columns=topology.kubernetes.io/zone --selector=topology.kubernetes.io/zone=ap-northeast-2c -o jsonpath={.items[0].status.addresses[0].address})
echo "export N1=$N1" >> /etc/profile
echo "export N2=$N2" >> /etc/profile
echo "export N3=$N3" >> /etc/profile
echo $N1, $N2, $N3
# λ
Έλ 보μκ·Έλ£Ή ID νμΈ
NGSGID=$(aws ec2 describe-security-groups --filters Name=group-name,Values=*ng1* --query "SecurityGroups[*].[GroupId]" --output text)
aws ec2 authorize-security-group-ingress --group-id $NGSGID --protocol '-1' --cidr 192.168.1.100/32
# μ컀 λ
Έλ SSH μ μ
ssh ec2-user@$N1 hostname
ssh ec2-user@$N2 hostname
ssh ec2-user@$N3 hostname
# λ
Έλμ ν΄ μ€μΉ
ssh ec2-user@$N1 sudo yum install links tree jq tcpdump sysstat -y
ssh ec2-user@$N2 sudo yum install links tree jq tcpdump sysstat -y
ssh ec2-user@$N3 sudo yum install links tree jq tcpdump sysstat -y
# AWS LB, ExternalDNS μ€μΉ
helm repo add eks https://aws.github.io/eks-charts
helm repo update
helm install aws-load-balancer-controller eks/aws-load-balancer-controller -n kube-system --set clusterName=$CLUSTER_NAME \
--set serviceAccount.create=false --set serviceAccount.name=aws-load-balancer-controller
# ExternalDNS
MyDomain=awskops.click
MyDnzHostedZoneId=$(aws route53 list-hosted-zones-by-name --dns-name "${MyDomain}." --query "HostedZones[0].Id" --output text)
echo $MyDomain, $MyDnzHostedZoneId
curl -s -O https://raw.githubusercontent.com/gasida/PKOS/main/aews/externaldns.yaml
MyDomain=$MyDomain MyDnzHostedZoneId=$MyDnzHostedZoneId envsubst < externaldns.yaml | kubectl apply -f -
1-1. kube-ops-view
- μκ°μ μΌλ‘ νμ¬ k8sμ μνλ₯Ό λ³Ό μ μλ ν΄
- μλλ μ€ μμλλ°, λ·°μ΄κ° λ° λκΉμ§ μκ°μ΄ 걸리λ κ²μ΄μμ.
