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

support pixie vizier #62

Merged
merged 2 commits into from
Aug 23, 2022
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
2 changes: 2 additions & 0 deletions cmd/kurator/app/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"kurator.dev/kurator/cmd/kurator/app/install/istio"
"kurator.dev/kurator/cmd/kurator/app/install/karmada"
"kurator.dev/kurator/cmd/kurator/app/install/kubeedge"
"kurator.dev/kurator/cmd/kurator/app/install/pixie"
"kurator.dev/kurator/cmd/kurator/app/install/prometheus"
"kurator.dev/kurator/cmd/kurator/app/install/submariner"
"kurator.dev/kurator/cmd/kurator/app/install/volcano"
Expand All @@ -46,5 +47,6 @@ func NewCmd(opts *generic.Options) *cobra.Command {
installCmd.AddCommand(prometheus.NewCmd(opts))
installCmd.AddCommand(submariner.NewCmd(opts))
installCmd.AddCommand(argocd.NewCmd(opts))
installCmd.AddCommand(pixie.NewCmd(opts))
return installCmd
}
39 changes: 39 additions & 0 deletions cmd/kurator/app/install/pixie/pixie.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright Kurator Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package pixie

import (
"github.com/spf13/cobra"

"kurator.dev/kurator/cmd/kurator/app/install/pixie/vizier"
"kurator.dev/kurator/pkg/generic"
)

func NewCmd(opts *generic.Options) *cobra.Command {
pixieCmd := &cobra.Command{
Use: "pixie",
Short: "Install pixie component",
DisableFlagsInUseLine: true,
zirain marked this conversation as resolved.
Show resolved Hide resolved
FParseErrWhitelist: cobra.FParseErrWhitelist{
UnknownFlags: true,
},
}

pixieCmd.AddCommand(vizier.NewCmd(opts))

return pixieCmd
}
60 changes: 60 additions & 0 deletions cmd/kurator/app/install/pixie/vizier/vizier.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
Copyright Kurator Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package vizier

import (
"fmt"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"kurator.dev/kurator/pkg/generic"
plugin "kurator.dev/kurator/pkg/plugin/pixie/vizier"
)

const (
communityCloudAddr = "withpixie.ai:443"
pxNamespace = "px"
)

func NewCmd(opts *generic.Options) *cobra.Command {
pluginArgs := plugin.InstallArgs{}
vizierCmd := &cobra.Command{
Use: "vizier",
Short: "Install vizier component",
RunE: func(c *cobra.Command, args []string) error {
plugin, err := plugin.NewPlugin(opts, &pluginArgs)
if err != nil {
logrus.Errorf("pixie vizier init error: %v", err)
return fmt.Errorf("pixie vizier init error: %v", err)
}

if err := plugin.Execute(args, nil); err != nil {
logrus.Errorf("pixie vizier execute error: %v", err)
return fmt.Errorf("pixie vizier execute error: %v", err)
}
logrus.Info("pixie vizier install completed.")
return nil
},
}

vizierCmd.PersistentFlags().StringVar(&pluginArgs.PxNamespace, "px-namespace", pxNamespace, "The namespace use to install vizier.")
vizierCmd.PersistentFlags().StringVar(&pluginArgs.CloudAddress, "cloud-addr", communityCloudAddr, "The address of the Pixie cloud instance that the vizier should be connected to.")
vizierCmd.PersistentFlags().StringVar(&pluginArgs.DeployKey, "deploy-key", "", "The deploy key is used to link the deployed vizier to a specific user/project.")

return vizierCmd
}
6 changes: 6 additions & 0 deletions manifests/profiles/components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ components:
version: 1.5.1
hub: docker.io/volcanosh
releaseURLPrefix: "https://raw.githubusercontent.com/volcano-sh/volcano/"
- name: pixie
version: 0.0.30
- name: prometheus
version:
- name: argocd
version: v2.4.8
releaseURLPrefix: "https://github.com/argoproj/argo-cd/releases/download/"
# FIXME: https://github.com/kurator-dev/kurator/issues/61
- name: helm
version: v3.9.3
releaseURLPrefix: "https://get.helm.sh/"
18 changes: 18 additions & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,21 @@ func (c *Client) NewClusterClientSet(clusterName string) (kubeclient.Interface,
}
return kubeclient.NewForConfig(clusterConfig)
}

