Skip to content

Commit

Permalink
Chart update
Browse files Browse the repository at this point in the history
Signed-off-by: Jian Qiu <[email protected]>
  • Loading branch information
qiujian16 committed Aug 29, 2024
1 parent 5f39e3d commit b762279
Show file tree
Hide file tree
Showing 20 changed files with 99 additions and 179 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
open-cluster-management.io/api v0.14.1-0.20240627145512-bd6f2229b53c
open-cluster-management.io/cluster-proxy v0.4.0
open-cluster-management.io/managed-serviceaccount v0.6.0
open-cluster-management.io/ocm v0.14.1-0.20240819063207-0536c757af31
open-cluster-management.io/ocm v0.14.1-0.20240829031425-567a9a4e188c
open-cluster-management.io/sdk-go v0.14.1-0.20240628095929-9ffb1b19e566
sigs.k8s.io/apiserver-network-proxy v0.29.0
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ open-cluster-management.io/cluster-proxy v0.4.0 h1:rm0UDaDWe3/P3xLzwqdHtqNksKwSz
open-cluster-management.io/cluster-proxy v0.4.0/go.mod h1:gTvfDHAhGezhdg4BD3ECBn6jbg2Y5PbHhV2ceW5nrB0=
open-cluster-management.io/managed-serviceaccount v0.6.0 h1:qIi5T9WQJBuoGqnYGIktXbtqfQoiN2H9XU2P/6lAQiw=
open-cluster-management.io/managed-serviceaccount v0.6.0/go.mod h1:G4LUTbZiyrB8c0+rqi/xnDmGlsg7Rdr4T7MPLCWhyQI=
open-cluster-management.io/ocm v0.14.1-0.20240819063207-0536c757af31 h1:on+ek8B5821n8VlDKKk8+FnQMbiJl0WVBV8QDuvPWqI=
open-cluster-management.io/ocm v0.14.1-0.20240819063207-0536c757af31/go.mod h1:KWsyZ9g9AyPcgwi8x+8g+LFJQ9oHNIRfsP5YI/npKFA=
open-cluster-management.io/ocm v0.14.1-0.20240829031425-567a9a4e188c h1:j2exRpAeji0qZispaOnSHsq6VhX8XHbIGS8F4djNw4E=
open-cluster-management.io/ocm v0.14.1-0.20240829031425-567a9a4e188c/go.mod h1:KWsyZ9g9AyPcgwi8x+8g+LFJQ9oHNIRfsP5YI/npKFA=
open-cluster-management.io/sdk-go v0.14.1-0.20240628095929-9ffb1b19e566 h1:8dgPiM3byX/rtOrFJIsea2haV4hSFTND65Tlj1EdK18=
open-cluster-management.io/sdk-go v0.14.1-0.20240628095929-9ffb1b19e566/go.mod h1:xFmN3Db5nN68oLGnstmIRv4us8HJCdXFnBNMXVp0jWY=
oras.land/oras-go v1.2.5 h1:XpYuAwAb0DfQsunIyMfeET92emK8km3W4yEzZvUbsTo=
Expand Down
55 changes: 0 additions & 55 deletions pkg/cmd/get/token/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import (
"fmt"

"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/api/errors"
"open-cluster-management.io/clusteradm/pkg/cmd/init/scenario"
"open-cluster-management.io/clusteradm/pkg/helpers"
clusteradmjson "open-cluster-management.io/clusteradm/pkg/helpers/json"
"open-cluster-management.io/clusteradm/pkg/helpers/reader"
)

