kubectl源码分析之总体

Elasticsearch 报错 error At least one unigram is required but all tokens were ngrams 【代码】Elasticsearch 报错 error At least one unigram is required but all tokens were ngrams。 阅读详情

 欢迎关注我的公众号:

 目前刚开始写一个月,一共写了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() {
	rand.Seed(time.Now().UnixNano())

	command := cmd.NewDefaultKubectlCommand()

	// TODO: once we switch everything over to Cobra commands, we can go back to calling
	// cliflag.InitFlags() (by removing its pflag.Parse() call). For now, we have to set the
	// normalize func and add the go flag set by hand.
	pflag.CommandLine.SetNormalizeFunc(cliflag.WordSepNormalizeFunc)
	pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)
	// cliflag.InitFlags()
	logs.InitLogs()
	defer logs.FlushLogs()

	if err := command.Execute(); err != nil {
		os.Exit(1)
	}
}
command := cmd.NewDefaultKubectlCommand()创建根命令,
command.Execute();运行命令
logs.InitLogs()展开:
func init() {
	klog.InitFlags(flag.CommandLine)
	flag.Set("logtostderr", "true")
}
func InitFlags(flagset *flag.FlagSet) {

	// Initialize defaults.
	initDefaultsOnce.Do(func() {
		logging.logDir = ""
		logging.logFile = ""
		logging.logFileMaxSizeMB = 1800
		logging.toStderr = true
		logging.alsoToStderr = false
		logging.skipHeaders = false
		logging.addDirHeader = false
		logging.skipLogHeaders = false
	})

	if flagset == nil {
		flagset = flag.CommandLine
	}

	flagset.StringVar(&logging.logDir, "log_dir", logging.logDir, "If non-empty, write log files in this directory")
	flagset.StringVar(&logging.logFile, "log_file", logging.logFile, "If non-empty, use this log file")
	flagset.Uint64Var(&logging.logFileMaxSizeMB, "log_file_max_size", logging.logFileMaxSizeMB,
		"Defines the maximum size a log file can grow to. Unit is megabytes. "+
			"If the value is 0, the maximum file size is unlimited.")
	flagset.BoolVar(&logging.toStderr, "logtostderr", logging.toStderr, "log to standard error instead of files")
	flagset.BoolVar(&logging.alsoToStderr, "alsologtostderr", logging.alsoToStderr, "log to standard error as well as files")
	flagset.Var(&logging.verbosity, "v", "number for the log level verbosity")
	flagset.BoolVar(&logging.skipHeaders, "add_dir_header", logging.addDirHeader, "If true, adds the file directory to the header")
	flagset.BoolVar(&logging.skipHeaders, "skip_headers", logging.skipHeaders, "If true, avoid header prefixes in the log messages")
	flagset.BoolVar(&logging.skipLogHeaders, "skip_log_headers", logging.skipLogHeaders, "If true, avoid headers when opening log files")
	flagset.Var(&logging.stderrThreshold, "stderrthreshold", "logs at or above this threshold go to stderr")
	flagset.Var(&logging.vmodule, "vmodule", "comma-separated list of pattern=N settings for file-filtered logging")
	flagset.Var(&logging.traceLocation, "log_backtrace_at", "when logging hits line file:N, emit a stack trace")
}

这里会设置klog命令行参数

进入:

cmd.NewDefaultKubectlCommand()
func NewDefaultKubectlCommand() *cobra.Command {
	return NewDefaultKubectlCommandWithArgs(NewDefaultPluginHandler(plugin.ValidPluginFilenamePrefixes), os.Args, os.Stdin, os.Stdout, os.Stderr)
}

// NewDefaultKubectlCommandWithArgs creates the `kubectl` command with arguments
func NewDefaultKubectlCommandWithArgs(pluginHandler PluginHandler, args []string, in io.Reader, out, errout io.Writer) *cobra.Command {
	cmd := NewKubectlCommand(in, out, errout)

	if pluginHandler == nil {
		return cmd
	}

	if len(args) > 1 {
		cmdPathPieces := args[1:]

		// only look for suitable extension executables if
		// the specified command does not already exist
		if _, _, err := cmd.Find(cmdPathPieces); err != nil {
			if err := HandlePluginCommand(pluginHandler, cmdPathPieces); err != nil {
				fmt.Fprintf(errout, "%v\n", err)
				os.Exit(1)
			}
		}
	}

	return cmd
}

