helm v3源码分析之总体

 欢迎关注我的公众号:

 目前刚开始写一个月,一共写了18篇原创文章,文章目录如下:

istio多集群探秘,部署了50次多集群后我得出的结论

istio多集群链路追踪,附实操视频

istio防故障利器,你知道几个,istio新手不要读,太难!

istio业务权限控制,原来可以这么玩

istio实现非侵入压缩,微服务之间如何实现压缩

不懂envoyfilter也敢说精通istio系列-http-rbac-不要只会用AuthorizationPolicy配置权限

不懂envoyfilter也敢说精通istio系列-02-http-corsFilter-不要只会vs

不懂envoyfilter也敢说精通istio系列-03-http-csrf filter-再也不用再代码里写csrf逻辑了

不懂envoyfilter也敢说精通istio系列http-jwt_authn-不要只会RequestAuthorization

不懂envoyfilter也敢说精通istio系列-05-fault-filter-故障注入不止是vs

不懂envoyfilter也敢说精通istio系列-06-http-match-配置路由不只是vs

不懂envoyfilter也敢说精通istio系列-07-负载均衡配置不止是dr

不懂envoyfilter也敢说精通istio系列-08-连接池和断路器

不懂envoyfilter也敢说精通istio系列-09-http-route filter

不懂envoyfilter也敢说精通istio系列-network filter-redis proxy

不懂envoyfilter也敢说精通istio系列-network filter-HttpConnectionManager

不懂envoyfilter也敢说精通istio系列-ratelimit-istio ratelimit完全手册

 

-----------------------------------------------------------------------------------------------------

func main() {//程序入口
	initKubeLogs()//初始化kube日志

	actionConfig := new(action.Configuration)
	cmd := newRootCmd(actionConfig, os.Stdout, os.Args[1:])//创建根命令

	if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), os.Getenv("HELM_DRIVER"), debug); err != nil {//初始化
		log.Fatal(err)
	}

	if err := cmd.Execute(); err != nil {执行命令
		debug("%+v", err)
		switch e := err.(type) {
		case pluginError:
			os.Exit(e.code)
		default:
			os.Exit(1)
		}
	}
}
func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string) *cobra.Command {//获取根命令
	cmd := &cobra.Command{//创建cobra命令
		Use:                    "helm",
		Short:                  "The Helm package manager for Kubernetes.",
		Long:                   globalUsage,
		SilenceUsage:           true,
		Args:                   require.NoArgs,
		BashCompletionFunction: fmt.Sprintf("%s%s", contextCompFunc, completion.GetBashCustomFunction()),
	}
	flags := cmd.PersistentFlags()

	settings.AddFlags(flags)//添加选项

	flag := flags.Lookup("namespace")
	// Setup shell completion for the namespace flag
	completion.RegisterFlagCompletionFunc(flag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, completion.BashCompDirective) {//自动补全
		if client, err := actionConfig.KubernetesClientSet(); err == nil {
			// Choose a long enough timeout that the user notices somethings is not working
			// but short enough that the user is not made to wait very long
			to := int64(3)
			completion.CompDebugln(fmt.Sprintf("About to call kube client for namespaces with timeout of: %d", to))

			nsNames := []string{}
			if namespaces, err := client.CoreV1().Namespaces().List(metav1.ListOptions{TimeoutSeconds: &to}); err == nil {
				for _, ns := range namespaces.Items {
					if strings.HasPrefix(ns.Name, toComplete) {
						nsNames = append(nsNames, ns.Name)
					}
				}
				return nsNames, completion.BashCompDirectiveNoFileComp
			}
		}
		return nil, completion.BashCompDirectiveDefault
	})

	// We can safely ignore any errors that flags.Parse encounters since
	// those errors will be caught later during the call to cmd.Execution.
	// This call is required to gather configuration information prior to
	// execution.
	flags.ParseErrorsWhitelist.UnknownFlags = true
	flags.Parse(args)

	// Add subcommands
	cmd.AddCommand(//添加子命令
		// chart commands
		newCreateCmd(out),// 添加create命令
		newDependencyCmd(out),// 添加dependency命令
		newPullCmd(out),//添加pull命令
		newShowCmd(out),//添加show命令
		newLintCmd(out),//添加lint命令
		newPackageCmd(out),//添加package命令
		newRepoCmd(out),//添加repo命令
		newSearchCmd(out),//添加search命令
		newVerifyCmd(out),//添加verify命令

		// release commands
		newGetCmd(actionConfig, out),//添加get命令
		newHistoryCmd(actionConfig, out),//添加history命令
		newInstallCmd(actionConfig, out),//添加install命令
		newListCmd(actionConfig, out),//添加list命令
		newReleaseTestCmd(actionConfig, out),//添加test命令
		newRollbackCmd(actionConfig, out),//添加rollback命令
		newStatusCmd(actionConfig, out),//添加status命令
		newTemplateCmd(actionConfig, out),//添加template命令
		newUninstallCmd(actionConfig, out),//添加uninstall命令
		newUpgradeCmd(actionConfig, out),//添加upgrade命令

		newCompletionCmd(out),//添加completion命令
		newEnvCmd(out),//添加env命令
		newPluginCmd(out),//添加plugin命令
		newVersionCmd(out),// 添加version命令

		// Hidden documentation generator command: 'helm docs'
		newDocsCmd(out),//添加docs命令

		// Setup the special hidden __complete command to allow for dynamic auto-completion
		completion.NewCompleteCmd(settings, out),
	)

	// Add annotation to flags for which we can generate completion choices
	for name, completion := range bashCompletionFlags {
		if cmd.Flag(name) != nil {
			if cmd.Flag(name).Annotations == nil {
				cmd.Flag(name).Annotations = map[string][]string{}
			}
			cmd.Flag(name).Annotations[cobra.BashCompCustom] = append(
				cmd.Flag(name).Annotations[cobra.BashCompCustom],
				completion,
			)
		}
	}

	// Add *experimental* subcommands
	registryClient, err := registry.NewClient(
		registry.ClientOptDebug(settings.Debug),
		registry.ClientOptWriter(out),
	)
	if err != nil {
		// TODO: don't panic here, refactor newRootCmd to return error
		panic(err)
	}
	actionConfig.RegistryClient = registryClient
	cmd.AddCommand(
		newRegistryCmd(actionConfig, out),//添加registry命令
		newChartCmd(actionConfig, out),//添加chart命令
	)

	// Find and add plugins
	loadPlugins(cmd, out)//加载插件

	return cmd
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hxpjava1

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值