리소스 상태
리소스 상태 (Status)
Kong Operator가 관리하는 리소스는 다른 쿠버네티스 오브젝트처럼 status 필드를 제공해요. kubectl get 명령으로 오브젝트의 상태를 확인하는 기본 방법을 소개해요. ControlPlane과 DataPlane의 상태 조회, status 필드에서 주소나 프록시 서비스 이름 같은 정보를 가져오는 방법도 함께 다뤄요. 마지막에는 status condition을 활용해 DataPlane 문제를 해결하는 방법까지 살펴봐요
출처: 문서
본문
오브젝트의 상태를 보려면 kubectl get 커맨드를 사용할 수 있어요:
kubectl get $TYPE $NAME -o jsonpath-as-json='{.status}'
위 커맨드는 status 필드의 실제 스키마와 오브젝트의 상태에 따라 달라지는 JSON 오브젝트를 출력해요.
ControlPlane
kong이라는 ControlPlane이 있다고 가정하면, 다음 kubectl 커맨드로 상태를 확인할 수 있어요:
kubectl get controlplane kong -o jsonpath-as-json='{.status}'
그러면 다음과 비슷한 출력이 표시돼요:
[
{
"conditions": [
{
"lastTransitionTime": "2024-03-22T18:17:00Z",
"message": "",
"observedGeneration": 3,
"reason": "Ready",
"status": "True",
"type": "Ready"
},
{
"lastTransitionTime": "2024-03-22T18:17:00Z",
"message": "pods for all Deployments are ready",
"observedGeneration": 3,
"reason": "PodsReady",
"status": "True",
"type": "Provisioned"
}
]
}
]
DataPlane
다음 DataPlane을 예시로 사용해 볼게요:
echo '
apiVersion: gateway-operator.konghq.com/v1beta1
kind: DataPlane
metadata:
name: example
spec:
deployment:
podTemplateSpec:
metadata:
labels:
dataplane-pod-label: example
annotations:
dataplane-pod-annotation: example
spec:
containers:
- name: proxy
image: kong/kong-gateway:3.16 ' | kubectl apply -f -
DataPlane이 준비될 때까지 기다리려면 다음 커맨드를 사용할 수 있어요:
kubectl wait -n default dataplane example --for=condition=Ready
몇 초 후에 다음과 같이 보일 거예요:
dataplane.gateway-operator.konghq.com/example condition met
DataPlane이 배포되면 status 필드에서 정보를 가져올 수 있어요.
예를 들어 주소를 확인하고 싶다면 다음을 실행하세요:
kubectl get -n default dataplane example -o jsonpath-as-json='{.status.addresses}'
그러면 다음과 같은 결과가 나올 수 있어요:
[
[
{
"sourceType": "PrivateLoadBalancer",
"type": "IPAddress",
"value": "172.18.128.1"
},
{
"sourceType": "PrivateIP",
"type": "IPAddress",
"value": "10.96.194.111"
}
]
]
DataPlane 프록시 서비스
DataPlane의 프록시 Service 이름을 가져오려면 .status.service 필드를 다음과 같이 조회하면 돼요:
kubectl get -n default dataplane dataplane-example -o jsonpath-as-json='{.status.service}'
[
"dataplane-ingress-dataplane-example-sj54n"
]
status condition으로 문제 해결하기
DataPlane이 동작하지 않는다면 .status.conditions 필드를 살펴볼 수 있어요.
kubectl get -n default dataplane dataplane-example -o jsonpath-as-json='{.status.conditions}'
이를 통해 근본적인 문제를 파악할 수 있어요:
[
[
{
"lastTransitionTime": "2024-03-22T17:59:13Z",
"message": "Waiting for the resource to become ready: Deployment dataplane-dataplane-example-bdqjq is not ready yet",
"observedGeneration": 2,
"reason": "WaitingToBecomeReady",
"status": "False",
"type": "Ready"
}
]
]
Gateway
Gateway의 status 필드를 가져오려면 다음 kubectl 커맨드를 사용할 수 있어요:
kubectl get gateway kong -o jsonpath-as-json='{.status}'
그러면 아래와 비슷한 출력이 나올 거예요:
[
{
"addresses": [
{
"type": "IPAddress",
"value": "172.18.128.1"
}
],
"conditions": [
{
"lastTransitionTime": "2024-03-22T18:17:00Z",
"message": "All listeners are accepted.",
"observedGeneration": 1,
"reason": "Accepted",
"status": "True",
"type": "Accepted"
},
{
"lastTransitionTime": "2024-03-22T18:17:00Z",
"message": "",
"observedGeneration": 1,
"reason": "Programmed",
"status": "True",
"type": "Programmed"
},
{
"lastTransitionTime": "2024-03-22T18:17:00Z",
"message": "",
"observedGeneration": 1,
"reason": "Ready",
"status": "True",
"type": "Ready"
},
{
"lastTransitionTime": "2024-03-22T18:17:00Z",
"message": "",
"observedGeneration": 1,
"reason": "Ready",
"status": "True",
"type": "DataPlaneReady"
},
{
"lastTransitionTime": "2024-03-22T18:17:00Z",
"message": "",
"observedGeneration": 1,
"reason": "Ready",
"status": "True",
"type": "ControlPlaneReady"
},
{
"lastTransitionTime": "2024-03-22T18:17:00Z",
"message": "",
"observedGeneration": 1,
"reason": "Ready",
"status": "True",
"type": "GatewayService"
}
],
"listeners": [
{
"attachedRoutes": 0,
"conditions": [
{
"lastTransitionTime": "2024-03-22T18:17:00Z",
"message": "",
"observedGeneration": 1,
"reason": "NoConflicts",
"status": "False",
"type": "Conflicted"
},
{
"lastTransitionTime": "2024-03-22T18:17:00Z",
"message": "",
"observedGeneration": 1,
"reason": "Accepted",
"status": "True",
"type": "Accepted"
},
{
"lastTransitionTime": "2024-03-22T18:17:00Z",
"message": "",
"observedGeneration": 1,
"reason": "Programmed",
"status": "True",
"type": "Programmed"
},
{
"lastTransitionTime": "2024-03-22T18:17:00Z",
"message": "Listeners' references are accepted.",
"observedGeneration": 1,
"reason": "ResolvedRefs",
"status": "True",
"type": "ResolvedRefs"
}
],
"name": "http",
"supportedKinds": [
{
"group": "gateway.networking.k8s.io",
"kind": "HTTPRoute"
}
]
}
]
}
]
더 알아보기 (Learn more)
이 문서에는 원문에서 추출한 별도의 관련 문서 링크가 없어요.