func (o *Options) complete(cmd *cobra.Command, args []string) (err error) {
Expand Down Expand Up @@ -38,44 +35,12 @@ func (o *Options) run() error {
return err
}

r := reader.NewResourceReader(o.ClusteradmFlags.KubectlFactory, o.ClusteradmFlags.DryRun, o.Streams)

//Retrieve token from service-account/bootstrap-token
// and if not found create it
var token string
if o.useBootstrapToken {
token, err = helpers.GetBootstrapToken(context.TODO(), kubeClient)
} else {
token, err = helpers.GetBootstrapTokenFromSA(context.TODO(), kubeClient)
}
switch {
case errors.IsNotFound(err):
err := o.applyToken(r)
if err != nil {
return err
}
case err != nil:
return err
}

//Update the cluster role as it could change over-time
files := []string{
"init/bootstrap_cluster_role.yaml",
}

err = r.Apply(scenario.Files, o.values, files...)
if err != nil {
return err
}

restConfig, err := o.ClusteradmFlags.KubectlFactory.ToRESTConfig()
if err != nil {
return err
}
// if dry-run then there is nothing else to do
if o.ClusteradmFlags.DryRun {
return o.writeResult(token, restConfig.Host)
}

//if bootstrap token then read the token
if o.useBootstrapToken {
Expand All @@ -95,26 +60,6 @@ func (o *Options) run() error {
return o.writeResult(token, restConfig.Host)
}

func (o *Options) applyToken(applier *reader.ResourceReader) error {
files := []string{
"init/namespace.yaml",
}
if o.useBootstrapToken {
files = append(files,
"init/bootstrap-token-secret.yaml",
"init/bootstrap_cluster_role.yaml",
"init/bootstrap_cluster_role_binding.yaml",
)
} else {
files = append(files,
"init/bootstrap_sa.yaml",
"init/bootstrap_cluster_role.yaml",
"init/bootstrap_sa_cluster_role_binding.yaml",
)
}
return applier.Apply(scenario.Files, o.values, files...)
}

func (o *Options) writeResult(token, host string) error {
if len(token) == 0 {
fmt.Println(o.Streams.Out, "token doesn't exist")
Expand Down
26 changes: 7 additions & 19 deletions pkg/cmd/init/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
ocmfeature "open-cluster-management.io/api/feature"
operatorv1 "open-cluster-management.io/api/operator/v1"
"open-cluster-management.io/clusteradm/pkg/cmd/init/preflight"
"open-cluster-management.io/clusteradm/pkg/cmd/init/scenario"
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
"open-cluster-management.io/clusteradm/pkg/helpers"
"open-cluster-management.io/clusteradm/pkg/helpers/helm"
Expand Down Expand Up @@ -161,32 +160,21 @@ func (o *Options) run() error {
return err
}
} else {
files := []string{}
if o.createNamespace {
files = append(files, "init/namespace.yaml")
} else {
o.clusterManagerChartConfig.CreateNamespace = o.createNamespace
if !o.createNamespace {
fmt.Fprintf(o.Streams.Out, "skip creating namespace\n")
}

if !o.useBootstrapToken {
files = append(files,
"init/bootstrap_sa.yaml",
"init/bootstrap_cluster_role.yaml",
"init/bootstrap_sa_cluster_role_binding.yaml",
)
o.clusterManagerChartConfig.CreateBootstrapSA = true
} else {
o.clusterManagerChartConfig.CreateBootstrapToken = true
}

r := reader.NewResourceReader(o.ClusteradmFlags.KubectlFactory, o.ClusteradmFlags.DryRun, o.Streams)
err = r.Apply(scenario.Files, nil, files...)
if err != nil {
return err
}

raw, err := chart.RenderChart[*clustermanagerchart.ChartConfig](
raw, err := chart.RenderClusterManagerChart(
o.clusterManagerChartConfig,
"open-cluster-management",
"cluster-manager",
clustermanagerchart.ChartFiles)
"open-cluster-management")
if err != nil {
return err
}
Expand Down
36 changes: 0 additions & 36 deletions pkg/cmd/init/scenario/init/bootstrap_cluster_role.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions pkg/cmd/init/scenario/init/bootstrap_sa.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions pkg/cmd/init/scenario/init/namespace.yaml

This file was deleted.

22 changes: 0 additions & 22 deletions pkg/cmd/init/scenario/resources.go

This file was deleted.

19 changes: 4 additions & 15 deletions pkg/cmd/join/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
ocmfeature "open-cluster-management.io/api/feature"
operatorv1 "open-cluster-management.io/api/operator/v1"
"open-cluster-management.io/clusteradm/pkg/cmd/join/preflight"
"open-cluster-management.io/clusteradm/pkg/cmd/join/scenario"
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions"
"open-cluster-management.io/clusteradm/pkg/helpers"
preflightinterface "open-cluster-management.io/clusteradm/pkg/helpers/preflight"
Expand Down Expand Up @@ -356,21 +355,11 @@ func (o *Options) applyKlusterlet(r *reader.ResourceReader, operatorClient opera

// If Deployment/klusterlet is not deployed, deploy it
if !available {
var files []string
if o.createNameSpace {
files = append(files, "join/namespace.yaml")
}

err = r.Apply(scenario.Files, nil, files...)
if err != nil {
return err
}
o.klusterletChartConfig.CreateNamespace = o.createNameSpace

raw, err := chart.RenderChart[*klusterletchart.ChartConfig](
raw, err := chart.RenderKlusterletChart(
o.klusterletChartConfig,
"open-cluster-management",
"klusterlet",
klusterletchart.ChartFiles)
"open-cluster-management")
if err != nil {
return err
}
Expand Down Expand Up @@ -673,7 +662,7 @@ func (o *Options) setKubeconfig() error {
return err
}

o.klusterletChartConfig.BootstrapHubKubeConfig = base64.StdEncoding.EncodeToString(bootstrapConfigBytes)
o.klusterletChartConfig.BootstrapHubKubeConfig = string(bootstrapConfigBytes)
return nil
}

Expand Down
6 changes: 2 additions & 4 deletions pkg/cmd/upgrade/clustermanager/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ func (o *Options) run() error {
return err
}

raw, err := chart.RenderChart[*clustermanagerchart.ChartConfig](
raw, err := chart.RenderClusterManagerChart(
o.clusterManagerChartConfig,
"open-cluster-management",
"cluster-manager",
clustermanagerchart.ChartFiles)
"open-cluster-management")
if err != nil {
return err
}
Expand Down
7 changes: 2 additions & 5 deletions pkg/cmd/upgrade/klusterlet/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"open-cluster-management.io/clusteradm/pkg/helpers"
"open-cluster-management.io/clusteradm/pkg/helpers/reader"
"open-cluster-management.io/clusteradm/pkg/helpers/wait"
klusterletchart "open-cluster-management.io/ocm/deploy/klusterlet/chart"
"open-cluster-management.io/ocm/pkg/operator/helpers/chart"
)

Expand Down Expand Up @@ -87,11 +86,9 @@ func (o *Options) run() error {
return err
}

raw, err := chart.RenderChart[*klusterletchart.ChartConfig](
raw, err := chart.RenderKlusterletChart(
o.klusterletChartConfig,
"open-cluster-management",
"klusterlet",
klusterletchart.ChartFiles)
"open-cluster-management")
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ open-cluster-management.io/managed-serviceaccount/pkg/generated/clientset/versio
open-cluster-management.io/managed-serviceaccount/pkg/generated/clientset/versioned/scheme
open-cluster-management.io/managed-serviceaccount/pkg/generated/clientset/versioned/typed/authentication/v1alpha1
open-cluster-management.io/managed-serviceaccount/pkg/generated/clientset/versioned/typed/authentication/v1beta1
# open-cluster-management.io/ocm v0.14.1-0.20240819063207-0536c757af31
# open-cluster-management.io/ocm v0.14.1-0.20240829031425-567a9a4e188c
## explicit; go 1.22.6
open-cluster-management.io/ocm/deploy/cluster-manager/chart
open-cluster-management.io/ocm/deploy/klusterlet/chart
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b762279

Please sign in to comment.