kubenetes helm使用

2018-07-05  本文已影响0人  苏州运维开发

最近在研究helm使用,以及使用场景;以下为自己使用心得

1.客户端安装

wget https://storage.googleapis.com/kubernetes-helm/helm-v2.9.1-linux-amd64.tar.gz tar -zxvf helm-v2.9.1-linux-amd64.tar.gz cd linux-amd64 mv helm /usr/local/bin/

2.服务端安装tiller(会以pod部署到k8s集群中)

helm init --tiller-image=daocloud.io/liukuan73/tiller-lk:v2.9.1 --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts --tiller-namespace=kube-system

tiller pod删除

helm reset

3.repoan安装

helm repo list

<meta charset="utf-8">

<meta charset="utf-8">


image.png

helm install stable/redis (去用远程repo安装redis)

自己服务应用需要安装本地repo

1.创建repo目录

mkdir -p /data/helm/local-repo

2.启动本地repo仓库服务

nohup helm serve --address 0.0.0.0:8879 --repo-path /data/helm/local-repo &

3.添加到本地repo仓库

helm repo add local-repo http://192.168.138.128:8879

4.创建本地应用

cd /data/helm/local-repo/

helm create mychart

会在本地默认生成模板文件

替换values.yaml文件变量,将变量换成自己真是环境即可

replicaCount: 1

image:
  repository: 192.168.138.131:5005/tomcat
  tag: latest
  pullPolicy: IfNotPresent

service:
  type: ClusterIP
  port: 8080

ingress:
  enabled: false
  annotations: {}
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  path: /
  hosts:
    - chart-example.local
  tls: []
  #  - secretName: chart-example-tls
  #    hosts:
  #      - chart-example.local

resources: {}
  # We usually recommend not to specify default resources and to leave this as a conscious
  # choice for the user. This also increases chances charts run on environments with little
  # resources, such as Minikube. If you do want to specify resources, uncomment the following
  # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
  # limits:
  #  cpu: 100m
  #  memory: 128Mi
  # requests:
  #  cpu: 100m
  #  memory: 128Mi

nodeSelector: {}

tolerations: []

affinity: {}

仔细观察文件夹中的模板文件,都是通过变量传值的,用户可自定义
helm install ./mychart 即可完成发布

如果要用远程自己的stable repo 安装redis,只需要输入如下命令


image.png

helm install stable/redis
即安裝redis,非常方便
总结;如果将k8s比作centos,helm类似yum;stable reop 相当于yum源,比如我想安装nginix,在centos只需yum install redis -y即可;如果在k8s中安装nginx ,可以用helm install stable/redis;问题是项目组自己开发的代码,stable repo中肯定没有,需要自己添加到local repo中,才可以用helm install {projent-name};每个项目都需要配置一个本地repo;个人认为helm在企业中的价值;开发和运维在本地搭建一个大的repo,然后在k8s中发布应用只需要像使用yum install 一样helm install (update)便捷部署
以上均为个人浅见,对helm研究不深,如有误处,欢迎指正!

上一篇下一篇

猜你喜欢

热点阅读