EKS에서 보통 EKS 노드가 생성될 때 bootstrap 스크립트를 통해 kubelet arguments를 설정할 수 있고, keep-alive 관련 수정을 원하는 경우 '--allowed-unsafe-sysctls' 파라미터를 포함하는 kubelet을 기동하는 node group을 생성하여 원하는 작업을 수행한다.
우선 아래 github link를 통해 eks 노드가 생성될때 각 설정에 대해 참고할 수 있다.
https://github.com/awslabs/amazon-eks-ami/blob/master/files/bootstrap.sh
GitHub - awslabs/amazon-eks-ami: Packer configuration for building a custom EKS AMI
Packer configuration for building a custom EKS AMI - GitHub - awslabs/amazon-eks-ami: Packer configuration for building a custom EKS AMI
github.com
또한 아래 링크에서 EKS(eksctl) Config 파일 설정에 대해 각 항목을 참고할 수 있다.
https://eksctl.io/usage/schema/#nodeGroups-overrideBootstrapCommand
Config file schema - eksctl
Config file schema Use eksctl utils schema to get the raw JSON schema.
eksctl.io
제목에 따라 EKS pod에 keep alive 관련 설정을 하려면 먼저 Custom AMI를 지정하고,
eksctl config file 설정 중 overrideBootstrapCommand 설정을 통해 bootstrap script를 지정하여
--allowed-unsafe-sysctls 파라미터가 설정된 kubelet 을 기동하는 노드 그룹을 생성한다.
pod.yaml 예시
apiVersion: v1
kind: Pod
metadata:
name: ubuntu
spec:
containers:
- name: ubuntu
image: ubuntu
command: ["sleep"]
args: ["1d"]
securityContext:
sysctls:
- name: net.ipv4.tcp_keepalive_intvl
value: "60"
eksctl-config.yaml 예시
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: <cluster name>
region: <region>
managedNodeGroups:
- name: <nodegroup name>
ami: <ami id>
amiFamily: AmazonLinux2
minSize: 0
maxSize: 10
desiredCapacity: 2
ssh:
allow: true
publicKeyName: <public key>
overrideBootstrapCommand: |
#!/bin/bash
set -ex
/etc/eks/bootstrap.sh <cluster name> --kubelet-extra-args "--node-labels=alpha.eksctl.io/cluster-name=<cluster name>,alpha.eksctl.io/nodegroup-name=<nodegroup-name>,eks.amazonaws.com/nodegroup=<nodegroup-name>,eks.amazonaws.com/nodegroup-image=<ami id> --allowed-unsafe-sysctls 'net.ipv4.tcp_keepalive_intvl'"
kubectl 명령어로 설정된 값을 확인한다.
$ kc exec -it ubuntu -- sysctl -a | grep -i keepalive
net.ipv4.tcp_keepalive_intvl = 60
net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_keepalive_time = 7200
추가 참고 자료:
쿠버네티스에서 sysctl 이용하기: https://kubernetes.io/docs/tasks/administer-cluster/sysctl-cluster/
'aws > k8s, eks study' 카테고리의 다른 글
EKS CNI issue - network plugin is not ready: cni config uninitialized (2) | 2023.03.15 |
---|---|
Adding rules (metric) on Prometheus config (2) | 2023.03.07 |
eks-controller ingress reconciler error with 403 response code (0) | 2023.03.02 |
Delete EKS pod and deploy again with pulled image (0) | 2023.02.28 |
Error of getting credential - no kind "ExecCredential" is registered for version (0) | 2023.02.15 |