Skip to content

Commit 92ca8a3

Browse files
committed
fix: grant pipeline RBAC secrets read access for image pull secret validation
The func CLI now validates that the referenced image pull secret exists before deploying. Grant get/list on secrets to the deploy-function Role so the Tekton func-deploy step can perform this validation. Also wrap the e2e imagePullSecrets check in Eventually to handle timing.
1 parent 224a525 commit 92ca8a3

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

internal/controller/function_rbac.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ func (r *FunctionReconciler) ensureDeployFunctionRole(ctx context.Context, names
7070
APIGroups: []string{""},
7171
Resources: []string{"services", "pods"},
7272
Verbs: []string{"create", "delete", "get", "list", "patch", "update", "watch"},
73+
}, {
74+
APIGroups: []string{""},
75+
Resources: []string{"secrets"},
76+
Verbs: []string{"get", "list"},
7377
}, {
7478
APIGroups: []string{"http.keda.sh"},
7579
Resources: []string{"httpscaledobjects"},

test/e2e/func_deploy_test.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -860,20 +860,21 @@ var _ = Describe("Operator", func() {
860860

861861
Eventually(functionBecomesReady(functionName, functionNamespace)).Should(Succeed())
862862

863-
// Verify the Knative Service has imagePullSecrets set on its pod template
864-
cmd := exec.Command("kubectl", "get", "ksvc", deployedFunctionName,
865-
"-n", functionNamespace,
866-
"-o", "jsonpath={.spec.template.spec.imagePullSecrets}")
867-
out, err := utils.Run(cmd)
868-
Expect(err).NotTo(HaveOccurred())
869-
870-
var pullSecrets []v1.LocalObjectReference
871-
err = json.Unmarshal([]byte(out), &pullSecrets)
872-
Expect(err).NotTo(HaveOccurred())
873-
874-
Expect(pullSecrets).To(ContainElement(v1.LocalObjectReference{
875-
Name: secret.Name,
876-
}))
863+
// Verify the Knative Service has imagePullSecrets set on its pod template.
864+
Eventually(func(g Gomega) {
865+
cmd := exec.Command("kubectl", "get", "ksvc", deployedFunctionName,
866+
"-n", functionNamespace,
867+
"-o", "jsonpath={.spec.template.spec.imagePullSecrets}")
868+
out, err := utils.Run(cmd)
869+
g.Expect(err).NotTo(HaveOccurred())
870+
g.Expect(out).NotTo(BeEmpty(), "imagePullSecrets not set on Knative Service %s", deployedFunctionName)
871+
872+
var pullSecrets []v1.LocalObjectReference
873+
g.Expect(json.Unmarshal([]byte(out), &pullSecrets)).To(Succeed())
874+
g.Expect(pullSecrets).To(ContainElement(v1.LocalObjectReference{
875+
Name: secret.Name,
876+
}))
877+
}, 2*time.Minute).Should(Succeed())
877878
})
878879
})
879880
})

0 commit comments

Comments
 (0)