diff --git a/2023/02/28/web/go/piwriw-blog/index.html b/2023/02/28/web/go/piwriw-blog/index.html index 9ff4f38eb..e486c64f7 100644 --- a/2023/02/28/web/go/piwriw-blog/index.html +++ b/2023/02/28/web/go/piwriw-blog/index.html @@ -162,7 +162,7 @@ } } detectApple() - })(window)

piwriw_blog

Piwriw Blog

+ })(window)

piwriw_blog

Piwriw Blog

@@ -289,7 +289,7 @@

Vue

作者

Piwriw

-

@Email:piwriw@163.com

+

@Email:piwriw@163.com

前端使用了 wejectchan的ginblog 并作出修改

鸣谢

avatar
Joohwan.
该知道的都知道,不知道的慢慢了解
Follow Me
公告
Please try your best!
来访者
打赏
  • alipay
    alipay

评论
- \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/01/cloud/kubeedge/Kubeedge-1_\350\276\271\347\274\230\350\256\241\347\256\227/index.html" "b/2023/03/01/cloud/kubeedge/Kubeedge-1_\350\276\271\347\274\230\350\256\241\347\256\227/index.html" index d3dc35455..42049c61e 100644 --- "a/2023/03/01/cloud/kubeedge/Kubeedge-1_\350\276\271\347\274\230\350\256\241\347\256\227/index.html" +++ "b/2023/03/01/cloud/kubeedge/Kubeedge-1_\350\276\271\347\274\230\350\256\241\347\256\227/index.html" @@ -165,7 +165,7 @@ } } detectApple() - })(window)

Kubeedge-边缘计算

why I write the series of kubeedge

-
文章作者: Joohwan.
文章链接: https://piwriw.github.io/2023/03/01/cloud/kubeedge/Kubeedge-1_边缘计算/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
打赏
  • alipay
    alipay

评论
打赏
  • alipay
    alipay

评论
avatar
Joohwan.
该知道的都知道,不知道的慢慢了解
Follow Me
来访者
- \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/01/cloud/kubeedge/Kubeedge-6_AI\345\215\217\345\220\214\345\255\220\351\241\271\347\233\256-Sedna/index.html" "b/2023/03/01/cloud/kubeedge/Kubeedge-6_AI\345\215\217\345\220\214\345\255\220\351\241\271\347\233\256-Sedna/index.html" index 589378d98..8a6188d98 100644 --- "a/2023/03/01/cloud/kubeedge/Kubeedge-6_AI\345\215\217\345\220\214\345\255\220\351\241\271\347\233\256-Sedna/index.html" +++ "b/2023/03/01/cloud/kubeedge/Kubeedge-6_AI\345\215\217\345\220\214\345\255\220\351\241\271\347\233\256-Sedna/index.html" @@ -165,7 +165,7 @@ } } detectApple() - })(window)

AI协同子项目-Sedna

Kubeedge - 6:AI协同子项目-Sedna

什么是 Sedna

- \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/02/web/go/Linux\351\203\250\347\275\262Go/index.html" "b/2023/03/02/web/go/Linux\351\203\250\347\275\262Go/index.html" index b8bfb0ada..d0f86f9c9 100644 --- "a/2023/03/02/web/go/Linux\351\203\250\347\275\262Go/index.html" +++ "b/2023/03/02/web/go/Linux\351\203\250\347\275\262Go/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

Linux部署Go

Linux部署Go

bash一键部署

bash地址

+ })(window)

Linux部署Go

Linux部署Go

bash一键部署

bash地址

下载

# 安装wget命令
yum install -y wget
# 在 ~ 下创建 go 文件夹,并进入 go 文件夹
mkdir ~/go && cd ~/go
# 下载的 go 压缩包
wget https://studygolang.com/dl/golang/go1.17.linux-amd64.tar.gz

解压