NewKubectlCommand:

func NewKubectlCommand(in io.Reader, out, err io.Writer) *cobra.Command {
	// Parent command to which all subcommands are added.
	cmds := &cobra.Command{
		Use:   "kubectl",
		Short: i18n.T("kubectl controls the Kubernetes cluster manager"),
		Long: templates.LongDesc(`
      kubectl controls the Kubernetes cluster manager.

      Find more information at:
            https://kubernetes.io/docs/reference/kubectl/overview/`),
		Run: runHelp,
		// Hook before and after Run initialize and write profiles to disk,
		// respectively.
		PersistentPreRunE: func(*cobra.Command, []string) error {
			return initProfiling()
		},
		PersistentPostRunE: func(*cobra.Command, []string) error {
			return flushProfiling()
		},
		BashCompletionFunction: bashCompletionFunc,
	}

	flags := cmds.PersistentFlags()
	flags.SetNormalizeFunc(cliflag.WarnWordSepNormalizeFunc) // Warn for "_" flags

	// Normalize all flags that are coming from other packages or pre-configurations
	// a.k.a. change all "_" to "-". e.g. glog package
	flags.SetNormalizeFunc(cliflag.WordSepNormalizeFunc)

	addProfilingFlags(flags)

	kubeConfigFlags := genericclioptions.NewConfigFlags(true).WithDeprecatedPasswordFlag()
	kubeConfigFlags.AddFlags(flags)
	matchVersionKubeConfigFlags := cmdutil.NewMatchVersionFlags(kubeConfigFlags)
	matchVersionKubeConfigFlags.AddFlags(cmds.PersistentFlags())

	cmds.PersistentFlags().AddGoFlagSet(flag.CommandLine)

	f := cmdutil.NewFactory(matchVersionKubeConfigFlags)

	// Sending in 'nil' for the getLanguageFn() results in using
	// the LANG environment variable.
	//
	// TODO: Consider adding a flag or file preference for setting
	// the language, instead of just loading from the LANG env. variable.
	i18n.LoadTranslations("kubectl", nil)

	// From this point and forward we get warnings on flags that contain "_" separators
	cmds.SetGlobalNormalizationFunc(cliflag.WarnWordSepNormalizeFunc)

	ioStreams := genericclioptions.IOStreams{In: in, Out: out, ErrOut: err}

	groups := templates.CommandGroups{
		{
			Message: "Basic Commands (Beginner):",
			Commands: []*cobra.Command{
				create.NewCmdCreate(f, ioStreams),
				expose.NewCmdExposeService(f, ioStreams),
				run.NewCmdRun(f, ioStreams),
				set.NewCmdSet(f, ioStreams),
			},
		},
		{
			Message: "Basic Commands (Intermediate):",
			Commands: []*cobra.Command{
				explain.NewCmdExplain("kubectl", f, ioStreams),
				get.NewCmdGet("kubectl", f, ioStreams),
				edit.NewCmdEdit(f, ioStreams),
				delete.NewCmdDelete(f, ioStreams),
			},
		},
		{
			Message: "Deploy Commands:",
			Commands: []*cobra.Command{
				rollout.NewCmdRollout(f, ioStreams),
				rollingupdate.NewCmdRollingUpdate(f, ioStreams),
				scale.NewCmdScale(f, ioStreams),
				autoscale.NewCmdAutoscale(f, ioStreams),
			},
		},
		{
			Message: "Cluster Management Commands:",
			Commands: []*cobra.Command{
				certificates.NewCmdCertificate(f, ioStreams),
				clusterinfo.NewCmdClusterInfo(f, ioStreams),
				top.NewCmdTop(f, ioStreams),
				drain.NewCmdCordon(f, ioStreams),
				drain.NewCmdUncordon(f, ioStreams),
				drain.NewCmdDrain(f, ioStreams),
				taint.NewCmdTaint(f, ioStreams),
			},
		},
		{
			Message: "Troubleshooting and Debugging Commands:",
			Commands: []*cobra.Command{
				describe.NewCmdDescribe("kubectl", f, ioStreams),
				logs.NewCmdLogs(f, ioStreams),
				attach.NewCmdAttach(f, ioStreams),
				cmdexec.NewCmdExec(f, ioStreams),
				portforward.NewCmdPortForward(f, ioStreams),
				proxy.NewCmdProxy(f, ioStreams),
				cp.NewCmdCp(f, ioStreams),
				auth.NewCmdAuth(f, ioStreams),
			},
		},
		{
			Message: "Advanced Commands:",
			Commands: []*cobra.Command{
				diff.NewCmdDiff(f, ioStreams),
				apply.NewCmdApply("kubectl", f, ioStreams),
				patch.NewCmdPatch(f, ioStreams),
				replace.NewCmdReplace(f, ioStreams),
				wait.NewCmdWait(f, ioStreams),
				convert.NewCmdConvert(f, ioStreams),
				kustomize.NewCmdKustomize(ioStreams),
			},
		},
		{
			Message: "Settings Commands:",
			Commands: []*cobra.Command{
				label.NewCmdLabel(f, ioStreams),
				annotate.NewCmdAnnotate("kubectl", f, ioStreams),
				completion.NewCmdCompletion(ioStreams.Out, ""),
			},
		},
	}
	groups.Add(cmds)

	filters := []string{"options"}

	// Hide the "alpha" subcommand if there are no alpha commands in this build.
	alpha := cmdpkg.NewCmdAlpha(f, ioStreams)
	if !alpha.HasSubCommands() {
		filters = append(filters, alpha.Name())
	}

	templates.ActsAsRootCommand(cmds, filters, groups...)

	for name, completion := range bashCompletionFlags {
		if cmds.Flag(name) != nil {
			if cmds.Flag(name).Annotations == nil {
				cmds.Flag(name).Annotations = map[string][]string{}
			}
			cmds.Flag(name).Annotations[cobra.BashCompCustom] = append(
				cmds.Flag(name).Annotations[cobra.BashCompCustom],
				completion,
			)
		}
	}

	cmds.AddCommand(alpha)
	cmds.AddCommand(cmdconfig.NewCmdConfig(f, clientcmd.NewDefaultPathOptions(), ioStreams))
	cmds.AddCommand(plugin.NewCmdPlugin(f, ioStreams))
	cmds.AddCommand(version.NewCmdVersion(f, ioStreams))
	cmds.AddCommand(apiresources.NewCmdAPIVersions(f, ioStreams))
	cmds.AddCommand(apiresources.NewCmdAPIResources(f, ioStreams))
	cmds.AddCommand(options.NewCmdOptions(ioStreams.Out))

	return cmds
}

