1Password SDK를 이용한 시크릿 (1Password Secrets with SDK)
1Password는 외부 장치 없이도 시크릿 provider를 편리하게 쓰도록 개발자용 SDK를 출시했어요. 이 덕분에 connect server 없이도 자동화 프로세스에서 훨씬 더 좋은 사용자 경험을 누릴 수 있어요.
참고 (Note): ESO를 1Password SDK와 함께 사용하려면 문서(item)들이 고유한 라벨 이름을 가져야 해요. 즉 어떤 라벨의 제목이 다른 라벨과 같으면 어떤 것을 업데이트해야 할지 알 수 없어서 에러가 발생해요:
found multiple labels with the same key.
출처: External Secrets
본문
Store 설정 (Store Configuration)
하나의 store는 하나의 vault에 해당해요. 이렇게 해서 하나의 ExternalSecret이 모든 vault에 접근하는 사고를 막아요.
샘플 store 설정은 이런 모양이에요:
---
apiVersion: external-secrets.io/v1
kind: SecretStore
metadata:
name: 1password-sdk
spec:
provider:
onepasswordSDK:
vault: staging
auth:
serviceAccountSecretRef:
name: onepassword-connect-token-staging
key: token
integrationInfo: # this is optional and defaulted
name: integration-info
version: v1
클라이언트 측 캐싱 (Client-Side Caching)
선택 사항인 클라이언트 측 캐싱은 1Password API 호출을 줄여줘요. store에서 TTL과 캐시 크기를 설정하세요:
apiVersion: external-secrets.io/v1
kind: SecretStore
metadata:
name: 1password-cached
spec:
provider:
onepasswordSDK:
vault: production
auth:
serviceAccountSecretRef:
name: op-token
key: token
cache:
ttl: 5m # Optional, default: 5m
maxSize: 100 # Optional, default: 100
캐싱은 읽기 작업(GetSecret, GetSecretMap, GetAllSecrets)에 적용돼요. 쓰기 작업(PushSecret, DeleteSecret)은 관련 캐시 항목을 자동으로 무효화해요.
실험적 (Experimental)
이 기능은 실험적인 기능이에요. TTL을 너무 길게 설정하면 시크릿 정보가 최신이 아닐 수 있어요.
GetSecret
유효한 시크릿 참조는 다음 키 형식을 사용해야 해요: <item>/[section/]<field>.
이 내용은 여기(Secret Reference Syntax)에서 설명하고 있어요.
일회용 비밀번호(one-time password)에는 다음 키 형식을 사용해요: <item>/[section/]one-time password?attribute=otp.
---
apiVersion: external-secrets.io/v1
kind: ExternalSecret
metadata:
name: fetch-from-onepassword
spec:
secretStoreRef:
kind: SecretStore
name: onepassword
target:
creationPolicy: Owner
data:
- secretKey: test-login-1
remoteRef:
key: test-login-1/username
# OR
dataFrom:
- extract:
key: test-login-1
property: username # optional field Label to match exactly
# OR
- find:
path: my-env-config # optional Item Title to match exactly
name:
regexp: "^username$"
# OR
- find:
tags:
tag1: "" # optional tags to match - value is unused, just needs to be present
PushSecret
시크릿 밀어넣기(push)도 지원돼요. 예를 들어 다음 시크릿을 사용하는 push 작업은:
apiVersion: v1
kind: Secret
metadata:
name: source-secret
stringData:
api-key: ***
api-url: "https://example.com/api"
이렇게 생겼어요:
---
apiVersion: external-secrets.io/v1alpha1
kind: PushSecret
metadata:
name: pushsecret-example # customizable
spec:
deletionPolicy: Delete
refreshInterval: 1h0m0s
secretStoreRefs:
- name: onepassword
kind: SecretStore
selector:
secret:
name: source-secret # Source Kubernetes secret
data:
- match:
secretKey: api-key # Source Kubernetes secret key to be pushed
remoteRef:
remoteKey: 1pw-item-name # 1Password item name
property: password # Field label within the 1Password item
metadata:
apiVersion: kubernetes.external-secrets.io/v1alpha1
kind: PushSecretMetadata
spec:
tags: ["tag1", "tag2"] # (Optional) tags on the 1Password item (item-level, not field-level)
# Tags are shared across all fields of the same remoteKey — last write wins if entries differ
fieldType: concealed # (Optional) field type (default: concealed)
# Accepted values (case-insensitive): text|string|concealed|password|url|email|phone|date|monthYear
- match:
secretKey: api-url
remoteRef:
remoteKey: 1pw-item-name # Same 1Password item — adds a second field
property: api-endpoint
metadata:
apiVersion: kubernetes.external-secrets.io/v1alpha1
kind: PushSecretMetadata
spec:
fieldType: url
시크릿의 모든 필드가 삭제되고, PushSecret 객체가 제거되며 policy가 delete로 설정되어 있으면 시크릿 전체가 삭제돼요.
시크릿 전체를 하나의 1Password 아이템으로 동기화하려면 다음 설정을 사용할 수 있어요:
---
apiVersion: external-secrets.io/v1alpha1
kind: PushSecret
metadata:
name: pushsecret-all-keys-example # customizable
spec:
deletionPolicy: Delete
refreshInterval: 1h0m0s
secretStoreRefs:
- name: onepassword
kind: SecretStore
selector:
secret:
name: source-secret # Source Kubernetes secret
data:
- match:
remoteRef:
remoteKey: 1pw-item-name-all-keys # 1Password item name, each Kubernetes secret key becomes a separate concealed field
metadata:
apiVersion: kubernetes.external-secrets.io/v1alpha1
kind: PushSecretMetadata
spec:
tags: ["tag1", "tag2"] # (Optional) tags on the 1Password item
Environments
1Password는 Environments 기능을 BETA 기능으로 추가했어요. 이 기능은 1Password SDK에서만 지원되고 connect server에서는 지원되지 않아요.
Environments는 Vaults의 대안이에요. Environment를 사용하려면 Store 설정에서 vault 값 대신 environment id를 정의하세요.
나머지 설정은 동일하게 유지하면 돼요.
이 글을 쓰는 시점 기준으로, SDK는 클라이언트 측 필터링을 지원하지 않아서 매 호출마다 항상 모든 것을 반환해요. 이 문제를 해결하기 위해 캐시가 개별 값을 캐시해서, 같은 객체가 캐시의 TTL 안에 다시 요청되면 그 단일 값만 가져와요.
또한 특수 키로 모든 값을 캐시해서, 반복적인 All 호출을 해도 문제가 없도록 해요.
BETA 기능이니 주의해서 사용하세요.
지원되는 기능 (Supported Functionality)
지원되는 기능에 대한 자세한 내용은 1password의 문서를 확인하세요.
더 알아보기 (Learn more)
- External Secrets Operator 공식 문서
- 1Password provider와 PushSecret 사용법에 대한 자세한 내용도 함께 살펴보세요.