Skip to content

Commit

Permalink
webhook: inject pod name and namespace to pod by default
Browse files Browse the repository at this point in the history
  • Loading branch information
torresdal committed Feb 28, 2021
1 parent 0d696cb commit 5ad4093
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions cmd/azure-keyvault-secrets-webhook/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,22 @@ func (p podWebHook) mutateContainers(ctx context.Context, containers []corev1.Co
Name: "ENV_INJECTOR_USE_AUTH_SERVICE",
Value: strconv.FormatBool(useAuthService),
},
{
Name: "ENV_INJECTOR_POD_NAMESPACE",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.namespace",
},
},
},
{
Name: "ENV_INJECTOR_POD_NAME",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.name",
},
},
},
}...)

if useAuthService {
Expand Down Expand Up @@ -210,22 +226,6 @@ func (p podWebHook) mutateContainers(ctx context.Context, containers []corev1.Co
Name: "ENV_INJECTOR_CLIENT_CERT_DIR",
Value: clientCertDir,
},
{
Name: "ENV_INJECTOR_POD_NAMESPACE",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.namespace",
},
},
},
{
Name: "ENV_INJECTOR_POD_NAME",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "metadata.name",
},
},
},
{
Name: "ENV_INJECTOR_AUTH_SERVICE",
Value: fmt.Sprintf("https://%s.%s.svc:%s", p.authServiceName, p.currentNamespace(), p.authServicePort),
Expand Down

0 comments on commit 5ad4093

Please sign in to comment.