这个函数创建kubectl根命令,以及添加子命令。

PersistentPreRunE: func(*cobra.Command, []string) error {
   return initProfiling()
},
PersistentPostRunE: func(*cobra.Command, []string) error {
   return flushProfiling()
},
在命令运行前和运行后执行profiling
func addProfilingFlags(flags *pflag.FlagSet) {
	flags.StringVar(&profileName, "profile", "none", "Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex)")
	flags.StringVar(&profileOutput, "profile-output", "profile.pprof", "Name of the file to write the profile to")
}

添加profiling选项

func (f *ConfigFlags) AddFlags(flags *pflag.FlagSet) {
	if f.KubeConfig != nil {
		flags.StringVar(f.KubeConfig, "kubeconfig", *f.KubeConfig, "Path to the kubeconfig file to use for CLI requests.")
	}
	if f.CacheDir != nil {
		flags.StringVar(f.CacheDir, flagHTTPCacheDir, *f.CacheDir, "Default HTTP cache directory")
	}

	// add config options
	if f.CertFile != nil {
		flags.StringVar(f.CertFile, flagCertFile, *f.CertFile, "Path to a client certificate file for TLS")
	}
	if f.KeyFile != nil {
		flags.StringVar(f.KeyFile, flagKeyFile, *f.KeyFile, "Path to a client key file for TLS")
	}
	if f.BearerToken != nil {
		flags.StringVar(f.BearerToken, flagBearerToken, *f.BearerToken, "Bearer token for authentication to the API server")
	}
	if f.Impersonate != nil {
		flags.StringVar(f.Impersonate, flagImpersonate, *f.Impersonate, "Username to impersonate for the operation")
	}
	if f.ImpersonateGroup != nil {
		flags.StringArrayVar(f.ImpersonateGroup, flagImpersonateGroup, *f.ImpersonateGroup, "Group to impersonate for the operation, this flag can be repeated to specify multiple groups.")
	}
	if f.Username != nil {
		flags.StringVar(f.Username, flagUsername, *f.Username, "Username for basic authentication to the API server")
	}
	if f.Password != nil {
		flags.StringVar(f.Password, flagPassword, *f.Password, "Password for basic authentication to the API server")
	}
	if f.ClusterName != nil {
		flags.StringVar(f.ClusterName, flagClusterName, *f.ClusterName, "The name of the kubeconfig cluster to use")
	}
	if f.AuthInfoName != nil {
		flags.StringVar(f.AuthInfoName, flagAuthInfoName, *f.AuthInfoName, "The name of the kubeconfig user to use")
	}
	if f.Namespace != nil {
		flags.StringVarP(f.Namespace, flagNamespace, "n", *f.Namespace, "If present, the namespace scope for this CLI request")
	}
	if f.Context != nil {
		flags.StringVar(f.Context, flagContext, *f.Context, "The name of the kubeconfig context to use")
	}

	if f.APIServer != nil {
		flags.StringVarP(f.APIServer, flagAPIServer, "s", *f.APIServer, "The address and port of the Kubernetes API server")
	}
	if f.Insecure != nil {
		flags.BoolVar(f.Insecure, flagInsecure, *f.Insecure, "If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure")
	}
	if f.CAFile != nil {
		flags.StringVar(f.CAFile, flagCAFile, *f.CAFile, "Path to a cert file for the certificate authority")
	}
	if f.Timeout != nil {
		flags.StringVar(f.Timeout, flagTimeout, *f.Timeout, "The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests.")
	}

}

