Added check for TapAPI service
Added check for TapAPI service
Fixes
Added a checker using `kube-aggregator` client
@@ -34,6 +34,7 @@ import (
yamlDecoder "k8s.io/apimachinery/pkg/util/yaml"
k8sVersion "k8s.io/apimachinery/pkg/version"
"k8s.io/client-go/kubernetes"
+ apiregistrationv1client "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/typed/apiregistration/v1"
"sigs.k8s.io/yaml"
)
@@ -145,6 +146,11 @@ const (
linkerdCNIDisabledSkipReason = "skipping check because CNI is not enabled"
linkerdCNIResourceName = "linkerd-cni"
linkerdCNIConfigMapName = "linkerd-cni-config"
+
+ // linkerdTapAPIServiceName is the name of the tap api service
+ // This key is passed to checkApiSercice method to check whether
+ // the api service is available or not
+ linkerdTapAPIServiceName = "v1alpha1.tap.linkerd.io"
)
// HintBaseURL is the base URL on the linkerd.io website that all check hints
@@ -1002,6 +1008,14 @@ func (hc *HealthChecker) allCategories() []category {
return hc.apiClient.SelfCheck(ctx, &healthcheckPb.SelfCheckRequest{})
},
},
+ {
+ description: "tap api service is running",
+ hintAnchor: "l5d-tap-api",
+ warning: true,
+ check: func(ctx context.Context) error {
+ return hc.checkAPIService(linkerdTapAPIServiceName)
+ },
+ },
},
},
{
@@ -1192,7 +1206,6 @@ func (hc *HealthChecker) addCategory(c category) {
// designated as warnings will not cause RunCheck to return false, however.
func (hc *HealthChecker) RunChecks(observer CheckObserver) bool {
success := true
-
for _, c := range hc.categories {
if c.enabled {
for _, checker := range c.checkers {
@@ -1788,6 +1801,29 @@ func (hc *HealthChecker) checkCanGet(namespace, group, version, resource string)
return hc.checkCanPerformAction("get", namespace, group, version, resource)
}
+func (hc *HealthChecker) checkAPIService(serviceName string) error {
+ apiServiceClient, err := apiregistrationv1client.NewForConfig(hc.kubeAPI.Config)
+ if err != nil {
+ return err
+ }
+
+ apiStatus, err := apiServiceClient.APIServices().Get(serviceName, metav1.GetOptions{})
+ if err != nil {
+ return err
+ }
+
+ for _, condition := range apiStatus.Status.Conditions {
+ if condition.Type == "Available" {
+ if condition.Status == "True" {
+ return nil
+ }
+ return fmt.Errorf("%s: %s", condition.Reason, condition.Message)
+ }
+ }
+
+ return fmt.Errorf("%s service not available", linkerdTapAPIServiceName)
+}
+
func (hc *HealthChecker) checkCapability(cap string) error {
if hc.kubeAPI == nil {
// we should never get here
