mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-31 10:11:59 +00:00
added k8s server version check (#404)
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/up9inc/mizu/shared/semver"
|
||||||
"k8s.io/apimachinery/pkg/version"
|
"k8s.io/apimachinery/pkg/version"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -83,6 +84,10 @@ func NewProvider(kubeConfigPath string) (*Provider, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := validateKubernetesVersion(clientSet); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return &Provider{
|
return &Provider{
|
||||||
clientSet: clientSet,
|
clientSet: clientSet,
|
||||||
kubernetesConfig: kubernetesConfig,
|
kubernetesConfig: kubernetesConfig,
|
||||||
@@ -761,3 +766,19 @@ func validateNotProxy(kubernetesConfig clientcmd.ClientConfig, restClientConfig
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func validateKubernetesVersion(clientSet *kubernetes.Clientset) error {
|
||||||
|
serverVersion, err := clientSet.ServerVersion()
|
||||||
|
if err != nil {
|
||||||
|
logger.Log.Debugf("error while getting kubernetes server version, err: %v", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
serverVersionSemVer := semver.SemVersion(serverVersion.GitVersion)
|
||||||
|
minKubernetesServerVersionSemVer := semver.SemVersion(mizu.MinKubernetesServerVersion)
|
||||||
|
if minKubernetesServerVersionSemVer.GreaterThan(serverVersionSemVer) {
|
||||||
|
return fmt.Errorf("kubernetes server version %v is not supported, supporting only kubernetes server version of %v or higher", serverVersion.GitVersion, mizu.MinKubernetesServerVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@@ -14,17 +14,18 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MizuResourcesPrefix = "mizu-"
|
MizuResourcesPrefix = "mizu-"
|
||||||
ApiServerPodName = MizuResourcesPrefix + "api-server"
|
ApiServerPodName = MizuResourcesPrefix + "api-server"
|
||||||
ClusterRoleBindingName = MizuResourcesPrefix + "cluster-role-binding"
|
ClusterRoleBindingName = MizuResourcesPrefix + "cluster-role-binding"
|
||||||
ClusterRoleName = MizuResourcesPrefix + "cluster-role"
|
ClusterRoleName = MizuResourcesPrefix + "cluster-role"
|
||||||
K8sAllNamespaces = ""
|
K8sAllNamespaces = ""
|
||||||
RoleBindingName = MizuResourcesPrefix + "role-binding"
|
RoleBindingName = MizuResourcesPrefix + "role-binding"
|
||||||
RoleName = MizuResourcesPrefix + "role"
|
RoleName = MizuResourcesPrefix + "role"
|
||||||
ServiceAccountName = MizuResourcesPrefix + "service-account"
|
ServiceAccountName = MizuResourcesPrefix + "service-account"
|
||||||
TapperDaemonSetName = MizuResourcesPrefix + "tapper-daemon-set"
|
TapperDaemonSetName = MizuResourcesPrefix + "tapper-daemon-set"
|
||||||
TapperPodName = MizuResourcesPrefix + "tapper"
|
TapperPodName = MizuResourcesPrefix + "tapper"
|
||||||
ConfigMapName = MizuResourcesPrefix + "policy"
|
ConfigMapName = MizuResourcesPrefix + "policy"
|
||||||
|
MinKubernetesServerVersion = "1.16.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetMizuFolderPath() string {
|
func GetMizuFolderPath() string {
|
||||||
|
Reference in New Issue
Block a user