添加kubectl通用选项

func (f *MatchVersionFlags) AddFlags(flags *pflag.FlagSet) {
	flags.BoolVar(&f.RequireMatchedServerVersion, flagMatchBinaryVersion, f.RequireMatchedServerVersion, "Require server version to match client version")
}

添加match-server-version选项

f := cmdutil.NewFactory(matchVersionKubeConfigFlags)

创建factory,factory可以转换成各种client和config,会在子命令中传递

type RESTClientGetter interface {
	// ToRESTConfig returns restconfig
	ToRESTConfig() (*rest.Config, error)
	// ToDiscoveryClient returns discovery client
	ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
	// ToRESTMapper returns a restmapper
	ToRESTMapper() (meta.RESTMapper, error)
	// ToRawKubeConfigLoader return kubeconfig loader as-is
	ToRawKubeConfigLoader() clientcmd.ClientConfig
}
RESTClientGetter接口,factory中的一个重要字段
type factoryImpl struct {
	clientGetter genericclioptions.RESTClientGetter

	// openAPIGetter loads and caches openapi specs
	openAPIGetter openAPIGetter
}

factory实现类,用于获取各种客户端和open api校验

type RESTMapper interface {
	// KindFor takes a partial resource and returns the single match.  Returns an error if there are multiple matches
	KindFor(resource schema.GroupVersionResource) (schema.GroupVersionKind, error)

	// KindsFor takes a partial resource and returns the list of potential kinds in priority order
	KindsFor(resource schema.GroupVersionResource) ([]schema.GroupVersionKind, error)

	// ResourceFor takes a partial resource and returns the single match.  Returns an error if there are multiple matches
	ResourceFor(input schema.GroupVersionResource) (schema.GroupVersionResource, error)

	// ResourcesFor takes a partial resource and returns the list of potential resource in priority order
	ResourcesFor(input schema.GroupVersionResource) ([]schema.GroupVersionResource, error)

	// RESTMapping identifies a preferred resource mapping for the provided group kind.
	RESTMapping(gk schema.GroupKind, versions ...string) (*RESTMapping, error)
	// RESTMappings returns all resource mappings for the provided group kind if no
	// version search is provided. Otherwise identifies a preferred resource mapping for
	// the provided version(s).
	RESTMappings(gk schema.GroupKind, versions ...string) ([]*RESTMapping, error)

	ResourceSingularizer(resource string) (singular string, err error)
}

一个比较重要接口,在client-go操作时会用到

type MetadataAccessor interface {
	APIVersion(obj runtime.Object) (string, error)
	SetAPIVersion(obj runtime.Object, version string) error

	Kind(obj runtime.Object) (string, error)
	SetKind(obj runtime.Object, kind string) error

	Namespace(obj runtime.Object) (string, error)
	SetNamespace(obj runtime.Object, namespace string) error

	Name(obj runtime.Object) (string, error)
	SetName(obj runtime.Object, name string) error

	GenerateName(obj runtime.Object) (string, error)
	SetGenerateName(obj runtime.Object, name string) error

	UID(obj runtime.Object) (types.UID, error)
	SetUID(obj runtime.Object, uid types.UID) error

	SelfLink(obj runtime.Object) (string, error)
	SetSelfLink(obj runtime.Object, selfLink string) error

	Labels(obj runtime.Object) (map[string]string, error)
	SetLabels(obj runtime.Object, labels map[string]string) error

	Annotations(obj runtime.Object) (map[string]string, error)
	SetAnnotations(obj runtime.Object, annotations map[string]string) error

	Continue(obj runtime.Object) (string, error)
	SetContinue(obj runtime.Object, c string) error

	runtime.ResourceVersioner
}

元数据访问接口,用于访问对象的元数据,如kind,namespace,annotation,labels等

func (f *factoryImpl) ToRESTConfig() (*restclient.Config, error) {
	return f.clientGetter.ToRESTConfig()
}

func (f *factoryImpl) ToRESTMapper() (meta.RESTMapper, error) {
	return f.clientGetter.ToRESTMapper()
}

func (f *factoryImpl) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error) {
	return f.clientGetter.ToDiscoveryClient()
}

func (f *factoryImpl) ToRawKubeConfigLoader() clientcmd.ClientConfig {
	return f.clientGetter.ToRawKubeConfigLoader()
}

func (f *factoryImpl) KubernetesClientSet() (*kubernetes.Clientset, error) {
	clientConfig, err := f.ToRESTConfig()
	if err != nil {
		return nil, err
	}
	return kubernetes.NewForConfig(clientConfig)
}

func (f *factoryImpl) DynamicClient() (dynamic.Interface, error) {
	clientConfig, err := f.ToRESTConfig()
	if err != nil {
		return nil, err
	}
	return dynamic.NewForConfig(clientConfig)
}

// NewBuilder returns a new resource builder for structured api objects.
func (f *factoryImpl) NewBuilder() *resource.Builder {
	return resource.NewBuilder(f.clientGetter)
}

func (f *factoryImpl) RESTClient() (*restclient.RESTClient, error) {
	clientConfig, err := f.ToRESTConfig()
	if err != nil {
		return nil, err
	}
	setKubernetesDefaults(clientConfig)
	return restclient.RESTClientFor(clientConfig)
}

func (f *factoryImpl) ClientForMapping(mapping *meta.RESTMapping) (resource.RESTClient, error) {
	cfg, err := f.clientGetter.ToRESTConfig()
	if err != nil {
		return nil, err
	}
	if err := setKubernetesDefaults(cfg); err != nil {
		return nil, err
	}
	gvk := mapping.GroupVersionKind
	switch gvk.Group {
	case corev1.GroupName:
		cfg.APIPath = "/api"
	default:
		cfg.APIPath = "/apis"
	}
	gv := gvk.GroupVersion()
	cfg.GroupVersion = &gv
	return restclient.RESTClientFor(cfg)
}

func (f *factoryImpl) UnstructuredClientForMapping(mapping *meta.RESTMapping) (resource.RESTClient, error) {
	cfg, err := f.clientGetter.ToRESTConfig()
	if err != nil {
		return nil, err
	}
	if err := restclient.SetKubernetesDefaults(cfg); err != nil {
		return nil, err
	}
	cfg.APIPath = "/apis"
	if mapping.GroupVersionKind.Group == corev1.GroupName {
		cfg.APIPath = "/api"
	}
	gv := mapping.GroupVersionKind.GroupVersion()
	cfg.ContentConfig = resource.UnstructuredPlusDefaultContentConfig()
	cfg.GroupVersion = &gv
	return restclient.RESTClientFor(cfg)
}

