Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cert-manager annotation to pod-identity-webhook mutatingwebhookco… #875

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions pkg/cloud/services/iam/podidentitywebhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package iam
import (
"context"
"errors"
"fmt"

v14 "k8s.io/api/admissionregistration/v1"
v13 "k8s.io/api/apps/v1"
Expand All @@ -17,6 +18,8 @@ import (
)

const (
certManagerInjectCAAnnotation = "cert-manager.io/inject-ca-from"

podIdentityWebhookName = "pod-identity-webhook"
podIdentityWebhookImage = "amazon/amazon-eks-pod-identity-webhook:v0.5.2"

Expand Down Expand Up @@ -323,6 +326,20 @@ func reconcileMutatingWebHook(ctx context.Context, ns string, secret *corev1.Sec
}

if check.UID != "" {
updateAnnotations := false
if len(check.Annotations) == 0 {
check.Annotations = map[string]string{
certManagerInjectCAAnnotation: fmt.Sprintf("%s/%s", ns, secret.Name),
}
updateAnnotations = true
} else if check.Annotations[certManagerInjectCAAnnotation] == "" {
check.Annotations[certManagerInjectCAAnnotation] = fmt.Sprintf("%s/%s", ns, secret.Name)
updateAnnotations = true
}

if updateAnnotations {
return remoteClient.Update(ctx, check)
}
return nil
}

Expand All @@ -332,6 +349,9 @@ func reconcileMutatingWebHook(ctx context.Context, ns string, secret *corev1.Sec
}

mwhMeta := objectMeta(podIdentityWebhookName, ns)
mwhMeta.Annotations = map[string]string{
certManagerInjectCAAnnotation: fmt.Sprintf("%s/%s", ns, secret.Name),
}
fail := v14.Ignore
none := v14.SideEffectClassNone
mutate := "/mutate"
Expand Down
Loading