apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig

metadata:
  name: wsi-eks-cluster
  version: "1.29"
  region: ap-northeast-2

cloudWatch:
  clusterLogging:
    enableTypes: ["*"]

iam:
  withOIDC: true
  serviceAccounts:
  - metadata:
      name: aws-load-balancer-controller
      namespace: kube-system
    wellKnownPolicies:
      awsLoadBalancerController: true
  - metadata:
      name: cert-manager
      namespace: cert-manager
    wellKnownPolicies:
      certManager: true

vpc:
  subnets:
    public:
      ap-northeast-2a: { id: public_a }
      ap-northeast-2b: { id: public_b }
    private:
      ap-northeast-2a: { id: private_a }
      ap-northeast-2b: { id: private_b }
      
managedNodeGroups:
  - name: wsi-app-nodegroup
    labels: { type: app }
    instanceName: wsi-app-node
    instanceType: t3.large
    desiredCapacity: 4
    minSize: 4
    maxSize: 20
    privateNetworking: true

  - name: wsi-addon-nodegroup
    labels: { type: addon }
    instanceName: wsi-addon-node
    instanceType: t3.medium
    desiredCapacity: 4
    minSize: 4
    maxSize: 20
    privateNetworking: true

fargateProfiles:
  - name: wsi-app-fargate-profile
    selectors:
      - namespace: wsi
        labels:
          type: fargate
#!/bin/bash
public_a=$(aws ec2 describe-subnets --filters "Name=tag:Name,Values=wsi-public-a" --query "Subnets[].SubnetId[]" --output text)
public_b=$(aws ec2 describe-subnets --filters "Name=tag:Name,Values=wsi-public-b" --query "Subnets[].SubnetId[]" --output text)
private_a=$(aws ec2 describe-subnets --filters "Name=tag:Name,Values=wsi-app-a" --query "Subnets[].SubnetId[]" --output text)
private_b=$(aws ec2 describe-subnets --filters "Name=tag:Name,Values=wsi-app-b" --query "Subnets[].SubnetId[]" --output text)

sed -i "s|public_a|$public_a|g" cluster.yaml
sed -i "s|public_b|$public_b|g" cluster.yaml
sed -i "s|private_a|$private_a|g" cluster.yaml
sed -i "s|private_b|$private_b|g" cluster.yaml
eksctl create cluster -f cluster.yaml
aws eks --region ap-northeast-2 update-kubeconfig --name wsi-eks-cluster
kind: Namespace
apiVersion: v1
metadata:
  name: wsi
  labels:
    aws-observability: enabled
kubectl apply -f ns.yaml