Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: etcd install fail #156

Merged
merged 6 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chart"
"helm.sh/helm/v3/pkg/chart/loader"
"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/cli"
"helm.sh/helm/v3/pkg/registry"
. "helm.sh/helm/v3/pkg/repo"
Expand All @@ -45,6 +46,11 @@ const (
helmFieldTag = "helm"
)

var (
// KubeVersion is the target version of the kubernetes.
KubeVersion string = "v1.20.0"
)

// Manager is the Helm charts manager. The implementation is based on Helm SDK.
// The main purpose of Manager is:
// 1. Load the chart from remote charts and save them in cache directory.
Expand Down Expand Up @@ -318,13 +324,19 @@ func (r *Manager) isInChartsCache(packageName string) bool {
}

func (r *Manager) newHelmClient(releaseName, namespace string) (*action.Install, error) {
kubeVersion, err := chartutil.ParseKubeVersion(KubeVersion)
if err != nil {
return nil, fmt.Errorf("invalid kube version '%s': %s", kubeVersion, err)
}

helmClient := action.NewInstall(new(action.Configuration))
helmClient.DryRun = true
helmClient.ReleaseName = releaseName
helmClient.Replace = true
helmClient.ClientOnly = true
helmClient.IncludeCRDs = true
helmClient.Namespace = namespace
helmClient.KubeVersion = kubeVersion

return helmClient, nil
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/kube/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import (
"k8s.io/client-go/util/homedir"

greptimev1alpha1 "github.com/GreptimeTeam/greptimedb-operator/apis/v1alpha1"

"github.com/GreptimeTeam/gtctl/pkg/helm"
)

type Client struct {
Expand Down Expand Up @@ -103,6 +105,12 @@ func NewClient(kubeconfig string) (*Client, error) {
}
})

kubeVersion, err := kubeClient.ServerVersion()
if err != nil {
return nil, fmt.Errorf("failed to get kubernetes server version: %v\n", err)
}
helm.KubeVersion = kubeVersion.String()

return &Client{
kubeClient: kubeClient,
dynamicKubeClient: dynamicKubeClient,
Expand Down