factory实现类获取各种client和config

k8s use-context是什么 kubectl的命令用于在 Kubernetes 集群中切换上下文(context),从而方便地在多个集群或命名空间之间进行操作。一个上下文定义了kubectl使用的和的组合。 阅读详情

相关推荐

Kubernetes Kubectl top 命令

kubectl top命令可显⽰节点和Pod对象的资源使⽤信息,它依赖于集群中的资源指标API来收集各项指标数据。它包含有node和pod两个⼦命令,可分别⽤于显⽰Node对象和Pod对象的相关资源占⽤率。,例如下⾯显⽰所有节点的资源占⽤状况的结果中显⽰了各节点累计CPU资源占⽤时长及百分⽐,以及内容空间占⽤量及占⽤⽐例。⽽名称空间级别的Pod对象资源占⽤率的使⽤⽅式会略有不同,使⽤时,⼀般应该限定名称空间及使⽤标签选择器过滤出⽬标Pod对象。列出Node资源占⽤率命令的语法格式为。

专注基础架构领域 2551

k8s实战之kubectl

本课程将详细介绍k8s所有命令,以及命令的go源码分析,学习知其然,知其所以然

Win11安装Office2021

windows11安装office2021。

1万+

helm源码分析之pull

发布一个k8s部署视频:https://edu.csdn.net/course/detail/26967 课程内容:各种k8s部署方式。包括minikube部署,kubeadm部署,kubeasz部署,rancher部署,k3s部署。包括开发测试环境部署k8s,和生产环境部署k8s。 腾讯课堂连接地址https://ke.qq.com/course/478827?taid=4373109931462251&tuin=ba64518 第二个视频发布https://edu.csdn.net/c..

mark's technic world 1370

别光看教程了!手把手带你用STM32F103C8T6最小系统板点亮第一个LED(附完整电路图)

本文详细介绍了如何使用STM32F103C8T6最小系统板点亮第一个LED,从硬件连接到软件开发环境搭建,再到编写和下载程序,手把手教你完成STM32入门的第一步。适合初学者快速上手STM32开发,附完整电路图和代码示例。

weixin_28678831的博客 196

EBOM转MBOM实战:华为云数字工厂如何5步搞定BOM自动转换(含避坑指南)

本文详细解析了华为云数字工厂平台如何通过五步自动化流程实现EBOM到MBOM的高效转换,涵盖模型预配置、逻辑流编排、工艺属性注入等关键步骤,并提供了多工厂差异化配置、历史数据迁移等典型场景的避坑指南。该方案显著提升转换效率,降低差错率,助力企业实现数字化转型。

weixin_29215391的博客 271

Kubernetes 源码分析之 Kubectl

1. 概述 本文以Kubernetes 1.9 进行分析。 Kubernetes 是采用微服务以集群的方式运行,并为用户提供服务。而与外界交互则是通过Apiserver模块向外提供接口支持。 kubectl用户与Kubernetes交互的命令行工具。用户使用kubectl工具调用Apiserver的接口来与Kubernetes服务进行交互。 2. 结构分析 Kubectl 依赖于cobra包构建命令行支持,该包是支持通用的命令行构建库。 如下所示 mds是kubectl中的命令集合,所有命令都会整理在里面

小太阳啊凯的博客 660

心理学量表汇总 50多个 附下载

目录一、心理健康与精神病态量表二、行为问题量表三、人格评估量表四、智力测验一、心理健康与精神病态量表1.一般症状自评量表(SCL-90)症状自评量表 (The self-report symptom inventory ,Symptom checklist ,90,简称 SCL90) 有 90 个评定项目 , 每个项目分五级评分 , 包含了比较广泛的精神病症状学内容, 从感觉、 情 感、思维、意识、行为直至生活习惯、人际关系、饮食等均有涉及,能准确刻划被试的自觉 症状,能较好地反映被试的问题及其严重程度和变

