zoukankan      html  css  js  c++  java
  • 使用helm管理复杂kubernetes应用

    1. 查看仓库:

    $ helm repo list
    NAME            URL
    stable          https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts/
    local           http://127.0.0.1:8879
    incubator       https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/

    启动本地仓库:

    $ helm serve&
    [1] 15148
    Regenerating index. This may take a moment.
    Now serving you on 127.0.0.1:8879

    2. 创建helm应用

    helm create test-chart

    结构如下:

    ├─test-chart
    ├── charts
    ├── Chart.yaml
    ├── templates
    │   ├── deployment.yaml
    │   ├── _helpers.tpl
    │   ├── NOTES.txt
    │   └── service.yaml
    └── values.yaml

    简单更改 values.yaml 配置如下

    replicaCount: 1
    
    image:
      repository: daemonza/test
      tag: latest
      pullPolicy: IfNotPresent
    
    
    service:
      name: test
      type: ClusterIP
      internalport: 80
      externalPort: 80
    
    resources:
      limits:
        cpu: 100m
        memory: 128Mi
      requests:
        cpu: 100m
        memory: 128Mi

    更改Chart.yaml 配置如下

    apiVersion: v1
    appVersion: "1.0"
    description: A Helm chart for Kubernetes
    name: test-chart
    version: 0.1.0

    3. 将test-chart打包

    $ helm package test-chart
    Successfully packaged chart and saved it to: D:zhuojian-projects
    ubik-Thealth-doc详细设计helm	est-chart-0.1.0.tgz

    打包的同时,会拷贝一份生成的 tgz 文件到本地仓库。

    4. 如法炮制2个 chart 包:test-chart2, test-chart3,且进行打包。

    $ helm search test
    NAME                    CHART VERSION   APP VERSION     DESCRIPTION
    local/test-chart        0.2.0           1.0             A Helm chart for Kubernetes
    local/test-chart2       0.1.0           1.0             A Helm chart for Kubernetes
    local/test-chart3       0.2.0           4.0             A Helm chart for Kubernetes

    5. 假设test-chart依赖:0.1.0版本的test-chart2, 0.2.0版本的test-chart3,针对包依赖关系的描述,可以使用文件 requirements.yaml,内容如下:

    dependencies:
    - name: test-chart2
      version: "0.1.0"
      repository: http://127.0.0.1:8879
    - name: test-chart3
      version: "0.2.0"
      repository: http://127.0.0.1:8879

    chart 目录如下

    ├─test-chart
    ├── charts
    ├── Chart.yaml
    ├── templates
    │   ├── deployment.yaml
    │   ├── _helpers.tpl
    │   ├── NOTES.txt
    │   ├── requirements.yaml
    │   └── service.yaml
    └── values.yaml

    然后执行以下命令,将对应的依赖包下载到test-chart的charts目录下:

    $ helm dep update test-chart
    Hang tight while we grab the latest from your chart repositories...
    ...Successfully got an update from the "local" chart repository
    ...Successfully got an update from the "stable" chart repository
    ...Successfully got an update from the "incubator" chart repository
    Update Complete.
    Saving 2 charts
    Downloading test-chart2 from repo http://127.0.0.1:8879
    Downloading test-chart3 from repo http://127.0.0.1:8879
    Deleting outdated charts

    执行完之后,再次查看test-chart目录结构,会发现依赖包已经下载下来了:

    ├─test-chart
    ├── charts
    │   ├── test-chart2-0.1.0.tgz
    │   ├── test-chart3-0.2.0.tgz
    ├── Chart.yaml
    ├── templates
    │   ├── deployment.yaml
    │   ├── _helpers.tpl
    │   ├── NOTES.txt
    │   ├── requirements.yaml
    │   └── service.yaml
    └── values.yaml

    将 test-chart2-0.1.0.tgz 解压缩,会发现也是一个完整的 test-chart2 的实例。

    然后可以使用 helm 将 test-chart 安装部署,至此,就完成了 helm 对具有复杂依赖关系的 kubernetes 应用的管理。

  • 相关阅读:
    VUE笔记-如何处理vue create demo时候,不能使用上下按键选择?
    帝国CMS之PC端上新栏目后,移动端无法同步,添加内容编辑页打开空白的处理方法
    帝国cms:迁移站点后,配置多端访问显示“访问端目录不存在”
    如何批量删除帝国CMS中同一前缀的数据表?
    宝塔插件"网站监控报表"错误日志显示大量不存在的链接,处理方法及流程
    mysql删除重复数据只保留一条
    VirtualBox 中 discuzq不能添加软链接的处理方法
    mysql8 source 导入大文件时 经常意外中断 且无法再链接断续 解决方法先设置 set names utf8;
    discuzq Virtualbox 虚拟机 在共享文件夹设置软链接 in 报错 Protocol error问题
    是的,奈学教育一周年了!
  • 原文地址:https://www.cnblogs.com/miaoying/p/11271023.html
Copyright © 2011-2022 走看看