Skip to content

Commit 84e56af

Browse files
authored
Merge branch 'main' into feature/oss-25-publish-versioned-chart
2 parents f5e3169 + ffbca7f commit 84e56af

File tree

19 files changed

+545
-144
lines changed

19 files changed

+545
-144
lines changed

CHANGELOG.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,93 @@
11
# CHANGELOG
22

33

4+
## v0.14.1 (2024-12-16)
5+
6+
### Bug Fixes
7+
8+
- Allow extra env vars in the operator's Chart
9+
([#491](https://github.com/Twingate/kubernetes-operator/pull/491),
10+
[`81bf885`](https://github.com/Twingate/kubernetes-operator/commit/81bf885b6c5c27dc075dab8b1f932f36170bff9c))
11+
12+
13+
## v0.14.0 (2024-12-16)
14+
15+
### Chores
16+
17+
- Bump github.com/gruntwork-io/terratest from 0.47.2 to 0.48.0
18+
([#480](https://github.com/Twingate/kubernetes-operator/pull/480),
19+
[`16dba29`](https://github.com/Twingate/kubernetes-operator/commit/16dba292e42961e6347df224ec36e2efb2a360ab))
20+
21+
Signed-off-by: dependabot[bot] <support@github.com>
22+
23+
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
24+
25+
- Bump golang.org/x/crypto from 0.21.0 to 0.31.0
26+
([#482](https://github.com/Twingate/kubernetes-operator/pull/482),
27+
[`48b5ad1`](https://github.com/Twingate/kubernetes-operator/commit/48b5ad113fb5167d7c692cebdbe2c14bdc53ca5f))
28+
29+
Signed-off-by: dependabot[bot] <support@github.com>
30+
31+
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
32+
33+
- Bump google-cloud-artifact-registry from 1.13.1 to 1.14.0
34+
([#484](https://github.com/Twingate/kubernetes-operator/pull/484),
35+
[`baeb563`](https://github.com/Twingate/kubernetes-operator/commit/baeb563f2fa9dc64fb69c78f5f3a2345ba3b0c12))
36+
37+
Signed-off-by: dependabot[bot] <support@github.com>
38+
39+
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
40+
41+
- Bump kopf from 1.37.3 to 1.37.4 ([#488](https://github.com/Twingate/kubernetes-operator/pull/488),
42+
[`f17436f`](https://github.com/Twingate/kubernetes-operator/commit/f17436fbd595fea4dc579acd3ded66bfad588ccb))
43+
44+
Signed-off-by: dependabot[bot] <support@github.com>
45+
46+
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
47+
48+
- Bump pydantic-settings from 2.6.1 to 2.7.0
49+
([#483](https://github.com/Twingate/kubernetes-operator/pull/483),
50+
[`f43c3c3`](https://github.com/Twingate/kubernetes-operator/commit/f43c3c3f050ea5ab143fa6badc559f546e9ebda8))
51+
52+
Signed-off-by: dependabot[bot] <support@github.com>
53+
54+
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
55+
56+
Co-authored-by: Eran Kampf <eran@ekampf.com>
57+
58+
- Bump python-semantic-release from 9.15.1 to 9.15.2
59+
([#489](https://github.com/Twingate/kubernetes-operator/pull/489),
60+
[`d911b83`](https://github.com/Twingate/kubernetes-operator/commit/d911b83ca3ad6240a56544033ab8cebbcb1d9d55))
61+
62+
Signed-off-by: dependabot[bot] <support@github.com>
63+
64+
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
65+
66+
- Bump ruff from 0.8.2 to 0.8.3 ([#485](https://github.com/Twingate/kubernetes-operator/pull/485),
67+
[`8a600a0`](https://github.com/Twingate/kubernetes-operator/commit/8a600a09a7e16cb5b04d43eb807f3c8770a8be25))
68+
69+
Signed-off-by: dependabot[bot] <support@github.com>
70+
71+
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
72+
73+
- Fix README markdownlint warnings
74+
([`c623d90`](https://github.com/Twingate/kubernetes-operator/commit/c623d9030e3266ab3ca4e141aee7d25079d3c228))
75+
76+
### Features
77+
78+
- Allow using a pull thru docker cache with the imagepolicy schedule
79+
([#477](https://github.com/Twingate/kubernetes-operator/pull/477),
80+
[`81fdb30`](https://github.com/Twingate/kubernetes-operator/commit/81fdb30022b8b7185c7148607b61dd1b7c5bb755))
81+
82+
Co-authored-by: Lior Rozner <1411811+liorr@users.noreply.github.com>
83+
84+
- Enable Configuration of Kopf Watch Settings via Environment Variables
85+
([#487](https://github.com/Twingate/kubernetes-operator/pull/487),
86+
[`3da4225`](https://github.com/Twingate/kubernetes-operator/commit/3da4225865e767fe8ca74477f477bf2b3ca8fc02))
87+
88+
Co-authored-by: Eran Kampf <205185+ekampf@users.noreply.github.com>
89+
90+
491
## v0.13.0 (2024-12-06)
592

693
### Bug Fixes

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test-cov:
6464

6565
.PHONY: test-int
6666
test-int:
67-
poetry run pytest -m "integration" -v -x
67+
poetry run pytest -m "integration" -vv -l -x
6868

6969
.PHONY: report-to-coveralls
7070
report-to-coveralls:

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ and manage Twingate resources within a Kubernetes environment. It provides
1212
seamless integration between your Kubernetes clusters and the Twingate Zero
1313
Trust Network.
1414

15-
[Wiki](https://github.com/Twingate/kubernetes-operator/wiki) | [Getting Started](https://github.com/Twingate/kubernetes-operator/wiki/Getting-Started) | [API Reference](https://github.com/Twingate/kubernetes-operator/wiki/API-Reference)
15+
[Wiki][1] | [Getting Started][2] | [API Reference][3]
1616

17+
[1]: https://github.com/Twingate/kubernetes-operator/wiki
18+
[2]: https://github.com/Twingate/kubernetes-operator/wiki/Getting-Started
19+
[3]: https://github.com/Twingate/kubernetes-operator/wiki/API-Reference
1720

1821
## Prerequisites
1922

app/settings.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from base64 import b64decode
66
from typing import Annotated, ClassVar
77

8+
import kopf
89
from pydantic.functional_validators import AfterValidator
910
from pydantic_core._pydantic_core import ValidationError
1011
from pydantic_settings import BaseSettings, SettingsConfigDict
@@ -36,6 +37,10 @@ class TwingateOperatorSettings(BaseSettings):
3637
remote_network_id: GlobalID = NULL_RN_ID
3738
remote_network_name: str | None = None
3839
host: str = "twingate.com"
40+
kopf_watching_server_timeout: float | None = None
41+
kopf_watching_client_timeout: float | None = None
42+
kopf_watching_connect_timeout: float | None = None
43+
kopf_watching_reconnect_backoff: float | None = None
3944

4045
@property
4146
def full_url(self) -> str:
@@ -56,6 +61,16 @@ def __init__(self, *args, **kwargs):
5661
if self.remote_network_id == self.NULL_RN_ID:
5762
raise ValidationError("Remote network id is required")
5863

64+
def update_kopf_watching_settings(self, settings: kopf.OperatorSettings):
65+
if self.kopf_watching_server_timeout:
66+
settings.watching.server_timeout = self.kopf_watching_server_timeout
67+
if self.kopf_watching_client_timeout:
68+
settings.watching.client_timeout = self.kopf_watching_client_timeout
69+
if self.kopf_watching_connect_timeout:
70+
settings.watching.connect_timeout = self.kopf_watching_connect_timeout
71+
if self.kopf_watching_reconnect_backoff:
72+
settings.watching.reconnect_backoff = self.kopf_watching_reconnect_backoff
73+
5974

6075
__settings: TwingateOperatorSettings | None = None
6176
__version: str | None = None

app/version_policy_providers/dockerhub.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
class DockerhubVersionPolicyProvider(VersionPolicyProvider):
99
_DOCKER_HUB_API_BASE_URL = "https://hub.docker.com/v2"
1010

11-
def __init__(self, repository: str | None = None):
12-
self.repository = repository or "twingate/connector"
11+
def __init__(self, _repository: str | None = None):
12+
self.repository = "twingate/connector"
1313
self.tags_api_url = (
1414
f"{self._DOCKER_HUB_API_BASE_URL}/repositories/{self.repository}/tags"
1515
)
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
---
2+
# Source: twingate-operator/templates/serviceaccount.yaml
3+
apiVersion: v1
4+
kind: ServiceAccount
5+
metadata:
6+
name: test-twingate-operator
7+
namespace: default
8+
labels:
9+
helm.sh/chart: twingate-operator-major.minor.patch-test
10+
app.kubernetes.io/name: twingate-operator
11+
app.kubernetes.io/instance: test
12+
app.kubernetes.io/managed-by: Helm
13+
---
14+
# Source: twingate-operator/templates/secrets.yaml
15+
apiVersion: v1
16+
kind: Secret
17+
metadata:
18+
name: test-twingate-operator
19+
namespace: default
20+
labels:
21+
helm.sh/chart: twingate-operator-major.minor.patch-test
22+
app.kubernetes.io/name: twingate-operator
23+
app.kubernetes.io/instance: test
24+
app.kubernetes.io/managed-by: Helm
25+
data:
26+
TWINGATE_API_KEY: PGFwaSBrZXk+
27+
---
28+
# Source: twingate-operator/templates/clusterrole.yaml
29+
apiVersion: rbac.authorization.k8s.io/v1
30+
kind: ClusterRole
31+
metadata:
32+
name: test-twingate-operator-role-cluster
33+
rules:
34+
# Framework: runtime observation of namespaces & CRDs (addition/deletion).
35+
- apiGroups: [apiextensions.k8s.io]
36+
resources: [customresourcedefinitions]
37+
verbs: [list, watch]
38+
- apiGroups: [""]
39+
resources: [namespaces]
40+
verbs: [list, watch]
41+
- apiGroups: ["", "events.k8s.io"]
42+
resources: [events]
43+
verbs: ['*']
44+
45+
# Framework: admission webhook configuration management.
46+
- apiGroups: [admissionregistration.k8s.io/v1, admissionregistration.k8s.io/v1beta1]
47+
resources: [validatingwebhookconfigurations, mutatingwebhookconfigurations]
48+
verbs: [create, patch]
49+
50+
# Application
51+
- apiGroups: [twingate.com]
52+
resources: [twingateresources, twingateresourceaccesses, twingateconnectors, twingategroups]
53+
verbs: [list, watch, patch, get, create]
54+
55+
- apiGroups: ["*"]
56+
resources: [pods, services, secrets, services/status]
57+
verbs: [list, watch, patch, get, create, delete]
58+
---
59+
# Source: twingate-operator/templates/clusterrolebinding.yaml
60+
apiVersion: rbac.authorization.k8s.io/v1
61+
kind: ClusterRoleBinding
62+
metadata:
63+
name: test-twingate-operator-rolebinding-cluster
64+
roleRef:
65+
apiGroup: rbac.authorization.k8s.io
66+
kind: ClusterRole
67+
name: test-twingate-operator-role-cluster
68+
subjects:
69+
- kind: ServiceAccount
70+
name: test-twingate-operator
71+
namespace: default
72+
---
73+
# Source: twingate-operator/templates/deployment.yaml
74+
apiVersion: apps/v1
75+
kind: Deployment
76+
metadata:
77+
name: test-twingate-operator
78+
namespace: default
79+
labels:
80+
helm.sh/chart: twingate-operator-major.minor.patch-test
81+
app.kubernetes.io/name: twingate-operator
82+
app.kubernetes.io/instance: test
83+
app.kubernetes.io/managed-by: Helm
84+
spec:
85+
replicas: 1
86+
strategy:
87+
type: Recreate
88+
selector:
89+
matchLabels:
90+
app.kubernetes.io/name: twingate-operator
91+
app.kubernetes.io/instance: test
92+
template:
93+
metadata:
94+
labels:
95+
app.kubernetes.io/name: twingate-operator
96+
app.kubernetes.io/instance: test
97+
spec:
98+
serviceAccountName: test-twingate-operator
99+
securityContext:
100+
seccompProfile:
101+
type: RuntimeDefault
102+
containers:
103+
- name: twingate-operator
104+
securityContext:
105+
allowPrivilegeEscalation: false
106+
capabilities:
107+
drop:
108+
- ALL
109+
readOnlyRootFilesystem: true
110+
runAsNonRoot: true
111+
runAsUser: 1000
112+
image: "twingate/kubernetes-operator:latest"
113+
imagePullPolicy: IfNotPresent
114+
command:
115+
- kopf
116+
- run
117+
- ./main.py
118+
- "-A"
119+
- "--standalone"
120+
- "--liveness=http://0.0.0.0:8080/healthz"
121+
- "--log-format=full"
122+
env:
123+
- name: TWINGATE_API_KEY
124+
valueFrom:
125+
secretKeyRef:
126+
name: test-twingate-operator
127+
key: TWINGATE_API_KEY
128+
- name: TWINGATE_NETWORK
129+
value: <network slug>
130+
- name: TWINGATE_HOST
131+
value: twingate.com
132+
- name: TWINGATE_REMOTE_NETWORK_ID
133+
value: <remote network id>
134+
- name: FOO
135+
value: "BAR"
136+
livenessProbe:
137+
httpGet:
138+
path: /healthz
139+
port: 8080
140+
readinessProbe:
141+
httpGet:
142+
path: /healthz
143+
port: 8080
144+
resources:
145+
{}

deploy/test/golden/extraEnvVars.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
twingateOperator:
2+
apiKey: "<api key>"
3+
network: "<network slug>"
4+
remoteNetworkId: "<remote network id>"
5+
6+
7+
extraEnvVars:
8+
- name: FOO
9+
value: BAR

deploy/twingate-operator/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: kubernetes-operator-chart
33
description: A Helm chart for installing twingate-operator
44
type: application
5-
version: 0.1.9
5+
version: 0.1.12
66
home: https://twingate.com
77
sources:
88
- https://github.com/Twingate/kubernetes-operator

deploy/twingate-operator/crds/twingate.com.twingateconnector.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,17 @@ spec:
6565
properties:
6666
provider:
6767
type: string
68-
description: "Provider to use for checking for new versions."
68+
description: >
69+
Provider determines how the operator looks for a new connector version.
70+
* dockerhub: Check Twingate's official DockerHub repository (`twingate/connector`) for new tags.
71+
* google: Check Google Container Registry specified by the `repository` value for new tags.
6972
enum:
7073
- dockerhub
7174
- google
7275
repository:
7376
type: string
7477
default: twingate/connector
75-
description: "Repository to check for new versions tags."
78+
description: "Repository to use for pod's image."
7679
schedule:
7780
type: string
7881
description: "Cron schedule to check for new versions."
@@ -85,15 +88,19 @@ spec:
8588
description: "Allow pre-release versions."
8689
containerExtra:
8790
type: object
91+
description: "Extra container configuration for the Connector Pod."
8892
x-kubernetes-preserve-unknown-fields: true
8993
podExtra:
9094
type: object
95+
description: "Extra pod configuration for the Connector Pod."
9196
x-kubernetes-preserve-unknown-fields: true
9297
podAnnotations:
9398
type: object
99+
description: "Extra annotations to add to the Connector Pod."
94100
x-kubernetes-preserve-unknown-fields: true
95101
podLabels:
96102
type: object
103+
description: "Extra labels to add to the Connector Pod."
97104
x-kubernetes-preserve-unknown-fields: true
98105
sidecarContainers:
99106
type: array

deploy/twingate-operator/templates/deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ spec:
7070
- name: TWINGATE_REMOTE_NETWORK_NAME
7171
value: {{ .Values.twingateOperator.remoteNetworkName }}
7272
{{- end }}
73+
{{- with .Values.extraEnvVars }}
74+
{{- range . }}
75+
- name: {{ .name }}
76+
value: {{ .value | quote }}
77+
{{- end }}
78+
{{- end }}
7379
livenessProbe:
7480
httpGet:
7581
path: /healthz

deploy/twingate-operator/values.schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
"pullPolicy": "Always"
4444
}]
4545
},
46+
"extraEnvVars": {
47+
"type": "array",
48+
"description": "Array with extra environment variables to add to the operator container",
49+
"default": [],
50+
"items": {}
51+
},
4652
"twingateOperator": {
4753
"type": "object",
4854
"default": {},

0 commit comments

Comments
 (0)