기존 Kubernetes Operator를 클러스터 범위로 변경
operator-sdk 설명서는 operator-sdk
main.go
에서 watchNamespace를 빈 문자열로 설정하는 방법에 대해 설명하며 다음과 같이 보일 수 있습니다. // check the WATCH_NAMESPACE env var to see if populated
var watchNamespaceEnvVar = "WATCH_NAMESPACE"
ns, found := os.LookupEnv(watchNamespaceEnvVar)
if !found {
return "", fmt.Errorf("%s must be set", watchNamespaceEnvVar)
}
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
LeaderElection: enableLeaderElection,
LeaderElectionID: "f1c5ece8.example.com",
Namespace: watchNamespace, // namespaced-scope when the value is not an empty string
})
Namespace
이 설정되지 않았거나 빈 문자열로 설정된 경우 연산자는 이미 클러스터 범위입니다.나처럼 OLM( Operator Lifecycle Mananger )을 사용하여 운영자의 설치 및 업그레이드를 처리하는 경우 main.go에서 코드를 변경할 필요가 없습니다. 이제 OLM이 모든 범위 지정 변경을 처리합니다. CSV와 클러스터의 운영자 그룹만 변경하면 됩니다.
NOTE: v1.0.0 the Operator-sdk or greater
먼저 CSV(ClusterServiceVersion)에서
installModes
에 대한 설치 AllNamespaces
을 true
으로 설정합니다. installModes:
- supported: true
type: OwnNamespace
- supported: true
type: SingleNamespace
- supported: false
type: MultiNamespace
- supported: true
type: AllNamespaces
이것이 설정되고 클러스터에서 OLM으로 배포되면 필요한 유일한 변경 사항은 OperatorGroup 사양입니다. 네임스페이스가 지정된 operatorGroup 사양은 다음과 같습니다.
spec:
targetNamespaces:
- whatever_WATCH_NAMESPACES_is
클러스터 범위로 설정하려면 사양을 변경하십시오.
spec: {}
AllNamespaces
이 CSV에 설정되어 있으므로 다른 작업을 수행할 필요가 없습니다. 연산자는 클러스터 범위로 변경하고 모든 네임스페이스를 감시합니다. operatorGroup을 업데이트하지 않으면 연산자는 네임스페이스 범위로 유지됩니다. 따라서 범위가 지정된 네임스페이스에서 이동합니다.
클러스터 범위로

리소스 풋프린트는 클러스터 범위 연산자의 경우 조금 더 높고 연산자의 CSV는 클러스터의 모든 네임스페이스에 생성됩니다.
Reference
이 문제에 관하여(기존 Kubernetes Operator를 클러스터 범위로 변경), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/austincunningham/changing-an-existing-kubernetes-operator-to-cluster-scoped-10a1텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)