func (c *Client) NewClusterCRDClientset(clusterName string) (crdclientset.Interface, error) {
clusterConfig, err := c.memberClusterConfig(clusterName)
if err != nil {
return nil, err
}
return crdclientset.NewForConfig(clusterConfig)
}

func (c *Client) NewClusterHelmClient(clusterName string) (helmclient.Interface, error) {
clusterConfig, err := c.memberClusterConfig(clusterName)
if err != nil {
return nil, err
}

clusterGetter := NewRESTClientGetter(clusterConfig)
return helmclient.New(clusterGetter), nil
}
92 changes: 92 additions & 0 deletions pkg/client/helmclient.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
Copyright Kurator Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package client

import (
"fmt"

"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/client-go/discovery"
"k8s.io/client-go/discovery/cached/memory"
"k8s.io/client-go/rest"
"k8s.io/client-go/restmapper"
"k8s.io/client-go/tools/clientcmd"
)

// RESTClientGetter defines the values of a helm REST client.
type RESTClientGetter struct {
restConfig *rest.Config
}

// NewRESTClientGetter returns a RESTClientGetter using the provided 'restConfig'.
//
// source: https://github.com/helm/helm/issues/6910#issuecomment-601277026
func NewRESTClientGetter(restConfig *rest.Config) *RESTClientGetter {
return &RESTClientGetter{
restConfig: restConfig,
}
}

// ToRESTConfig returns a REST config build from a given kubeconfig
func (c *RESTClientGetter) ToRESTConfig() (*rest.Config, error) {
if c.restConfig != nil {
return c.restConfig, nil
}

return nil, fmt.Errorf("restconfig can not be empty")
}

// ToDiscoveryClient returns a CachedDiscoveryInterface that can be used as a discovery client.
func (c *RESTClientGetter) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error) {
config, err := c.ToRESTConfig()
if err != nil {
return nil, err
}

// The more API groups exist, the more discovery requests need to be made.
// Given 25 API groups with about one version each, discovery needs to make 50 requests.
// This setting is only used for discovery.
config.Burst = 100

discoveryClient, err := discovery.NewDiscoveryClientForConfig(config)
if err != nil {
return nil, err
}
return memory.NewMemCacheClient(discoveryClient), nil
}

func (c *RESTClientGetter) ToRESTMapper() (meta.RESTMapper, error) {
discoveryClient, err := c.ToDiscoveryClient()
if err != nil {
return nil, err
}

mapper := restmapper.NewDeferredDiscoveryRESTMapper(discoveryClient)
expander := restmapper.NewShortcutExpander(mapper, discoveryClient)
return expander, nil
}

func (c *RESTClientGetter) ToRawKubeConfigLoader() clientcmd.ClientConfig {
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
// use the standard defaults for this client command
// DEPRECATED: remove and replace with something more accurate
loadingRules.DefaultClientConfig = &clientcmd.DefaultClientConfig

overrides := &clientcmd.ConfigOverrides{ClusterDefaults: clientcmd.ClusterDefaults}

return clientcmd.NewNonInteractiveDeferredLoadingClientConfig(loadingRules, overrides)
}
2 changes: 1 addition & 1 deletion pkg/plugin/istio/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func (p *IstioPlugin) installRemotes(remotePilotAddress string) error {
defer wg.Done()
err := waitIngressgatewayReady(p.Client, p.options, cluster)
if err != nil {
_ = multierror.Append(multiErr, err)
multiErr = multierror.Append(multiErr, err)
}
}(remote)
}
Expand Down
Loading