Skip to content

Commit 7e6525f

Browse files
authored
Merge pull request #40 from netfoundry/refactor-for-router
2 parents d0098d5 + 9c5c0ee commit 7e6525f

File tree

15 files changed

+1158
-694
lines changed

15 files changed

+1158
-694
lines changed

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,5 @@
2323
# build dir
2424
/build
2525

26-
# local temp files
27-
/ziti-agent.yaml
28-
/ziti-client.yaml
29-
/test-admin.j*
26+
# local test files
27+
/test-*

README.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,41 @@ Pods authorized to bind a Ziti service require that service to have a host addre
7979
These optional variables will override defaults.
8080

8181
```bash
82-
export ZITI_AGENT_NAMESPACE="default"
83-
export CLUSTER_DNS_ZONE="cluster.local"
82+
# Namespace configuration
83+
export ZITI_AGENT_NAMESPACE="default" # Namespace to deploy the agent
84+
export CLUSTER_DNS_ZONE="cluster.local" # Kubernetes cluster DNS zone
85+
86+
# Agent image configuration
87+
export ZITI_AGENT_IMAGE="docker.io/netfoundry/ziti-k8s-agent" # Agent container image
88+
export ZITI_AGENT_IMAGE_PULL_POLICY="IfNotPresent" # Pull policy for agent image
89+
export ZITI_AGENT_LOG_LEVEL="2" # Log level for agent (0-5)
90+
91+
# Sidecar configuration
92+
export SIDECAR_IMAGE="docker.io/openziti/ziti-tunnel" # Sidecar container image
93+
export SIDECAR_IMAGE_VERSION="latest" # Sidecar image version
94+
export SIDECAR_IMAGE_PULL_POLICY="IfNotPresent" # Pull policy for sidecar image
95+
96+
# Resource configuration
97+
export ZITI_AGENT_CPU="100m" # CPU request for agent
98+
export ZITI_AGENT_MEMORY="128Mi" # Memory request for agent
99+
export ZITI_AGENT_CPU_LIMIT="500m" # CPU limit for agent
100+
export ZITI_AGENT_MEMORY_LIMIT="512Mi" # Memory limit for agent
101+
102+
# Webhook configuration
103+
export ZITI_AGENT_WEBHOOK_FAILURE_POLICY="Fail" # How webhook failures are handled (Fail or Ignore)
104+
105+
# DNS configuration
106+
export SEARCH_DOMAINS="" # Space-separated list of DNS search domains
84107
```
85108

86109
You may replace the cluster's default DNS search domains for selected pods by exporting `SEARCH_DOMAINS` as a space separated list of domain name suffixes. This may be useful if the selected pods never need to resolve the names of cluster services, but do need to resolve short names in a DNS zone that you control outside of the cluster, e.g., `ziti.internal ziti.example.com`.
87110

88111
### Generate a Manifest
89112

