Skip to content

Commit

Permalink
remove linkerd-prometheus healthchecks
Browse files Browse the repository at this point in the history
Signed-off-by: Tarun Pothulapati <tarunpothulapati@outlook.com>
  • Loading branch information
Pothulapati committed May 10, 2020
1 parent be3d3ea commit ab854df
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 146 deletions.
2 changes: 0 additions & 2 deletions pkg/healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ var ExpectedServiceAccountNames = []string{
"linkerd-destination",
"linkerd-grafana",
"linkerd-identity",
"linkerd-prometheus",
"linkerd-proxy-injector",
"linkerd-sp-validator",
"linkerd-web",
Expand Down Expand Up @@ -1764,7 +1763,6 @@ func (hc *HealthChecker) expectedRBACNames() []string {
return []string{
fmt.Sprintf("linkerd-%s-controller", hc.ControlPlaneNamespace),
fmt.Sprintf("linkerd-%s-identity", hc.ControlPlaneNamespace),
fmt.Sprintf("linkerd-%s-prometheus", hc.ControlPlaneNamespace),
fmt.Sprintf("linkerd-%s-proxy-injector", hc.ControlPlaneNamespace),
fmt.Sprintf("linkerd-%s-sp-validator", hc.ControlPlaneNamespace),
fmt.Sprintf("linkerd-%s-tap", hc.ControlPlaneNamespace),
Expand Down
139 changes: 3 additions & 136 deletions pkg/healthcheck/healthcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ data:
apiVersion: v1
kind: ConfigMap
metadata:
name: extension-apiserver-authentication
name: extension-apiserver-authentication
namespace: kube-system
data:
%s : 'bar'
Expand Down Expand Up @@ -570,7 +570,7 @@ metadata:
},
[]string{
"linkerd-config control plane Namespace exists",
"linkerd-config control plane ClusterRoles exist: missing ClusterRoles: linkerd-test-ns-controller, linkerd-test-ns-identity, linkerd-test-ns-prometheus, linkerd-test-ns-proxy-injector, linkerd-test-ns-sp-validator, linkerd-test-ns-tap",
"linkerd-config control plane ClusterRoles exist: missing ClusterRoles: linkerd-test-ns-controller, linkerd-test-ns-identity, linkerd-test-ns-proxy-injector, linkerd-test-ns-sp-validator, linkerd-test-ns-tap",
},
},
{
Expand Down Expand Up @@ -599,14 +599,6 @@ metadata:
`
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-prometheus
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-proxy-injector
labels:
Expand All @@ -632,7 +624,7 @@ metadata:
[]string{
"linkerd-config control plane Namespace exists",
"linkerd-config control plane ClusterRoles exist",
"linkerd-config control plane ClusterRoleBindings exist: missing ClusterRoleBindings: linkerd-test-ns-controller, linkerd-test-ns-identity, linkerd-test-ns-prometheus, linkerd-test-ns-proxy-injector, linkerd-test-ns-sp-validator, linkerd-test-ns-tap",
"linkerd-config control plane ClusterRoleBindings exist: missing ClusterRoleBindings: linkerd-test-ns-controller, linkerd-test-ns-identity, linkerd-test-ns-proxy-injector, linkerd-test-ns-sp-validator, linkerd-test-ns-tap",
},
},
{
Expand Down Expand Up @@ -661,14 +653,6 @@ metadata:
`
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-prometheus
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-proxy-injector
labels:
Expand Down Expand Up @@ -709,14 +693,6 @@ metadata:
`
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-prometheus
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-proxy-injector
labels:
Expand Down Expand Up @@ -768,15 +744,6 @@ metadata:
`
kind: ServiceAccount
apiVersion: v1
metadata:
name: linkerd-prometheus
namespace: test-ns
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ServiceAccount
apiVersion: v1
metadata:
name: linkerd-proxy-injector
namespace: test-ns
Expand Down Expand Up @@ -872,14 +839,6 @@ metadata:
`
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-prometheus
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-proxy-injector
labels:
Expand Down Expand Up @@ -920,14 +879,6 @@ metadata:
`
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-prometheus
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-proxy-injector
labels:
Expand Down Expand Up @@ -979,15 +930,6 @@ metadata:
`
kind: ServiceAccount
apiVersion: v1
metadata:
name: linkerd-prometheus
namespace: test-ns
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ServiceAccount
apiVersion: v1
metadata:
name: linkerd-proxy-injector
namespace: test-ns
Expand Down Expand Up @@ -1092,14 +1034,6 @@ metadata:
`
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-prometheus
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-proxy-injector
labels:
Expand Down Expand Up @@ -1140,14 +1074,6 @@ metadata:
`
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-prometheus
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-proxy-injector
labels:
Expand Down Expand Up @@ -1199,15 +1125,6 @@ metadata:
`
kind: ServiceAccount
apiVersion: v1
metadata:
name: linkerd-prometheus
namespace: test-ns
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ServiceAccount
apiVersion: v1
metadata:
name: linkerd-proxy-injector
namespace: test-ns
Expand Down Expand Up @@ -1321,14 +1238,6 @@ metadata:
`
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-prometheus
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-proxy-injector
labels:
Expand Down Expand Up @@ -1369,14 +1278,6 @@ metadata:
`
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-prometheus
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-proxy-injector
labels:
Expand Down Expand Up @@ -1428,15 +1329,6 @@ metadata:
`
kind: ServiceAccount
apiVersion: v1
metadata:
name: linkerd-prometheus
namespace: test-ns
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ServiceAccount
apiVersion: v1
metadata:
name: linkerd-proxy-injector
namespace: test-ns
Expand Down Expand Up @@ -1559,14 +1451,6 @@ metadata:
`
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-prometheus
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-proxy-injector
labels:
Expand Down Expand Up @@ -1607,14 +1491,6 @@ metadata:
`
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-prometheus
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: linkerd-test-ns-proxy-injector
labels:
Expand Down Expand Up @@ -1666,15 +1542,6 @@ metadata:
`
kind: ServiceAccount
apiVersion: v1
metadata:
name: linkerd-prometheus
namespace: test-ns
labels:
linkerd.io/control-plane-ns: test-ns
`,
`
kind: ServiceAccount
apiVersion: v1
metadata:
name: linkerd-proxy-injector
namespace: test-ns
Expand Down
15 changes: 7 additions & 8 deletions test/serviceaccounts/serviceaccounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}

// namesMatch checks if all the expectedServiceAccountNames are present in the given list,
// The passed argument list is allowed to contain extra members.
func namesMatch(names []string) bool {
for _, name := range names {
if name == "default" || name == "linkerd-heartbeat" {
continue
}
for _, expectedname := range healthcheck.ExpectedServiceAccountNames {
found := false
for _, expectedName := range healthcheck.ExpectedServiceAccountNames {
if name == expectedName {
for _, name := range names {
if expectedname == name {
found = true
break
}
Expand Down Expand Up @@ -53,7 +52,7 @@ func TestServiceAccountsMatch(t *testing.T) {
saNames = append(saNames, strings.TrimPrefix(name, "serviceaccount/"))
}
// disregard `default` and `linkerd-heartbeat`
if len(saNames)-2 != len(expectedNames) || !namesMatch(saNames) {
if len(saNames) < len(expectedNames) || !namesMatch(saNames) {
testutil.Fatalf(t, "the service account list doesn't match the expected list: %s", expectedNames)
}

Expand All @@ -68,7 +67,7 @@ func TestServiceAccountsMatch(t *testing.T) {
}
saNamesPSP := strings.Split(res, " ")
// disregard `linkerd-heartbeat`
if len(saNamesPSP)-1 != len(expectedNames) || !namesMatch(saNamesPSP) {
if len(saNamesPSP) < len(expectedNames) || !namesMatch(saNamesPSP) {
t.Fatalf(
"The service accounts in the linkerd-psp rolebindings don't match the expected list: %s",
expectedNames)
Expand Down

0 comments on commit ab854df

Please sign in to comment.