EKS
Create
VPC & Subnet
kubernetes.io/cluster/<cluster-name>: <shared|owned>
태그를 추가해주세요.
Role
const roleName = "eks-role";
const role = new aws.iam.Role(
roleName,
{
namePrefix: `${roleName}-`,
assumeRolePolicy: {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: {
Service: "eks.amazonaws.com",
},
Action: "sts:AssumeRole",
},
],
},
tags: {
Name: roleName,
"loliot.net/stack": variable.stackName,
},
},
{ protect: true },
);
const clusterPolicyARNs = {
"0": "arn:aws:iam::aws:policy/AmazonEKSClusterPolicy",
};
const rpas = Object.entries(clusterPolicyARNs).map(
([i, arn]) =>
new aws.iam.RolePolicyAttachment(
`eks-rpa-${i}`,
{
policyArn: arn,
role: role.name,
},
{ protect: true },
),
);
Cluster
const clusterName = "eks";
export const cluster = new aws.eks.Cluster(
clusterName,
{
name: clusterName,
version: "1.28",
roleArn: role.arn,
vpcConfig: {
endpointPublicAccess: true,
subnetIds: [vpc.privateSubnet1.id, vpc.privateSubnet2.id, vpc.privateSubnet3.id, vpc.privateSubnet4.id],
},
kubernetesNetworkConfig: { serviceIpv4Cidr: "10.96.0.0/16" },
tags: {
Name: clusterName,
"loliot.net/stack": variable.stackName,
},
},
{ dependsOn: [...rpas], protect: true },
);
정보
Cluster를 생성할 때 설정하는 subnetIds
는 EKS 마스터와 워커가 통신하기 위해 2~4 개의 ENI를 추가할 서브넷을 선택하기 위한 설정입니다. 해당 ENI의 설명은 Amazon EKS <clusterName>
로 표시됩니다.
워커와 통신을 위해 설정하는 서브넷일 뿐, 워커가 배포될 서브넷 전체를 설정하는 것은 아닙니다.
aws eks list-clusters
aws eks update-kubeconfig \
--name <cluster-name> \
--region <region> \
--kubeconfig ~/.kube/<cluster-name>_config
export KUBECONFIG=<config-path>[:<config-path>]
OIDC
- EKS - 클러스터 - 개요 - 세부 정보
- OpenID Connect 공급자 URL 복사
- IAM - 액세스 관리(Access management) - 자격 증명 공급자(Identity Providers) - 공급자 추가
- OpenID Connect
- 공급자 URL 붙여넣기
- 지문 가져오기
const oidcProviderName = "eks-oidc-provider";
export const oidcProvider = new aws.iam.OpenIdConnectProvider(
oidcProviderName,
{
url: cluster.identities[0].oidcs[0].issuer,
clientIdLists: ["sts.amazonaws.com"],
thumbprintLists: ["**********"],
tags: {
Name: oidcProviderName,
"loliot.net/stack": variable.stackName,
},
},
{ protect: true },
);