Skip to content

Commit d1b7df4

Browse files
committed
Rename the annotation used to inject the proxy
apply deislabs#49
1 parent 2b63700 commit d1b7df4

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ spec:
138138
labels:
139139
app: nginx
140140
annotations:
141-
osiris.dm.gg/enabled: "true"
141+
osiris.dm.gg/collectMetrics: "true"
142142
# ...
143143
# ...
144144
```
@@ -191,7 +191,7 @@ The following table lists the supported annotations for Kubernetes `Pods` and th
191191

192192
| Annotation | Description | Default |
193193
| ---------- | ----------- | ------- |
194-
| `osiris.dm.gg/enabled` | Enable the metrics collecting proxy sidecar container to be injected into this pod. Allowed values: `y`, `yes`, `true`, `on`, `1`. | _no value_ (= disabled) |
194+
| `osiris.dm.gg/collectMetrics` | Enable the metrics collecting proxy to be injected as a sidecar container into this pod. This is _required_ for metrics collection. Allowed values: `y`, `yes`, `true`, `on`, `1`. | _no value_ (= disabled) |
195195
| `osiris.dm.gg/ignoredPaths` | The list of (url) paths that should be "ignored" by Osiris. Requests to such paths won't be "counted" by the proxy. Format: comma-separated string. | _no value_ |
196196

197197
#### Service Annotations

example/hello-osiris.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ spec:
4040
labels:
4141
app: hello-osiris
4242
annotations:
43-
osiris.dm.gg/enabled: "true"
43+
osiris.dm.gg/collectMetrics: "true"
4444
osiris.dm.gg/ignoredPaths: "/first/path,/second-path"
4545
spec:
4646
containers:

pkg/kubernetes/osiris.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,23 @@ const (
99
IgnoredPathsAnnotationName = "osiris.dm.gg/ignoredPaths"
1010
MetricsCheckIntervalAnnotationName = "osiris.deislabs.io/metricsCheckInterval"
1111
osirisEnabledAnnotationName = "osiris.dm.gg/enabled"
12+
collectMetricsAnnotationName = "osiris.dm.gg/collectMetrics"
1213
)
1314

1415
// ResourceIsOsirisEnabled checks the annotations to see if the
1516
// kube resource is enabled for osiris or not.
1617
func ResourceIsOsirisEnabled(annotations map[string]string) bool {
17-
enabled, ok := annotations[osirisEnabledAnnotationName]
18+
return annotationBooleanValue(annotations, osirisEnabledAnnotationName)
19+
}
20+
21+
// PodIsEligibleForProxyInjection checks the annotations to see if the
22+
// pod is eligible for proxy injection or not.
23+
func PodIsEligibleForProxyInjection(annotations map[string]string) bool {
24+
return annotationBooleanValue(annotations, collectMetricsAnnotationName)
25+
}
26+
27+
func annotationBooleanValue(annotations map[string]string, key string) bool {
28+
enabled, ok := annotations[key]
1829
if !ok {
1930
return false
2031
}

pkg/metrics/proxy/injector/pod_patch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (i *injector) getPodPatchOperations(
4141
req.UserInfo,
4242
)
4343

44-
if !kubernetes.ResourceIsOsirisEnabled(pod.Annotations) ||
44+
if !kubernetes.PodIsEligibleForProxyInjection(pod.Annotations) ||
4545
(podContainsProxyInitContainer(&pod) && podContainsProxyContainer(&pod)) {
4646
return nil, nil
4747
}

0 commit comments

Comments
 (0)