워크로드
워크로드 (Workload)
워크로드 (Workload) 리소스는 같은 워크로드 식별자를 공유하는 데이터 플레인 프록시들을 논리적으로 묶은 거예요. 데이터 플레인 프록시에 kuma.io/workload 레이블이 붙으면 Kong Mesh가 이 리소스를 자동으로 만들고 관리해 줘요. 이 문서에서는 Kubernetes와 Universal 환경에서 레이블을 설정하는 방법부터 MeshIdentity로 워크로드에 아이덴티티를 부여하는 방법, 그리고 여러 메시가 한 네임스페이스에 섞일 때 생기는 문제를 감지하고 해결하는 방법까지 살펴봐요
출처: 문서
본문
Workload 리소스는 동일한 워크로드 식별자를 공유하는 데이터 플레인 프록시들의 논리적 그룹을 나타내요. 데이터 플레인 프록시가 kuma.io/workload 레이블을 가지고 있으면 Kong Mesh가 Workload 리소스를 자동으로 생성하고 관리해요. Kubernetes에서는 Pod에 kuma.io/workload 어노테이션을 사용해 레이블을 설정하세요. Universal에서는 Dataplane 리소스에 레이블을 직접 설정하세요.
Workload 리소스는 다음과 같은 용도로 사용해요:
- 워크로드별로 연결되고 정상 상태인 데이터 플레인 프록시를 모니터링해요.
- 관찰 가능성을 위해 워크로드 식별자별로 데이터 플레인 프록시를 그룹화해요.
MeshIdentity와 통합해서 워크로드 기반으로 아이덴티티를 할당해요.
Kong Mesh가
Workload리소스를 자동으로 관리해요. 수동으로 만들지 마세요.kuma.io/workload레이블을 가진 데이터 플레인 프록시가 배포되면 컨트롤 플레인이Workload리소스를 생성하고, 이 리소스를 참조하는 데이터 플레인 프록시가 없으면 삭제해요.
Workload를 참조하는 모든 데이터 플레인 프록시는 같은 메시에 속해야 해요. Kubernetes에서는 Kong Mesh가 네임스페이스 수준에서 이를 강제해요. 하나의 네임스페이스에는 여러 메시에 속한 Pod가 함께 존재할 수 없어요.같은 네임스페이스 안에 여러 메시에 속한 Pod가 있는 걸 감지하면 Kong Mesh가 해당 네임스페이스에 Kubernetes 경고 이벤트를 발생시키고, 해당 워크로드에 대한
Workload생성은 건너뛰어요. 이미 존재하던Workload리소스는 삭제되지 않고 고아 상태로 남아 있어요.이 설정 문제를 예방하는 방법에 대한 자세한 내용은 네임스페이스-메시 제약 문서를 참고하세요.
예제
다음 예제는 Kong Mesh가 데이터 플레인 프록시로부터 Workload 리소스를 생성하는 방법, MeshIdentity로 워크로드에 아이덴티티를 할당하는 방법, 워크로드 상태를 확인하는 방법을 보여줘요.
자동으로 생성되는 Workload
데이터 플레인 프록시를 배포하면 Kong Mesh가 kuma.io/workload 레이블을 생성하고 Workload 리소스를 만들어요:
Kubernetes
ServiceAccount가 있는 Pod를 정의해요. 기본적으로 Kong Mesh는 ServiceAccount 이름을 워크로드 식별자로 사용해요:
apiVersion: v1
kind: Pod
metadata:
name: demo-app
spec:
serviceAccountName: demo-workload
그러면 Kong Mesh가 일치하는 Workload를 만들어요:
apiVersion: kuma.io/v1alpha1
kind: Workload
metadata:
name: demo-workload
namespace: default
labels:
kuma.io/mesh: default
kuma.io/managed-by: k8s-controller
spec: {}
status:
dataplaneProxies:
connected: 3
healthy: 3
total: 3
Universal
워크로드 레이블이 있는 Dataplane을 정의해요:
type: Dataplane
mesh: default
name: demo-app
networking:
address: 192.168.0.1
inbound:
- port: 8080
tags:
kuma.io/service: demo-service
kuma.io/workload: demo-workload
그러면 Kong Mesh가 일치하는 Workload를 만들어요:
type: Workload
mesh: default
name: demo-workload
status:
dataplaneProxies:
connected: 3
healthy: 3
total: 3
MeshIdentity와 함께 사용하는 Workload
Workload와 MeshIdentity를 결합하면 워크로드 식별자를 기반으로 아이덴티티를 할당할 수 있어요:
Kubernetes
kuma.io/workload 레이블로 데이터 플레인 프록시를 선택하는 MeshIdentity를 정의해요:
apiVersion: kuma.io/v1alpha1
kind: MeshIdentity
metadata:
name: workload-identity
namespace: kong-mesh-system
labels:
kuma.io/mesh: default
spec:
selector:
dataplane:
matchLabels:
kuma.io/workload: demo-workload
spiffeID:
trustDomain: example.com
path: "/workload/{{ .Workload }}"
provider:
type: Bundled
bundled:
meshTrustCreation: Enabled
insecureAllowSelfSigned: true
autogenerate:
enabled: true
이 설정에서는 kuma.io/workload: demo-workload 레이블이 붙은 데이터 플레인 프록시가 SPIFFE ID spiffe://example.com/workload/demo-workload를 받아요.
Universal
kuma.io/workload 레이블로 데이터 플레인 프록시를 선택하는 MeshIdentity를 정의해요:
type: MeshIdentity
mesh: default
name: workload-identity
spec:
selector:
dataplane:
matchLabels:
kuma.io/workload: demo-workload
spiffeID:
trustDomain: example.com
path: "/workload/{{ .Workload }}"
provider:
type: Bundled
bundled:
meshTrustCreation: Enabled
insecureAllowSelfSigned: true
autogenerate:
enabled: true
이 설정에서는 kuma.io/workload: demo-workload 레이블이 붙은 데이터 플레인 프록시가 SPIFFE ID spiffe://example.com/workload/demo-workload를 받아요.
워크로드 상태 확인하기
워크로드 목록을 조회하고 상태를 확인하면 연결되고 정상 상태인 데이터 플레인 프록시를 모니터링할 수 있어요:
Kubernetes
네임스페이스의 워크로드 목록을 조회해요:
kubectl get workloads -n default
출력에는 등록된 각 워크로드와 해당 메시가 표시돼요:
NAME MESH AGE
demo-workload default 5m
{:.no-copy-code}
특정 워크로드의 상세 상태를 확인해요:
kubectl get workload demo-workload -n default -o yaml
Universal
메시의 워크로드 목록을 조회해요:
kumactl get workloads --mesh default
출력에는 등록된 각 워크로드와 해당 메시가 표시돼요:
NAME MESH AGE
demo-workload default 5m
{:.no-copy-code}
특정 워크로드의 상세 상태를 확인해요:
kumactl get workload demo-workload --mesh default -o yaml
Workload 레이블 관리
kuma.io/workload 레이블은 데이터 플레인 프록시가 어느 Workload 리소스에 속하는지 결정해요.
Kubernetes
Kubernetes에서는 Kong Mesh가 다음 로직에 따라 각 Pod에 kuma.io/workload 레이블을 생성해요:
- Pod 레이블에서 자동 생성: 컨트롤 플레인에
runtime.kubernetes.workloadLabels가 설정되어 있으면, Kong Mesh가 설정된 우선순위 순서대로 각 Pod 레이블을 확인하고 비어 있지 않은 첫 번째 값을 사용해요. - ServiceAccount로 폴백: 설정된 레이블이 없거나 모두 비어 있으면, Kong Mesh가 Pod의 ServiceAccount 이름을 사용해요.
- 기본 동작: 기본적으로
workloadLabels는 비어 있기 때문에 Kong Mesh가 ServiceAccount 이름을 사용해요.
kuma.io/workload는 Pod 레이블로 수동 설정할 수 없어요. 이 레이블이 포함된 Pod 생성 및 업데이트 요청은 Kong Mesh가 거부해요.
Universal
Universal에서는 Dataplane 리소스의 inbound 태그에 kuma.io/workload 레이블을 직접 설정해요.
데이터 플레인 프록시의
kuma.io/workload레이블은Workload리소스 이름과 정확히 일치해야 해요.Workload를 참조하는 모든 데이터 플레인 프록시는 같은 메시에 속해야 해요.
제약 사항
- 단일 메시: 워크로드를 참조하는 모든 데이터 플레인 프록시는 같은 메시에 속해야 해요. Kubernetes에서는 Kong Mesh가 네임스페이스 수준에서 이를 강제해요. 하나의 네임스페이스에는 여러 메시에 속한 Pod가 함께 존재할 수 없어요. 네임스페이스가 이 제약을 위반하면 Kong Mesh가
Workload생성을 건너뛰고 경고 이벤트를 발생시켜요. - 자동 라이프사이클:
Workload는 수동으로 만들거나 수정할 수 없어요. 리소스는 컨트롤 플레인이 전적으로 관리해요. - 런타임 강제: 멀티 메시 네임스페이스를 사전에 방지하려면
runtime.kubernetes.disallowMultipleMeshesPerNamespace플래그를 활성화하세요. 이 플래그가 활성화되면, 네임스페이스에 다른 메시에 속한Dataplane리소스가 이미 있을 때 어드미션 웹훅이 Pod 생성과 Pod 업데이트를 거부해요.
문제 해결
멀티 메시 네임스페이스 문제 감지하기
Kong Mesh가 예상대로 Workload 리소스를 만들지 않는다면, 멀티 메시 네임스페이스 경고가 있는지 확인해 보세요:
kubectl get events -n <namespace> --field-selector type=Warning
다음 메시지가 있는 이벤트를 찾아 보세요: Skipping Workload generation: namespace has pods in multiple meshes for workload. This configuration is not supported.
Pod와 각 Pod의 메시를 확인해요:
kubectl get pods -n <namespace> -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.metadata.annotations.kuma\.io/mesh}{"\n"}{end}'
멀티 메시 네임스페이스 문제 해결하기
멀티 메시 네임스페이스 충돌은 다음과 같이 해결해요:
- 영향을 받는 Pod 파악: 위의 명령어로 네임스페이스에 있는 모든 Pod와 각 Pod의 메시 할당을 조회해요.
- 워크로드 재구성: 서로 다른 메시에 속한 Pod는 별도의 네임스페이스로 옮겨요.
- (선택 사항) 사전 방지 활성화: 컨트롤 플레인 설정에서
runtime.kubernetes.disallowMultipleMeshesPerNamespace=true를 설정하면 문제가 재발하는 걸 예방할 수 있어요.
스키마
{
"description": "Workload represents a logical grouping of data plane proxies in the mesh, providing visibility into their operational status. It tracks statistics about the data plane proxies that belong to a workload, including the number of connected, healthy, and total proxies, enabling monitoring and health assessment of your workload deployments. Workloads is also the primary way data-planes are grouped together in metrics and traces.",
"properties": {
"apiVersion": {
"description": "APIVersion defines the versioned schema of this representation of an object.\nServers should convert recognized schemas to the latest internal value, and\nmay reject unrecognized values.\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
"type": "string"
},
"kind": {
"description": "Kind is a string value representing the REST resource this object represents.\nServers may infer this from the endpoint the client submits requests to.\nCannot be updated.\nIn CamelCase.\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
"type": "string"
},
"metadata": {
"type": "object"
},
"spec": {
"description": "Spec is the specification of the Kuma Workload resource.",
"type": "object"
},
"status": {
"description": "Status is the current status of the Kuma Workload resource.",
"properties": {
"dataplaneProxies": {
"description": "DataplaneProxies defines statistics of data plane proxies that are part of this workload",
"properties": {
"connected": {
"description": "Connected defines number of connected data plane proxies",
"format": "int32",
"type": "integer"
},
"healthy": {
"description": "Healthy defines number of healthy data plane proxies for this workload",
"format": "int32",
"type": "integer"
},
"total": {
"description": "Total defines total number of data plane proxies for this workload",
"format": "int32",
"type": "integer"
}
},
"required": [
"connected",
"healthy",
"total"
],
"type": "object"
}
},
"type": "object"
}
},
"type": "object"
}
관련 리소스
더 알아보기 (Learn more)
- 데이터 플레인 프록시의 기본 개념을 먼저 확인해 봐요 — data plane proxies
- 워크로드에 아이덴티티를 부여하는 정책 사용법을 살펴봐요 —
MeshIdentity - 네임스페이스와 메시 제약 조건으로 멀티 메시 문제를 예방하는 방법을 알아봐요 — namespace-mesh constraint documentation
- 네임스페이스당 여러 메시 사용을 막는 설정 옵션을 확인해 봐요 —
runtime.kubernetes.disallowMultipleMeshesPerNamespace