Skip to content

Commit 8042d87

Browse files
authored
Merge pull request #38 from phasehq/feat--use-daemons-for-operator-sync
feat: use daemons for operator sync
2 parents 12c0106 + e3811b7 commit 8042d87

File tree

10 files changed

+45
-46
lines changed

10 files changed

+45
-46
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11-alpine
1+
FROM python:3.12.1-alpine3.19
22

33
# Set the working directory in the container
44
WORKDIR /app

cr-template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ spec:
88
phaseAppEnv: "production" # OPTIONAL The Phase application environment to fetch secrets from
99
phaseAppEnvPath: "/" # OPTIONAL Path within the Phase application environment to fetch secrets from
1010
phaseHost: "https://console.phase.dev" # OPTIONAL - URL of a Phase Console instance
11+
pollingInterval: 5 # OPTIONAL - Interval in seconds to poll for secret updates. Default is 60 seconds.
1112
authentication:
1213
serviceToken:
1314
serviceTokenSecretReference:

crd-template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ spec:
126126
description: Interval at which to poll for secret updates.
127127
type: integer
128128
default: 60
129+
minimum: 5
129130
required:
130131
- phaseApp
131132
- managedSecretReferences
@@ -157,7 +158,6 @@ spec:
157158
observedGeneration:
158159
description: Generation that the condition was set based upon.
159160
type: integer
160-
format: int64
161161
minimum: 0
162162
reason:
163163
description: Programmatic identifier for the reason of the condition's last transition.

helm-repo/index.yaml

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
entries:
33
phase:
44
- apiVersion: v2
5-
created: "2025-09-27T18:45:20.618693+05:30"
5+
created: "2026-01-12T19:28:48.14049+05:30"
66
description: A Helm chart for deploying the Phase Secrets Manager
77
digest: cdd437fc2cce88e078da782dd69b18eb2ddc22fe380df1ca72c767f550cecd6d
88
home: https://github.com/phasehq/kubernetes-secrets-operator
@@ -18,50 +18,34 @@ entries:
1818
- https://github.com/phasehq/console
1919
type: application
2020
urls:
21-
- https://helm.phase.dev/phase-0.4.2.tgz
21+
- phase-0.4.2.tgz
2222
version: 0.4.2
23+
phase-kubernetes-operator:
2324
- apiVersion: v2
24-
created: "2025-09-27T18:45:20.618273+05:30"
25-
description: A Helm chart for deploying the Phase Secrets Manager
26-
digest: 45321c29e26c00c8c052cc5cfeeca7b383caa0958fa97415ed81e3d2817c011b
27-
home: https://github.com/phasehq/kubernetes-secrets-operator
28-
icon: https://phase.dev/apple-touch-icon.png
29-
keywords:
30-
- phase
31-
- deployment
32-
maintainers:
33-
- email: nimish@phase.dev
34-
name: Nimish
35-
name: phase
36-
sources:
37-
- https://github.com/phasehq/console
38-
type: application
39-
urls:
40-
- https://helm.phase.dev/phase-0.4.1.tgz
41-
version: 0.4.1
42-
- apiVersion: v2
43-
created: "2025-09-24T20:12:36.640449+05:30"
44-
description: A Helm chart for deploying the Phase Secrets Manager
45-
digest: e7c0c633fe75fef2c20c4499e740cf6c940e0437c0b30101e09930f58d54a8a9
25+
appVersion: 1.4.0
26+
created: "2026-01-12T19:28:48.140947+05:30"
27+
description: A Helm chart for deploying the Phase Kubernetes Operator
28+
digest: c63fff0a875204cdb096952570f1e045fced435c7e13d03be06209bf40032e66
4629
home: https://github.com/phasehq/kubernetes-secrets-operator
4730
icon: https://phase.dev/apple-touch-icon.png
4831
keywords:
4932
- phase
50-
- deployment
33+
- kubernetes
34+
- operator
35+
- secrets
5136
maintainers:
52-
- email: nimish@phase.dev
53-
name: Nimish
54-
name: phase
37+
- email: info@phase.dev
38+
name: Phase Security Inc.
39+
name: phase-kubernetes-operator
5540
sources:
56-
- https://github.com/phasehq/console
41+
- https://github.com/phasehq/kubernetes-secrets-operator
5742
type: application
5843
urls:
59-
- phase-0.4.0.tgz
60-
version: 0.4.0
61-
phase-kubernetes-operator:
44+
- phase-kubernetes-operator-1.4.0.tgz
45+
version: 1.4.0
6246
- apiVersion: v2
6347
appVersion: 1.3.0
64-
created: "2025-09-27T18:45:20.619088+05:30"
48+
created: "2026-01-12T19:28:48.140716+05:30"
6549
description: A Helm chart for deploying the Phase Kubernetes Operator
6650
digest: ac562ccaea71b4ae9bdefeeef9b3660f092b998d673ca96f7f557d05aff93895
6751
home: https://github.com/phasehq/kubernetes-secrets-operator
@@ -79,6 +63,6 @@ entries:
7963
- https://github.com/phasehq/kubernetes-secrets-operator
8064
type: application
8165
urls:
82-
- https://helm.phase.dev/phase-kubernetes-operator-1.3.0.tgz
66+
- phase-kubernetes-operator-1.3.0.tgz
8367
version: 1.3.0
84-
generated: "2025-09-27T18:45:20.617165+05:30"
68+
generated: "2026-01-12T19:28:48.139841+05:30"
3.06 KB
Binary file not shown.

