개요
Atlas API Service Accounts provide a secure, token-based alternative to Programmatic API Keys for authenticating Atlas Kubernetes Operator with the Atlas Administration API. Service Accounts use short-lived access tokens derived from a clientId and clientSecret pair, reducing the risk of long-lived credential exposure.
MongoDB는 새 배포서버에 대해 프로그래밍 API 키보다 서비스 계정을 권장합니다. 서비스 계정은 다음과 같은 이점을 제공합니다.
managed에 의해 관리되는 자동 토큰 새로 고침이 있는 토큰 기반 인증.
조직 수준 및 프로젝트 수준 범위 모두 지원.
Atlas Kubernetes Operator 워크로드에 대한 감사 가능하고 고유한 신원을 제공합니다.
중요
서비스 계정 비밀 만료
Unlike API Keys, Service Account secrets are expirable. You can set a TTL of up to one year maximum. You must rotate Service Account secrets before they expire to maintain uninterrupted access. Atlas automatically raises a Service Account Secrets are about to expire alert as the expiry date approaches. Plan your rotation schedule accordingly.
이는 조직 수준 및 프로젝트 수준 서비스 계정 모두에 적용됩니다.
전제 조건
시작하기 전에 다음이 준비되어 있는지 확인하세요.
조직 수준 서비스 계정의 경우 Organization Owner 역할이 있는 Atlas 계정, 프로젝트 수준 서비스 계정의 경우 Project Owner 역할이 있는 Atlas 계정.
Atlas Kubernetes Operator가 설치된 실행 중인 Kubernetes 클러스터.
kubectlAtlas Kubernetes Operator가 실행되는 Kubernetes 클러스터에 액세스합니다.
절차
Atlas에서 서비스 계정 만들기
Create a Service Account in Atlas using the Atlas UI or the Atlas Administration API. To learn how to create an organization-level Service Account, see Create a Service Account in an Organization. To learn how to create a project-level Service Account, see Create a Service Account in a Project.
clientId 및 clientSecret을(를) 복사합니다. 생성 후에는 clientSecret 를 다시 조회할 수 없으므로 안전하게 저장합니다.
Kubernetes 연결 시크릿 생성
Create a Kubernetes secret containing the orgId, clientId, and clientSecret.
globalAtlas Kubernetes Operator 시크릿의 경우 다음 명령을 실행 .참고
The name of the
globalAtlas Kubernetes Operator secret must conform to the predefined format. The default name of the Atlas Kubernetes Operator deployment ismongodb-atlas-operator. So, the secret should be namedmongodb-atlas-operator-service-account.kubectl create secret generic mongodb-atlas-operator-service-account \ --from-literal="orgId=<the_atlas_organization_id>" \ --from-literal="clientId=<the_service_account_client_id>" \ --from-literal="clientSecret=<the_service_account_client_secret>" \ -n <operator_namespace> kubectl label secret mongodb-atlas-operator-service-account \ atlas.mongodb.com/type=credentials \ -n mongodb-atlas-system projectAtlas Kubernetes Operator 시크릿의 경우 다음 명령을 실행 .kubectl create secret generic my-project-connection \ --from-literal="orgId=<the_atlas_organization_id>" \ --from-literal="clientId=<the_service_account_client_id>" \ --from-literal="clientSecret=<the_service_account_client_secret>" \ -n <atlas_project_namespace> kubectl label secret my-project-connection \ atlas.mongodb.com/type=credentials \ -n <atlas_project_namespace>
시크릿에서 참조 AtlasProject
Reference the secret from your AtlasProject custom resource using spec.connectionSecretRef.name.
If you created a global secret, all projects use it by default and no additional configuration is needed.
If you created a project secret, add the connectionSecretRef to your AtlasProject custom resource:
apiVersion: atlas.mongodb.com/v1 kind: AtlasProject metadata: name: my-project spec: name: "My Project" connectionSecretRef: name: my-project-connection
연산자가 서비스 계정을 사용하는지 확인
After you configure the secret, verify that Atlas Kubernetes Operator authenticates successfully:
kubectl get atlasproject my-project -o jsonpath='{.status.conditions}'
Ready 조건이 True 인지 확인합니다. Atlas Kubernetes Operator가 Service Account 자격 증명으로 인증할 수 없으면 조건에 문제를 설명하는 오류가 표시됩니다.
YAML 예시
다음 예시에서는 서비스 계정에 대해 구성된 연결 시크릿을 보여줍니다.
apiVersion: v1 kind: Secret metadata: name: my-project-connection namespace: atlas-operator labels: atlas.mongodb.com/type: credentials type: Opaque stringData: orgId: "5d39f0719ccf646554345678" clientId: "mdb_sa_id_67890abcdef1234567890abc" clientSecret: "mdb_sa_sk_abcdef1234567890abcdef12"
고려 사항
토큰 관리
Atlas Kubernetes Operator manages access tokens automatically. When the Atlas Kubernetes Operator detects a Service Account Connection Secret, it obtains an access token from the Atlas Administration API and stores it in a separate Kubernetes secret. Do not manually edit or delete the Access Token Secret. Atlas Kubernetes Operator refreshes tokens as needed.
자격 증명 로터이션
Atlas에서 서비스 계정 시크릿을 로테이션할 때:
새
clientSecret로 Kubernetes 연결 시크릿을 업데이트합니다.Atlas Kubernetes Operator는 변경 사항을 감지하고 다음 재조정 사이클에서 새 액세스 토큰을 확보합니다. 다시 시작할 필요가 없습니다.
중요
Service Account secrets have a maximum TTL of one year. Monitor the Service Account Secrets are about to expire alert in Atlas and rotate your secrets before they expire to avoid authentication failures. This applies to both organization-level and project-level Service Accounts.
IP 액세스 목록
The Service Account's API access list must include the egress IP address or CIDR block used by the Atlas Kubernetes Operator pod, the same as for Programmatic API Keys. If the operator pod's egress IP is not on the Service Account access list, API requests fail.