90-
- `IDENTITY_FILE` is the path to the JSON file from the enrollment step.
91-
- `SIDECAR_SELECTORS` is a comma-separated list of methods by which pods are selected for sidecar injection: `namespace`, `pod`, or both (see [Select Pods for Sidecar Injection](#select-pods-for-sidecar-injection) above).
113+
Required environment variables:
114+
115+
- `IDENTITY_FILE` - path to the JSON file from the admin identity enrollment step
116+
- `SIDECAR_SELECTORS` - comma-separated list of methods by which pods are selected for sidecar injection: `namespace`, `pod`, or both (see [Select Pods for Sidecar Injection](#select-pods-for-sidecar-injection) above)
92117

93118
```bash
94119
IDENTITY_FILE="ziti-k8s-agent.json" SIDECAR_SELECTORS="namespace,pod" ./generate-ziti-agent-manifest.bash > ./ziti-agent.yaml

generate-ziti-agent-manifest.bash

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ webhooks:
189189
- name: tunnel.ziti.webhook
190190
admissionReviewVersions: ["v1"]
191191
matchPolicy: Equivalent
192+
failurePolicy: ${ZITI_AGENT_WEBHOOK_FAILURE_POLICY:-Fail}
192193
namespaceSelector:
193194
matchExpressions:
194195
- key: kubernetes.io/metadata.name
@@ -201,16 +202,23 @@ for SELECTOR in "${SELECTORS[@]}"; do
201202
case "$SELECTOR" in
202203
namespace)
203204
cat <<SEL
204-
namespaceSelector:
205-
matchLabels:
206-
tunnel.openziti.io/enabled: "true"
205+
- key: tunnel.openziti.io/enabled
206+
operator: In
207+
values:
208+
- "true"
209+
- "false"
207210
SEL
208211
;;
209212
pod)
210213
cat <<SEL
211214
objectSelector:
212-
matchLabels:
213-
tunnel.openziti.io/enabled: "true"
215+
namespaceSelector:
216+
matchExpressions:
217+
- key: tunnel.openziti.io/enabled
218+
operator: In
219+
values:
220+
- "true"
221+
- "false"
214222
SEL
215223
;;
216224
*)
@@ -245,11 +253,8 @@ metadata:
245253
rules:
246254
# "" indicates the core API group
247255
- apiGroups: [""]
248-
resources: ["secrets"]
249-
verbs: ["get", "list", "create", "delete"]
250-
- apiGroups: [""]
251-
resources: ["services"]
252-
verbs: ["get"]
256+
resources: ["services", "namespaces"]
257+
verbs: ["get", "list"]
253258
254259
---
255260
apiVersion: rbac.authorization.k8s.io/v1

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/netfoundry/ziti-k8s-agent
33
go 1.23.2
44

55
require (
6-
github.com/openziti/edge-api v0.26.22
6+
github.com/openziti/edge-api v0.26.38
77
github.com/openziti/sdk-golang v0.23.39
88
github.com/pkg/errors v0.9.1
99
github.com/spf13/cobra v1.8.1
@@ -12,7 +12,6 @@ require (
1212
k8s.io/apimachinery v0.30.3
1313
k8s.io/client-go v0.30.3
1414
k8s.io/klog/v2 v2.130.1
15-
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
1615
)
1716

1817
require (
@@ -104,6 +103,7 @@ require (
104103
gopkg.in/yaml.v2 v2.4.0 // indirect
105104
gopkg.in/yaml.v3 v3.0.1 // indirect
106105
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
106+
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
107107
nhooyr.io/websocket v1.8.17 // indirect
108108
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
109109
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+
327327
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
328328
github.com/openziti/channel/v2 v2.0.136 h1:XWjcNrPhto2XiD5HLhsh7GhmqfHEweQIJ/eUjtVKUJs=
329329
github.com/openziti/channel/v2 v2.0.136/go.mod h1:7jhk6JtJPP1O8aWYx+w2IuwCunFJ88Ot4AQcrKiX5og=
330-
github.com/openziti/edge-api v0.26.22 h1:kpd+SxdO4UO4/SO3DFWyndseY90J5zWtO5EsAqHJHvM=
331-
github.com/openziti/edge-api v0.26.22/go.mod h1:t0qfgV5u2+HItpvgDIShA69v6m7RZ+PrbQuLQaDDdx8=
330+
github.com/openziti/edge-api v0.26.38 h1:3xDWC5SFn3qUVR428TIBpRc2lrjVV7Gz0Rx4pQx0JSg=
331+
github.com/openziti/edge-api v0.26.38/go.mod h1:sYHVpm26Jr1u7VooNJzTb2b2nGSlmCHMnbGC8XfWSng=
332332
github.com/openziti/foundation/v2 v2.0.56 h1:YXqBmkrN0fYr3TqIlWZSZGluE2QpJxlA29Z6okZyQ5I=
333333
github.com/openziti/foundation/v2 v2.0.56/go.mod h1:f12R1pwEod348qONZr6esZgackX1ScLGDcEyPF2G5/w=
334334
github.com/openziti/identity v1.0.94 h1:nF4etu/5LmOlbT24lpSKq9p+90A9jeyLr5U23LemgD4=

ziti-agent/cmd/webhook/config.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,9 @@ func lookupEnvVars() {
169169
}
170170

171171
value, ok = os.LookupEnv("ZITI_ROLE_KEY")
172-
if ok && len(value) > 0 {
172+
if ok {
173173
zitiRoleKey = value
174174
}
175-
if len(zitiRoleKey) == 0 {
176-
klog.V(4).Info(&MissingEnvVarError{variable: "ZITI_ROLE_KEY"})
177-
klog.V(4).Info(&MissingCmdLineVarError{variable: "ZITI_ROLE_KEY"})
178-
}
175+
zitiRoleKey = getValueOrDefault(zitiRoleKey, defaultZitiRoleAttributesKey)
176+
klog.V(4).Infof("Using Ziti role key: %s", zitiRoleKey)
179177
}

ziti-agent/cmd/webhook/convert.go

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)