Skip to content

Commit db2f4c9

Browse files
committed
Skip pod mutation if vault agent inject annotation present
1 parent bea5594 commit db2f4c9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

webhook.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ func (srv webHookServer) mutate(ar *v1beta1.AdmissionReview) *v1beta1.AdmissionR
120120
ownerKind = pod.ObjectMeta.OwnerReferences[0].Kind
121121
ownerName = pod.ObjectMeta.OwnerReferences[0].Name
122122
}
123+
124+
if pod.ObjectMeta.Annotations["vault.hashicorp.com/agent-inject"] == "true" {
125+
log.Infof("Skipping mutation for %s/%s, vault agent-inject annotation found", req.Namespace, ownerName)
126+
return &v1beta1.AdmissionResponse{
127+
Allowed: true,
128+
}
129+
}
130+
123131
log.Infof("AdmissionReview for Kind=%v, Namespace=%v Name=%v UID=%v patchOperation=%v UserInfo=%v",
124132
ownerKind, req.Namespace, ownerName, req.UID, req.Operation, req.UserInfo)
125133

0 commit comments

Comments
 (0)