forked from istio/istio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trim job suffix to extract out cron job name for workload metadata (i…
…stio#27195) * special case cron job processing in webhook * update
- Loading branch information
1 parent
5f2c5db
commit 10d12b8
Showing
5 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
pkg/kube/inject/testdata/webhook/TestWebhookInject_cron_job.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
[ | ||
{ | ||
"op": "add", | ||
"path": "/spec/initContainers", | ||
"value": [ | ||
{ | ||
"name": "istio-init", | ||
"image": "example.com/init:latest", | ||
"resources": {} | ||
} | ||
] | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/spec/containers/-", | ||
"value": { | ||
"name": "istio-proxy", | ||
"image": "example.com/proxy:latest", | ||
"env": [ | ||
{ | ||
"name": "ISTIO_META_WORKLOAD_NAME", | ||
"value": "hello" | ||
}, | ||
{ | ||
"name": "ISTIO_META_OWNER", | ||
"value": "kubernetes://apis/batch/v1beta1/namespaces/default/cronjobs/hello" | ||
} | ||
], | ||
"resources": {} | ||
} | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/spec/securityContext", | ||
"value": { | ||
"fsGroup": 1337 | ||
} | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/metadata/annotations", | ||
"value": { | ||
"prometheus.io/path": "/stats/prometheus" | ||
} | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/metadata/annotations/prometheus.io~1port", | ||
"value": "15020" | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/metadata/annotations/prometheus.io~1scrape", | ||
"value": "true" | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/metadata/annotations/sidecar.istio.io~1status", | ||
"value": "{\"version\":\"unit-test-fake-version\",\"initContainers\":[\"istio-init\"],\"containers\":[\"istio-proxy\"],\"volumes\":null,\"imagePullSecrets\":null}" | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/metadata/labels", | ||
"value": { | ||
"istio.io/rev": "" | ||
} | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/metadata/labels/security.istio.io~1tlsMode", | ||
"value": "istio" | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/metadata/labels/service.istio.io~1canonical-name", | ||
"value": "hello" | ||
}, | ||
{ | ||
"op": "add", | ||
"path": "/metadata/labels/service.istio.io~1canonical-revision", | ||
"value": "latest" | ||
} | ||
] |
10 changes: 10 additions & 0 deletions
10
pkg/kube/inject/testdata/webhook/TestWebhookInject_cron_job.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
metadata: | ||
generateName: hello-1599753180- | ||
ownerReferences: | ||
- apiVersion: batch/v1 | ||
controller: true | ||
kind: Job | ||
name: hello-1599753180 | ||
spec: | ||
containers: | ||
- name: c |
20 changes: 20 additions & 0 deletions
20
pkg/kube/inject/testdata/webhook/TestWebhookInject_cron_job_template.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
policy: enabled | ||
alwaysInjectSelector: [] | ||
neverInjectSelector: [] | ||
injectedAnnotations: {} | ||
template: |- | ||
initContainers: | ||
- name: istio-init | ||
image: example.com/init:latest | ||
containers: | ||
- name: istio-proxy | ||
image: example.com/proxy:latest | ||
env: | ||
{{- if .DeploymentMeta.Name }} | ||
- name: ISTIO_META_WORKLOAD_NAME | ||
value: "{{ .DeploymentMeta.Name }}" | ||
{{ end }} | ||
{{- if and .TypeMeta.APIVersion .DeploymentMeta.Name }} | ||
- name: ISTIO_META_OWNER | ||
value: kubernetes://apis/{{ .TypeMeta.APIVersion }}/namespaces/{{ valueOrDefault .DeploymentMeta.Namespace `default` }}/{{ toLower .TypeMeta.Kind}}s/{{ .DeploymentMeta.Name }} | ||
{{- end}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters