K8s Operator Kotlin Why Java
클러스터에 앱을 배포/백업/모니터링/자동꺼짐 등을 제공하는 관리 기능에 오퍼레이터가 적합하다고 판단해서 기술 검토
k8s 오퍼레이터 순위??
- Go operator-sdk
- Python kopf
- Java operator-sdk-java
- quarkus operator
3위의 서브인 Quarkus SDK를 선택한 이유
- 프레임워크에서 공식적으로 sdk를 제공하고 그 회사에서 사용중
- CRD 자동 생성
- 적당히 제공되는 샘플코드와 문서
선택 실패?
spring이 아닌 quarkus를 쓰는 것 까지는 괜찮았던 것 같은데 java가 아닌 kotlin을 쓴 것은 실수였던 것 같다
코드가 조금 간결해져서 편해지는 부분보다 고생하는게 더 크다.
Spec코드
죄다 nullable이거나 기본값이 있어야 하는데 코틀린 쓰는 보람이 없다
nullable
MatcherAssert.assertThat<Deployment>(
client.apps().deployments()
.inNamespace(metadata.namespace)
.withName(metadata.name).get(), Matchers.nullValue()
)
이 코드만 딱 보면 잘못된게 없는데 코틀린에서는 오류가 난다. get()에서 null이 나올 수 없어서
리소스 관리 코드도 뭔가 편하게 해주려고 노력한 것 같은데… 어설프다.
@ControllerConfiguration(
namespaces = [Constants.WATCH_CURRENT_NAMESPACE],
name = "wordpressapp",
dependents = [
Dependent(
name = "fastcgi-config",
type = ConfigmapFastcgiDependent::class,
useEventSourceWithName = "fastcgi-config"
),
Dependent(
name = "wp-config",
type = ConfigmapWpDependent::class,
useEventSourceWithName = "wp-config"
),
Dependent(type = SecretDependentResource::class),
Dependent(type = DeploymentDependent::class),
Dependent(
name = "service",
type = ServiceDependent::class
),
Dependent(type = IngressDependent::class, readyPostcondition = IngressDependent::class),
]
)
class WordpressAppReconciler
대강 이런 모양인데… ConfigMap이 두개라고 오류가 난다. 어쩌라고 씨