tar -C /usr/local -zxvf go1.17.0.linux-amd64.tar.gz
@@ -180,7 +180,7 @@

  • 运行项目:go run main.go
  • -

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/03/02/web/go/Linux部署Go/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/02/web/go/\346\225\260\346\215\256\345\272\223\347\257\207/index.html" "b/2023/03/02/web/go/\346\225\260\346\215\256\345\272\223\347\257\207/index.html" index 43f1d6db8..f727329c7 100644 --- "a/2023/03/02/web/go/\346\225\260\346\215\256\345\272\223\347\257\207/index.html" +++ "b/2023/03/02/web/go/\346\225\260\346\215\256\345\272\223\347\257\207/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    整合zap日志

    数据库(MySql)篇

    连接数据库

    	db, err := sql.Open("mysql", "root:root@tcp(127.0.0.1:3306)/DB_TEST")
    // 测试连接
    db.Ping()
    // 使用 defer 释放连接
    defer db.Close()
    ```
    ## insert 插入数据
    ```java
    db, err := sql.Open("mysql", "root:root@tcp(127.0.0.1:3306)/DB_TEST")
    db.Ping()
    defer db.Close()

    if err != nil {
    fmt.Println("数据库连接失败!")
    }

    _, err := db.Query("INSERT INTO user VALUES(1, 'test')")
    if err != nil {
    fmt.Println(err.Error())
    }

    + })(window)

    整合zap日志

    数据库(MySql)篇

    连接数据库

    	db, err := sql.Open("mysql", "root:root@tcp(127.0.0.1:3306)/DB_TEST")
    // 测试连接
    db.Ping()
    // 使用 defer 释放连接
    defer db.Close()
    ```
    ## insert 插入数据
    ```java
    db, err := sql.Open("mysql", "root:root@tcp(127.0.0.1:3306)/DB_TEST")
    db.Ping()
    defer db.Close()

    if err != nil {
    fmt.Println("数据库连接失败!")
    }

    _, err := db.Query("INSERT INTO user VALUES(1, 'test')")
    if err != nil {
    fmt.Println(err.Error())
    }

    select 查询所有数据

    db, err := sql.Open("mysql", "root:root@tcp(127.0.0.1:3306)/DB_TEST")
    db.Ping()
    defer db.Close()

    if err != nil {
    fmt.Println("数据库连接失败!")
    log.Fatalln(err)
    }

    result, err2 := db.Query("SELECT * FROM user")
    if err2 != nil {
    log.Fatal(err2)
    }

    for result.Next() {

    var id int
    var name string

    err = result.Scan(&id, &name)

    if err != nil {
    panic(err)
    }

    fmt.Printf("Id: %d, Name: %s\n", id, name)
    }

    where 条件查询

    result, err := db.Query("SELECT * FROM user WHERE id = ?", mid)
    @@ -173,7 +173,7 @@

    delete 删除

       sql := "DELETE FROM user WHERE id = 1"
    res, err := db.Exec(sql)
    // 获取删除的行数(收到sql影响的行数)
    affectedRows, err := res.RowsAffected()

    update 修改数据

       sql := "update user set name = ? WHERE id = ?"
    res, err2 := db.Exec(sql, "Yuzhou1su", 2)
    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/03/02/web/go/数据库篇/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/02/web/go/\346\225\264\345\220\210JWT/index.html" "b/2023/03/02/web/go/\346\225\264\345\220\210JWT/index.html" index 0b58317dd..8380c4eb7 100644 --- "a/2023/03/02/web/go/\346\225\264\345\220\210JWT/index.html" +++ "b/2023/03/02/web/go/\346\225\264\345\220\210JWT/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    整合JWT

    整合JWT

    What is JWT

      + })(window)

      整合JWT

      整合JWT

      What is JWT

      • JWT 是 JSON Web Token 的缩写,是为了在⽹络应⽤环境间传递声明⽽执⾏的⼀种基于JSON的开放标准((RFC 7519)。JWT 本身没有定义任何技术实现,它只是定义了⼀种基于 Token 的会话管理的规则,涵盖 Token 需要包含的标准内容和 Token 的⽣成过程,特别适⽤于分布式站点的单点登录(SSO)场景
      • 一段JWT Token 由”.”切割成头部、负载、签名三部分
      @@ -199,7 +199,7 @@

      GenTokenWithRefreshToken 生成RefreshToken


      // GenTokenWithRefreshToken : 生成Access token 和 RefreshToken
      func GenTokenWithRefreshToken(userID int64) (acToken, reToken string, err error) {
      c := MyClaims{
      userID,
      "username",
      jwt.StandardClaims{
      ExpiresAt: time.Now().Add(TokenExpireTime).Unix(), //签发日期
      Issuer: "Piwirw", //签发人
      },
      }
      // 加密并获得编码Token
      acToken, err = jwt.NewWithClaims(jwt.SigningMethodES256, c).SignedString(mySecret)

      // refresh token 不需要存储子自定义数据
      reToken, err = jwt.NewWithClaims(jwt.SigningMethodES256, jwt.StandardClaims{
      ExpiresAt: time.Now().Add(time.Second * 30).Unix(), // 过期时间
      Issuer: "Piwriw", //签发人
      }).SignedString(mySecret)
      // 使用自定secret签名并获得完整后的Token
      return
      }

      // ParseToken2 : 解析Access Token
      func ParseToken2(tokenString string)(claims *MyClaims,err error) {
      // 解析tokenn
      var token *jwt.Token
      claims=new(MyClaims)
      token,err=jwt.ParseWithClaims(tokenString,claims, func(token *jwt.Token) (i interface{}, err error) {
      // 直接使用标准的Claim则可以直接使用Parse方法
      //token, err := jwt.Parse(tokenString, func(token *jwt.Token) (i interface{}, err error) {
      return mySecret, nil
      })
      if err != nil {
      return
      }
      if !token.Valid {
      err=errors.New("Invalid token")
      }
      return
      }

      RefreshToken 刷新token


      // RefreshToken : 刷新RefreshToken
      func RefreshToken(acToken, reToken string) (newToken, newReToken string, err error) {
      // refresh token is invalid returnn
      _,err=jwt.Parse(reToken,func(token *jwt.Token) (i interface{}, err error) {
      // 直接使用标准的Claim则可以直接使用Parse方法
      //token, err := jwt.Parse(tokenString, func(token *jwt.Token) (i interface{}, err error) {
      return mySecret, nil
      })
      if err!=nil{
      return
      }
      // 从 older access token 解析出claims
      var claims MyClaims
      _,err=jwt.ParseWithClaims(acToken,&claims,func(token *jwt.Token) (i interface{}, err error) {
      // 直接使用标准的Claim则可以直接使用Parse方法
      //token, err := jwt.Parse(tokenString, func(token *jwt.Token) (i interface{}, err error) {
      return mySecret, nil
      })
      v,_:=err.(*jwt.ValidationError)
      // 当access token is 过期错误并且 refresh token 没有过期 ->>>create a new access token
      if v.Errors==jwt.ValidationErrorExpired{
      return GenTokenWithRefreshToken(claims.UserID)
      }
      return
      }

      ParseToken 解析Access Token


      // ParseToken2 : 解析Access Token
      func ParseToken2(tokenString string)(claims *MyClaims,err error) {
      // 解析tokenn
      var token *jwt.Token
      claims=new(MyClaims)
      token,err=jwt.ParseWithClaims(tokenString,claims, func(token *jwt.Token) (i interface{}, err error) {
      // 直接使用标准的Claim则可以直接使用Parse方法
      //token, err := jwt.Parse(tokenString, func(token *jwt.Token) (i interface{}, err error) {
      return mySecret, nil
      })
      if err != nil {
      return
      }
      if !token.Valid {
      err=errors.New("Invalid token")
      }
      return
      }
      -
      文章作者: Joohwan.
      文章链接: https://piwriw.github.io/2023/03/02/web/go/整合JWT/
      版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
      打赏
      • alipay
        alipay

      评论
      打赏
      • alipay
        alipay

      评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/02/web/go/\346\225\264\345\220\210Swagger/index.html" "b/2023/03/02/web/go/\346\225\264\345\220\210Swagger/index.html" index d16f7686b..7e357a3bc 100644 --- "a/2023/03/02/web/go/\346\225\264\345\220\210Swagger/index.html" +++ "b/2023/03/02/web/go/\346\225\264\345\220\210Swagger/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    整合Swagger

    整合Swagger

    What is Swagger

    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/02/web/go/\346\225\264\345\220\210sql\345\222\214sqlx/index.html" "b/2023/03/02/web/go/\346\225\264\345\220\210sql\345\222\214sqlx/index.html" index 86f2317d5..2f60db0a0 100644 --- "a/2023/03/02/web/go/\346\225\264\345\220\210sql\345\222\214sqlx/index.html" +++ "b/2023/03/02/web/go/\346\225\264\345\220\210sql\345\222\214sqlx/index.html" @@ -165,7 +165,7 @@ } } detectApple() - })(window)

    整合sql和sqlx

    整合sql和sqlx

    What is sqlx

    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/02/web/go/\346\225\264\345\220\210validation\345\272\223/index.html" "b/2023/03/02/web/go/\346\225\264\345\220\210validation\345\272\223/index.html" index f5a131cb4..e5020f309 100644 --- "a/2023/03/02/web/go/\346\225\264\345\220\210validation\345\272\223/index.html" +++ "b/2023/03/02/web/go/\346\225\264\345\220\210validation\345\272\223/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    整合validation库

    整合validation库

    Background

      + })(window)

      整合validation库

      整合validation库

      Background

      • 利用validation库进行对参数校验,减少业务逻辑的手动校验

      Get validation

        @@ -500,7 +500,7 @@

        All Examle Code

        package controller

        import (

        "fmt"
        "github.com/gin-gonic/gin/binding"
        "github.com/go-playground/locales/en"
        "github.com/go-playground/locales/zh"
        ut "github.com/go-playground/universal-translator"
        "github.com/go-playground/validator/v10"
        enTranslations "github.com/go-playground/validator/v10/translations/en"
        zhTranslations "github.com/go-playground/validator/v10/translations/zh"
        "reflect"
        "strings"
        )

        // 定义一个全局翻译器T
        var trans ut.Translator

        // InitTrans 初始化翻译器
        func InitTrans(locale string) (err error) {
        // 修改gin框架中的Validator引擎属性,实现自定制
        if v, ok := binding.Validator.Engine().(*validator.Validate); ok {

        // 注册一个获取json tag的自定义方法
        v.RegisterTagNameFunc(func(fld reflect.StructField) string {
        name := strings.SplitN(fld.Tag.Get("json"), ",", 2)[0]
        if name == "-" {
        return ""
        }
        return name
        })
        // 给SignUpParam注册自定义校验方法
        v.RegisterStructValidation(SignUpParamStructLevelValidation,models.ParamSignUp{})

        zhT := zh.New() // 中文翻译器
        enT := en.New() // 英文翻译器

        // 第一个参数是备用(fallback)的语言环境
        // 后面的参数是应该支持的语言环境(支持多个)
        // uni := ut.New(zhT, zhT) 也是可以的
        uni := ut.New(enT, zhT, enT)

        // locale 通常取决于 http 请求头的 'Accept-Language'
        var ok bool
        // 也可以使用 uni.FindTranslator(...) 传入多个locale进行查找
        trans, ok = uni.GetTranslator(locale)
        if !ok {
        return fmt.Errorf("uni.GetTranslator(%s) failed", locale)
        }

        // 注册翻译器
        switch locale {
        case "en":
        err = enTranslations.RegisterDefaultTranslations(v, trans)
        case "zh":
        err = zhTranslations.RegisterDefaultTranslations(v, trans)
        default:
        err = enTranslations.RegisterDefaultTranslations(v, trans)
        }
        return
        }
        return
        }
        // removeTopStruct: 去除提示信息中的结构体名称
        func removeTopStruct(fields map[string]string) map[string]string {
        res := map[string]string{}
        for field, err := range fields {
        res[field[strings.Index(field, ".")+1:]] = err
        }
        return res
        }

        // SignUpParamStructLevelValidation 自定义SignUpParam结构体校验函数
        func SignUpParamStructLevelValidation(sl validator.StructLevel) {
        su := sl.Current().Interface().(models.ParamSignUp)

        if su.Password != su.RePassword {
        // 输出错误提示信息,最后一个参数就是传递的param
        sl.ReportError(su.RePassword, "re_password", "RePassword", "eqfield", "password")
        }
        }
        -
      文章作者: Joohwan.
      文章链接: https://piwriw.github.io/2023/03/02/web/go/整合validation库/
      版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
      打赏
      • alipay
        alipay

      评论
      avatar
      Joohwan.
      该知道的都知道,不知道的慢慢了解
      Follow Me
      公告
      Please try your best!
      来访者
      打赏
      • alipay
        alipay

      评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/02/web/go/\346\225\264\345\220\210zap\346\227\245\345\277\227/index.html" "b/2023/03/02/web/go/\346\225\264\345\220\210zap\346\227\245\345\277\227/index.html" index e5fbb9c92..cbc6c943b 100644 --- "a/2023/03/02/web/go/\346\225\264\345\220\210zap\346\227\245\345\277\227/index.html" +++ "b/2023/03/02/web/go/\346\225\264\345\220\210zap\346\227\245\345\277\227/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    整合zap日志

    整合zap日志

    To Get zap

    go get go.uber.org/zap

    + })(window)

    整合zap日志

    整合zap日志

    To Get zap

    go get go.uber.org/zap

    Fast Use

    全局loggger

    logger, _ := zap.NewProduction()
    defer logger.Sync() // 将 buffer 中的日志写到文件中
    logger.Info("this is a test log")

    Zap.S 和 Zap.L

    zap.SugarLogger

    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/02/web/go/\346\225\264\345\220\210\347\203\255\345\212\240\350\275\275/index.html" "b/2023/03/02/web/go/\346\225\264\345\220\210\347\203\255\345\212\240\350\275\275/index.html" index c0b337d48..dd08eae5d 100644 --- "a/2023/03/02/web/go/\346\225\264\345\220\210\347\203\255\345\212\240\350\275\275/index.html" +++ "b/2023/03/02/web/go/\346\225\264\345\220\210\347\203\255\345\212\240\350\275\275/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    整合热加载

    整合热加载

    热加载 和 热部署

    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/02/web/go/\346\225\264\345\220\210\347\256\241\347\220\206\351\205\215\347\275\256 - viper/index.html" "b/2023/03/02/web/go/\346\225\264\345\220\210\347\256\241\347\220\206\351\205\215\347\275\256 - viper/index.html" index 8c670cf22..3d4d94e83 100644 --- "a/2023/03/02/web/go/\346\225\264\345\220\210\347\256\241\347\220\206\351\205\215\347\275\256 - viper/index.html" +++ "b/2023/03/02/web/go/\346\225\264\345\220\210\347\256\241\347\220\206\351\205\215\347\275\256 - viper/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    整合管理配置 - viper

    整合管理配置 - viper

    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/02/web/go/\350\207\252\345\256\232\344\271\211\344\270\232\345\212\241\347\212\266\346\200\201\347\240\201/index.html" "b/2023/03/02/web/go/\350\207\252\345\256\232\344\271\211\344\270\232\345\212\241\347\212\266\346\200\201\347\240\201/index.html" index c5f077d88..60b86aab6 100644 --- "a/2023/03/02/web/go/\350\207\252\345\256\232\344\271\211\344\270\232\345\212\241\347\212\266\346\200\201\347\240\201/index.html" +++ "b/2023/03/02/web/go/\350\207\252\345\256\232\344\271\211\344\270\232\345\212\241\347\212\266\346\200\201\347\240\201/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    自定义业务状态码

    自定义业务状态码

    业务状态码和HTTP状态码

    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/02/web/go/\351\231\220\346\265\201\347\255\226\347\225\245/index.html" "b/2023/03/02/web/go/\351\231\220\346\265\201\347\255\226\347\225\245/index.html" index afcfadc57..4ab6a6387 100644 --- "a/2023/03/02/web/go/\351\231\220\346\265\201\347\255\226\347\225\245/index.html" +++ "b/2023/03/02/web/go/\351\231\220\346\265\201\347\255\226\347\225\245/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    整合限流策略

    整合限流策略

    限流

    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/05/cloud/kubeedge/Kubeedge-2_\351\203\250\347\275\262\345\256\211\350\243\205KubeEdge/index.html" "b/2023/03/05/cloud/kubeedge/Kubeedge-2_\351\203\250\347\275\262\345\256\211\350\243\205KubeEdge/index.html" index 19425682c..78df5c37f 100644 --- "a/2023/03/05/cloud/kubeedge/Kubeedge-2_\351\203\250\347\275\262\345\256\211\350\243\205KubeEdge/index.html" +++ "b/2023/03/05/cloud/kubeedge/Kubeedge-2_\351\203\250\347\275\262\345\256\211\350\243\205KubeEdge/index.html" @@ -165,7 +165,7 @@ } } detectApple() - })(window)

    部署安装KubeEdge

    Kubeedge - 2: 部署安装KubeEdge

    KubeEdge 部署环境

    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/05/cloud/kubeedge/Kubeedge-3_\351\203\250\347\275\262\345\256\211\350\243\205EdgeMesh/index.html" "b/2023/03/05/cloud/kubeedge/Kubeedge-3_\351\203\250\347\275\262\345\256\211\350\243\205EdgeMesh/index.html" index adb40c020..a64ef4882 100644 --- "a/2023/03/05/cloud/kubeedge/Kubeedge-3_\351\203\250\347\275\262\345\256\211\350\243\205EdgeMesh/index.html" +++ "b/2023/03/05/cloud/kubeedge/Kubeedge-3_\351\203\250\347\275\262\345\256\211\350\243\205EdgeMesh/index.html" @@ -165,7 +165,7 @@ } } detectApple() - })(window)

    部署安装EdgeMesh

    Kubeedge - 3: 部署安装EdgeMesh

    什么是EdgeMesh

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/03/05/cloud/kubeedge/Kubeedge-3_部署安装EdgeMesh/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/12/cloud/kubeedge/Kubeedge-4_\347\216\251\350\275\254Devicetwin/index.html" "b/2023/03/12/cloud/kubeedge/Kubeedge-4_\347\216\251\350\275\254Devicetwin/index.html" index 86f2a41ac..9bbb5ada3 100644 --- "a/2023/03/12/cloud/kubeedge/Kubeedge-4_\347\216\251\350\275\254Devicetwin/index.html" +++ "b/2023/03/12/cloud/kubeedge/Kubeedge-4_\347\216\251\350\275\254Devicetwin/index.html" @@ -165,7 +165,7 @@ } } detectApple() - })(window)

    玩转 Device twin

    Kubeedge - 4: 玩转 Device twin

    什么是 Device twin

    Device twin

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/03/12/cloud/kubeedge/Kubeedge-4_玩转Devicetwin/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/12/cloud/kubeedge/Kubeedge-5_\347\216\251\350\275\254Router/index.html" "b/2023/03/12/cloud/kubeedge/Kubeedge-5_\347\216\251\350\275\254Router/index.html" index bca0d0916..6faac79f8 100644 --- "a/2023/03/12/cloud/kubeedge/Kubeedge-5_\347\216\251\350\275\254Router/index.html" +++ "b/2023/03/12/cloud/kubeedge/Kubeedge-5_\347\216\251\350\275\254Router/index.html" @@ -165,7 +165,7 @@ } } detectApple() - })(window)

    玩转 Router

    Kubeedge - 5: 玩转 Router

    什么是 Router

    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/13/web/go/Gin\344\270\255session\345\222\214cookies/index.html" "b/2023/03/13/web/go/Gin\344\270\255session\345\222\214cookies/index.html" index 2b966fc46..54aa3037e 100644 --- "a/2023/03/13/web/go/Gin\344\270\255session\345\222\214cookies/index.html" +++ "b/2023/03/13/web/go/Gin\344\270\255session\345\222\214cookies/index.html" @@ -166,7 +166,7 @@ } } detectApple() - })(window)

    Gin中session和cookies

    Gin中session和cookies

    session

    什么是session

    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/03/13/web/go/Gin\344\270\255\351\227\264\344\273\266/index.html" "b/2023/03/13/web/go/Gin\344\270\255\351\227\264\344\273\266/index.html" index 3b51b3dae..90cbc088b 100644 --- "a/2023/03/13/web/go/Gin\344\270\255\351\227\264\344\273\266/index.html" +++ "b/2023/03/13/web/go/Gin\344\270\255\351\227\264\344\273\266/index.html" @@ -165,7 +165,7 @@ } } detectApple() - })(window)

    Gin中间件

    Gin中间件

    内置中间件

    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/06/10/cloud/k8s/K8s\345\246\202\344\275\225\346\224\257\346\214\201\345\205\254\347\275\221\350\256\277\351\227\256/index.html" "b/2023/06/10/cloud/k8s/K8s\345\246\202\344\275\225\346\224\257\346\214\201\345\205\254\347\275\221\350\256\277\351\227\256/index.html" index 3e574ac60..024335d19 100644 --- "a/2023/06/10/cloud/k8s/K8s\345\246\202\344\275\225\346\224\257\346\214\201\345\205\254\347\275\221\350\256\277\351\227\256/index.html" +++ "b/2023/06/10/cloud/k8s/K8s\345\246\202\344\275\225\346\224\257\346\214\201\345\205\254\347\275\221\350\256\277\351\227\256/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    K8s如何支持公网访问

    K8s如何支持公网访问

    因为k8s默认启动支持内网ip,下面是三种 让k8s支持公网访问的模式

    + })(window)

    K8s如何支持公网访问

    K8s如何支持公网访问

    因为k8s默认启动支持内网ip,下面是三种 让k8s支持公网访问的模式

    keadm init添加参数

    # 未实践
    kubeadm init --apiserver-advertise-address= 内网ip --apiserver-cert-extra-sans 公网ip --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.19.4 --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16

    重新生成apiserver证书

      @@ -207,7 +207,7 @@

      整合上述可:

      func InitK8sClient() error {
      var err error
      switch setting.Conf.K8sConfig.AuthModel {
      case "token":
      err = ClientWithToken()
      case "config":
      err = ClientWithConfig()
      default:
      return errors.New("目前只支持 token | config")
      }
      if err!=nil{
      return err
      }
      return nil
      }
      func ClientWithConfig() error {
      kubeconifg := ".kube/config"
      flag.Parse()

      // use the current context in kubeconfig
      config, err := clientcmd.BuildConfigFromFlags("", kubeconifg)
      if err != nil {
      return err
      }

      // create the clientset
      clientSet, err = kubernetes.NewForConfig(config)
      if err != nil {
      return err
      }

      configLoader, err := cf.NewKubeConfigLoaderFromYAMLFile(kubeconifg, false)

      configuration, err := configLoader.LoadAndSet()

      ctx = context.Background()
      //ctx = context.WithValue(ctx, client.ContextAPIKey, client.APIKey{Key: "Bearer " + string(token), Prefix: ""})
      clientAPI = client.NewAPIClient(configuration)
      return nil
      }

      func ClientWithToken() error {
      token, err := ioutil.ReadFile(setting.Conf.K8sConfig.TokenPath)
      if err != nil {
      return err
      }

      config := &rest.Config{
      Host: fmt.Sprintf("https://%s:6443", setting.Conf.K8sConfig.Host),
      BearerToken: string(token),
      TLSClientConfig: rest.TLSClientConfig{
      Insecure: true, // 设置为true时 不需要CA
      CAData: []byte(""),
      },
      }
      clientSet2, err := kubernetes.NewForConfig(config)
      clientSet = clientSet2
      if err != nil {
      return err
      }
      configuration := &client.Configuration{
      BasePath: fmt.Sprintf("https://%s:6443", setting.Conf.K8sConfig.Host),
      DefaultHeader: map[string]string{
      "Authorization": fmt.Sprintf("Bearer %s", string(token)),
      },
      HTTPClient: &http.Client{
      Transport: &http.Transport{
      TLSClientConfig: &tls.Config{
      InsecureSkipVerify: true,
      },
      },
      },
      }
      clientAPI = client.NewAPIClient(configuration)
      return nil
      }
      -

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/06/10/cloud/k8s/K8s如何支持公网访问/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/06/18/web/go/\345\276\256\346\234\215\345\212\241\344\271\213\346\263\250\345\206\214\344\270\255\345\277\203/index.html" "b/2023/06/18/web/go/\345\276\256\346\234\215\345\212\241\344\271\213\346\263\250\345\206\214\344\270\255\345\277\203/index.html" index a8f65f3b6..c409c6300 100644 --- "a/2023/06/18/web/go/\345\276\256\346\234\215\345\212\241\344\271\213\346\263\250\345\206\214\344\270\255\345\277\203/index.html" +++ "b/2023/06/18/web/go/\345\276\256\346\234\215\345\212\241\344\271\213\346\263\250\345\206\214\344\270\255\345\277\203/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    微服务之注册中心

    微服务之注册中心

    什么是注册中心

    注册中心的作用一句话概括就是存放和调度服务,实现服务和注册中心,服务和服务之间的相互通信

    + })(window)

    微服务之注册中心

    微服务之注册中心

    什么是注册中心

    注册中心的作用一句话概括就是存放和调度服务,实现服务和注册中心,服务和服务之间的相互通信

    常见的几种注册中心

    @@ -217,7 +217,7 @@

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/06/18/web/go/微服务之注册中心/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/06/19/web/go/\345\276\256\346\234\215\345\212\241\344\271\213\351\205\215\347\275\256\344\270\255\345\277\203/index.html" "b/2023/06/19/web/go/\345\276\256\346\234\215\345\212\241\344\271\213\351\205\215\347\275\256\344\270\255\345\277\203/index.html" index 2e3659e90..f19ac4418 100644 --- "a/2023/06/19/web/go/\345\276\256\346\234\215\345\212\241\344\271\213\351\205\215\347\275\256\344\270\255\345\277\203/index.html" +++ "b/2023/06/19/web/go/\345\276\256\346\234\215\345\212\241\344\271\213\351\205\215\347\275\256\344\270\255\345\277\203/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    微服务之配置中心

    微服务之配置中心

    为什么需要配置中心

      + })(window)

      微服务之配置中心

      打赏
      • alipay
        alipay

      评论
      avatar
      Joohwan.
      该知道的都知道,不知道的慢慢了解
      Follow Me
      公告
      Please try your best!
      来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/06/19/web/go/\350\264\237\350\275\275\345\235\207\350\241\241/index.html" "b/2023/06/19/web/go/\350\264\237\350\275\275\345\235\207\350\241\241/index.html" index c5f645977..ab7e2905f 100644 --- "a/2023/06/19/web/go/\350\264\237\350\275\275\345\235\207\350\241\241/index.html" +++ "b/2023/06/19/web/go/\350\264\237\350\275\275\345\235\207\350\241\241/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    微服务之配置中心

    负载均衡

    什么是负载均衡

    负载均衡是将网络流量分发到多个后台服务的一种机制。通过负载均衡的流量分发,降低了单台服务器的负载,减少了应用的响应时间

    + })(window)

    微服务之配置中心

    负载均衡

    什么是负载均衡

    负载均衡是将网络流量分发到多个后台服务的一种机制。通过负载均衡的流量分发,降低了单台服务器的负载,减少了应用的响应时间

    20230618122934

    负载均衡类型

    集中式Load balance

    集中式LB方案,如下图。首先,服务的消费方和提供方不直接耦合,而是在服务消费者和服务提供者之间有一个独立的LB(LB通常是专门的硬件设备如F5,或者基于软件如LVS,HAproxy等实现)。

    20230618144003

    @@ -197,7 +197,7 @@

    最小连接数法

    前面我们费尽心思来实现服务消费者请求次数分配的均衡,我们知道这样做是没错的,可以为后端的多台服务器平均分配工作量,最大程度地提高服务器的利用率,但是,实际上,请求次数的均衡并不代表负载的均衡。因此我们需要介绍最小连接数法,最小连接数法比较灵活和智能,由于后台服务器的配置不尽相同,对请求的处理有快有慢,它正是根据后端服务器当前的连接情况,动态的选取其中当前积压连接数最少的一台服务器来处理当前请求,尽可能的提高后台服务器利用率,将负载合理的分流到每一台服务器。

    GRPC与负载均衡

    配置grpc中的负载均衡


    import (
    "fmt"
    "github.com/hashicorp/consul/api"
    "go.uber.org/zap"
    "google.golang.org/grpc"
    "google.golang.org/grpc/credentials/insecure"
    "shop_api/user-web/global"
    "shop_api/user-web/proto"
    )

    // InitSrvConn 配置了负载均衡的grpc client
    func InitSrvConn() error {
    consulInfo := global.AppConf.Consul
    userConn, err := grpc.Dial(fmt.Sprintf("consul://%s:%d/%s?wait=14s", consulInfo.IP, consulInfo.Port, global.AppConf.System.Name),
    grpc.WithTransportCredentials(insecure.NewCredentials()),
    grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy":"round_robin"`))
    if err != nil {
    zap.S().Errorw("[InitSrvConn] 连接 【用户服务失败】", "msg", err.Error())
    return err
    }
    global.UserSrvClient = proto.NewUserClient(userConn)
    return nil
    }
    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/06/19/web/go/负载均衡/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/06/23/tools/Git \350\247\204\350\214\203/index.html" "b/2023/06/23/tools/Git \350\247\204\350\214\203/index.html" index 10efdb169..d87b88e00 100644 --- "a/2023/06/23/tools/Git \350\247\204\350\214\203/index.html" +++ "b/2023/06/23/tools/Git \350\247\204\350\214\203/index.html" @@ -162,7 +162,7 @@ } } detectApple() - })(window)

    Git 规范

    Git 规范

    为什么需要git规范

    遵循 Git Commit 规范可以提高团队协作效率和代码库的可维护性。 通过明确的 Commit 类型和格式,开发者能够更轻松地理解每个提交所带来的更改,并能够快速回溯和回滚代码。 建议团队在项目中制定统一的 Git Commit 规范,并通过培训和代码审查来确保规范的遵循

    + })(window)

    Git 规范

    Git 规范

    为什么需要git规范

    遵循 Git Commit 规范可以提高团队协作效率和代码库的可维护性。 通过明确的 Commit 类型和格式,开发者能够更轻松地理解每个提交所带来的更改,并能够快速回溯和回滚代码。 建议团队在项目中制定统一的 Git Commit 规范,并通过培训和代码审查来确保规范的遵循

    git规范

    1. 约定式():
    2. git commit 合并
    3. @@ -223,7 +223,7 @@

      持续集成 -

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/06/23/tools/Git 规范/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/06/23/web/go/\344\274\230\351\233\205\351\200\200\345\207\272\346\263\250\351\224\200\346\234\215\345\212\241/index.html" "b/2023/06/23/web/go/\344\274\230\351\233\205\351\200\200\345\207\272\346\263\250\351\224\200\346\234\215\345\212\241/index.html" index de9fab93d..c11d63747 100644 --- "a/2023/06/23/web/go/\344\274\230\351\233\205\351\200\200\345\207\272\346\263\250\351\224\200\346\234\215\345\212\241/index.html" +++ "b/2023/06/23/web/go/\344\274\230\351\233\205\351\200\200\345\207\272\346\263\250\351\224\200\346\234\215\345\212\241/index.html" @@ -164,14 +164,14 @@ } } detectApple() - })(window)

    优雅退出注销服务

    优雅退出注销服务

    为什么需要优雅注销服务

    当往服务中心注册了服务之后,由于调试,可能会重复注册同一个服务。当时之前服务由于健康检查,并不会立即退出注销,这就会多线多个“重复的服务”

    + })(window)

    优雅退出注销服务

    优雅退出注销服务

    为什么需要优雅注销服务

    当往服务中心注册了服务之后,由于调试,可能会重复注册同一个服务。当时之前服务由于健康检查,并不会立即退出注销,这就会多线多个“重复的服务”

    整合优雅退出服务

    package consul

    import (
    "fmt"

    "github.com/hashicorp/consul/api"
    )
    // register.go 工具
    type Registry struct {
    Host string
    Port int
    }

    type RegistryClient interface {
    Register(address string, port int, name string, tags []string, id string) error
    DeRegister(serviceId string) error
    }

    func NewRegistryClient(host string, port int) RegistryClient {
    return &Registry{
    Host: host,
    Port: port,
    }
    }

    func (r *Registry) Register(address string, port int, name string, tags []string, id string) error {
    cfg := api.DefaultConfig()
    cfg.Address = fmt.Sprintf("%s:%d", r.Host, r.Port)

    client, err := api.NewClient(cfg)
    if err != nil {
    panic(err)
    }
    //生成对应的检查对象
    check := &api.AgentServiceCheck{
    // GRPC: fmt.Sprintf("%s:%d", global.AppConf.Grpc.IP, global.AppConf.Grpc.Port),
    HTTP: fmt.Sprintf("http://%s:%d/health", address, port),
    Timeout: "5s",
    Interval: "5s",
    DeregisterCriticalServiceAfter: "10s",
    }

    //生成注册对象
    registration := new(api.AgentServiceRegistration)
    registration.Name = name
    registration.ID = id
    registration.Port = port
    registration.Tags = tags
    registration.Address = address
    registration.Check = check

    err = client.Agent().ServiceRegister(registration)
    if err != nil {
    panic(err)
    }
    return nil
    }

    func (r *Registry) DeRegister(serviceId string) error {
    cfg := api.DefaultConfig()
    cfg.Address = fmt.Sprintf("%s:%d", r.Host, r.Port)

    client, err := api.NewClient(cfg)
    if err != nil {
    return err
    }
    err = client.Agent().ServiceDeregister(serviceId)
    return err
    }

    package main

    import (
    "fmt"
    "github.com/nacos-group/nacos-sdk-go/inner/uuid"
    "go.uber.org/zap"
    "os"
    "os/signal"
    "shop_api/good-web/global"
    "shop_api/good-web/initialize"
    "shop_api/good-web/utils/register/consul"
    "syscall"
    )
    // main.go 优雅退出
    func main() {
    router := initialize.Routers()

    registerClient := consul.NewRegistryClient(global.AppConf.Consul.IP, global.AppConf.Consul.Port)
    // 生成UUID
    u, err := uuid.NewV4()
    if err != nil {
    panic("failed new uuid:" + err.Error())
    }
    serverId := u.String()
    err = registerClient.Register(global.AppConf.System.Host, global.AppConf.System.Port,
    global.AppConf.System.Name, global.AppConf.System.Tags, serverId)
    if err != nil {
    panic(err.Error())
    }
    zap.S().Infof("启动服务器,端口:%d", global.AppConf.System.Port)
    // gin会卡住现场
    go func() {
    if err := router.Run(fmt.Sprintf("%s:%d", global.AppConf.System.Host, global.AppConf.System.Port)); err != nil {
    zap.S().Panic(err)
    }
    }()

    //接收终止信号
    quit := make(chan os.Signal)
    signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
    <-quit
    // 注销服务
    if err = registerClient.DeRegister(serverId); err != nil {
    zap.S().Info("注销失败")
    }
    zap.S().Info("注销成功")
    }

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/06/23/web/go/优雅退出注销服务/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/06/26/web/go/Go-\346\227\245\345\277\227\345\272\223Zap/index.html" "b/2023/06/26/web/go/Go-\346\227\245\345\277\227\345\272\223Zap/index.html" index 10be8971c..9044ebd70 100644 --- "a/2023/06/26/web/go/Go-\346\227\245\345\277\227\345\272\223Zap/index.html" +++ "b/2023/06/26/web/go/Go-\346\227\245\345\277\227\345\272\223Zap/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    Go-日志库Zap

    Go-日志库Zap

    什么是zap

    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/07/01/basic/go/Go\345\206\205\345\255\230\345\257\271\351\275\220/index.html" "b/2023/07/01/basic/go/Go\345\206\205\345\255\230\345\257\271\351\275\220/index.html" index 9817b6dc6..bb0f6f8d7 100644 --- "a/2023/07/01/basic/go/Go\345\206\205\345\255\230\345\257\271\351\275\220/index.html" +++ "b/2023/07/01/basic/go/Go\345\206\205\345\255\230\345\257\271\351\275\220/index.html" @@ -162,7 +162,7 @@ } } detectApple() - })(window)

    Go-内存对齐

    内存对齐

    什么是内存对齐

    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/07/04/basic/meeting/\351\235\242\350\257\225\345\205\253\350\202\241\346\226\207-\350\256\241\347\256\227\346\234\272\347\275\221\347\273\234\347\257\207/index.html" "b/2023/07/04/basic/meeting/\351\235\242\350\257\225\345\205\253\350\202\241\346\226\207-\350\256\241\347\256\227\346\234\272\347\275\221\347\273\234\347\257\207/index.html" index 326aaa20c..a5d2225d8 100644 --- "a/2023/07/04/basic/meeting/\351\235\242\350\257\225\345\205\253\350\202\241\346\226\207-\350\256\241\347\256\227\346\234\272\347\275\221\347\273\234\347\257\207/index.html" +++ "b/2023/07/04/basic/meeting/\351\235\242\350\257\225\345\205\253\350\202\241\346\226\207-\350\256\241\347\256\227\346\234\272\347\275\221\347\273\234\347\257\207/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    面试八股文-计算机网络篇

    面试八股文-计算机网络篇

    OSI七层模型和TCP/IP四层协议概述

    OSI七层模型协议

    20230703141100

    + })(window)

    面试八股文-计算机网络篇

    面试八股文-计算机网络篇

    OSI七层模型和TCP/IP四层协议概述

    OSI七层模型协议

    20230703141100

    帧结构

    20230703141556

    各层级之间的作用

    网络层:

    关键协议:IP协议、ICMP协议

    @@ -581,7 +581,7 @@

    VPN(虚拟专用网)

    VPN的隧道协议主要有三种,PPTP、L2TP和IPSec,其中PPTP和L2TP协议工作在OSI模型的第二层,又称为二层隧道协议;IPSec是第三层隧道协议。
    按VPN的应用分类:
    (1)Access VPN(远程接入VPN):客户端到网关,使用公网作为骨干网在设备之间传输VPN数据流量;
    (2)Intranet VPN(内联网VPN):网关到网关,通过公司的网络架构连接来自同公司的资源;
    (3)Extranet VPN(外联网VPN):与合作伙伴企业网构成Extranet,将一个公司与另一个公司的资源进行连接。

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/07/04/basic/meeting/面试八股文-计算机网络篇/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    来访者
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/07/18/web/go/\345\270\270\350\247\201\347\232\204\345\210\206\345\270\203\345\274\217\346\234\215\345\212\241\345\217\221\347\216\260\345\222\214\346\234\215\345\212\241\346\263\250\345\206\214\346\226\271\346\241\210/index.html" "b/2023/07/18/web/go/\345\270\270\350\247\201\347\232\204\345\210\206\345\270\203\345\274\217\346\234\215\345\212\241\345\217\221\347\216\260\345\222\214\346\234\215\345\212\241\346\263\250\345\206\214\346\226\271\346\241\210/index.html" index 1f2ce8d48..39c6b6645 100644 --- "a/2023/07/18/web/go/\345\270\270\350\247\201\347\232\204\345\210\206\345\270\203\345\274\217\346\234\215\345\212\241\345\217\221\347\216\260\345\222\214\346\234\215\345\212\241\346\263\250\345\206\214\346\226\271\346\241\210/index.html" +++ "b/2023/07/18/web/go/\345\270\270\350\247\201\347\232\204\345\210\206\345\270\203\345\274\217\346\234\215\345\212\241\345\217\221\347\216\260\345\222\214\346\234\215\345\212\241\346\263\250\345\206\214\346\226\271\346\241\210/index.html" @@ -10,8 +10,8 @@ - +

    常见的分布式服务发现和服务注册方案

    常见的分布式服务发现和服务注册方案

    + })(window)

    常见的分布式服务发现和服务注册方案

    常见的分布式服务发现和服务注册方案

    @@ -267,7 +267,7 @@

    etcd

    et

    etcd 采用 Go 语言编写,它具有出色的跨平台支持,很小的二进制文件和强大的社区。 etcd 机器之间的通信通过 Raft 算法处理。

    Eureka

    Eureka是 Netflix 开发的服务发现框架,本身是一个基于 REST 的服务,主要用于定位运行在 AWS 域中的中间层服务,以达到负载均衡和中间层服务故障转移的目的。. SpringCloud将它集成在其子项目spring-cloud-netflix中,以实现SpringCloud的服务发现功能。. [1] Eureka包含两个组件:Eureka Server和Eureka Client。. Eureka Server提供服务注册服务,各个节点启动后,会在Eureka Server中进行注册,这样EurekaServer中的服务注册表中将会存储所有可用服务节点的信息,服务节点的信息可以在界面中直观的看到

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/07/18/web/go/常见的分布式服务发现和服务注册方案/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/07/18/web/go/\345\270\270\350\247\201\347\232\204\345\210\206\345\270\203\345\274\217\351\224\201\350\247\243\345\206\263\346\226\271\346\241\210/index.html" "b/2023/07/18/web/go/\345\270\270\350\247\201\347\232\204\345\210\206\345\270\203\345\274\217\351\224\201\350\247\243\345\206\263\346\226\271\346\241\210/index.html" index 63663b99b..bf3bb2b53 100644 --- "a/2023/07/18/web/go/\345\270\270\350\247\201\347\232\204\345\210\206\345\270\203\345\274\217\351\224\201\350\247\243\345\206\263\346\226\271\346\241\210/index.html" +++ "b/2023/07/18/web/go/\345\270\270\350\247\201\347\232\204\345\210\206\345\270\203\345\274\217\351\224\201\350\247\243\345\206\263\346\226\271\346\241\210/index.html" @@ -10,8 +10,8 @@ - +

    常见的分布式锁解决方案

    常见的分布式锁解决方案

      + })(window)

      常见的分布式锁解决方案

      打赏
      • alipay
        alipay

      评论
      avatar
      Joohwan.
      该知道的都知道,不知道的慢慢了解
      Follow Me
      公告
      Please try your best!
      来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/08/16/cloud/docker/Docker-\345\274\200\345\220\257\350\277\234\347\250\213Cli/index.html" "b/2023/08/16/cloud/docker/Docker-\345\274\200\345\220\257\350\277\234\347\250\213Cli/index.html" index 59ddb6e71..8574153a5 100644 --- "a/2023/08/16/cloud/docker/Docker-\345\274\200\345\220\257\350\277\234\347\250\213Cli/index.html" +++ "b/2023/08/16/cloud/docker/Docker-\345\274\200\345\220\257\350\277\234\347\250\213Cli/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    Docker配置远程访问

    Docker配置远程访问

    暴力修改

    这种就很简单暴力,直接修改/lib/systemd/system/docker.service文件,注释掉默认的 ExecStart 并添加新的 ExecStart 配置:

    + })(window)

    Docker配置远程访问

    Docker配置远程访问

    暴力修改

    这种就很简单暴力,直接修改/lib/systemd/system/docker.service文件,注释掉默认的 ExecStart 并添加新的 ExecStart 配置:

    Feature
    # ExecStart=/usr/bin/dockerd -H fd://
    ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock

    然后重启 docker.service:

    @@ -195,7 +195,7 @@

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/08/16/cloud/docker/Docker-开启远程Cli/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan

    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/08/16/cloud/k8s/K8s\346\265\205\345\255\246/index.html" "b/2023/08/16/cloud/k8s/K8s\346\265\205\345\255\246/index.html" index d6d0d9ba3..ecd2515ad 100644 --- "a/2023/08/16/cloud/k8s/K8s\346\265\205\345\255\246/index.html" +++ "b/2023/08/16/cloud/k8s/K8s\346\265\205\345\255\246/index.html" @@ -162,7 +162,7 @@ } } detectApple() - })(window)

    K8s浅学

    k8s

    1、安装(v.1.17.1,docker-cri)

    1.1 env.bash

    #!/bin/bash

    # 在 master 节点和 worker 节点都要执行

    # 卸载旧版本
    yum remove docker \
    docker-client \
    docker-client-latest \
    docker-common \
    docker-latest \
    docker-latest-logrotate \
    docker-logrotate \
    docker-engine

    # 安装并启动 docker(cri)
    yum install -y docker-ce-19.03.5 docker-ce-cli-19.03.5 containerd.io
    systemctl enable docker
    systemctl start docker

    # 关闭 防火墙
    systemctl stop firewalld
    systemctl disable firewalld

    # 关闭 SeLinux
    setenforce 0
    sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

    # 关闭 swap
    swapoff -a
    yes | cp /etc/fstab /etc/fstab_bak
    cat /etc/fstab_bak |grep -v swap > /etc/fstab

    # 修改 /etc/sysctl.conf
    # 如果有配置,则修改
    sed -i "s#^net.ipv4.ip_forward.*#net.ipv4.ip_forward=1#g" /etc/sysctl.conf
    sed -i "s#^net.bridge.bridge-nf-call-ip6tables.*#net.bridge.bridge-nf-call-ip6tables=1#g" /etc/sysctl.conf
    sed -i "s#^net.bridge.bridge-nf-call-iptables.*#net.bridge.bridge-nf-call-iptables=1#g" /etc/sysctl.conf
    # 可能没有,追加
    echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
    echo "net.bridge.bridge-nf-call-ip6tables = 1" >> /etc/sysctl.conf
    echo "net.bridge.bridge-nf-call-iptables = 1" >> /etc/sysctl.conf
    # 执行命令以应用
    sysctl -p

    docker version
    + })(window)

    K8s浅学

    k8s

    1、安装(v.1.17.1,docker-cri)

    1.1 env.bash

    #!/bin/bash

    # 在 master 节点和 worker 节点都要执行

    # 卸载旧版本
    yum remove docker \
    docker-client \
    docker-client-latest \
    docker-common \
    docker-latest \
    docker-latest-logrotate \
    docker-logrotate \
    docker-engine

    # 安装并启动 docker(cri)
    yum install -y docker-ce-19.03.5 docker-ce-cli-19.03.5 containerd.io
    systemctl enable docker
    systemctl start docker

    # 关闭 防火墙
    systemctl stop firewalld
    systemctl disable firewalld

    # 关闭 SeLinux
    setenforce 0
    sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

    # 关闭 swap
    swapoff -a
    yes | cp /etc/fstab /etc/fstab_bak
    cat /etc/fstab_bak |grep -v swap > /etc/fstab

    # 修改 /etc/sysctl.conf
    # 如果有配置,则修改
    sed -i "s#^net.ipv4.ip_forward.*#net.ipv4.ip_forward=1#g" /etc/sysctl.conf
    sed -i "s#^net.bridge.bridge-nf-call-ip6tables.*#net.bridge.bridge-nf-call-ip6tables=1#g" /etc/sysctl.conf
    sed -i "s#^net.bridge.bridge-nf-call-iptables.*#net.bridge.bridge-nf-call-iptables=1#g" /etc/sysctl.conf
    # 可能没有,追加
    echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
    echo "net.bridge.bridge-nf-call-ip6tables = 1" >> /etc/sysctl.conf
    echo "net.bridge.bridge-nf-call-iptables = 1" >> /etc/sysctl.conf
    # 执行命令以应用
    sysctl -p

    docker version

    1.2 k8ssetup.bash

    1.2.1 k8ssetup.yaml

    apiVersion: kubeadm.k8s.io/v1beta2
    kind: ClusterConfiguration
    kubernetesVersion: v1.17.1
    controlPlaneEndpoint: "apiserver.k8s.com:6443"
    networking:
    serviceSubnet: "10.96.0.0/16"
    podSubnet: "10.11.10.0/16"
    dnsDomain: "cluster.local
    @@ -438,7 +438,7 @@

    api list
  • kubernetes教程
  • -

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/08/16/cloud/k8s/K8s浅学/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    目录
    1. 1. k8s
  • 1、安装(v.1.17.1,docker-cri)
    1. 1. 1.1 env.bash
    2. 2. 1.2 k8ssetup.bash
      1. 2.1. 1.2.1 k8ssetup.yaml
      2. 2.2. 1.2.2 k8s run setup(single-host Kubernetes cluster)
  • 2、资源管理
    1. 1. 2.1Pod
      1. 1.1. 2.1.1创建容器
      2. 1.2. 2.1.2查看容器
      3. 1.3. 2.1.3查看容器日志
      4. 1.4. 2.1.4向pod发送请求
  • 3、标签管理
    1. 1. 3.1pod
    2. 2. 3.2node
      1. 2.1. 指定调度到特定节点(nodeselector)
    3. 3. 3.3命名空间(namespace)
      1. 3.1. 创建ns
  • 4、控制器
    1. 1. 4.1探针
      1. 1.1. 4.1.1存活探针
        1. 1.1.1. 基于Http的存活探针
      2. 1.2. 4.1.2就绪探针
    2. 2. 4.2 ReplicationController
      1. 2.1. 4.2.1将pod移入或移出ReplicationController的作用域
      2. 2.2. 4.2.2修改pod 模版
      3. 2.3. 4.2.3删除RC
    3. 3. 4.3 ReplicaSet(RC进化版,更优秀)
    4. 4. 4.4 Job
      1. 4.1. 4.4.1顺序运行job pod
      2. 4.2. 4.4.2并行运行job pod
      3. 4.3. 4.4.3job的缩放
      4. 4.4. 4.4.4限制job pod完成任务时间
      5. 4.5. job定期运行(Crodjob)
  • 5.Service
    1. 0.1. 5.1 如何在一个已有的pod,访问service
  • 1. 5.2配置每次请求来自于同一个pod
  • 2. 5.3 同一个服务暴露多个端口
  • 3. 5.4服务发现
  • 4. 5.5服务对外暴露
    1. 4.1. 5.5.1使用NodePort类型的服务
    2. 4.2. 5.5.2使用负载均衡器
  • 6.k8s的卷
    1. 1. 6.1emptyDir卷
    2. 2. 6.2hostPath卷
    3. 3. 6.3持久卷
  • 7.ConfigMap和Secret
    1. 1. 7.1向容器传递命令行参数
      1. 1.1. 7.1.1Docker中的命令和参数
        1. 1.1.1. Dockerfile中的ENTRYOINT和CMD
        2. 1.1.2. shell和exec形式的区别
      2. 1.2. 7.1.2k8s中覆盖命令和参数
    2. 2. 7.2在容器定义中指定环境变量
    3. 3. 7.3ConfigMap
      1. 3.1. 7.3.1创建cm
      2. 3.2. 7.3.2cm设置环境变量
      3. 3.3. 7.3.3 cm在pod中作为文件使用
    4. 4. 7.4Secret
      1. 4.1. 7.4.1在Docker
      2. 4.2. 7.4.2基本身份认证
  • 8.从应用访问Pod元数据以及其他资源
    1. 1. 8.1Downward API传递元数据
    2. 2. 8.2K8s 的REST API
  • 9.Deployment
    1. 1. 9.1滚动升级
    2. 2. 9.2回滚升级
    3. 3. 9.3暂停滚动升级
  • 10.k8s的架构
    1. 1. 10.1控制面的组件
    2. 2. 10.2工作节点上运行的组件
    3. 3. 10.3附加组件
  • 11.认证方式
    1. 1.
      1. 1.1. 创建serviceAccount
  • 12.污点
  • 13.其他一些资料
  • 最新文章
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    来访者
    目录
    1. 1. k8s
  • 1、安装(v.1.17.1,docker-cri)
    1. 1. 1.1 env.bash
    2. 2. 1.2 k8ssetup.bash
      1. 2.1. 1.2.1 k8ssetup.yaml
      2. 2.2. 1.2.2 k8s run setup(single-host Kubernetes cluster)
  • 2、资源管理
    1. 1. 2.1Pod
      1. 1.1. 2.1.1创建容器
      2. 1.2. 2.1.2查看容器
      3. 1.3. 2.1.3查看容器日志
      4. 1.4. 2.1.4向pod发送请求
  • 3、标签管理
    1. 1. 3.1pod
    2. 2. 3.2node
      1. 2.1. 指定调度到特定节点(nodeselector)
    3. 3. 3.3命名空间(namespace)
      1. 3.1. 创建ns
  • 4、控制器
    1. 1. 4.1探针
      1. 1.1. 4.1.1存活探针
        1. 1.1.1. 基于Http的存活探针
      2. 1.2. 4.1.2就绪探针
    2. 2. 4.2 ReplicationController
      1. 2.1. 4.2.1将pod移入或移出ReplicationController的作用域
      2. 2.2. 4.2.2修改pod 模版
      3. 2.3. 4.2.3删除RC
    3. 3. 4.3 ReplicaSet(RC进化版,更优秀)
    4. 4. 4.4 Job
      1. 4.1. 4.4.1顺序运行job pod
      2. 4.2. 4.4.2并行运行job pod
      3. 4.3. 4.4.3job的缩放
      4. 4.4. 4.4.4限制job pod完成任务时间
      5. 4.5. job定期运行(Crodjob)
  • 5.Service
    1. 0.1. 5.1 如何在一个已有的pod,访问service
  • 1. 5.2配置每次请求来自于同一个pod
  • 2. 5.3 同一个服务暴露多个端口
  • 3. 5.4服务发现
  • 4. 5.5服务对外暴露
    1. 4.1. 5.5.1使用NodePort类型的服务
    2. 4.2. 5.5.2使用负载均衡器
  • 6.k8s的卷
    1. 1. 6.1emptyDir卷
    2. 2. 6.2hostPath卷
    3. 3. 6.3持久卷
  • 7.ConfigMap和Secret
    1. 1. 7.1向容器传递命令行参数
      1. 1.1. 7.1.1Docker中的命令和参数
        1. 1.1.1. Dockerfile中的ENTRYOINT和CMD
        2. 1.1.2. shell和exec形式的区别
      2. 1.2. 7.1.2k8s中覆盖命令和参数
    2. 2. 7.2在容器定义中指定环境变量
    3. 3. 7.3ConfigMap
      1. 3.1. 7.3.1创建cm
      2. 3.2. 7.3.2cm设置环境变量
      3. 3.3. 7.3.3 cm在pod中作为文件使用
    4. 4. 7.4Secret
      1. 4.1. 7.4.1在Docker
      2. 4.2. 7.4.2基本身份认证
  • 8.从应用访问Pod元数据以及其他资源
    1. 1. 8.1Downward API传递元数据
    2. 2. 8.2K8s 的REST API
  • 9.Deployment
    1. 1. 9.1滚动升级
    2. 2. 9.2回滚升级
    3. 3. 9.3暂停滚动升级
  • 10.k8s的架构
    1. 1. 10.1控制面的组件
    2. 2. 10.2工作节点上运行的组件
    3. 3. 10.3附加组件
  • 11.认证方式
    1. 1.
      1. 1.1. 创建serviceAccount
  • 12.污点
  • 13.其他一些资料
  • 最新文章
    - \ No newline at end of file + \ No newline at end of file diff --git a/2023/09/16/cloud/Harbor/index.html b/2023/09/16/cloud/Harbor/index.html index d63b6e4ca..b8325726f 100644 --- a/2023/09/16/cloud/Harbor/index.html +++ b/2023/09/16/cloud/Harbor/index.html @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    Harbor

    Harbor

    什么是Harbor

    Harbor 是一个开源的企业级容器镜像注册中心,用于管理和存储 Docker 镜像以及其他容器化应用的相关资源。它允许团队或组织在内部搭建自己的容器镜像仓库,以便更好地控制镜像的分发、访问和安全性。

    + })(window)

    Harbor

    Harbor

    什么是Harbor

    Harbor 是一个开源的企业级容器镜像注册中心,用于管理和存储 Docker 镜像以及其他容器化应用的相关资源。它允许团队或组织在内部搭建自己的容器镜像仓库,以便更好地控制镜像的分发、访问和安全性。

    Harbor的安装

    安装最小配置

    最低建议配置:

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/09/16/cloud/Harbor/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/09/16/tools/Bash\345\205\245\351\227\250/index.html" "b/2023/09/16/tools/Bash\345\205\245\351\227\250/index.html" index daf4e01a9..09df0bfea 100644 --- "a/2023/09/16/tools/Bash\345\205\245\351\227\250/index.html" +++ "b/2023/09/16/tools/Bash\345\205\245\351\227\250/index.html" @@ -162,7 +162,7 @@ } } detectApple() - })(window)

    Bash入门

    Bash入门

    什么是bash

    Bash 是 Unix 系统和 Linux 系统的一种 Shell(命令行环境),是目前绝大多数 Linux 发行版的默认 Shell

    + })(window)

    Bash入门

    Bash入门

    什么是bash

    Bash 是 Unix 系统和 Linux 系统的一种 Shell(命令行环境),是目前绝大多数 Linux 发行版的默认 Shell

    什么是shell

    学习 Bash,首先需要理解 Shell 是什么。Shell 这个单词的原意是“外壳”,跟 kernel(内核)相对应,比喻内核外面的一层,即用户跟内核交互的对话界面。

    首先,Shell 是一个程序,提供一个与用户对话的环境。这个环境只有一个命令提示符,让用户从键盘输入命令,所以又称为命令行环境(command line interface,简写为 CLI)。Shell 接收到用户输入的命令,将命令送入操作系统执行,并将结果返回给用户。

    @@ -490,7 +490,7 @@

    数组Set命令

    # 执行脚本时,如果遇到不存在的变量,Bash 默认忽略它。
    set -u

    # 默认情况下,脚本执行后,只输出运行结果,没有其他内容。如果多个命令连续执行,它们的运行结果就会连续输出
    set -x

    #上面这些写法多少有些麻烦,容易疏忽。set -e从根本上解决了这个问题,它使得脚本只要发生错误,就终止执行
    set -e

    # -e 在有|情况下不生效 用来解决这种情况,只要一个子命令失败,整个管道命令就失败,脚本就会终止执行
    set -o pipefail

    set -n:等同于set -o noexec,不运行命令,只检查语法是否正确。
    set -f:等同于set -o noglob,表示不对通配符进行文件名扩展。
    set -v:等同于set -o verbose,表示打印 Shell 接收到的每一行输入。
    set -o noclobber:防止使用重定向运算符>覆盖已经存在的文件

    Bash 的错误处理

    # 写法一
    command || { echo "command failed"; exit 1; }

    # 写法二
    if ! command; then echo "command failed"; exit 1; fi

    # 写法三
    command
    if [ "$?" -ne 0 ]; then echo "command failed"; exit 1; fi
    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/09/16/tools/Bash入门/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    来访者
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/09/22/cloud/k8s/\351\203\250\347\275\262K8s(\350\204\232\346\234\254\347\211\210\346\234\254)/index.html" "b/2023/09/22/cloud/k8s/\351\203\250\347\275\262K8s(\350\204\232\346\234\254\347\211\210\346\234\254)/index.html" index 8b29a569e..3800417f7 100644 --- "a/2023/09/22/cloud/k8s/\351\203\250\347\275\262K8s(\350\204\232\346\234\254\347\211\210\346\234\254)/index.html" +++ "b/2023/09/22/cloud/k8s/\351\203\250\347\275\262K8s(\350\204\232\346\234\254\347\211\210\346\234\254)/index.html" @@ -164,14 +164,14 @@ } } detectApple() - })(window)

    部署K8s(脚本版本)

    部署K8s(脚本版本)

    文件位置:https://github.com/Piwriw/k8s_base/tree/master/k8s-setup

    + })(window)

    部署K8s(脚本版本)

    部署K8s(脚本版本)

    文件位置:https://github.com/Piwriw/k8s_base/tree/master/k8s-setup

    分发文件(push-file.sh)

    #!/bin/bash
    set -e
    # 源文件路径
    source_file="../k8s-setup"

    # 目标主机列表
    target_hosts=(
    "root@10.10.103.79:/root"
    "root@10.10.103.80:/root"
    "root@10.10.103.81:/root"
    )

    # 循环迭代目标主机列表,并使用 scp 命令将文件复制到每个主机
    for target_host in "${target_hosts[@]}"; do
    scp -r "$source_file" "$target_host"
    done

    部署包括docker(set-up.sh)

    ⚠️注意修改

    # 需要修改
    kubeadm join 10.10.101.158:6443 --token m6ygdj.wrlffvuvofffj2c5 --discovery-token-ca-cert-hash

    # 执行bash 传入hostname 参数 会自动设置本机hostname
    bash set-up.sh $homename
    #!/bin/bash
    set -e
    # 需要传递harbor hostname:ip h
    hostname="$1"
    initYum(){
    yum install -y wget
    mkdir /etc/yum.repos.d/bak && mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.cloud.tencent.com/repo/epel-7.repo
    yum clean all && yum makecache
    }
    setHostname(){
    hostnamectl set-hostname $hostname
    echo "`ip -4 addr show scope global | awk '/inet/ {print $2; exit}' | cut -d '/' -f1` $hostname" >> /etc/hosts
    /etc/init.d/network restart
    }
    setupdocker(){

    curl -k -fsSL https://get.docker.com -o get-docker.sh
    sh get-docker.sh --version 20.10
    systemctl start docker
    systemctl enable docker
    touch /etc/docker/daemon.json
    echo '{ "exec-opts": ["native.cgroupdriver=systemd"] }' > /etc/docker/daemon.json
    systemctl restart docker
    }
    setupK8s(){
    bash ./k8s-setup.sh
    # 不使用可能会出现 sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables
    modprobe br_netfilter
    yum install -y kubeadm-1.20.4 kubelet-1.20.4 kubectl-1.20.4
    systemctl start kubelet
    systemctl enable kubelet
    # 需要修改
    kubeadm join 10.10.101.158:6443 --token m6ygdj.wrlffvuvofffj2c5 --discovery-token-ca-cert-hash sha256:fb74344fe281551bf7c32e1959a1d5a5439a8fa8a5ee209adb4eab0a568b8990
    }

    if [ -z "$hostname" ]; then
    echo "没有提供参数 需要hostname"
    exit 1 # 退出脚本,并返回非零退出状态
    fi

    initYum
    setHostname
    setupdocker
    setupK8s
    -

    k8s-prepare(k8s-setup.sh)

    #k8s-setup.sh
    cat <<EOF > /etc/yum.repos.d/kubernetes.repo
    [kubernetes]
    name=Kubernetes
    baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
    enabled=1
    gpgcheck=1
    repo_gpgcheck=1
    gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
    EOF
    setenforce 0

    systemctl stop firewalld
    systemctl disable firewalld
    setenforce 0
    sed -i "s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
    swapoff -a
    sed -i 's/.*swap.*/#&/' /etc/fstab

    cat > /etc/sysctl.d/k8s.conf <<EOF
    net.bridge.bridge-nf-call-ip6tables = 1
    net.bridge.bridge-nf-call-iptables = 1
    EOF

    echo "1" > /proc/sys/net/ipv4/ip_forward
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/09/22/cloud/k8s/部署K8s(脚本版本)/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/09/23/tools/\345\217\252\345\205\263\351\227\255chrome\346\267\261\350\211\262\346\250\241\345\274\217/index.html" "b/2023/09/23/tools/\345\217\252\345\205\263\351\227\255chrome\346\267\261\350\211\262\346\250\241\345\274\217/index.html" index 6919f5145..94432b892 100644 --- "a/2023/09/23/tools/\345\217\252\345\205\263\351\227\255chrome\346\267\261\350\211\262\346\250\241\345\274\217/index.html" +++ "b/2023/09/23/tools/\345\217\252\345\205\263\351\227\255chrome\346\267\261\350\211\262\346\250\241\345\274\217/index.html" @@ -162,10 +162,10 @@ } } detectApple() - })(window)

    只关闭chrome深色模式

    只关闭chrome深色模式

    背景

    chrome会自动根据系统的深浅色模式,进行匹配。

    + })(window)

    只关闭chrome深色模式

    只关闭chrome深色模式

    背景

    chrome会自动根据系统的深浅色模式,进行匹配。

    单独关闭chrome深色模式

    # 单独关闭
    defaults write com.google.Chrome NSRequiresAquaSystemAppearance -bool YES
    # 重启chrome 生效

    # 开启深色模式
    defaults write com.google.Chrome NSRequiresAquaSystemAppearance -bool NO
    # 重启chrome 生效

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/09/23/tools/只关闭chrome深色模式/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/09/26/tools/\347\211\210\346\234\254\346\216\247\345\210\266\345\267\245\345\205\267-Git/index.html" "b/2023/09/26/tools/\347\211\210\346\234\254\346\216\247\345\210\266\345\267\245\345\205\267-Git/index.html" index c73a5dd11..6cb87392f 100644 --- "a/2023/09/26/tools/\347\211\210\346\234\254\346\216\247\345\210\266\345\267\245\345\205\267-Git/index.html" +++ "b/2023/09/26/tools/\347\211\210\346\234\254\346\216\247\345\210\266\345\267\245\345\205\267-Git/index.html" @@ -162,7 +162,7 @@ } } detectApple() - })(window)

    版本控制工具-Git

    版本控制工具-Git

    什么是git

    Git是一个版本控制工具,在编程中用于进行管理代码

    + })(window)

    版本控制工具-Git

    版本控制工具-Git

    什么是git

    Git是一个版本控制工具,在编程中用于进行管理代码

    安装Git

    Git安装

    # 一些常见安装罗列

    # mac安装
    brew install git

    # Windows 安装
    https://git-scm.com/download/win

    # linux 安装
    yum install -y git
    @@ -175,7 +175,7 @@

    4.因为忽略了第一步(在这可以只设置当前的)

    git config user.name 'yourname' && git config  user.email 'youremail@163.com' &&ssh-add ~/.ssh/yourid_rsa

    #example:
    git config user.name 'piwriw' && git config user.email 'piwriw@163.com' &&ssh-add ~/.ssh/piwriw
    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/09/26/tools/版本控制工具-Git/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/03/basic/go/Go\347\232\204\347\275\221\347\273\234\347\274\226\347\250\213/index.html" "b/2023/10/03/basic/go/Go\347\232\204\347\275\221\347\273\234\347\274\226\347\250\213/index.html" index 65cc3225d..3174a0484 100644 --- "a/2023/10/03/basic/go/Go\347\232\204\347\275\221\347\273\234\347\274\226\347\250\213/index.html" +++ "b/2023/10/03/basic/go/Go\347\232\204\347\275\221\347\273\234\347\274\226\347\250\213/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    Go-网络编程

    Go的网络编程

    TCP

    什么是TCP

    TCP/IP(Transmission Control Protocol/Internet Protocol) 即传输控制协议/网际协议,是一种面向连接(连接导向)的、可靠的、基于字节流的传输层(Transport layer)通信协议,因为是面向连接的协议,数据像水流一样传输,会存在黏包问题。

    + })(window)

    Go-网络编程

    Go的网络编程

    TCP

    什么是TCP

    TCP/IP(Transmission Control Protocol/Internet Protocol) 即传输控制协议/网际协议,是一种面向连接(连接导向)的、可靠的、基于字节流的传输层(Transport layer)通信协议,因为是面向连接的协议,数据像水流一样传输,会存在黏包问题。

    TCP的工作流程

    服务端:

    1. 监听端口
    2. @@ -203,7 +203,7 @@

      -

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/10/03/basic/go/Go的网络编程/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/05/basic/go/Go-panic\344\270\216recover/index.html" "b/2023/10/05/basic/go/Go-panic\344\270\216recover/index.html" index 1195be2d5..9a8504419 100644 --- "a/2023/10/05/basic/go/Go-panic\344\270\216recover/index.html" +++ "b/2023/10/05/basic/go/Go-panic\344\270\216recover/index.html" @@ -162,7 +162,7 @@ } } detectApple() - })(window)

    Go 的panic与recover

    Go 的panic与recover

    panic和recover调用时机

    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/06/basic/go/Go-\346\267\261\345\205\245\347\220\206\350\247\243GMP/index.html" "b/2023/10/06/basic/go/Go-\346\267\261\345\205\245\347\220\206\350\247\243GMP/index.html" index e399b3770..e80770409 100644 --- "a/2023/10/06/basic/go/Go-\346\267\261\345\205\245\347\220\206\350\247\243GMP/index.html" +++ "b/2023/10/06/basic/go/Go-\346\267\261\345\205\245\347\220\206\350\247\243GMP/index.html" @@ -162,7 +162,7 @@ } } detectApple() - })(window)

    Go-深入理解GMP

    深入理解GMP

    为什么需要调度器

      + })(window)

      Go-深入理解GMP

      打赏
      • alipay
        alipay

      评论
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/06/tools/homebrew\345\256\211\350\243\205redis\357\274\210Mac\357\274\211/index.html" "b/2023/10/06/tools/homebrew\345\256\211\350\243\205redis\357\274\210Mac\357\274\211/index.html" index 6805b90e5..f8e04f1c4 100644 --- "a/2023/10/06/tools/homebrew\345\256\211\350\243\205redis\357\274\210Mac\357\274\211/index.html" +++ "b/2023/10/06/tools/homebrew\345\256\211\350\243\205redis\357\274\210Mac\357\274\211/index.html" @@ -162,7 +162,7 @@ } } detectApple() - })(window)

    homebrew安装redis(Mac)

    homebrew安装redis(Mac)

    已经确保安装好brew

    # 安装redis
    brew install redis

    # 启动redis
    #方式一:使用brew帮助我们启动软件
    brew services start redis
    #方式二
    redis-server /usr/local/etc/redis.conf
    #方式三 redis-server

    + })(window)

    homebrew安装redis(Mac)

    homebrew安装redis(Mac)

    已经确保安装好brew

    # 安装redis
    brew install redis

    # 启动redis
    #方式一:使用brew帮助我们启动软件
    brew services start redis
    #方式二
    redis-server /usr/local/etc/redis.conf
    #方式三 redis-server

    配置文件安装位置

    • Homebrew安装的软件会默认在/usr/local/Cellar/路径下
    • @@ -172,7 +172,7 @@

      Redis可视化工具推荐

      AnotherRedisDesktopManager

      2023-10 目前已经获得27K :star:

      -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/10/06/tools/homebrew安装redis(Mac)/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/07/basic/go/\346\267\261\345\205\245\347\220\206\350\247\243GO\347\232\204GC/index.html" "b/2023/10/07/basic/go/\346\267\261\345\205\245\347\220\206\350\247\243GO\347\232\204GC/index.html" index 2825ee449..4364b4e80 100644 --- "a/2023/10/07/basic/go/\346\267\261\345\205\245\347\220\206\350\247\243GO\347\232\204GC/index.html" +++ "b/2023/10/07/basic/go/\346\267\261\345\205\245\347\220\206\350\247\243GO\347\232\204GC/index.html" @@ -162,7 +162,7 @@ } } detectApple() - })(window)

    深入理解GO的GC

    深入理解GO的GC

    Gov1.3之前的标记清除法(mark and sweep)

      + })(window)

      深入理解GO的GC

      深入理解GO的GC

      Gov1.3之前的标记清除法(mark and sweep)

      1. 进行STW暂停

      2. 把所有的程序可达对象标记

        @@ -243,7 +243,7 @@

        场景4:一个栈对象删除引用,成为另一个堆对象的下游

        -
      文章作者: Joohwan.
      文章链接: https://piwriw.github.io/2023/10/07/basic/go/深入理解GO的GC/
      版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
      打赏
      • alipay
        alipay

      评论
      打赏
      • alipay
        alipay

      评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/08/cloud/k8s/K8s\346\211\271\351\207\217\350\216\267\345\217\226\345\244\247\351\207\217\346\225\260\346\215\256\350\265\204\346\272\220\350\247\243\345\206\263\346\226\271\346\241\210/index.html" "b/2023/10/08/cloud/k8s/K8s\346\211\271\351\207\217\350\216\267\345\217\226\345\244\247\351\207\217\346\225\260\346\215\256\350\265\204\346\272\220\350\247\243\345\206\263\346\226\271\346\241\210/index.html" index 3ba84d922..5be4c583c 100644 --- "a/2023/10/08/cloud/k8s/K8s\346\211\271\351\207\217\350\216\267\345\217\226\345\244\247\351\207\217\346\225\260\346\215\256\350\265\204\346\272\220\350\247\243\345\206\263\346\226\271\346\241\210/index.html" +++ "b/2023/10/08/cloud/k8s/K8s\346\211\271\351\207\217\350\216\267\345\217\226\345\244\247\351\207\217\346\225\260\346\215\256\350\265\204\346\272\220\350\247\243\345\206\263\346\226\271\346\241\210/index.html" @@ -163,13 +163,13 @@ } } detectApple() - })(window)

    K8s批量获取大量数据资源解决方案

    K8s批量获取大量数据资源解决方案

    背景

    当使用kubelet已经无法获取到资源的级别,比如万级别

    + })(window)

    K8s批量获取大量数据资源解决方案

    K8s批量获取大量数据资源解决方案

    背景

    当使用kubelet已经无法获取到资源的级别,比如万级别

    可以先直接采用client-go,去获取,这会更快,因为当我们使用kubelet get nodes|wc -l计算的时候,要先打印到出来再遍历

    :star:最后最大数据可以采用NewSharedInformerFactory来获取,使用informer,former 提供了基于事件通知的只读缓存机制,可以注册资源变化的回调函数,并可以极大减少 API 的调用。

    官方exampleURL

    代码实例

    package main

    import (
    "flag"
    "fmt"
    "k8s.io/apimachinery/pkg/labels"
    "k8s.io/client-go/informers"
    "k8s.io/client-go/kubernetes"
    "k8s.io/client-go/tools/cache"
    "k8s.io/client-go/tools/clientcmd"
    "k8s.io/client-go/util/homedir"
    "path/filepath"
    "time"
    )

    func GetClientOutside() (*kubernetes.Clientset, error) {
    // 支持以 Pod 形式或者在宿主机上运行代码的形式获取 kubeconfig 配置
    var kubeconfig *string
    if home := homedir.HomeDir(); home != "" {
    kubeconfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file")
    } else {
    kubeconfig = flag.String("kubeconfig", "./kube/config", "absolute path to the kubeconfig file")
    }
    flag.Parse()

    config, err := clientcmd.BuildConfigFromFlags("", *kubeconfig)
    if err != nil {
    return nil, err

    }
    clientSet, err := kubernetes.NewForConfig(config)
    if err != nil {
    return nil, err
    }

    return clientSet, nil
    }

    func main() {
    start := time.Now()

    // 在这里执行您的代码或函数

    clientset, err := GetClientOutside()
    if err != nil {
    fmt.Println(err)
    return
    }
    //var timeout int64
    //timeout = 6000
    // 创建本地缓存
    informerFactory := informers.NewSharedInformerFactory(clientset, 0)
    nodeInformer := informerFactory.Core().V1().Nodes().Informer()
    nodeLister := informerFactory.Core().V1().Nodes().Lister()

    // 启动本地缓存的同步
    stopCh := make(chan struct{})
    defer close(stopCh)
    informerFactory.Start(stopCh)
    cache.WaitForCacheSync(stopCh, nodeInformer.HasSynced)

    // 在这里执行您的代码或函数,可以从缓存中获取资源对象

    // 示例:从缓存中获取所有 Pod 资源对象并打印它们的名称
    nodes, _ := nodeLister.List(labels.Everything())
    fmt.Printf("集群节点数%d\n", len(nodes))
    //for _, node := range nodes {
    // fmt.Println(node.Name)
    // for _, statu := range node.Status.Conditions {
    // if statu.Status == corev1.ConditionTrue && statu.Type == corev1.NodeReady {
    // fmt.Println(node.Name)
    // }
    // }
    //}

    //items, err := clientset.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{Limit: 5000, ResourceVersion: "0", TimeoutSeconds: &timeout})
    //for _, item := range items.Items {
    // for _, statu := range item.Status.Conditions {
    // if statu.Status == corev1.ConditionTrue && statu.Type == corev1.NodeReady {
    // fmt.Println(item.Name)
    // }
    // }
    //}
    //if err != nil {
    // fmt.Println(err)
    // return
    //}
    //fmt.Println(len(items.Items))

    elapsed := time.Since(start)
    fmt.Printf("代码执行时间:%s\n", elapsed)
    }
    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/10/08/cloud/k8s/K8s批量获取大量数据资源解决方案/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/09/cloud/k8s/K8s-\351\200\232\350\277\207URL\350\256\277\351\227\256\346\250\241\345\274\217/index.html" "b/2023/10/09/cloud/k8s/K8s-\351\200\232\350\277\207URL\350\256\277\351\227\256\346\250\241\345\274\217/index.html" index a43706c2c..0bd438f6a 100644 --- "a/2023/10/09/cloud/k8s/K8s-\351\200\232\350\277\207URL\350\256\277\351\227\256\346\250\241\345\274\217/index.html" +++ "b/2023/10/09/cloud/k8s/K8s-\351\200\232\350\277\207URL\350\256\277\351\227\256\346\250\241\345\274\217/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-通过URL访问模式

    K8s-通过URL访问模式

    背景

    大多情况下,一般操作K8s资源都会使用SDK模式,比如client-go

    + })(window)

    K8s-通过URL访问模式

    K8s-通过URL访问模式

    背景

    大多情况下,一般操作K8s资源都会使用SDK模式,比如client-go

    但是其实还支持原生的URL访问模式

    几种模式

    kubectl

    # 启动代理程序
    kubectl proxy --port=8080 &

    # 查看 http 模式
    curl http://localhost:8080/api/ '{"versions": ["v1"]}'

    @@ -193,7 +193,7 @@

    示例代码

    package main

    import (
    "crypto/tls"
    "fmt"
    "io"
    "net/http"
    )

    func main() {
    // 忽略严重ssl
    client := &http.Client{Transport: &http.Transport{
    TLSClientConfig: &tls.Config{
    InsecureSkipVerify: true,
    },
    }}
    targetUrl := "https://10.10.102.96:6443/api/v1/namespaces/default/services"

    req, _ := http.NewRequest("GET", targetUrl, nil)

    req.Header.Add("Authorization", "Bearer xxx")

    response, err := client.Do(req)
    if err != nil {
    fmt.Println(err)
    return
    }
    s, err := io.ReadAll(response.Body)
    if err != nil {
    fmt.Println(err)
    return
    }
    sprintf := fmt.Sprintf("%s", s)
    fmt.Println(sprintf)
    }
    -

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/10/09/cloud/k8s/K8s-通过URL访问模式/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/13/cloud/k8s/\347\274\226\350\257\221Kubemark/index.html" "b/2023/10/13/cloud/k8s/\347\274\226\350\257\221Kubemark/index.html" index dc1c6aa08..76480260a 100644 --- "a/2023/10/13/cloud/k8s/\347\274\226\350\257\221Kubemark/index.html" +++ "b/2023/10/13/cloud/k8s/\347\274\226\350\257\221Kubemark/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-编译Kubemark

    编译Kubemark

    背景

    Kubemark是k8s虚拟化节点的工具,用于测试。

    + })(window)

    K8s-编译Kubemark

    编译Kubemark

    背景

    Kubemark是k8s虚拟化节点的工具,用于测试。

    目前找不到现成可用Kubamark镜像,所以自行编译。

    安装

    # gcc 环境准备
    yum -y install gcc gcc-c++ autoconf pcre pcre-devel make automake
    yum -y install wget httpd-tools vim
    yum -y install glibc-static.x86_64
    yum -y install binutils
    @@ -185,7 +185,7 @@

    安装问题 rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.ImageService


    cat > /etc/containerd/config.toml <<EOF
    [plugins."io.containerd.grpc.v1.cri"]
    systemd_cgroup = true
    EOF

    systemctl restart containerd

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/10/13/cloud/k8s/编译Kubemark/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/23/cloud/k8s/\350\247\243\350\257\273Kubeadm\346\272\220\347\240\201/index.html" "b/2023/10/23/cloud/k8s/\350\247\243\350\257\273Kubeadm\346\272\220\347\240\201/index.html" index 2620c4542..53b53cd88 100644 --- "a/2023/10/23/cloud/k8s/\350\247\243\350\257\273Kubeadm\346\272\220\347\240\201/index.html" +++ "b/2023/10/23/cloud/k8s/\350\247\243\350\257\273Kubeadm\346\272\220\347\240\201/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    解读Kubeadm源码

    解读Kubeadm源码

    kubeadm init过程

    官网教程:https://kubernetes.io/zh-cn/docs/reference/setup-tools/kubeadm/kubeadm-init/

    + })(window)

    解读Kubeadm源码

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/10/23/cloud/k8s/解读Kubeadm源码/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/24/tools/Homebrew\345\205\261\345\255\230arm\345\222\214X86/index.html" "b/2023/10/24/tools/Homebrew\345\205\261\345\255\230arm\345\222\214X86/index.html" index ec93a4a81..4b6718526 100644 --- "a/2023/10/24/tools/Homebrew\345\205\261\345\255\230arm\345\222\214X86/index.html" +++ "b/2023/10/24/tools/Homebrew\345\205\261\345\255\230arm\345\222\214X86/index.html" @@ -162,7 +162,7 @@ } } detectApple() - })(window)

    Homebrew共存arm和X86(Mac)

    Homebrew共存arm和X86

    背景

    部分包支持arm,部分支持x86,主要是x86和arm的包的位置不一样

    + })(window)

    Homebrew共存arm和X86(Mac)

    Homebrew共存arm和X86

    背景

    部分包支持arm,部分支持x86,主要是x86和arm的包的位置不一样

    arm安装

    # 切换到/opt目录
    cd /opt
    # 创建homebrew目录
    sudo mkdir homebrew
    # 修改目录所属用户
    sudo chown -R $(whoami) /opt/homebrew
    # 安装Arm版Homebrew
    curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

    x86 安装

    arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
    @@ -181,7 +181,7 @@

    如何查看当前brew的版本

    # 查看brew架构
    brew config
    >
    HOMEBREW_VERSION: 4.1.17
    ORIGIN: https://mirrors.ustc.edu.cn/brew.git
    HEAD: 35746e0a6ba6c3c5cfe56d99f79d9ec9f52ee15f
    Last commit: 2 days ago
    Core tap origin: https://github.com/Homebrew/homebrew-core
    Core tap HEAD: cfa52a1f3d877a726b6006f4413000b3437c2709
    Core tap last commit: 4 hours ago
    Core tap branch: master
    Core tap JSON: 24 Oct 09:20 UTC
    HOMEBREW_PREFIX: /usr/local
    HOMEBREW_API_DOMAIN: https://mirrors.ustc.edu.cn/homebrew-bottles/api
    HOMEBREW_BOTTLE_DOMAIN: https://mirrors.ustc.edu.cn/homebrew-bottles/bottles
    HOMEBREW_CASK_OPTS: []
    HOMEBREW_MAKE_JOBS: 8
    HOMEBREW_NO_AUTO_UPDATE: set
    Homebrew Ruby: 2.6.10 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
    CPU: octa-core 64-bit westmere
    Clang: 14.0.0 build 1400
    Git: 2.37.1 => /Library/Developer/CommandLineTools/usr/bin/git
    Curl: 8.1.2 => /usr/bin/curl
    macOS: 12.6.8-x86_64
    CLT: 14.2.0.0.1.1668646533
    Xcode: N/A
    Rosetta 2: true

    abrew
    >
    HOMEBREW_VERSION: >=2.5.0 (shallow or no git repository)
    ORIGIN: (none)
    HEAD: (none)
    Last commit: never
    Core tap JSON: 24 Oct 09:20 UTC
    HOMEBREW_PREFIX: /opt/homebrew
    HOMEBREW_API_DOMAIN: https://mirrors.ustc.edu.cn/homebrew-bottles/api
    HOMEBREW_BOTTLE_DOMAIN: https://mirrors.ustc.edu.cn/homebrew-bottles/bottles
    HOMEBREW_CASK_OPTS: []
    HOMEBREW_MAKE_JOBS: 8
    HOMEBREW_NO_AUTO_UPDATE: set
    Homebrew Ruby: 2.6.10 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
    CPU: octa-core 64-bit arm_firestorm_icestorm
    Clang: 14.0.0 build 1400
    Git: 2.37.1 => /Library/Developer/CommandLineTools/usr/bin/git
    Curl: 8.1.2 => /usr/bin/curl
    macOS: 12.6.8-arm64
    CLT: 14.2.0.0.1.1668646533
    Xcode: N/A
    Rosetta 2: false

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/10/24/tools/Homebrew共存arm和X86/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/25/cloud/k8s/K8s-Service\347\253\257\347\202\271\345\210\207\347\211\207\345\222\214\346\234\215\345\212\241\346\213\223\346\211\221/index.html" "b/2023/10/25/cloud/k8s/K8s-Service\347\253\257\347\202\271\345\210\207\347\211\207\345\222\214\346\234\215\345\212\241\346\213\223\346\211\221/index.html" index 4b5f9c4ed..5d05c19eb 100644 --- "a/2023/10/25/cloud/k8s/K8s-Service\347\253\257\347\202\271\345\210\207\347\211\207\345\222\214\346\234\215\345\212\241\346\213\223\346\211\221/index.html" +++ "b/2023/10/25/cloud/k8s/K8s-Service\347\253\257\347\202\271\345\210\207\347\211\207\345\222\214\346\234\215\345\212\241\346\213\223\346\211\221/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-Service端点切片和服务拓扑

    K8s-Service端点切片和服务拓扑

    背景

    Service背后指向了一组Endpoint列表,当集群规范增大时,kube-proxy负载迅速上升,同时Service对Endpoint的CRUD操作成本是上升。

    + })(window)

    K8s-Service端点切片和服务拓扑

    K8s-Service端点切片和服务拓扑

    背景

    Service背后指向了一组Endpoint列表,当集群规范增大时,kube-proxy负载迅速上升,同时Service对Endpoint的CRUD操作成本是上升。

    所以在K8s 1.16引入了端点切片(Endpoint Slices)机制,包括一个新的EndpointSlice资源对象和新的EndpointSlice控制器。

    在K8s 1.17进入beta阶段,其原理是对Endpoint进行分片管理,实现降低Master和Node之间的网络传输数据量和提供整体性能。

    默认:EndpointSlice控制器创建Endpoint为100,需要修改需要设置kube-controller-manager –max- endpoint-per-slice设置,但是最大上限不能超过1000

    @@ -179,7 +179,7 @@

    服务拓扑(Service Topology)

    服务拓扑机制从Kubernetes 1.17版本开始引入,目前为Alpha阶段, 目标是实现基于Node拓扑的流量路由,例如将发送到某个服务的流量优 先路由到与客户端相同Node的Endpoint上,或者路由到与客户端相同 Zone的那些Node的Endpoint上

    在默认情况下,发送到一个Service的流量会被均匀转发到每个后端 Endpoint,但无法根据更复杂的拓扑信息设置复杂的路由策略。服务拓 扑机制的引入就是为了实现基于Node拓扑的服务路由,允许Service创建 者根据来源Node和目标Node的标签来定义流量路由策略

    服务拓扑机制需要通过设置kube-apiserver和kube-proxy服务的启动 参数–feature-gates=”ServiceTopology=true,EndpointSlice=true”进行启用 (需要同时启用EndpointSlice功能),然后就可以在Service资源对象上 通过定义topologyKeys字段来控制到Service的流量路由了

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/10/25/cloud/k8s/K8s-Service端点切片和服务拓扑/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/26/cloud/k8s/K8s-Pod\347\232\204\346\211\251\345\256\271/index.html" "b/2023/10/26/cloud/k8s/K8s-Pod\347\232\204\346\211\251\345\256\271/index.html" index 941051a12..abcd00526 100644 --- "a/2023/10/26/cloud/k8s/K8s-Pod\347\232\204\346\211\251\345\256\271/index.html" +++ "b/2023/10/26/cloud/k8s/K8s-Pod\347\232\204\346\211\251\345\256\271/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-Pod的扩容

    K8s-Pod的扩容

    背景

    在实际生产系统中,我们经常会遇到某个服务需要扩容的场景,也 可能会遇到由于资源紧张或者工作负载降低而需要减少服务实例数量的 场景。此时可以利用Deployment/RC的Scale机制来完成这些工作。

    + })(window)

    K8s-Pod的扩容

    K8s-Pod的扩容

    背景

    在实际生产系统中,我们经常会遇到某个服务需要扩容的场景,也 可能会遇到由于资源紧张或者工作负载降低而需要减少服务实例数量的 场景。此时可以利用Deployment/RC的Scale机制来完成这些工作。

    手动扩容

    1. 通过kubectl scale deployment $nginx-deploymenr --replicas 5
    2. 本质上是通过修改replicas 实现的
    3. @@ -174,7 +174,7 @@

      期望副本数 = ceil[当前副本数 * (当前指标 / 期望指标)]
      -
      apiVersion: autoscaling/v2
      kind: HorizontalPodAutoscaler
      metadata:
      name: php-apache
      spec:
      # 指向的副本控制器
      scaleTargetRef:
      apiVersion: apps/v1
      kind: Deployment
      name: php-apache
      # 最小
      minReplicas: 1
      # 最大拓展
      maxReplicas: 10
      #Pod指标
      metrics:
      - type: Resource
      resource:
      name: cpu
      target:
      # 百分比类型
      type: Utilization
      averageUtilization: 50
      - type: Resource
      resource:
      name: memory
      target:
      # 绝对值类型
      type: AverageValue
      averageValue: 100M

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/10/26/cloud/k8s/K8s-Pod的扩容/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/26/cloud/k8s/K8s-Service\347\232\204\350\264\237\350\275\275\345\235\207\350\241\241\346\234\272\345\210\266/index.html" "b/2023/10/26/cloud/k8s/K8s-Service\347\232\204\350\264\237\350\275\275\345\235\207\350\241\241\346\234\272\345\210\266/index.html" index 95dfc3bb7..107db6c44 100644 --- "a/2023/10/26/cloud/k8s/K8s-Service\347\232\204\350\264\237\350\275\275\345\235\207\350\241\241\346\234\272\345\210\266/index.html" +++ "b/2023/10/26/cloud/k8s/K8s-Service\347\232\204\350\264\237\350\275\275\345\235\207\350\241\241\346\234\272\345\210\266/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-Service的负载均衡机制

    K8s-Service的负载均衡机制

    Service对象通过关联转发到PodI实现负载均衡,每个Node的kube-proxy负责实现。

    + })(window)

    K8s-Service的负载均衡机制

    K8s-Service的负载均衡机制

    Service对象通过关联转发到PodI实现负载均衡,每个Node的kube-proxy负责实现。

    kube-proxy的代理模式

    通过启动参数–proxy-mode设 置

    userspace模式(x)

    用户空间模式,由kube-proxy完成的代理模式,效率低,不再推荐

    iptables模式

    kube-proxy通过设置Linux Kernel的iptables规则, 实现从Service到后端Endpoint列表的负载分发规则,效率很高。但是, 如果某个后端Endpoint在转发时不可用,此次客户端请求就会得到失败 的响应,相对于userspace模式来说更不可靠。

    @@ -180,7 +180,7 @@

    kernelspace模式

    Windows Server上的代理模式。

    会话保持机制

    Service支持通过设置sessionAffinity实现基于客户端IP的会话保持机制,即首次将某个客户端来源IP发起的请求转发到后端的某个Pod上, 之后从相同的客户端IP发起的请求都将被转发到相同的后端Pod上,配 置参数为service.spec.sessionAffinity

    -
    apiVersion: v1
    kind: Service
    metadata:
    name: sessionService
    spec:
    # 设置
    sessionAffinity: ClientIP
    # 会话保持时间
    sessionAffinityConfig:
    clientIP:
    timeoutSeconds: 10800
    selector:
    app: sessionService
    ports:
    - protocol: TCP
    port: 80
    targetPort: 8080
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/10/26/cloud/k8s/K8s-Service的负载均衡机制/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/26/cloud/k8s/K8s\347\232\204\344\272\224\347\247\215\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/index.html" "b/2023/10/26/cloud/k8s/K8s\347\232\204\344\272\224\347\247\215\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/index.html" index e82bb51f6..f7803427e 100644 --- "a/2023/10/26/cloud/k8s/K8s\347\232\204\344\272\224\347\247\215\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/index.html" +++ "b/2023/10/26/cloud/k8s/K8s\347\232\204\344\272\224\347\247\215\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s的五种代码生成器

    K8s的五种代码生成器

    概述

    + })(window)

    K8s的五种代码生成器

    K8s的五种代码生成器

    概述

    @@ -212,7 +212,7 @@

    prerelese- lifecycle-gen

    主要为beta API生成zz_api_status.go文件,该文件指示种类、引入版本,将被弃用的版本以及被删除的版本。

    代码生成器
    // +k8s:prereplease-lifecycle-gen=package
    # 注册是一个整体选项,不适用单个对象
    // +k8s:prereplease-lifecycle-gen:introduced=1.19
    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/10/26/cloud/k8s/K8s的五种代码生成器/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/27/cloud/k8s/K8s-Service\347\232\204\346\234\215\345\212\241\345\217\221\347\216\260\346\234\272\345\210\266/index.html" "b/2023/10/27/cloud/k8s/K8s-Service\347\232\204\346\234\215\345\212\241\345\217\221\347\216\260\346\234\272\345\210\266/index.html" index 96088bba3..12d2b3f89 100644 --- "a/2023/10/27/cloud/k8s/K8s-Service\347\232\204\346\234\215\345\212\241\345\217\221\347\216\260\346\234\272\345\210\266/index.html" +++ "b/2023/10/27/cloud/k8s/K8s-Service\347\232\204\346\234\215\345\212\241\345\217\221\347\216\260\346\234\272\345\210\266/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-Service的服务发现机制

    K8s-Service的服务发现机制

    服务发现机制主要是K8s集群如何获取后端服务的访问地址。

    + })(window)

    K8s-Service的服务发现机制

    K8s-Service的服务发现机制

    服务发现机制主要是K8s集群如何获取后端服务的访问地址。

    K8s主要提供了俩种模式,环境变量方式和DNS方式

    环境变量

    apiVersion: v1
    kind: Service
    metadata:
    name: kubia
    spec:
    selector:
    app: kubia-service
    ports:
    - protocol: TCP
    port: 8080
    targetPort: 8080
    @@ -183,7 +183,7 @@

    <_portname>.<_protocol>...svc.

    会多一条:_http._tcp.webapp.default.svc.cluster.local

    -

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/10/27/cloud/k8s/K8s-Service的服务发现机制/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/10/29/cloud/k8s/K8s-\344\270\211\345\244\247\346\240\270\345\277\203\346\225\260\346\215\256\347\273\223\346\236\204/index.html" "b/2023/10/29/cloud/k8s/K8s-\344\270\211\345\244\247\346\240\270\345\277\203\346\225\260\346\215\256\347\273\223\346\236\204/index.html" index 2b706a105..3b042724c 100644 --- "a/2023/10/29/cloud/k8s/K8s-\344\270\211\345\244\247\346\240\270\345\277\203\346\225\260\346\215\256\347\273\223\346\236\204/index.html" +++ "b/2023/10/29/cloud/k8s/K8s-\344\270\211\345\244\247\346\240\270\345\277\203\346\225\260\346\215\256\347\273\223\346\236\204/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-三大核心数据结构

    K8s-三大核心数据结构

    构成

    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/11/01/cloud/k8s/K8s-\344\275\277\347\224\250swagger-ui\345\217\257\350\247\206\345\214\226K8s API\346\226\207\346\241\243/index.html" "b/2023/11/01/cloud/k8s/K8s-\344\275\277\347\224\250swagger-ui\345\217\257\350\247\206\345\214\226K8s API\346\226\207\346\241\243/index.html" index 80511e731..2a3eace5b 100644 --- "a/2023/11/01/cloud/k8s/K8s-\344\275\277\347\224\250swagger-ui\345\217\257\350\247\206\345\214\226K8s API\346\226\207\346\241\243/index.html" +++ "b/2023/11/01/cloud/k8s/K8s-\344\275\277\347\224\250swagger-ui\345\217\257\350\247\206\345\214\226K8s API\346\226\207\346\241\243/index.html" @@ -163,12 +163,12 @@ } } detectApple() - })(window)

    K8s-使用swagger-ui可视化K8s API文档

    使用swagger-ui可视化K8s API文档

    背景

    需要进行K8s API开发的时候,不方便查看

    + })(window)

    K8s-使用swagger-ui可视化K8s API文档

    使用swagger-ui可视化K8s API文档

    背景

    需要进行K8s API开发的时候,不方便查看

    具体实现

    # 启动代理
    kubectl proxy --port=8080

    # 获取到swagger.json
    curl localhost:8080/openapi/v2 > k8s-swagger.json

    # docker启动swagger
    docker run \
    --rm \
    -d \
    -p 8087:8080 \
    -e SWAGGER_JSON=/k8s-swagger.json \
    -v $(pwd)/k8s-swagger.json:/k8s-swagger.json \
    swaggerapi/swagger-ui


    # 通过http://ip:8087
    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/11/01/cloud/k8s/K8s-使用swagger-ui可视化K8s API文档/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/11/01/cloud/k8s/K8s-\351\233\206\347\276\244\345\256\211\350\243\205\350\256\244\350\257\201/index.html" "b/2023/11/01/cloud/k8s/K8s-\351\233\206\347\276\244\345\256\211\350\243\205\350\256\244\350\257\201/index.html" index 638f08a6b..1f46491aa 100644 --- "a/2023/11/01/cloud/k8s/K8s-\351\233\206\347\276\244\345\256\211\350\243\205\350\256\244\350\257\201/index.html" +++ "b/2023/11/01/cloud/k8s/K8s-\351\233\206\347\276\244\345\256\211\350\243\205\350\256\244\350\257\201/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-集群安装认证

    K8s-集群安装认证

    API Server认证

    三大K8s API访问模式:

    + })(window)

    K8s-集群安装认证

    K8s-集群安装认证

    API Server认证

    三大K8s API访问模式:

    1. 以Service Account方式访问K8s的内部服务进程
    2. 以匿名方式访问的进程
    3. @@ -197,7 +197,7 @@

      OpenID Connect Token第三方认证

      Kubernetes也支持使用OpenID Connect协议(简称OIDC)进行身份 认证。OIDC协议是基于OAuth 2.0协议的身份认证标准协议,在OAuth 2.0上构建了一个身份层,OIDC的登录过程与OAuth相比,最主要的扩 展就是提供了ID Token,这是一个JWT格式的加密Token。API Server本 身与OIDC Server(即Identity Provider)没有太多交互,用户(主要是 kubectl用户)通过OIDC Server得到一个合法的ID Token,并作为命令行 参数(或者kubectl的配置文件)传递给API Server,API Server则通过验 证该Token是否合法及是否有效来确定用户的身份。虽然在OIDC Server 中可以做到用户的权限管理,但Kubernetes并不使用OIDC Server的权限 管理,因为它有自己完善的BRAC权限管理体系

      Authenticating Proxy

      在这种方式下,将API Server配置为从HTTP Header(例如XRemote-User字段)对用户进行识别。这需要与Authenticating Proxy程序 一同工作,由Authenticating Proxy设置HTTP Header的值。

      Service Account

      Service Account也是一种账号,但它并不是给Kubernetes集群的用户 (系统管理员、运维人员、租户用户等)用的,而是给运行在Pod里的 进程用的,它为Pod里的进程提供了必要的身份证明。

      -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/11/01/cloud/k8s/K8s-集群安装认证/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/11/02/cloud/k8s/K8s-CNI\347\275\221\347\273\234\346\250\241\345\236\213/index.html" "b/2023/11/02/cloud/k8s/K8s-CNI\347\275\221\347\273\234\346\250\241\345\236\213/index.html" index 6579fd752..7e13e5c01 100644 --- "a/2023/11/02/cloud/k8s/K8s-CNI\347\275\221\347\273\234\346\250\241\345\236\213/index.html" +++ "b/2023/11/02/cloud/k8s/K8s-CNI\347\275\221\347\273\234\346\250\241\345\236\213/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-CNI网络模型

    K8s-CNI网络模型

    背景

    跨主机容器间的网络互通已经成为基本要求,更 高的要求包括容器固定IP地址、一个容器多个IP地址、多个子网隔离、 ACL控制策略、与SDN集成等。所以提出了Container Network Interface(CNI)

    + })(window)

    K8s-CNI网络模型

    K8s-CNI网络模型

    背景

    跨主机容器间的网络互通已经成为基本要求,更 高的要求包括容器固定IP地址、一个容器多个IP地址、多个子网隔离、 ACL控制策略、与SDN集成等。所以提出了Container Network Interface(CNI)

    CNM网络模型

    主要组件功能:

      @@ -299,7 +299,7 @@

      Versi
    • CNI_PATH:可执行文件的查找路径,可以设置多个

    错误返回码说明

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/11/02/cloud/k8s/K8s-CNI网络模型/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git a/2023/11/02/cloud/k8s/K8s-DNS-CoreDNS/index.html b/2023/11/02/cloud/k8s/K8s-DNS-CoreDNS/index.html index aad0f0365..b1ef1c39c 100644 --- a/2023/11/02/cloud/k8s/K8s-DNS-CoreDNS/index.html +++ b/2023/11/02/cloud/k8s/K8s-DNS-CoreDNS/index.html @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-DNS-CoreDNS

    K8s-DNS-CoreDNS

    修改Node上的kubelet的DNS启动参数

    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/11/02/cloud/k8s/K8s-\345\255\230\345\202\250\347\263\273\347\273\237/index.html" "b/2023/11/02/cloud/k8s/K8s-\345\255\230\345\202\250\347\263\273\347\273\237/index.html" index cbb14a642..150d05219 100644 --- "a/2023/11/02/cloud/k8s/K8s-\345\255\230\345\202\250\347\263\273\347\273\237/index.html" +++ "b/2023/11/02/cloud/k8s/K8s-\345\255\230\345\202\250\347\263\273\347\273\237/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-存储系统

    K8s-存储系统

    Config Map

    apiVersion: v1
    kind: ConfigMap
    metadata:
    name: game-demo
    data:
    # 类属性键;每一个键都映射到一个简单的值
    player_initial_lives: "3"
    ui_properties_file_name: "user-interface.properties"

    # 类文件键
    game.properties: |
    enemy.types=aliens,monsters
    player.maximum-lives=5
    user-interface.properties: |
    color.good=purple
    color.bad=yellow
    allow.textmode=true
    ---
    apiVersion: v1
    kind: Pod
    metadata:
    name: cm-test-app
    spec:
    containers:
    - name: cm-test-app
    image: kubeguide/tomcat-app:v1
    ports:
    - containerPort: 8080
    volumeMounts:
    # 挂载的容器目录
    - mountPath: /configfiles
    name: serverxml
    volumes:
    # volume的名字
    - name: serverxml
    configMap:
    #cm 的name
    name: game-demo
    items:
    # cm的 key
    - key: game.properties
    # 容器内文件名字
    path: containergame.properties
    # cm的 key
    - key: user-interface.properties
    # 容器内文件名字
    path: user-xxx.properties
    + })(window)

    K8s-存储系统

    K8s-存储系统

    Config Map

    apiVersion: v1
    kind: ConfigMap
    metadata:
    name: game-demo
    data:
    # 类属性键;每一个键都映射到一个简单的值
    player_initial_lives: "3"
    ui_properties_file_name: "user-interface.properties"

    # 类文件键
    game.properties: |
    enemy.types=aliens,monsters
    player.maximum-lives=5
    user-interface.properties: |
    color.good=purple
    color.bad=yellow
    allow.textmode=true
    ---
    apiVersion: v1
    kind: Pod
    metadata:
    name: cm-test-app
    spec:
    containers:
    - name: cm-test-app
    image: kubeguide/tomcat-app:v1
    ports:
    - containerPort: 8080
    volumeMounts:
    # 挂载的容器目录
    - mountPath: /configfiles
    name: serverxml
    volumes:
    # volume的名字
    - name: serverxml
    configMap:
    #cm 的name
    name: game-demo
    items:
    # cm的 key
    - key: game.properties
    # 容器内文件名字
    path: containergame.properties
    # cm的 key
    - key: user-interface.properties
    # 容器内文件名字
    path: user-xxx.properties

    ​ ConfigMap中的配置内容如果是UTF-8编码的字符,则将被系统认 为是文本文件。如果是其他字符,则系统将以二进制数据格式进行保存 (设置为binaryData字段)

    Node本地存储卷

    Kubernetes管理的Node本地存储卷(Volume)的类型如下。

    @@ -298,7 +298,7 @@

    CS
  • 与kubelet通信的辅助sidecar容器的node-driver-register,主要功能是将存储驱动注册到kubelet中
  • CSI Driver存储驱动容器,,由第三方存储提供商提供,主要功 能是接收kubelet的调用,需要实现一系列与Node相关的CSI接口,例如 NodePublishVolume接口(用于将Volume挂载到容器内的目标路径)、 NodeUnpublishVolume接口(用于从容器中卸载Volume),等等。node-driver-registrar容器与kubelet通过Node主机一个hostPath目录下 的unix socket进行通信。CSI Driver容器与kubelet通过Node主机另一个 hostPath目录下的unix socket进行通信,同时需要将kubelet的工作目录 (默认为/var/lib/kubelet)挂载给CSI Driver容器,用于为Pod进行 Volume的管理操作(包括mount、umount等)
  • -

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/11/02/cloud/k8s/K8s-存储系统/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/11/07/cloud/k8s/K8s-\346\240\270\345\277\203\346\225\260\346\215\256\347\273\223\346\236\204-scheme\350\265\204\346\272\220\346\263\250\345\206\214\350\241\250/index.html" "b/2023/11/07/cloud/k8s/K8s-\346\240\270\345\277\203\346\225\260\346\215\256\347\273\223\346\236\204-scheme\350\265\204\346\272\220\346\263\250\345\206\214\350\241\250/index.html" index 20f5c1751..aeb677264 100644 --- "a/2023/11/07/cloud/k8s/K8s-\346\240\270\345\277\203\346\225\260\346\215\256\347\273\223\346\236\204-scheme\350\265\204\346\272\220\346\263\250\345\206\214\350\241\250/index.html" +++ "b/2023/11/07/cloud/k8s/K8s-\346\240\270\345\277\203\346\225\260\346\215\256\347\273\223\346\236\204-scheme\350\265\204\346\272\220\346\263\250\345\206\214\350\241\250/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-核心数据结构-scheme资源注册表

    K8s-核心数据结构-scheme资源注册表

    所有的K8s资源类型都会注册到Scheme资源注册表中,有如下的特点:

    + })(window)

    K8s-核心数据结构-scheme资源注册表

    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/11/08/cloud/k8s/K8s-client-go\357\274\232\346\272\220\347\240\201\347\273\223\346\236\204/index.html" "b/2023/11/08/cloud/k8s/K8s-client-go\357\274\232\346\272\220\347\240\201\347\273\223\346\236\204/index.html" index 685da4a4c..a4f272f62 100644 --- "a/2023/11/08/cloud/k8s/K8s-client-go\357\274\232\346\272\220\347\240\201\347\273\223\346\236\204/index.html" +++ "b/2023/11/08/cloud/k8s/K8s-client-go\357\274\232\346\272\220\347\240\201\347\273\223\346\236\204/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    K8s-client-go:源码结构

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/11/08/cloud/k8s/K8s-client-go:源码结构/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/11/08/cloud/k8s/K8s-\345\270\270\350\247\201API Server\345\223\215\345\272\224\350\257\264\346\230\216/index.html" "b/2023/11/08/cloud/k8s/K8s-\345\270\270\350\247\201API Server\345\223\215\345\272\224\350\257\264\346\230\216/index.html" index 1cb1a676d..6082f80ac 100644 --- "a/2023/11/08/cloud/k8s/K8s-\345\270\270\350\247\201API Server\345\223\215\345\272\224\350\257\264\346\230\216/index.html" +++ "b/2023/11/08/cloud/k8s/K8s-\345\270\270\350\247\201API Server\345\223\215\345\272\224\350\257\264\346\230\216/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-常见API Server响应说明

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/11/08/cloud/k8s/K8s-常见API Server响应说明/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/11/11/cloud/k8s/K8s-Client-go\357\274\232\345\233\233\347\247\215\345\256\242\346\210\267\347\253\257/index.html" "b/2023/11/11/cloud/k8s/K8s-Client-go\357\274\232\345\233\233\347\247\215\345\256\242\346\210\267\347\253\257/index.html" index 27682ebd2..390df9f9b 100644 --- "a/2023/11/11/cloud/k8s/K8s-Client-go\357\274\232\345\233\233\347\247\215\345\256\242\346\210\267\347\253\257/index.html" +++ "b/2023/11/11/cloud/k8s/K8s-Client-go\357\274\232\345\233\233\347\247\215\345\256\242\346\210\267\347\253\257/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    K8s-Client-go:四种客户端

    K8s-Client-go:四种客户端

    概述

    ClientSet、DynamicClient、DiscoveryClient. —> RESTClient —> kubeconfig

    + })(window)

    K8s-Client-go:四种客户端

    K8s-Client-go:四种客户端

    概述

    ClientSet、DynamicClient、DiscoveryClient. —> RESTClient —> kubeconfig

    其实,前面三种都是依赖于 RESTClient

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/11/11/cloud/k8s/K8s-Client-go:四种客户端/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/11/11/cloud/k8s/K8s-client-goWorkQueue\345\267\245\344\275\234\351\230\237\345\210\227/index.html" "b/2023/11/11/cloud/k8s/K8s-client-goWorkQueue\345\267\245\344\275\234\351\230\237\345\210\227/index.html" index 3697e070d..48f6f284a 100644 --- "a/2023/11/11/cloud/k8s/K8s-client-goWorkQueue\345\267\245\344\275\234\351\230\237\345\210\227/index.html" +++ "b/2023/11/11/cloud/k8s/K8s-client-goWorkQueue\345\267\245\344\275\234\351\230\237\345\210\227/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    K8s-client-go:WorkQueue工作队列

    K8s-client-go:WorkQueue工作队列

    WorkQueue队列与普通的FIFO队列,添加了标记和去重功能。有如下特性:

    + })(window)

    K8s-client-go:WorkQueue工作队列

    K8s-client-go:WorkQueue工作队列

    WorkQueue队列与普通的FIFO队列,添加了标记和去重功能。有如下特性:

    1. 有序:按照顺序处理元素
    2. 去重:相同元素同一时间不会被重复处理
    3. @@ -208,7 +208,7 @@

      exp := r.failures[item]
      r.failures[item] = r.failures[item] + 1

      // The backoff is capped such that 'calculated' value never overflows.
      backoff := float64(r.baseDelay.Nanoseconds()) * math.Pow(2, float64(exp))
      if backoff > math.MaxInt64 {
      return r.maxDelay
      }

      calculated := time.Duration(backoff)
      if calculated > r.maxDelay {
      return r.maxDelay
      }

      return calculated

      计数器算法

      计数器算法就是限制一段时间内允许通过的元素数量。但是WorkQueue添加了fastslow速率

      -
      func (r *ItemFastSlowRateLimiter) When(item interface{}) time.Duration {
      r.failuresLock.Lock()
      defer r.failuresLock.Unlock()

      r.failures[item] = r.failures[item] + 1

      if r.failures[item] <= r.maxFastAttempts {
      return r.fastDelay
      }

      return r.slowDelay
      }

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/11/11/cloud/k8s/K8s-client-goWorkQueue工作队列/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/11/14/cloud/k8s/K8s-\350\212\202\347\202\271/index.html" "b/2023/11/14/cloud/k8s/K8s-\350\212\202\347\202\271/index.html" index e14c7d1ca..22802f973 100644 --- "a/2023/11/14/cloud/k8s/K8s-\350\212\202\347\202\271/index.html" +++ "b/2023/11/14/cloud/k8s/K8s-\350\212\202\347\202\271/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-节点

    K8s-节点

    K8s的node(节点)是一个工作机器。每个节点都是归属master组件管理。

    + })(window)

    K8s-节点

    K8s-节点

    K8s的node(节点)是一个工作机器。每个节点都是归属master组件管理。

    节点的状态

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/11/14/cloud/k8s/K8s-节点/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/12/01/cloud/k8s/K8s-\345\256\271\345\231\250/index.html" "b/2023/12/01/cloud/k8s/K8s-\345\256\271\345\231\250/index.html" index df0153386..1c9bcaf2d 100644 --- "a/2023/12/01/cloud/k8s/K8s-\345\256\271\345\231\250/index.html" +++ "b/2023/12/01/cloud/k8s/K8s-\345\256\271\345\231\250/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-容器

    K8s-容器

    镜像

    在 Kubernetes 的 Pod 中使用容器镜像之前,您必须将其推送到一个镜像仓库(或者使用仓库中已经有的容器镜像)。在 Kubernetes 的 Pod 定义中定义容器时,必须指定容器所使用的镜像,容器中的 image 字段支持与 docker 命令一样的语法,包括私有镜像仓库和标签。

    + })(window)

    K8s-容器

    K8s-容器

    镜像

    在 Kubernetes 的 Pod 中使用容器镜像之前,您必须将其推送到一个镜像仓库(或者使用仓库中已经有的容器镜像)。在 Kubernetes 的 Pod 定义中定义容器时,必须指定容器所使用的镜像,容器中的 image 字段支持与 docker 命令一样的语法,包括私有镜像仓库和标签。

    例如:my-registry.example.com:5000/example/web-example:v1.0.1 由如下几个部分组成:

    my-registry.example.com:5000/example/web-example:v1.0.1

      @@ -282,7 +282,7 @@

      定义postStart和preStop处理程序

      apiVersion: v1
      kind: Pod
      metadata:
      name: lifecycle-demo
      spec:
      containers:
      - name: lifecycle-demo-container
      image: nginx
      lifecycle:
      postStart:
      exec:
      command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
      preStop:
      exec:
      command: ["/bin/sh","-c","nginx -s quit; while killall -0 nginx; do sleep 1; done"]

      -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/12/01/cloud/k8s/K8s-容器/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/12/02/cloud/k8s/K8s-\345\257\271\350\261\241/index.html" "b/2023/12/02/cloud/k8s/K8s-\345\257\271\350\261\241/index.html" index f3c467804..106440a8f 100644 --- "a/2023/12/02/cloud/k8s/K8s-\345\257\271\350\261\241/index.html" +++ "b/2023/12/02/cloud/k8s/K8s-\345\257\271\350\261\241/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-对象

    K8s-对象

    对象的spec和status

    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/12/04/cloud/k8s/K8s-\351\233\206\347\276\244\345\206\205\347\232\204\351\200\232\344\277\241/index.html" "b/2023/12/04/cloud/k8s/K8s-\351\233\206\347\276\244\345\206\205\347\232\204\351\200\232\344\277\241/index.html" index 122cbfd68..1a8af0751 100644 --- "a/2023/12/04/cloud/k8s/K8s-\351\233\206\347\276\244\345\206\205\347\232\204\351\200\232\344\277\241/index.html" +++ "b/2023/12/04/cloud/k8s/K8s-\351\233\206\347\276\244\345\206\205\347\232\204\351\200\232\344\277\241/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-集群内的通信

    K8s-集群内的通信

    Master-WorkNode

    Cluster to Master

    集群访问K8s Master,其实本质就是对于apiserver的通信(通信不是节点之间的通信,而是进程之间的通信

    + })(window)

    K8s-集群内的通信

    K8s-集群内的通信

    Master-WorkNode

    Cluster to Master

    集群访问K8s Master,其实本质就是对于apiserver的通信(通信不是节点之间的通信,而是进程之间的通信


    K8s安装K8s,apiserver默认是监听HTTPS端口(443),并且配置了客户端认证模式,提供授权模式.节点上必须配置集群(apiserver)的公钥根证书(public root certificate),此时,在提供有效的客户端身份认证的情况下,节点可以安全地访问 APIServer。


    @@ -184,7 +184,7 @@

    这些连接的访问端点是 kubelet 的 HTTPS 端口。默认情况下,apiserver 不校验 kubelet 的 HTTPS 证书,这种情况下,连接可能会收到 man-in-the-middle 攻击,因此该连接如果在不受信网络或者公网上运行时,是 不安全 的。

    如果要校验 kubelet 的 HTTPS 证书,可以通过 --kubelet-certificate-authority 参数为 apiserver 提供校验 kubelet 证书的根证书。

    apiserver to nodes, pods, services

    从 apiserver 到 节点/Pod/Service 的连接使用的是 HTTP 连接,没有进行身份认证,也没有进行加密传输。您也可以通过增加 https 作为 节点/Pod/Service 请求 URL 的前缀,但是 HTTPS 证书并不会被校验,也无需客户端身份认证,因此该连接是无法保证一致性的。目前,此类连接如果运行在非受信网络或公网上时,是 不安全

    -

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/12/04/cloud/k8s/K8s-集群内的通信/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/12/05/cloud/k8s/K8s-\346\234\215\345\212\241\345\217\221\347\216\260\343\200\201\350\264\237\350\275\275\345\235\207\350\241\241\343\200\201\347\275\221\347\273\234/index.html" "b/2023/12/05/cloud/k8s/K8s-\346\234\215\345\212\241\345\217\221\347\216\260\343\200\201\350\264\237\350\275\275\345\235\207\350\241\241\343\200\201\347\275\221\347\273\234/index.html" index 36b913af7..72792794f 100644 --- "a/2023/12/05/cloud/k8s/K8s-\346\234\215\345\212\241\345\217\221\347\216\260\343\200\201\350\264\237\350\275\275\345\235\207\350\241\241\343\200\201\347\275\221\347\273\234/index.html" +++ "b/2023/12/05/cloud/k8s/K8s-\346\234\215\345\212\241\345\217\221\347\216\260\343\200\201\350\264\237\350\275\275\345\235\207\350\241\241\343\200\201\347\275\221\347\273\234/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-服务发现、负载均衡、网络

    K8s-服务发现、负载均衡、网络

    Service

    Service 是 Kubernetes 中的一种服务发现机制:

    + })(window)

    K8s-服务发现、负载均衡、网络

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/12/05/cloud/k8s/K8s-服务发现、负载均衡、网络/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/12/23/cloud/k8s/K8s[\345\206\205\346\240\270\344\274\230\345\214\226]-\345\244\247\350\247\204\346\250\241\344\270\213\351\233\206\347\276\244\344\274\230\345\214\226/index.html" "b/2023/12/23/cloud/k8s/K8s[\345\206\205\346\240\270\344\274\230\345\214\226]-\345\244\247\350\247\204\346\250\241\344\270\213\351\233\206\347\276\244\344\274\230\345\214\226/index.html" index 47e41fa76..daf9206f2 100644 --- "a/2023/12/23/cloud/k8s/K8s[\345\206\205\346\240\270\344\274\230\345\214\226]-\345\244\247\350\247\204\346\250\241\344\270\213\351\233\206\347\276\244\344\274\230\345\214\226/index.html" +++ "b/2023/12/23/cloud/k8s/K8s[\345\206\205\346\240\270\344\274\230\345\214\226]-\345\244\247\350\247\204\346\250\241\344\270\213\351\233\206\347\276\244\344\274\230\345\214\226/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s[内核优化]-大规模下集群优化

    K8s[内核优化]-大规模下集群优化

    最大线程数和文件打开数。

    + })(window)

    K8s[内核优化]-大规模下集群优化

    K8s[内核优化]-大规模下集群优化

    最大线程数和文件打开数。

    编辑 /etc/security/limits.conf 。

    root soft nofile 655350
    root hard nofile 655350
    root soft nproc 655350
    root hard nproc 655350
    * soft nofile 655350
    * hard nofile 655350
    * soft nproc 655350
    * hard nproc 655350
    @@ -171,7 +171,7 @@

    编辑 /etc/sysctl.conf

    # 容器环境下,优化这些参数可以避免 NAT 过的 TCP 连接带宽上不去。
    net.netfilter.nf_conntrack_tcp_be_liberal = 1
    net.netfilter.nf_conntrack_tcp_loose = 1
    net.netfilter.nf_conntrack_max = 3200000
    net.netfilter.nf_conntrack_buckets = 1600512
    net.netfilter.nf_conntrack_tcp_timeout_time_wait = 30
    net.netfilter.nf_conntrack_tcp_timeout_established = 1200

    # tcp 队列
    net.ipv4.tcp_syncookies = 1
    net.core.somaxconn = 4096
    net.ipv4.tcp_max_syn_backlog = 8192

    # 端口范围
    net.ipv4.ip_local_port_range = "1024 65000"

    # timewait相关优化
    net.ipv4.tcp_max_tw_buckets = 50000
    net.ipv4.tcp_fin_timeout = 30

    # 以下三个参数是 arp 缓存的 gc 阀值
    net.ipv4.neigh.default.gc_thresh1="2048"
    net.ipv4.neigh.default.gc_thresh2="4096"
    net.ipv4.neigh.default.gc_thresh3="8192"

    # 磁盘 IO 优化
    vm.dirty_background_ratio = 5
    vm.dirty_expire_centisecs = 300
    vm.dirty_ratio = 10
    vm.dirty_writeback_centisecs = 50
    vm.dirtytime_expire_seconds = 43200

    # fd优化
    fs.file-max=655360
    fs.inotify.max_user_instances="8192"
    fs.inotify.max_user_watches="524288"
    # 最大线程数量
    kernel.pid_max = 655350
    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/12/23/cloud/k8s/K8s[内核优化]-大规模下集群优化/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/12/23/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-CronJob/index.html" "b/2023/12/23/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-CronJob/index.html" index 816b1b3ce..1cd96634a 100644 --- "a/2023/12/23/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-CronJob/index.html" +++ "b/2023/12/23/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-CronJob/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s[控制器]-CronJob

    K8s[控制器]-CronJob

    CronJob 按照预定的时间计划(schedule)创建 Job。一个 CronJob 对象类似于 crontab (cron table) 文件中的一行记录。该对象根据 Cron (opens new window)格式定义的时间计划,周期性地创建 Job 对象

    + })(window)

    K8s[控制器]-CronJob

    K8s[控制器]-CronJob

    CronJob 按照预定的时间计划(schedule)创建 Job。一个 CronJob 对象类似于 crontab (cron table) 文件中的一行记录。该对象根据 Cron (opens new window)格式定义的时间计划,周期性地创建 Job 对象

    本质上:CronJob 只负责按照时间计划的规定创建 Job 对象,由 Job 来负责管理具体 Pod 的创建和执行

    CronJob限制

    当以下两个条件都满足时,Job 将至少运行一次:

    如果将其设置为 0,则 CronJob 不会保留已经结束的 Job 的记录

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/12/23/cloud/k8s/K8s[控制器]-CronJob/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/12/24/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-DaemonSet/index.html" "b/2023/12/24/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-DaemonSet/index.html" index 5886dba0e..6113e6c5b 100644 --- "a/2023/12/24/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-DaemonSet/index.html" +++ "b/2023/12/24/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-DaemonSet/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s[控制器]-DaemonSet

    K8s[控制器]-DaemonSet

    什么是DaemonSet

    DaemonSet 控制器确保所有(或一部分)的节点都运行了一个指定的 Pod 副本。

    + })(window)

    K8s[控制器]-DaemonSet

    K8s[控制器]-DaemonSet

    什么是DaemonSet

    DaemonSet 控制器确保所有(或一部分)的节点都运行了一个指定的 Pod 副本。

    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/12/24/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-Job/index.html" "b/2023/12/24/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-Job/index.html" index acb4d8609..164cd57c6 100644 --- "a/2023/12/24/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-Job/index.html" +++ "b/2023/12/24/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-Job/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s[控制器]-Job

    K8s[控制器]-Job

    什么是Job

    Kubernetes中的 Job 对象将创建一个或多个 Pod,并确保指定数量的 Pod 可以成功执行到进程正常结束:

    + })(window)

    K8s[控制器]-Job

    K8s[控制器]-Job

    什么是Job

    Kubernetes中的 Job 对象将创建一个或多个 Pod,并确保指定数量的 Pod 可以成功执行到进程正常结束:

    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/12/25/cloud/k8s/K8s-GC(\345\236\203\345\234\276\345\233\236\346\224\266)/index.html" "b/2023/12/25/cloud/k8s/K8s-GC(\345\236\203\345\234\276\345\233\236\346\224\266)/index.html" index c44aff7a0..1cf77d83a 100644 --- "a/2023/12/25/cloud/k8s/K8s-GC(\345\236\203\345\234\276\345\233\236\346\224\266)/index.html" +++ "b/2023/12/25/cloud/k8s/K8s-GC(\345\236\203\345\234\276\345\233\236\346\224\266)/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-GC(垃圾回收)

    K8s-GC(垃圾回收)

    什么是GC

    Kubernetes garbage collector(垃圾回收器)的作用是删除那些曾经有 owner,后来又不再有 owner 的对象。

    + })(window)

    K8s-GC(垃圾回收)

    K8s-GC(垃圾回收)

    什么是GC

    Kubernetes garbage collector(垃圾回收器)的作用是删除那些曾经有 owner,后来又不再有 owner 的对象。

    通过metadata.ownerReferences可以知道Pod所属的对象

    垃圾收集器如何删除从属对象

    当删除某个对象时,可以指定该对象的从属对象是否同时被自动删除,这种操作叫做级联删除(cascading deletion)。级联删除有两种模式:后台(background)和前台(foreground)

    如果删除对象时不删除自动删除其从属对象,此时,从属对象被认为是孤儿(或孤立的 orphaned)。

    @@ -190,7 +190,7 @@

    kubectl delete replicaset my-repset --cascade=false

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/12/25/cloud/k8s/K8s-GC(垃圾回收)/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/12/25/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-StatefulSet/index.html" "b/2023/12/25/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-StatefulSet/index.html" index 08e6d0a56..34335d882 100644 --- "a/2023/12/25/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-StatefulSet/index.html" +++ "b/2023/12/25/cloud/k8s/K8s[\346\216\247\345\210\266\345\231\250]-StatefulSet/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s[控制器]-StatefulSet

    K8s[控制器]-StatefulSet

    什么是StatefulSet

    StatefulSet 顾名思义,用于管理 Stateful(有状态)的应用程序。

    + })(window)

    K8s[控制器]-StatefulSet

    K8s[控制器]-StatefulSet

    什么是StatefulSet

    StatefulSet 顾名思义,用于管理 Stateful(有状态)的应用程序。

    StatefulSet 管理 Pod 时,确保其 Pod 有一个按顺序增长的 ID。

    StatefulSet 使用场景

    对于有如下要求的应用程序,StatefulSet 非常适用:

    打赏
    • alipay
      alipay

    评论
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/12/29/cloud/k8s/K8s-\350\247\243\346\236\220\344\272\221\344\270\212\345\210\235\345\247\213\345\214\226(keadm init)/index.html" "b/2023/12/29/cloud/k8s/K8s-\350\247\243\346\236\220\344\272\221\344\270\212\345\210\235\345\247\213\345\214\226(keadm init)/index.html" index 87277d6bc..42b939e32 100644 --- "a/2023/12/29/cloud/k8s/K8s-\350\247\243\346\236\220\344\272\221\344\270\212\345\210\235\345\247\213\345\214\226(keadm init)/index.html" +++ "b/2023/12/29/cloud/k8s/K8s-\350\247\243\346\236\220\344\272\221\344\270\212\345\210\235\345\247\213\345\214\226(keadm init)/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-解析云上初始化(keadm init)

    K8s-解析云上初始化(keadm init)

    什么是keadm init

    keadm init通过keadm init可以实现初始化cloudcore。

    + })(window)

    K8s-解析云上初始化(keadm init)

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/12/29/cloud/k8s/K8s-解析云上初始化(keadm init)/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2023/12/30/cloud/kubeedge/Kubeedge-\350\247\243\346\236\220\350\216\267\345\217\226Token\357\274\210keadm gettoken)/index.html" "b/2023/12/30/cloud/kubeedge/Kubeedge-\350\247\243\346\236\220\350\216\267\345\217\226Token\357\274\210keadm gettoken)/index.html" index 0f5847775..c50424ef6 100644 --- "a/2023/12/30/cloud/kubeedge/Kubeedge-\350\247\243\346\236\220\350\216\267\345\217\226Token\357\274\210keadm gettoken)/index.html" +++ "b/2023/12/30/cloud/kubeedge/Kubeedge-\350\247\243\346\236\220\350\216\267\345\217\226Token\357\274\210keadm gettoken)/index.html" @@ -165,11 +165,11 @@ } } detectApple() - })(window)

    Kubeedge-解析获取Token(keadm gettoken)

    Kubeedge-解析获取Token(keadm gettoken)

    什么是keadm gettoken

    leads gettoken一般用于我们接入cloudcore的token的值的获取。

    + })(window)

    Kubeedge-解析获取Token(keadm gettoken)

    Kubeedge-解析获取Token(keadm gettoken)

    什么是keadm gettoken

    leads gettoken一般用于我们接入cloudcore的token的值的获取。

    如何获取token

    通过解析keadm gettoken源码,我们发现,其实keadm gettoken本质上就是查询下了kubeedge namespace 下的name为tokensecret 的Secret的tokendata的值

    https://github.com/kubeedge/kubeedge/blob/4ab8abe101e1037415d2c641feef642ab73a1d47/keadm/cmd/keadm/app/cmd/cloud/gettoken.go#L63

    这是一个Kubeedge 获取token的最简单的抽象:

    -
    package main

    import (
    "context"
    "fmt"
    metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    "k8s.io/client-go/kubernetes"
    "k8s.io/client-go/tools/clientcmd"
    )

    func main() {
    config, err := clientcmd.BuildConfigFromFlags("", "/Users/joohwan/k8sipconfig/K8sconfigfile")
    if err != nil {
    panic(err)
    }

    clientset, err := kubernetes.NewForConfig(config)
    secret, err := clientset.CoreV1().Secrets("kubeedge").Get(context.Background(), "tokensecret", metaV1.GetOptions{})
    if err != nil {
    panic(err)
    }
    fmt.Printf("Kubeedge JOIN TOKEN:%s", secret.Data["tokendata"])
    }

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2023/12/30/cloud/kubeedge/Kubeedge-解析获取Token(keadm gettoken)/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/01/01/tools/Goland\342\200\224\350\277\234\347\250\213Debug/index.html" "b/2024/01/01/tools/Goland\342\200\224\350\277\234\347\250\213Debug/index.html" index bfb7b5ae0..007ca8794 100644 --- "a/2024/01/01/tools/Goland\342\200\224\350\277\234\347\250\213Debug/index.html" +++ "b/2024/01/01/tools/Goland\342\200\224\350\277\234\347\250\213Debug/index.html" @@ -162,11 +162,11 @@ } } detectApple() - })(window)

    Goland—远程Debug

    Goland—远程Debug

    Introduce

    主要是本地不能调试的代码,通过Goland远程断点调试

    + })(window)

    Goland—远程Debug

    Goland—远程Debug

    Introduce

    主要是本地不能调试的代码,通过Goland远程断点调试

    步骤

    1. 安装Go
    curl https://github.com/Piwriw/k8s_example_tools/blob/master/setup-packages/go/setup-linux.sh -o setup-go.sh
    sh setup-go.sh 1.19


    2. 安装dlv
    go install github.com/go-delve/delve/cmd/dlv@latest

    3. 安装gcc
    cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH
    yum install -y gcc
    apt install -y gcc

    4. 远程服务器启动dlv

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/01/01/tools/Goland—远程Debug/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/01/02/cloud/k8s/StatefulSet[\345\256\236\344\276\213]-Mysql\351\233\206\347\276\244/index.html" "b/2024/01/02/cloud/k8s/StatefulSet[\345\256\236\344\276\213]-Mysql\351\233\206\347\276\244/index.html" index 5aa712114..4a71a7814 100644 --- "a/2024/01/02/cloud/k8s/StatefulSet[\345\256\236\344\276\213]-Mysql\351\233\206\347\276\244/index.html" +++ "b/2024/01/02/cloud/k8s/StatefulSet[\345\256\236\344\276\213]-Mysql\351\233\206\347\276\244/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    StatefulSet[实例]-Mysql集群

    StatefulSet[实例]-Mysql集群

    Introduce

    基于StatefulSet搭建K8s集群中的Mysql集群

    + })(window)

    StatefulSet[实例]-Mysql集群

    StatefulSet[实例]-Mysql集群

    Introduce

    基于StatefulSet搭建K8s集群中的Mysql集群

    1. —个‘主从复制”(MaserˉSlaveReplicatjon)的MySQL集群;

    2. @@ -201,7 +201,7 @@

      Deploy

      StatefulSet

      apiVersion: apps/v1
      kind: StatefulSet
      metadata:
      name: mysql-statefulset
      spec:
      selector:
      matchLabels:
      app: mysql # 必须匹配 .spec.template.metadata.labels
      serviceName: "mysql-headless"
      replicas: 1 # 默认值是 1
      minReadySeconds: 10 # 默认值是 0
      template:
      metadata:
      labels:
      app: mysql # 必须匹配 .spec.selector.matchLabels
      spec:
      terminationGracePeriodSeconds: 10
      initContainers:
      - name: init-mysql
      image: mysql:8.0.
      command:
      - bash
      - "-c"
      - |
      set -ex
      # 从Pod的序号生成server-id
      [[ `hostname` =~ -([0-9]+) $ ]] exit ]
      ordinal=${BASH_REMATCH[1]}
      echo [mysqld] > /mnt/conf.d/server-id.cnf
      #由于server-1d=0有特殊含义, 因此给ID加一个100避开它
      echo server-id=$(100+$ordinal)) >> /mnt/conf.d/server-id.crd

      if [[ $ordinal -eq 0 ]] ; then
      cp /mnt/config-map/master.conf /mnt/conf.d/
      else
      cp /mnt/config-map/slave.conf /mnt/conf.d/
      fi
      volumeMounts:
      - name: conf
      mountPath: /mnt/conf.d
      - name: config-map
      mountPath: /mnt/config-map
      - name: clone-mysql
      image: grc.io/google-samples/xtrabackup:1.0
      command:
      - bash
      - "-c"
      - |
      set -ex
      # 复制操作只要在第一次启动运行,数据存在就pass
      [ [ -d /var/lib/mysql/mysql ] ] && exit 0
      # 主节点(序号为0)不需要进行该操作
      [[ `hostname` =~ -([0-9+)$ ]] && exit 1
      ordinal=${BASH_REMATCH[1]}
      # 使用nact 远程从一个节点复制数据到本地
      nact --recv-only mysql-$(($ordinal-1)).mysql 3307 | xbstream -x -C /var/lib/mysql
      xtrabackup --prepare --target-dir=/var/lib/mysql
      volumeMounts:
      - name: data
      mountPath: /var/lib/mysql
      subPath: mysql
      - name: conf
      mountPath: /etc/mysql/conf.d
      containers:
      - name: xtrabackup
      image: grc.io/google-samples/xtrabackup:1.0
      ports:
      - name: xtrabackup
      containerPort: 3007
      command:
      - bash
      - "-c"
      - |
      set -ex
      cd /var/lib/mysql

      # 从备份文件里面读取MASTER_LOG_FILEM 和 MASTER_LOG_POS 这俩个字段的值
      if [[ -f xtrabackup_slave_info ]] ; then
      # 如果xtrabackup_slave_info 存在,说明备份数据来自另外一个节点
      mv xtrabackup_slave_info change change_master_to.sql.in
      rm -f xtrabackup_slave_info
      elifi [[ -f xtrabackup_binlog_info ]]; then
      # 如果只存在 xtrabackup_binlog_info 文件,说明备份来自主节点
      [[ `cat xtrabackup_binlog_info` =~ ^(.*?) [[:space:]]+(.*?)$ ]] || exit 1
      rm xtrabackup_binlog_info

      echo "CHANGE MASTER TO MASTER_LOG_FILE='${BASH_REMATCH[1]}',\
      MASTER_LOG_POS=${BASH_REMATCH[2]}" > change_master_to.sql.in
      fi

      # 如果change_master_to.sql.in 存在吗,进行集群初始化
      if [[ -f change_master_to.sql.in ]];then
      echo "Waiting ofr mysqld to be ready (Accepting connections)"
      until mysql -h 127.0.0.1 -e "SELECT 1"; do sleep 1; done

      echo "Initializing replication from clone position"
      # 把change_master_to.sql.in文件重命名,防止重复初始化
      mv change_master_to.sql.in change_master_to.sql.in.orig
      mysql -h 127.0.0.1 <<EOF
      $(<change_master_to.sql.in.orig),
      MASTER_HOST='myslq-0.mysql'
      MASTER_USER='root',
      MASTER_PASSWORD='',
      MASTER_CONNECT_RETRY=10;
      START SLAVE;
      EOF
      fi

      # ncat 监听3307,收到传输请求执行 xtrabackup --backup
      exec ncat --listen --keep-one --send-only --max-conns=1 3308 -c \
      " xtrabackup --backup --slave-info --stream=xbstream --host=127.0.0.1 --user=root "
      volumeMounts:
      - mountPath: /var/lib/mysql
      name: data
      subPath: mysql
      - mountPath: conf
      name: conf
      subPath: /etc/mysql/conf.d
      - name: mysql
      image: mysql:8.0.26
      env:
      - name: MYSQL_ALLOW_EMPTY_PASSWORD
      value: "1"
      - name: MYSQL_ROOT_PASSWORD
      value: root
      - name: MYSQL_USER_HOST
      value: '%'
      - name: MYSQL_ROOT_HOST
      value: '%'
      - name: MYSQL_PORT
      value: "3306"
      - name: TZ
      value: Asia/Shanghai
      - name: LANG
      value: en_US.UTF-8
      ports:
      - containerPort: 3306
      name: mysql
      volumeMounts:
      - mountPath: /var/lib/mysql
      name: data
      - mountPath: /etc/mysql/conf.d
      name: conf
      resources:
      requests:
      cpu: 500m
      memory: 1Gi
      livenessProbe:
      exec:
      command: [mysqladmin,"ping"]
      initialDelaySeconds: 30
      periodSeconds: 10
      timeoutSeconds: 5
      readinessProbe:
      exec:
      command: ["mysql","-h","127.0.0.1","-e","SELECT 1"]
      initialDelaySeconds: 5
      periodSeconds: 2
      timeoutSeconds: 1
      volumes:
      - name: conf
      emptyDir: { }
      - name: config-map
      configMap:
      name: mysql

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/01/02/cloud/k8s/StatefulSet[实例]-Mysql集群/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/01/08/cloud/k8s/K8s\345\205\254\347\275\221\351\203\250\347\275\262/index.html" "b/2024/01/08/cloud/k8s/K8s\345\205\254\347\275\221\351\203\250\347\275\262/index.html" index 93650840f..b2ee7b89f 100644 --- "a/2024/01/08/cloud/k8s/K8s\345\205\254\347\275\221\351\203\250\347\275\262/index.html" +++ "b/2024/01/08/cloud/k8s/K8s\345\205\254\347\275\221\351\203\250\347\275\262/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-公网部署集群

    K8s 公网部署集群

    BackGroud

    在公网环境下,或者需要跨局域网组成集群下。需要让Master以公网IP启动,而kubeadm init 参数启动,只支持局域网。

    + })(window)

    K8s-公网部署集群

    K8s 公网部署集群

    BackGroud

    在公网环境下,或者需要跨局域网组成集群下。需要让Master以公网IP启动,而kubeadm init 参数启动,只支持局域网。

    Deploy

    1. 获取配置文件kubead config default > k8s-init.yamllocalAPIEndpoint.advertiseAddress就是公网IP地址
    @@ -180,7 +180,7 @@

    Deploy

    查看是否正确,cat /root/.kube/config,的IP和配置文件。

    -

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/01/08/cloud/k8s/K8s公网部署/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/01/16/cloud/cri-o\347\232\204\345\256\211\350\243\205/index.html" "b/2024/01/16/cloud/cri-o\347\232\204\345\256\211\350\243\205/index.html" index 8ca7c5017..2b183b520 100644 --- "a/2024/01/16/cloud/cri-o\347\232\204\345\256\211\350\243\205/index.html" +++ "b/2024/01/16/cloud/cri-o\347\232\204\345\256\211\350\243\205/index.html" @@ -162,13 +162,13 @@ } } detectApple() - })(window)

    cri-o的安装

    cri-o的安装

    CRI-O是一个为容器运行时提供轻量级、高效和符合标准的解决方案的开源项目。它是Kubernetes使用的容器运行时接口(CRI)规范的实现之一。

    + })(window)

    cri-o的安装

    cri-o的安装

    CRI-O是一个为容器运行时提供轻量级、高效和符合标准的解决方案的开源项目。它是Kubernetes使用的容器运行时接口(CRI)规范的实现之一。

    安装

    1.关闭防火墙等

    #!/bin/bash

    # 关闭 防火墙
    systemctl stop firewalld
    systemctl disable firewalld

    # 关闭 SeLinux
    setenforce 0
    sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

    # 关闭 swap
    swapoff -a
    yes | cp /etc/fstab /etc/fstab_bak
    cat /etc/fstab_bak |grep -v swap > /etc/fstab

    # 修改 /etc/sysctl.conf
    # modprobe br_netfilter
    # 如果有配置,则修改
    sed -i "s#^net.ipv4.ip_forward.*#net.ipv4.ip_forward=1#g" /etc/sysctl.conf
    sed -i "s#^net.bridge.bridge-nf-call-ip6tables.*#net.bridge.bridge-nf-call-ip6tables=1#g" /etc/sysctl.conf
    sed -i "s#^net.bridge.bridge-nf-call-iptables.*#net.bridge.bridge-nf-call-iptables=1#g" /etc/sysctl.conf
    # 可能没有,追加
    echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
    echo "net.bridge.bridge-nf-call-ip6tables = 1" >> /etc/sysctl.conf
    echo "net.bridge.bridge-nf-call-iptables = 1" >> /etc/sysctl.conf
    # 执行命令以应用
    sysctl -p

    systemctl enable kubelet
    systemctl start kubelet

    2.安装CRI-O

    Centos_7:

    export VERSION=1.28
    sudo curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/CentOS_7/devel:kubic:libcontainers:stable.repo
    sudo curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable:cri-o:${VERSION}.repo https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:${VERSION}/CentOS_7/devel:kubic:libcontainers:stable:cri-o:${VERSION}.repo

    ## 通过yum下载
    yum install -y cri-o
    -

    部署K8s集群

    修改配置文件

    # 修改镜像,国内地址拉取不到
    vim /etc/crio/crio.conf
    pause_image = "registry.aliyuncs.com/google_containers/pause:3.1"

    # 启动集群
    kubeadm init --pod-network-cidr=<192.168.0.0/16> --apiserver-advertise-address=<10.10.101.123> --image-repository registry.aliyuncs.com/google_containers --service-cidr=<10.96.0.0/12> --kubernetes-version=<v1.25.14> --cri-socket=unix:///var/run/crio/crio.sock
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/01/16/cloud/cri-o的安装/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/02/02/cloud/istio/Istion-\345\210\235\350\257\206/index.html" "b/2024/02/02/cloud/istio/Istion-\345\210\235\350\257\206/index.html" index da00a5f91..1ac77ceeb 100644 --- "a/2024/02/02/cloud/istio/Istion-\345\210\235\350\257\206/index.html" +++ "b/2024/02/02/cloud/istio/Istion-\345\210\235\350\257\206/index.html" @@ -162,7 +162,7 @@ } } detectApple() - })(window)

    Istio-初识

    Istio-初识

    What is Istio?

      + })(window)

      Istio-初识

      Istio-初识

      What is Istio?

      1. Istio是一个用于服务治理的开发平台
      2. Istio是一个Service Mesh形态的服务治理开发平台
      3. Istio是一个Kubernetes紧密结合的适用于云原生场景的Service Mesh形态的平台
      4. @@ -197,7 +197,7 @@

        Istio-sidecar-injector负责自动主任,开启自动注入之后在Pod创建时,就会注入Sidecar容器

        istio-proxy

        但关注Pod的详细信息,会发 现这个容器的正式名字是istio-proxy,不是通用的Envoy镜像,而是叠 加了Istio的Proxy功能的一个扩展版本

        istio-ingressgateway

        istio-ingressgateway 就是入口处的 Gateway,从网格外访问网格内 的服务就是通过这个Gateway进行的。istio-ingressgateway比较特别, 是一个Loadbalancer类型的Service,不同于其他服务组件只有一两个端 口,istio-ingressgateway 开放了一组端口,这些就是网格内服务的外部 访问端口

        -
      文章作者: Joohwan.
      文章链接: https://piwriw.github.io/2024/02/02/cloud/istio/Istion-初识/
      版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
      打赏
      • alipay
        alipay

      评论
      avatar
      Joohwan.
      该知道的都知道,不知道的慢慢了解
      Follow Me
      公告
      Please try your best!
      来访者
      打赏
      • alipay
        alipay

      评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/02/03/cloud/k8s/K8s-\347\275\221\347\273\234\346\250\241\345\236\213/index.html" "b/2024/02/03/cloud/k8s/K8s-\347\275\221\347\273\234\346\250\241\345\236\213/index.html" index 9b8db1b2d..eb1a0fb2f 100644 --- "a/2024/02/03/cloud/k8s/K8s-\347\275\221\347\273\234\346\250\241\345\236\213/index.html" +++ "b/2024/02/03/cloud/k8s/K8s-\347\275\221\347\273\234\346\250\241\345\236\213/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-网络模型

    K8s-网络模型

    K8s场景网络主要有以下几种:

    + })(window)

    K8s-网络模型

    K8s-网络模型

    K8s场景网络主要有以下几种:

    1. Container-to-Container网络
    2. Pod-to-Pod网络
    3. @@ -272,7 +272,7 @@
      Ingress控制器
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/02/03/cloud/k8s/K8s-网络模型/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/02/20/cloud/prometheus/Grafana-\345\265\214\345\205\245\345\211\215\347\253\257/index.html" "b/2024/02/20/cloud/prometheus/Grafana-\345\265\214\345\205\245\345\211\215\347\253\257/index.html" index 606e81cec..24f43a9b2 100644 --- "a/2024/02/20/cloud/prometheus/Grafana-\345\265\214\345\205\245\345\211\215\347\253\257/index.html" +++ "b/2024/02/20/cloud/prometheus/Grafana-\345\265\214\345\205\245\345\211\215\347\253\257/index.html" @@ -162,7 +162,7 @@ } } detectApple() - })(window)

    Grafana-嵌入前端

    Grafana-嵌入前端

    Introduce

    Grafana能展示好看的图表,但是前端不能直接展示

    + })(window)

    Grafana-嵌入前端

    Grafana-嵌入前端

    Introduce

    Grafana能展示好看的图表,但是前端不能直接展示

    Quick Start

    iframe模式

    演示使用prometheus中的grafana,K8s部署

    1. 添加配grafana置项

      @@ -181,7 +181,7 @@

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/02/20/cloud/prometheus/Grafana-嵌入前端/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/02/20/cloud/prometheus/Grafana-\346\225\264\345\220\210\346\227\245\345\277\227\346\237\245\350\257\242Loki/index.html" "b/2024/02/20/cloud/prometheus/Grafana-\346\225\264\345\220\210\346\227\245\345\277\227\346\237\245\350\257\242Loki/index.html" index e41501fdf..ab1d4c37c 100644 --- "a/2024/02/20/cloud/prometheus/Grafana-\346\225\264\345\220\210\346\227\245\345\277\227\346\237\245\350\257\242Loki/index.html" +++ "b/2024/02/20/cloud/prometheus/Grafana-\346\225\264\345\220\210\346\227\245\345\277\227\346\237\245\350\257\242Loki/index.html" @@ -162,7 +162,7 @@ } } detectApple() - })(window)

    Grafana-整合日志查询Loki

    Grafana-整合日志查询Loki

    Introduce

    为Grafana添加日志指标

    + })(window)

    Grafana-整合日志查询Loki

    Grafana-整合日志查询Loki

    Introduce

    为Grafana添加日志指标

    flubit-bit

    Fluent Bit:Fluent Bit 是一个轻量级的日志收集器和处理器。它设计用于从各种来源(如应用程序、容器、操作系统等)收集日志数据,并将其发送到不同的目标。Fluent Bit 可以将日志数据发送到多种目标,包括存储系统、消息队列和分析工具等。它提供了灵活的插件机制,可用于解析、过滤和转换日志数据

    Loki

    Loki 是一个开源的日志聚合系统,专门用于处理和查询大规模分布式日志数据。它是由 Grafana Labs 开发的,作为 Grafana 生态系统的一部分。Loki 使用了 Prometheus 的标签索引和查询语言,可以高效地存储和查询日志数据。Loki 的设计目标是可扩展性和低资源消耗,适用于云原生环境

    # 1. 添加Helm仓库
    helm repo add grafana https://grafana.github.io/helm-charts
    # *2. 拉取本地Helm文件
    helm pull grafana/loki-stack
    # 3. helm安装loki
    helm upgrade --install loki-stack loki-stack --set fluent-bit.enabled=true,promtail.enabled=false -n monitoring --create-namespace
    @@ -181,7 +181,7 @@

    -

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/02/20/cloud/prometheus/Grafana-整合日志查询Loki/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/02/20/web/distributed/Raft \347\256\227\346\263\225\346\246\202\350\277\260/index.html" "b/2024/02/20/web/distributed/Raft \347\256\227\346\263\225\346\246\202\350\277\260/index.html" index bfb84a3ac..c1c0ba394 100644 --- "a/2024/02/20/web/distributed/Raft \347\256\227\346\263\225\346\246\202\350\277\260/index.html" +++ "b/2024/02/20/web/distributed/Raft \347\256\227\346\263\225\346\246\202\350\277\260/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    Raft 算法概述

    Raft 算法概述

    What is Raft

    Raft 协议是一种共识算法(consensus algorithm)

    + })(window)

    Raft 算法概述

    Raft 算法概述

    What is Raft

    Raft 协议是一种共识算法(consensus algorithm)

    简单来说,其实就是大家投票,超过半数,通过✅

    为什么需要 Raft ?

    回答该问题之前可以思考一下另一个问题:为什么需要共识算法?

    @@ -236,7 +236,7 @@

    参考

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/02/20/web/distributed/Raft 算法概述/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/02/20/web/micro/Raft \347\256\227\346\263\225\346\246\202\350\277\260/index.html" "b/2024/02/20/web/micro/Raft \347\256\227\346\263\225\346\246\202\350\277\260/index.html" index 7cc56c9f7..37217640c 100644 --- "a/2024/02/20/web/micro/Raft \347\256\227\346\263\225\346\246\202\350\277\260/index.html" +++ "b/2024/02/20/web/micro/Raft \347\256\227\346\263\225\346\246\202\350\277\260/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    Raft 算法概述

    Raft 算法概述

    What is Raft

    Raft 协议是一种共识算法(consensus algorithm)

    + })(window)

    Raft 算法概述

    Raft 算法概述

    What is Raft

    Raft 协议是一种共识算法(consensus algorithm)

    简单来说,其实就是大家投票,超过半数,通过✅

    为什么需要 Raft ?

    回答该问题之前可以思考一下另一个问题:为什么需要共识算法?

    @@ -236,7 +236,7 @@

    参考

    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/02/20/web/micro/Raft 算法概述/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/02/22/cloud/prometheus/Prometheus-\346\216\245\345\205\245ETCD\347\233\221\346\216\247/index.html" "b/2024/02/22/cloud/prometheus/Prometheus-\346\216\245\345\205\245ETCD\347\233\221\346\216\247/index.html" index b87e3e90a..6e8c5ada2 100644 --- "a/2024/02/22/cloud/prometheus/Prometheus-\346\216\245\345\205\245ETCD\347\233\221\346\216\247/index.html" +++ "b/2024/02/22/cloud/prometheus/Prometheus-\346\216\245\345\205\245ETCD\347\233\221\346\216\247/index.html" @@ -162,7 +162,7 @@ } } detectApple() - })(window)

    Prometheus-接入ETCD监控

    Prometheus-接入ETCD监控

    Introduce

    通过Prometheus监控ETCD数据,包括Grafana

    + })(window)

    Prometheus-接入ETCD监控

    Prometheus-接入ETCD监控

    Introduce

    通过Prometheus监控ETCD数据,包括Grafana

    Overview

    # 通过2379 获取指标
    curl http://<hostip>:2379/metrics

    # 开启tls认证的etcd
    certs=/etc/kubernetes/pki/etcd/
    curl --cacert $certs/ca.crt --cert $certs/peer.crt --key $certs/peer.key https://<hostip>:2379/metrics

    Etcd 中的指标可以分为三大类:

    @@ -266,7 +266,7 @@

    配置prometheus:

    kubectl -n monitoring get prometheus

    apiVersion: monitoring.coreos.com/v1
    kind: Prometheus
    metadata:
    name: example
    spec:
    serviceAccountName: prometheus
    replicas: 2
    alerting:
    alertmanagers:
    - namespace: default
    name: alertmanager-example
    port: web
    serviceMonitorSelector:
    matchLabels:
    team: frontend
    ruleSelector:
    matchLabels:
    prometheus: k8s
    role: alert-rules
    ruleNamespaceSelector:
    matchLabels:
    team: frontend
    -

    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/02/22/cloud/prometheus/Prometheus-接入ETCD监控/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/02/25/cloud/k8s/K8s-List-watch\346\234\272\345\210\266/index.html" "b/2024/02/25/cloud/k8s/K8s-List-watch\346\234\272\345\210\266/index.html" index bcc9df602..c2569bd7d 100644 --- "a/2024/02/25/cloud/k8s/K8s-List-watch\346\234\272\345\210\266/index.html" +++ "b/2024/02/25/cloud/k8s/K8s-List-watch\346\234\272\345\210\266/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-List-watch机制

    K8s-List-watch机制

    BackGround

    在 Kubernetes 中,有5个主要的组件,分别是 master 节点上的 kube-api-server、kube-controller-manager 和 kube-scheduler,node 节点上的 kubelet 和kube-proxy 。这其中 kube-apiserver 是对外和对内提供资源的声明式 API 的组件,其它4个组件都需要和它交互。为了保证消息的实时性,有两种方式:

    + })(window)

    K8s-List-watch机制

    K8s-List-watch机制

    BackGround

    在 Kubernetes 中,有5个主要的组件,分别是 master 节点上的 kube-api-server、kube-controller-manager 和 kube-scheduler,node 节点上的 kubelet 和kube-proxy 。这其中 kube-apiserver 是对外和对内提供资源的声明式 API 的组件,其它4个组件都需要和它交互。为了保证消息的实时性,有两种方式:

    • 客户端组件 (kubelet, scheduler, controller-manager 等) 轮询 apiserver
    • apiserver 通知客户端
    • @@ -204,7 +204,7 @@

      Example

      // 全局对象,存储所有deployments
      var DepMapImpl *DeploymentMap

      func init() {
      DepMapImpl = &DeploymentMap{Data: new(sync.Map)}
      }

      type DeploymentMap struct {
      Data *sync.Map // key:namespace value:[]*v1.Deployments
      }

      // 添加
      func (this *DeploymentMap) Add(deployment *v1.Deployment) {
      if depList, ok := this.Data.Load(deployment.Namespace); ok {
      depList = append(depList.([]*v1.Deployment), deployment)
      this.Data.Store(deployment.Namespace, depList)
      } else {
      this.Data.Store(deployment.Namespace, []*v1.Deployment{deployment})
      }
      }

      // 获取列表
      func (this *DeploymentMap) ListByNs(namespace string) ([]*v1.Deployment, error) {
      if depList, ok := this.Data.Load(namespace); ok {
      return depList.([]*v1.Deployment), nil
      }

      return nil, fmt.Errorf("record not found")
      }

      // 更新
      func (this *DeploymentMap) Update(deployment *v1.Deployment) error {
      if depList, ok := this.Data.Load(deployment.Namespace); ok {
      depList := depList.([]*v1.Deployment)
      for i, dep := range depList {
      if dep.Name == deployment.Name {
      depList[i] = deployment
      break
      }
      }
      return nil
      }

      return fmt.Errorf("deployment [%s] not found", deployment.Name)
      }

      // 删除
      func (this *DeploymentMap) Delete(deployment *v1.Deployment) {
      if depList, ok := this.Data.Load(deployment.Namespace); ok {
      depList := depList.([]*v1.Deployment)
      for i, dep := range depList {
      if dep.Name == deployment.Name {
      newDepList := append(depList[:i], depList[i+1:]...)
      this.Data.Store(deployment.Namespace, newDepList)
      break
      }
      }
      }
      }

      // informer实现
      type DepHandler struct{}
      func (this *DepHandler) OnAdd(obj interface{}) {
      DepMapImpl.Add(obj.(*v1.Deployment))
      }
      func (this *DepHandler) OnUpdate(oldObj, newObj interface{}) {
      err := DepMapImpl.Update(newObj.(*v1.Deployment))
      if err != nil {
      log.Println(err)
      }
      }
      func (this *DepHandler) OnDelete(obj interface{}) {
      DepMapImpl.Delete(obj.(*v1.Deployment))
      }

      // 执行监听
      func InitDeployments() {
      informerFactory := informers.NewSharedInformerFactory(K8sClient, 0)

      depInformer := informerFactory.Apps().V1().Deployments()
      depInformer.Informer().AddEventHandler(&DepHandler{})

      informerFactory.Start(wait.NeverStop)
      }
      -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/02/25/cloud/k8s/K8s-List-watch机制/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/02/27/poem/\344\270\200\343\200\201\347\220\206\346\203\263/index.html" "b/2024/02/27/poem/\344\270\200\343\200\201\347\220\206\346\203\263/index.html" index f9c1f2f3b..441084465 100644 --- "a/2024/02/27/poem/\344\270\200\343\200\201\347\220\206\346\203\263/index.html" +++ "b/2024/02/27/poem/\344\270\200\343\200\201\347\220\206\346\203\263/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    一、迷茫:理想

    + })(window)

    一、迷茫:理想

    @@ -174,7 +174,7 @@
    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/02/27/poem/一、理想/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/02/27/poem/一、理想/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/02/27/poem/\345\272\217\347\253\240\357\274\232\351\242\204\345\205\206/index.html" "b/2024/02/27/poem/\345\272\217\347\253\240\357\274\232\351\242\204\345\205\206/index.html" index 2cfca7add..a85f6b3ac 100644 --- "a/2024/02/27/poem/\345\272\217\347\253\240\357\274\232\351\242\204\345\205\206/index.html" +++ "b/2024/02/27/poem/\345\272\217\347\253\240\357\274\232\351\242\204\345\205\206/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    序章:预兆

    + })(window)

    序章:预兆

    @@ -174,7 +174,7 @@
    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/02/27/poem/序章:预兆/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/02/27/poem/序章:预兆/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/02/28/poem/\344\272\214\343\200\201\345\244\261\350\264\245\346\211\215\346\230\257\344\272\272\347\224\237\347\232\204\344\270\273\346\227\213\345\276\213/index.html" "b/2024/02/28/poem/\344\272\214\343\200\201\345\244\261\350\264\245\346\211\215\346\230\257\344\272\272\347\224\237\347\232\204\344\270\273\346\227\213\345\276\213/index.html" index d6053795d..602c5309b 100644 --- "a/2024/02/28/poem/\344\272\214\343\200\201\345\244\261\350\264\245\346\211\215\346\230\257\344\272\272\347\224\237\347\232\204\344\270\273\346\227\213\345\276\213/index.html" +++ "b/2024/02/28/poem/\344\272\214\343\200\201\345\244\261\350\264\245\346\211\215\346\230\257\344\272\272\347\224\237\347\232\204\344\270\273\346\227\213\345\276\213/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    二、失败才是人生的主旋律

    + })(window)

    二、失败才是人生的主旋律

    @@ -174,7 +174,7 @@
    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/02/28/poem/二、失败才是人生的主旋律/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/02/28/poem/二、失败才是人生的主旋律/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/02/29/cloud/devops/DevOps-Argo\345\256\211\350\243\205/index.html" "b/2024/02/29/cloud/devops/DevOps-Argo\345\256\211\350\243\205/index.html" index 1b03a3625..15c2466e5 100644 --- "a/2024/02/29/cloud/devops/DevOps-Argo\345\256\211\350\243\205/index.html" +++ "b/2024/02/29/cloud/devops/DevOps-Argo\345\256\211\350\243\205/index.html" @@ -164,7 +164,7 @@ } } detectApple() - })(window)

    DevOps-Argo安装

    DevOps-Argo安装

    What is argo

    Argo Workflows 是一个开源的云原生工作流引擎,用于在 Kubernetes 上编排并行作业。Argo 工作流作为Kubernetes CRD 实现。

    + })(window)

    DevOps-Argo安装

    DevOps-Argo安装

    What is argo

    Argo Workflows 是一个开源的云原生工作流引擎,用于在 Kubernetes 上编排并行作业。Argo 工作流作为Kubernetes CRD 实现。

    • 定义工作流,其中工作流中的每个步骤都是一个容器。
    • 将多步骤工作流建模为一系列任务,或使用 DAG 来捕获任务之间的依赖关系图。
    • @@ -184,7 +184,7 @@

      DeployTest

      kubectl create -f - << EOF
      apiVersion: argoproj.io/v1alpha1
      kind: Workflow
      metadata:
      generateName: steps-
      spec:
      entrypoint: hello # We reference our first "template" here
      templates:
      - name: hello # The first "template" in this Workflow, it is referenced by "entrypoint"
      steps: # The type of this "template" is "steps"
      - - name: hello
      template: whalesay # We reference our second "template" here
      arguments:
      parameters: [{name: message, value: "Hello ArgoWorkflow!"}]

      - name: whalesay # The second "template" in this Workflow, it is referenced by "hello"
      inputs:
      parameters:
      - name: message
      container: # The type of this "template" is "container"
      image: docker/whalesay
      command: [cowsay]
      args: ["{{inputs.parameters.message}}"]
      EOF
      -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/02/29/cloud/devops/DevOps-Argo安装/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/03/01/cloud/docker/Docker-\351\225\234\345\203\217\344\274\230\345\214\226/index.html" "b/2024/03/01/cloud/docker/Docker-\351\225\234\345\203\217\344\274\230\345\214\226/index.html" index c4395d9c7..3ef89b226 100644 --- "a/2024/03/01/cloud/docker/Docker-\351\225\234\345\203\217\344\274\230\345\214\226/index.html" +++ "b/2024/03/01/cloud/docker/Docker-\351\225\234\345\203\217\344\274\230\345\214\226/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    Docker-镜像优化

    Docker-镜像优化

    BackGround

    Docker如果最后的镜像很大,所以是需要优化的。

    + })(window)

    Docker-镜像优化

    打赏
    • alipay
      alipay

    评论
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/03/02/poem/\344\270\211\343\200\201\347\241\254\345\270\201\346\212\233\345\220\221\347\251\272\344\270\255\345\260\261\346\230\257\347\255\224\346\241\210/index.html" "b/2024/03/02/poem/\344\270\211\343\200\201\347\241\254\345\270\201\346\212\233\345\220\221\347\251\272\344\270\255\345\260\261\346\230\257\347\255\224\346\241\210/index.html" index 57548722a..9c933c5bd 100644 --- "a/2024/03/02/poem/\344\270\211\343\200\201\347\241\254\345\270\201\346\212\233\345\220\221\347\251\272\344\270\255\345\260\261\346\230\257\347\255\224\346\241\210/index.html" +++ "b/2024/03/02/poem/\344\270\211\343\200\201\347\241\254\345\270\201\346\212\233\345\220\221\347\251\272\344\270\255\345\260\261\346\230\257\347\255\224\346\241\210/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    三、硬币抛向空中就是答案

    + })(window)

    三、硬币抛向空中就是答案

    @@ -174,7 +174,7 @@
    -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/03/02/poem/三、硬币抛向空中就是答案/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/03/02/poem/三、硬币抛向空中就是答案/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git "a/2024/03/08/cloud/k8s/K8s-\346\226\207\344\273\266\347\256\241\347\220\206\347\263\273\347\273\237nfs/index.html" "b/2024/03/08/cloud/k8s/K8s-\346\226\207\344\273\266\347\256\241\347\220\206\347\263\273\347\273\237nfs/index.html" index 97fac4e55..4786af31b 100644 --- "a/2024/03/08/cloud/k8s/K8s-\346\226\207\344\273\266\347\256\241\347\220\206\347\263\273\347\273\237nfs/index.html" +++ "b/2024/03/08/cloud/k8s/K8s-\346\226\207\344\273\266\347\256\241\347\220\206\347\263\273\347\273\237nfs/index.html" @@ -163,7 +163,7 @@ } } detectApple() - })(window)

    K8s-文件管理系统nfs(centos)

    K8s-文件管理系统nfs(centos)

    什么是nfs

    NFS在文件传送或信息传输过程中依赖于RPC协议,RPC协议可以在不同的系统之间使用。使用NFS用户端时只需要把远程文件系统挂载到自己的文件系统下即可访问,NFS有客户端和服务端

    + })(window)

    K8s-文件管理系统nfs(centos)

    K8s-文件管理系统nfs(centos)

    什么是nfs

    NFS在文件传送或信息传输过程中依赖于RPC协议,RPC协议可以在不同的系统之间使用。使用NFS用户端时只需要把远程文件系统挂载到自己的文件系统下即可访问,NFS有客户端和服务端

    Deploy

    nfs部署

    1. centos部署nfs

      yum install -y nfs-utils rpcbind

      @@ -176,7 +176,7 @@

      Deploy

      nfs-provisoner部署

      # 获取helm charts
      helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
      # 给有nfs的服务器打标签
      kubectl label node <nfsnode> nfs=work

      # 修改value.yaml
      affinity:
      nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
      nodeSelectorTerms:
      - matchExpressions:
      - key: "nfs"
      operator: In
      values:
      - "work"
      # 安装nfs
      helm install nfs-subdir-external-provisioner nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \
      --set nfs.server=x.x.x.x \
      --set nfs.path=/exported/path

      helm upgrade --install nfs-subdir-external-provisioner nfs-subdir-external-provisioner -n nfs --create-namespace

      -
    文章作者: Joohwan.
    文章链接: https://piwriw.github.io/2024/03/08/cloud/k8s/K8s-文件管理系统nfs/
    版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Joohwan
    打赏
    • alipay
      alipay

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    打赏
    • alipay
      alipay

    评论
    - \ No newline at end of file + \ No newline at end of file diff --git a/about/index.html b/about/index.html index abad60249..006d6e7f3 100644 --- a/about/index.html +++ b/about/index.html @@ -162,7 +162,7 @@ } } detectApple() - })(window)

    🧑‍💻 个人介绍

    我专注于 Go 云原生
    Refactoring Codes & Work for soul.
    一名憧憬着充满理想主义及其浪漫主义的现实主义诗人

    + })(window)

    🧑‍💻 个人介绍

    我专注于 Go 云原生
    Refactoring Codes & Work for soul.
    一名憧憬着充满理想主义及其浪漫主义的现实主义诗人

    🚀 技能

    Languages and Tools

    Kubernetes Docker @@ -182,10 +182,10 @@

    🌐 理想

    You Only Live Once.

    📞 联系方式

    -

    评论
    avatar
    Joohwan.
    该知道的都知道,不知道的慢慢了解
    Follow Me
    公告
    Please try your best!
    来访者
    - \ No newline at end of file + \ No newline at end of file diff --git a/archives/2023/02/index.html b/archives/2023/02/index.html index 0b5eae249..69c1b6d74 100644 --- a/archives/2023/02/index.html +++ b/archives/2023/02/index.html @@ -56,7 +56,7 @@ isHome: false, isHighlightShrink: false, isToc: false, - postUpdate: '2024-03-08 23:26:26' + postUpdate: '2024-03-09 15:30:45' }