@@ -31,16 +31,16 @@ import (
3131)
3232
3333// namespace where the project is deployed in
34- const namespace = "cluster-api-provider-metal-stack -system"
34+ const namespace = "capms -system"
3535
3636// serviceAccountName created for the project
37- const serviceAccountName = "cluster-api-provider-metal-stack -controller-manager"
37+ const serviceAccountName = "capms -controller-manager"
3838
3939// metricsServiceName is the name of the metrics service of the project
40- const metricsServiceName = "cluster-api-provider-metal-stack -controller-manager-metrics-service"
40+ const metricsServiceName = "capms -controller-manager-metrics-service"
4141
4242// metricsRoleBindingName is the name of the RBAC that will be created to allow get the metrics data
43- const metricsRoleBindingName = "cluster-api-provider-metal-stack -metrics-binding"
43+ const metricsRoleBindingName = "capms -metrics-binding"
4444
4545var _ = Describe ("Manager" , Ordered , func () {
4646 var controllerPodName string
@@ -68,7 +68,11 @@ var _ = Describe("Manager", Ordered, func() {
6868 // and deleting the namespace.
6969 AfterAll (func () {
7070 By ("cleaning up the curl pod for metrics" )
71- cmd := exec .Command ("kubectl" , "delete" , "pod" , "curl-metrics" , "-n" , namespace )
71+ cmd := exec .Command ("kubectl" , "delete" , "pod" , "curl-metrics" , "-n" , "kube-system" )
72+ _ , _ = utils .Run (cmd )
73+
74+ By ("cleaning up metrics-server cluster role binding" )
75+ cmd = exec .Command ("kubectl" , "delete" , "clusterrolebinding" , metricsRoleBindingName )
7276 _ , _ = utils .Run (cmd )
7377
7478 By ("undeploying the controller-manager" )
@@ -108,7 +112,7 @@ var _ = Describe("Manager", Ordered, func() {
108112 }
109113
110114 By ("Fetching curl-metrics logs" )
111- cmd = exec .Command ("kubectl" , "logs" , "curl-metrics" , "-n" , namespace )
115+ cmd = exec .Command ("kubectl" , "logs" , "curl-metrics" , "-n" , "kube-system" )
112116 metricsOutput , err := utils .Run (cmd )
113117 if err == nil {
114118 _ , _ = fmt .Fprintf (GinkgoWriter , "Metrics logs:\n %s" , metricsOutput )
@@ -166,7 +170,7 @@ var _ = Describe("Manager", Ordered, func() {
166170 It ("should ensure the metrics endpoint is serving metrics" , func () {
167171 By ("creating a ClusterRoleBinding for the service account to allow access to metrics" )
168172 cmd := exec .Command ("kubectl" , "create" , "clusterrolebinding" , metricsRoleBindingName ,
169- "--clusterrole=cluster-api-provider-metal-stack -metrics-reader" ,
173+ "--clusterrole=capms -metrics-reader" ,
170174 fmt .Sprintf ("--serviceaccount=%s:%s" , namespace , serviceAccountName ),
171175 )
172176 _ , err := utils .Run (cmd )
@@ -208,7 +212,7 @@ var _ = Describe("Manager", Ordered, func() {
208212
209213 By ("creating the curl-metrics pod to access the metrics endpoint" )
210214 cmd = exec .Command ("kubectl" , "run" , "curl-metrics" , "--restart=Never" ,
211- "--namespace" , namespace ,
215+ "--namespace" , "kube-system" ,
212216 "--image=curlimages/curl:7.78.0" ,
213217 "--" , "/bin/sh" , "-c" , fmt .Sprintf (
214218 "curl -v -k -H 'Authorization: Bearer %s' https://%s.%s.svc.cluster.local:8443/metrics" ,
@@ -220,7 +224,7 @@ var _ = Describe("Manager", Ordered, func() {
220224 verifyCurlUp := func (g Gomega ) {
221225 cmd := exec .Command ("kubectl" , "get" , "pods" , "curl-metrics" ,
222226 "-o" , "jsonpath={.status.phase}" ,
223- "-n" , namespace )
227+ "-n" , "kube-system" )
224228 output , err := utils .Run (cmd )
225229 g .Expect (err ).NotTo (HaveOccurred ())
226230 g .Expect (output ).To (Equal ("Succeeded" ), "curl pod in wrong status" )
@@ -291,7 +295,7 @@ func serviceAccountToken() (string, error) {
291295// getMetricsOutput retrieves and returns the logs from the curl pod used to access the metrics endpoint.
292296func getMetricsOutput () string {
293297 By ("getting the curl-metrics logs" )
294- cmd := exec .Command ("kubectl" , "logs" , "curl-metrics" , "-n" , namespace )
298+ cmd := exec .Command ("kubectl" , "logs" , "curl-metrics" , "-n" , "kube-system" )
295299 metricsOutput , err := utils .Run (cmd )
296300 Expect (err ).NotTo (HaveOccurred (), "Failed to retrieve logs from curl pod" )
297301 Expect (metricsOutput ).To (ContainSubstring ("< HTTP/1.1 200 OK" ))
0 commit comments