zoukankan      html  css  js  c++  java
  • Helm二:安装

    Helm安装

    Helm client安装

    helm项目地址:
    https://github.com/helm/helm

    可以直接下载helm的二进制包,解压后,将二进制文件复制到标准命令路径即可完成安装

    Helm tiller安装

    Helm Tiller是Helm的server,Tiller有多种安装方式,比如本地安装或以pod形式部署到Kubernetes集群中。我们这里采用pod安装的方式。

    安装Tiller的最简单方式是helm init, 该命令会检查helm本地环境设置是否正确,helm init会连接kubectl默认连接的kubernetes集群(可以通过kubectl config view查看),一旦连接集群成功,tiller会被安装到kube-system namespace中。

    但是,在国内环境中,我们直接使用helm init会无法拉取到tiller镜像,需要手动指定镜像地址,同时如果Kubernetes集群开启了rbac,还需要指定运行tiller的servicaccount,并为该serviceaccount作合适的授权。

    下面是实际安装时的指令:

    helm init --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.9.0 --service-account=tiller --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
    

    上面的命令指定了安装时使用的tiller镜像的地址,同时指定了默认的chart仓库的地址。

    helm init常用配置项如下:

    • --canary-image:安装金丝雀build
    • --tiller-image:安装指定image
    • --kube-context:安装到指定的kubernetes集群
    • --tiller-namespace:安装到指定的namespace中
    • --upgrade:如果tiller server已经被安装了,可以使用此选项更新镜像
    • --service-account:用于指定运行tiller server的serviceaccount,该account需要事先在kubernetes集群中创建,且需要相应的rbac授权

    创建serviceaccount并授权的示例:

    # cat helm-account.yaml
    
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      labels:
        k8s-app: helm
      name: tiller
      namespace: kube-system
    
    # cat helm-rbac.yaml
    
    apiVersion: rbac.authorization.k8s.io/v1beta1
    metadata:
      name: helm-rbac
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: cluster-admin 
    subjects:
    - kind: ServiceAccount
      name: tiller
      namespace: kube-system
    
    

    我这里是直接为其授予超级管理员权限,如果需要对其进行精细权限控制,可参考helm官方文档:https://docs.helm.sh/using_helm/#role-based-access-control

    安装完成以后,可以通过如下操作查看tiller server的pod:

    root@k8s-m:/home/www/server/kube-yamls/public/helm# kubectl get pods -n kube-system
    NAME                                              READY     STATUS    RESTARTS   AGE
    tiller-deploy-5d4b89d6c9-srvpr                    1/1       Running   0          4d
    

    看到tiller server正常运行,即安装成功。

    Chart仓库配置

    chart仓库用来存储和分享打包的chart,分为公共仓库和私有仓库,其中官方仓库由Kubernetes Charts维护,地址是https://github.com/helm/charts。但是在国内访问官方仓库,一个要翻墙,另一个慢。所以在国内环境中,公共仓库推荐使用阿里云chart仓库,地址为https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts。

    私有chart仓库

    chart仓库的组成

    在更多的时候,我们需要自己维护一个私有的chart仓库。而chart仓库实际上,就是一个可用来存储index.yaml与打包的chart文件的http server,任何一个能够提供yaml与tar文件的http server都可以当做chart仓库。

    下面我们简单说一说chart仓库的结构:

    一个chart仓库是由chart包与index.yaml文件组成,index.yaml记录了chart仓库中全部chart的索引,一个chart仓库示例如下:

    charts/
      |
      |- index.yaml
      |
      |- alpine-0.1.2.tgz
      |
      |- alpine-0.1.2.tgz.prov
    

    其中index.yaml文件中记录了chart的诸如名称、url、version等一些metadata信息:

    apiVersion: v1
    entries:
      alpine:
        - created: 2016-10-06T16:23:20.499814565-06:00
          description: Deploy a basic Alpine Linux pod
          digest: 99c76e403d752c84ead610644d4b1c2f2b453a74b921f422b9dcb8a7c8b559cd
          home: https://k8s.io/helm
          name: alpine
          sources:
          - https://github.com/kubernetes/helm
          urls:
          - https://technosophos.github.io/tscharts/alpine-0.2.0.tgz
          version: 0.2.0
        - created: 2016-10-06T16:23:20.499543808-06:00
          description: Deploy a basic Alpine Linux pod
          digest: 515c58e5f79d8b2913a10cb400ebb6fa9c77fe813287afbacf1a0b897cd78727
          home: https://k8s.io/helm
          name: alpine
          sources:
          - https://github.com/kubernetes/helm
          urls:
          - https://technosophos.github.io/tscharts/alpine-0.1.0.tgz
          version: 0.1.0
      nginx:
        - created: 2016-10-06T16:23:20.499543808-06:00
          description: Create a basic nginx HTTP server
          digest: aaff4545f79d8b2913a10cb400ebb6fa9c77fe813287afbacf1a0b897cdffffff
          home: https://k8s.io/helm
          name: nginx
          sources:
          - https://github.com/kubernetes/charts
          urls:
          - https://technosophos.github.io/tscharts/nginx-1.1.0.tgz
          version: 1.1.0
    generated: 2016-10-06T16:23:20.499029981-06:00
    

    创建本地仓库

    一个简单的创建一个本地仓库的示例:

    helm serve --address 0.0.0.0:8879 --repo-path ./charts
    

    chart仓库基本管理

    1. 列出仓库中的charts
      helm repo list
      
    2. 打包本地开发的chart
      helm package mychart
      
    3. 上传chart到chart仓库
      helm repo add mychart http://1270.0.1:8879/charts
      
    4. 查找chart
      helm search mychart -l
      
  • 相关阅读:
    windwos8.1英文版安装SQL2008 R2中断停止的解决方案
    indwows8.1 英文版64位安装数据库时出现The ENU localization is not supported by this SQL Server media
    Server Tomcat v7.0 Server at localhost was unable to start within 45 seconds
    SQL数据附加问题
    eclipse,myeclipse中集合svn的方法
    JAVA SSH 框架介绍
    SSH框架-相关知识点
    SuperMapRealSpace Heading Tilt Roll的理解
    SuperMap iserver manage不能访问本地目的(IE9)
    Myeclipse中js文件中的乱码处理
  • 原文地址:https://www.cnblogs.com/breezey/p/9398927.html
Copyright © 2011-2022 走看看