码迷,mamicode.com
首页 > 其他好文 > 详细

helm3

时间:2020-03-25 23:28:44      阅读:1896      评论:0      收藏:0      [点我收藏+]

标签:arc   des   pos   -bash   adb   get   ase   container   strategy   

部署helm客户端


安装

wget https://get.helm.sh/helm-v3.0.0-linux-amd64.tar.gz
tar zxvf helm-v3.0.0-linux-amd64.tar.gz 
mv linux-amd64/helm /usr/bin/

配置仓库

helm repo add stable http://mirror.azure.cn/kubernetes/charts
helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts 
helm repo update

  • 查看配置的存储库
helm repo list
helm search repo stable

  • 删除存储库
helm repo remove aliyun

案例1


 helm create nginx
 cd nginx/

  • 目录结构
├── charts
├── Chart.yaml   # 可以被templates下面的文件引用
├── templates
│?? ├── deployment.yaml
│?? ├── _helpers.tpl
│?? ├── ingress.yaml
│?? ├── NOTES.txt
│?? ├── serviceaccount.yaml
│?? ├── service.yaml
│?? └── tests
│??     └── test-connection.yaml
└── values.yaml  # 定义变量, 可以被templates下面的文件引用

手动deploy

rm -rf /root/nginx/templates/*
kubectl create deployment web --image=nginx --dry-run -o yaml>/root/nginx/templates/deployment.yaml
kubectl apply -f /root/nginx/templates/deployment.yaml
kubectl expose deployment web --port=80 --target-port=80 --dry-run -o yaml > service.yaml

  • deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: web
  name: web
spec:
  replicas: 1
  selector:
    matchLabels:
      app: web
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: web
    spec:
      containers:
      - image: nginx
        name: nginx
        resources: {}
status: {}

  • service.yaml
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: web
  name: web
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: web
status:
  loadBalancer: {}

  • 查看pod
kubectl get pods

技术图片


  • 查看service
kubectl get svc

技术图片


helm 安装

kubectl delete -f /root/nginx/templates/
kubectl delete -f /root/nginx/
helm install web /root/nginx/

技术图片


  • 查看部署状态
helm ls

技术图片


  • 查看dashboard

技术图片


helm定义变量安装


  • helm全局变量
Release.Name release 名称
Release.Name helm install时候 的 release 名字
Release.Namespace release 命名空间
Release.Service release 服务的名称
Release.Revision release 修订版本号,从1开始累加

  • deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    chart: {{ .Chart.Name }}
    app: {{ .Release.Name }}
  name: {{ .Release.Name }}
spec:
  replicas: {{ .Values.replicas }}
  selector:
    matchLabels:
      app: {{ .Values.label }}
  template:
    metadata:
      labels:
        app: {{ .Values.label }}
    spec:
      containers:
      - image: {{ .Values.image }}:{{ .Values.imageTag}}
        name: {{ .Release.Name }}
        resources: {}
status: {}

  • service.yaml
apiVersion: v1
kind: Service
metadata:
  labels:
    chart: {{ .Chart.Name }}
    app: {{ .Release.Name }}
  name: {{ .Release.Name }}
spec:
  ports:
  - port: {{ .Values.port }}
    protocol: TCP
    targetPort: {{ .Values.targetPort }}
  selector:
    app: {{ .Values.label }}

  • values.yaml
replicas: 3
image: nginx
imageTag: 1.17
label: nginx_label
port: 80
targetPort: 80

  • Chart.yaml
apiVersion: v2
name: nginx
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: 1.16.0

  • 安装
 helm install lyysb  /root/nginx/

  • 更新
helm upgrade lyysb  /root/nginx/

  • 删除
helm delete lyysb

helm3

标签:arc   des   pos   -bash   adb   get   ase   container   strategy   

原文地址:https://www.cnblogs.com/cjwnb/p/12571199.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!