CRD 기반 IPAM
CRD 기반 IPAM (CRD-Backed)
CRD 기반 IPAM 모드는 Kubernetes 사용자 지정 리소스 정의(CRD)를 통해 IP 주소 관리를 제어할 수 있는 확장 가능한 인터페이스를 제공해요. IPAM을 외부 operator에 위임하거나 노드별로 사용자가 구성할 수 있게 해 줍니다.
출처: CRD-Backed
본문
CRD 기반 IPAM 모드는 Kubernetes 사용자 지정 리소스 정의 (CRD)를 통해 IP 주소 관리를 제어할 수 있는 확장 가능한 인터페이스를 제공합니다. 이는 IPAM을 외부 operator에 위임하거나 노드별로 사용자가 구성할 수 있게 해 줘요.
아키텍처
이 모드가 활성화되면 각 Cilium 에이전트는 에이전트가 실행 중인 Kubernetes 노드와 이름이 일치하는 ciliumnodes.cilium.io Kubernetes 사용자 지정 리소스를 감시하기 시작합니다.
사용자 지정 리소스가 업데이트될 때마다 spec.ipam.available 필드에 나열된 모든 주소로 노드별 할당 풀이 업데이트됩니다. 현재 할당된 IP가 제거되면, 그 IP는 계속 사용되지만 해제 후에는 재할당에 사용할 수 없어요.
할당 풀에서 IP가 할당되면 IP는 status.ipam.inuse 필드에 추가됩니다.
Note
노드 상태 업데이트는 최대 15초에 한 번으로 제한됩니다. 따라서 여러 Pod가 동시에 스케줄되면 상태 섹션의 업데이트가 뒤처질 수 있어요.
구성
CRD 기반 IPAM 모드는 cilium-config ConfigMap에서 ipam: crd 를 설정하거나 --ipam=crd 옵션을 지정해 활성화됩니다. 활성화되면 에이전트는 Kubernetes 노드 이름과 일치하는 CiliumNode 사용자 지정 리소스가 하나 이상의 IP 주소를 사용 가능으로 나열한 채로 제공되기를 기다립니다. 연결 헬스 체크가 활성화되면 최소 두 개의 IP 주소가 사용 가능해야 해요.
기다리는 동안 에이전트는 다음 로그 메시지를 출력합니다:
Waiting for initial IP to become available in '<node-name>' custom resource
Cilium으로 CRD IPAM 모드를 활성화하는 실용적인 튜토리얼은 CRD-Backed IPAM 섹션을 참고하세요.
권한
사용자 지정 리소스가 기능하려면 다음 추가 권한이 필요합니다. 이 권한은 표준 Cilium 배포 아티팩트를 사용할 때 자동으로 부여됩니다:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: cilium
rules:
- apiGroups:
- cilium.io
resources:
- ciliumnodes
- ciliumnodes/status
verbs:
- '*'
CRD 정의
CiliumNode 사용자 지정 리소스는 표준 Kubernetes 리소스를 본떠 만들어졌으며 spec 과 status 섹션으로 나뉩니다:
type CiliumNode struct {
[...]
// Spec is the specification of the node
Spec NodeSpec `json:"spec"`
// Status it the status of the node
Status NodeStatus `json:"status"`
}
IPAM 명세
spec 섹션은 노드가 할당에 사용할 수 있는 모든 IP 목록을 정의할 수 있는 IPAM 특유의 필드를 포함합니다:
// AllocationMap is a map of allocated IPs indexed by IP
type AllocationMap map[string]AllocationIP
// NodeSpec is the configuration specific to a node
type NodeSpec struct {
// [...]
// IPAM is the address management specification. This section can be
// populated by a user or it can be automatically populated by an IPAM
// operator
//
// +optional
IPAM IPAMSpec `json:"ipam,omitempty"`
}
// IPAMSpec is the IPAM specification of the node
type IPAMSpec struct {
// Pool is the list of IPs available to the node for allocation. When
// an IP is used, the IP will remain on this list but will be added to
// Status.IPAM.InUse
//
// +optional
Pool AllocationMap `json:"pool,omitempty"`
}
// AllocationIP is an IP available for allocation or already allocated
type AllocationIP struct {
// Owner is the owner of the IP, this field is set if the IP has been
// allocated. It will be set to the pod name or another identifier
// representing the usage of the IP
//
// The owner field is left blank for an entry in Spec.IPAM.Pool
// and filled out as the IP is used and also added to
// Status.IPAM.InUse.
//
// +optional
Owner string `json:"owner,omitempty"`
// Resource is set for both available and allocated IPs, it represents
// what resource the IP is associated with, e.g. in combination with
// AWS ENI, this will refer to the ID of the ENI
//
// +optional
Resource string `json:"resource,omitempty"`
}
IPAM 상태
status 섹션은 IPAM 특유의 필드를 포함합니다. IPAM 상태는 해당 노드의 모든 사용된 주소를 보고합니다:
// NodeStatus is the status of a node
type NodeStatus struct {
// [...]
// IPAM is the IPAM status of the node
//
// +optional
IPAM IPAMStatus `json:"ipam,omitempty"`
}
// IPAMStatus is the IPAM status of a node
type IPAMStatus struct {
// InUse lists all IPs out of Spec.IPAM.Pool which have been
// allocated and are in use.
//
// +optional
InUse AllocationMap `json:"used,omitempty"`
}