南七小僧的学海无涯 1905

kubectl源码分析之apply

发布一个k8s部署视频:https://edu.csdn.net/course/detail/26967 课程内容:各种k8s部署方式。包括minikube部署,kubeadm部署,kubeasz部署,rancher部署,k3s部署。包括开发测试环境部署k8s,和生产环境部署k8s。 腾讯课堂连接地址https://ke.qq.com/course/478827?taid=4373109931462251&tuin=ba64518 第二个视频发布https://edu.csdn.net/c..

mark's technic world 1809

人形机器人维护保养指南:硬件工程师必备手册

随着科技的不断进步,人形机器人在各个领域的应用越来越广泛。本指南的目的是为硬件工程师提供一份系统、全面的人形机器人维护保养手册,涵盖从基础概念到实际操作的各个方面,帮助工程师们更好地理解和处理人形机器人在使用过程中出现的各种问题,确保机器人的正常运行。本文将首先介绍人形机器人维护保养涉及的核心概念,解释各硬件组件的原理和它们之间的关系;接着阐述维护保养的核心算法原理和具体操作步骤,结合数学模型进行详细讲解;然后通过项目实战案例展示如何在实际中应用这些知识;

AI天才研究院 965

加权均值向量算法(INFO)详解:从数学原理到智能算法

本文系统介绍了加权均值向量算法(INFO)的理论基础、数学模型与实现应用。该算法基于加权均值数学概念,通过MeanRule规则平衡探索与开发能力,具有结构新颖、参数合理的特点。核心内容包括:1) 算法理论基础,阐述加权均值数学定义与小波函数权重计算;2) 算法原理,详细解析更新规则、向量组合和局部搜索三阶段数学模型;3) 实现方法,提供MATLAB代码关键参数解析;4) 改进方向,介绍INFO-KELM混合模型等变体;5) 应用案例,涵盖函数优化、工程设计与机器学习领域。

qq_42212808的博客 235

【原创】k8s源码分析-----kubectl(2)Factory

本文QQ空间的链接:http://user.qzone.qq.com/29185807/blog/1461036130 本文csdn博文的链接:http://blog.csdn.net/screscent/article/details/51188790   源码为k8s v1.1.1   1、原因 首先讲讲为啥,我们要讲解Factory 代码在k8s.io\kubernetes\c...

月牙寂 7993

21、二维卷积层(convolution2dLayer)的全面解析

本文全面解析了二维卷积层(convolution2dLayer)的原理、属性和应用,详细介绍了其在深度学习中的作用及实现方法。文章涵盖创建卷积层的语法、参数设置、算法原理、输入输出格式、优化策略以及实际应用案例,旨在帮助读者更好地理解和应用二维卷积层构建高效的深度学习模型。

red88的博客 326

k8s源码分析——kubectl主要框架

代码版本:1.13 先整体的流程走一遍,不需要太过于关系细节,先整体把握整体的流程概念,后续在一步一步分析。 1. main 先从main函数开始,代码在k8s.io\kubernetes\cmd\kubectl\kubectl.go main函数中调用了NewDefaultKubectlCommand函数,该函数的实现在: /pkg/kubectl/cmd/cmd.go中: 该函数调用...

cbmljs的博客 3379

姿态传感器/陀螺仪之LSM6DSLTR应用驱动程序设计

* LSM6DSLTR I2C地址(SA0=1) *//* 初始化LSM6DSLTR传感器(加速度计±2g,陀螺仪±250°/s) *//* 加速度计灵敏度 *//* 角速度值(°/s) *//* I2C句柄 *//* 陀螺仪灵敏度 *//* 加速度值(g) *//* 温度值(°C) *//* 设备地址 *//* IF_INC=1: 自动增量地址 *//* 10Hz采样率 *//* 配置I2C1引脚:PB6->SCL, PB7->SDA *//* 转换为实际温度值(°C),参考手册中温度计算公式 */

corlin6688的博客 396

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

【原创】k8s源码分析-----kubectl(3)主要框架