phase-kubernetes-operator/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ description: A Helm chart for deploying the Phase Kubernetes Operator
55
type: application
66

77
# Version of the chart
8-
version: 1.3.0
8+
version: 1.4.0
99

1010
# Version of the application (operator) that is being deployed
11-
appVersion: "1.3.0"
11+
appVersion: "1.4.0"
1212

1313
# Keywords, maintainers, and source URLs can also be added here
1414
keywords:

phase-kubernetes-operator/crds/crd-template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ spec:
126126
description: Interval at which to poll for secret updates.
127127
type: integer
128128
default: 60
129+
minimum: 5
129130
required:
130131
- phaseApp
131132
- managedSecretReferences
@@ -157,7 +158,6 @@ spec:
157158
observedGeneration:
158159
description: Generation that the condition was set based upon.
159160
type: integer
160-
format: int64
161161
minimum: 0
162162
reason:
163163
description: Programmatic identifier for the reason of the condition's last transition.

src/cmd/secrets/fetch.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
import logging
32
from utils.phase_io import Phase
43
from utils.secret_referencing import resolve_all_secrets
@@ -32,14 +31,14 @@ def phase_secrets_fetch(phase_service_token=None, phase_service_host=None, env_n
3231

3332
except ValueError as e:
3433
logger.error(f"Failed to fetch secrets: {e}")
35-
sys.exit(1)
34+
raise
3635

3736
# Create a dictionary with keys and resolved values outside the loop
3837
all_secrets_dict = {secret["key"]: secret["value"] for secret in resolved_secrets}
3938

4039
except Exception as e:
4140
logger.error(f"Failed to fetch secrets: {e}")
42-
sys.exit(1)
41+
raise
4342

4443
# Return secrets as a dictionary, ensure this is outside the try-except block
4544
return all_secrets_dict

src/main.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,23 @@
1212
from utils.misc import phase_get_context
1313
from dateutil import parser
1414

15-
@kopf.timer('secrets.phase.dev', 'v1alpha1', 'phasesecrets', interval=60)
16-
def phase_secret_sync(spec, name, namespace, logger, uid, **kwargs):
15+
@kopf.daemon('secrets.phase.dev', 'v1alpha1', 'phasesecrets')
16+
def phase_secret_sync(spec, name, namespace, logger, uid, stopped, **kwargs):
17+
while not stopped:
18+
polling_interval = max(spec.get('pollingInterval', 60), 5)
19+
20+
try:
21+
_phase_sync_secrets(spec, name, namespace, logger, uid, **kwargs)
22+
except Exception as e:
23+
logger.error(
24+
f"Unexpected error in daemon while syncing PhaseSecret {name} in namespace {namespace}: {e}"
25+
)
26+
27+
# Wait for the next poll
28+
if stopped.wait(polling_interval):
29+
break
30+
31+
def _phase_sync_secrets(spec, name, namespace, logger, uid, **kwargs):
1732
try:
1833
api_instance = CoreV1Api()
1934
managed_secret_references = spec.get('managedSecretReferences', [])

src/utils/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import re
3-
__version__ = "1.3.0"
3+
__version__ = "1.4.0"
44
__ph_version__ = "v1"
55

66
description = "Securely manage application secrets and environment variables with Phase."

0 commit comments

Comments
 (0)