发布一个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/course/detail/27109
腾讯课堂连接地址https://ke.qq.com/course/484107?tuin=ba64518
介绍主要的k8s资源的使用配置和命令。包括configmap,pod,service,replicaset,namespace,deployment,daemonset,ingress,pv,pvc,sc,role,rolebinding,clusterrole,clusterrolebinding,secret,serviceaccount,statefulset,job,cronjob,podDisruptionbudget,podSecurityPolicy,networkPolicy,resourceQuota,limitrange,endpoint,event,conponentstatus,node,apiservice,controllerRevision等。
第三个视频发布:https://edu.csdn.net/course/detail/27574
详细介绍helm命令,学习helm chart语法,编写helm chart。深入分析各项目源码,学习编写helm插件
第四个课程发布:https://edu.csdn.net/course/detail/28488
本课程将详细介绍k8s所有命令,以及命令的go源码分析,学习知其然,知其所以然 ————————————————
type RenameContextOptions struct {//rename-context结构体 configAccess clientcmd.ConfigAccess contextName string newName string } //创建rename-context命令 func NewCmdConfigRenameContext(out io.Writer, configAccess clientcmd.ConfigAccess) *cobra.Command { options := &RenameContextOptions{configAccess: configAccess}//初始化结构体 cmd := &cobra.Command{//创建cobra命令 Use: renameContextUse, DisableFlagsInUseLine: true, Short: renameContextShort, Long: renameContextLong, Example: renameContextExample, Run: func(cmd *cobra.Command, args []string) { cmdutil.CheckErr(options.Complete(cmd, args, out))//准备 cmdutil.CheckErr(options.Validate())//校验 cmdutil.CheckErr(options.RunRenameContext(out))//运行 }, } return cmd } //准备 func (o *RenameContextOptions) Complete(cmd *cobra.Command, args []string, out io.Writer) error { if len(args) != 2 {//参数必须是2个 return helpErrorf(cmd, "Unexpected args: %v", args) } o.contextName = args[0]//设置原名称 o.newName = args[1]//设置新名称 return nil } // Validate makes sure that provided values for command-line options are valid //校验 func (o RenameContextOptions) Validate() error { if len(o.newName) == 0 {//新名称不能为空 return errors.New("You must specify a new non-empty context name") } return nil } //运行 func (o RenameContextOptions) RunRenameContext(out io.Writer) error { config, err := o.configAccess.GetStartingConfig()//加载config if err != nil { return err } configFile := o.configAccess.GetDefaultFilename()//获取config文件路径 if o.configAccess.IsExplicitFile() {//如果指定了kubecofnig configFile = o.configAccess.GetExplicitFile()//获取kubeconfig指定的文件路径 } context, exists := config.Contexts[o.contextName]//判断context是否存在 if !exists {//不存在报错 return fmt.Errorf("cannot rename the context %q, it's not in %s", o.contextName, configFile) } _, newExists := config.Contexts[o.newName]//判断新名称是否存在 if newExists {//如果存在报错 return fmt.Errorf("cannot rename the context %q, the context %q already exists in %s", o.contextName, o.newName, configFile) } config.Contexts[o.newName] = context//设置新context delete(config.Contexts, o.contextName)//删除旧context if config.CurrentContext == o.contextName {//如果旧context是正在使用的context config.CurrentContext = o.newName//正在使用的context设置为新名称 } if err := clientcmd.ModifyConfig(o.configAccess, *config, true); err != nil {//把配置写回文件 return err } fmt.Fprintf(out, "Context %q renamed to %q.\n", o.contextName, o.newName)// 打印结果 return nil }