本文QQ空间的链接:http://user.qzone.qq.com/29185807/blog/1461123088 本文csdn博文的链接:http://blog.csdn.net/screscent/article/details/51199351   源码为k8s v1.1.1   1、整体流程 我们先整体的流程走一遍,不用太过于关心看不看的懂,先有个整体的流程概念,后续再一步...

月牙寂 9597

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

Kubernetes CLI 插件 - kubectl 源码分析与入门教程

Kubernetes CLI 插件 - kubectl 源码分析与入门教程 项目概述 kubectl 是一个基于 Kubernetes 的 CLI 工具插件,它扩展了 kubectl 命令的功能,尽管原链接指向的是一个特定用户的仓库,真实的 kubectl 官方仓库位于 kubernetes/kubectl,但为了符合您的要求,我们将假设您想要了解一个类似自定义扩展或第三方插件的结构与配置说明。...

gitblog_00058的博客 416

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

【原创】k8s源码分析-----kubectl(1)api.RESTMapper

  本文QQ空间链接:http://user.qzone.qq.com/29185807/blog/1460961715 本文csdn博文链接:http://blog.csdn.net/screscent/article/details/51179485 源码为k8s v1.1.1稳定版本   api. RESTMapper是kube-apiserver和kubectl的基础,在讲解ku...

月牙寂 1万+

kubectl 源码分析 -- version子命令

kubectl version代码分析

oneslide 855

Kubernetes源码之kubectl剖析

1.kubectl作用 2.源码模板 3.关键源码剖析

枫 2883

kubectl get pod 源码分析

kubectl get pod printers.go文件printPod方法, 根据pod属性,状态进行转换 转载于:https://my.oschina.net/u/1263909/...

1609

kubectl源码分析之create configmap

发布一个k8s部署视频:https://edu.csdn.net/course/detail/26967 课程内容:各种k8s部署方式。包括minikube部署,kubeadm部署,kubeasz部署,rancher部署,k3s部署。包括开发测试环境部署k8s,和生产环境部署k8s。 腾讯课堂连接地址https://ke.qq.com/course/478827?taid=4373109931462251&tuin=ba64518 第二个视频发布https://edu.csdn.net/c..

mark's technic world 460

kubectl源码分析之create clusterrole

发布一个k8s部署视频:https://edu.csdn.net/course/detail/26967 课程内容:各种k8s部署方式。包括minikube部署,kubeadm部署,kubeasz部署,rancher部署,k3s部署。包括开发测试环境部署k8s,和生产环境部署k8s。 腾讯课堂连接地址https://ke.qq.com/course/478827?taid=4373109931462251&tuin=ba64518 第二个视频发布https://edu.csdn.net/c..

mark's technic world 531

kubectl源码解读

kubectl源码解读kubectl源码解读kubectl 入口函数NewDefaultKubectlCommand() -主函数的执行流程NewKubectlCommand() - 命令command对象的创建NewCmdCreate() - create命令详解RunCreate() -create的执行 kubectl源码解读 kubectl 入口函数 cmd/kubectl/kubectl.go func main() { // 如果不调用rand.Seed,每次重新运行这个main函数,rand

weixin_44726315的博客 1347

k8s-kubectl进程源码分析

kubectl与之前的kubernetes进程不同,它不是一个后台运行的守护进程,而是kubernetes提供的一个命令行工具(CLI),它提供了一组命令来操作kubernetes集群。kubectl入口类源码位置如下:/cmd/kubectl/kubectl.gofunc main() { rand.Seed(time.Now().UTC().UnixNano()) command := ...

hahachenchen789的博客 1767

k8s-kubectl功能源码分析

kubernetes里的命令行接口叫做kubectl,用来控制kubernetes集群,我们要追踪的命令是kubectl create -f-会从指定文件创建k8s资源,我们要创建的资源是使用了nginx基础镜像的单副本pod。首先是kubectl命令的创建,在/cmd/kubectl/kubectl.go文件中,实现了kubectl命令的创建:func main() { rand.Seed(t...

hahachenchen789的博客 1928
上一篇: 手写chart
下一篇: kubectl源码分析之create命令
hxpjava1
博客等级 码龄19年 1365粉丝 511原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

打赏作者

hxpjava1

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

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

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

打赏作者

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

抵扣说明:

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

余额充值