Kubernetes(K8S) helm 安装

本文涉及的产品
容器服务 Serverless 版 ACK Serverless,952元额度 多规格
容器服务 Serverless 版 ACK Serverless,317元额度 多规格
简介: Kubernetes(K8S) helm 安装

Helm 是一个 Kubernetes 的包管理工具, 就像 Linux 下的包管理器, 如 yum/apt 等, 可以很方便的将之前打包好的 yaml 文件部署到 kubernetes 上。

Helm 有 3 个重要概念:

  • helm: 一个命令行客户端工具, 主要用于 Kubernetes 应用 chart 的创建、 打包、 发布和管理。
  • Chart: 应用描述, 一系列用于描述 k8s 资源相关文件的集合。
  • Release: 基于 Chart 的部署实体, 一个 chart 被 Helm 运行后将会生成对应的一个release; 将在 k8s 中创建出真实运行的资源对象。

在部署微服务项目时,可能有几十个服务,每个服务都有一套 yaml 文件,需要维护大量 yaml 文件,版本管理特别不方便

使用 helm 可以解决下列问题:

  • 可以把微服务中的几十个 yaml 作为一个整体管理
  • 实现 yaml 高效复用
  • 应用级别的版本管理,当前V3,回滚到V2

helm 2019年 V3版本,变化项

  • V3 版本删除 Tiller (架构变化)
  • Release 可以在不同命名空间重用
  • 将 Chart 推送到 docker 仓库中

安装

https://helm.sh/

https://helm.sh/zh/docs/intro/install/

下载 helm 安装压缩包,上传到 linux

解压 helm,把目录复制到 usr/bin 目录中

[root@k8smaster ~]# cd /opt/k8s/
[root@k8smaster k8s]# tar zxfv helm-v3.0.0-linux-amd64.tar.gz 
linux-amd64/
linux-amd64/helm
linux-amd64/README.md
linux-amd64/LICENSE
[root@k8smaster k8s]# mv ./linux-amd64/helm /usr/bin/
# 显示版本,安装完成
[root@k8smaster k8s]# helm version
version.BuildInfo{Version:"v3.0.0", GitCommit:"e29ce2a54e96cd02ccfce88bee4f58bb6e2a28b6", GitTreeState:"clean", GoVersion:"go1.13.4"}
[root@k8smaster k8s]#

配置

添加仓库

# 添加 仓库
[root@k8smaster ~]# helm repo add stable http://mirror.azure.cn/kubernetes/charts
"stable" has been added to your repositories
# 添加 阿里云仓库
[root@k8smaster ~]# helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
"aliyun" has been added to your repositories
# 查看
[root@k8smaster ~]# helm repo list
NAME    URL
stable  http://mirror.azure.cn/kubernetes/charts
aliyun  https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
# 更新
[root@k8smaster ~]# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "aliyun" chart repository
...Successfully got an update from the "stable" chart repository
Update Complete. ⎈ Happy Helming!⎈ 
# 删除阿里云
[root@k8smaster ~]# helm repo remove aliyun
"aliyun" has been removed from your repositories
[root@k8smaster ~]# helm repo list
NAME    URL
stable  http://mirror.azure.cn/kubernetes/charts
[root@k8smaster ~]#

部署应用

# 查找 chart
[root@k8smaster ~]# helm search repo weave
NAME                    CHART VERSION   APP VERSION     DESCRIPTION                                       
stable/weave-cloud      0.3.9           1.4.0           DEPRECATED - Weave Cloud is a add-on to Kuberne...
stable/weave-scope      1.1.12          1.12.0          DEPRECATED - A Helm chart for the Weave Scope c...
# 查看 chrt 信息
[root@k8smaster ~]# helm show chart stable/weave-scope
apiVersion: v1
appVersion: 1.12.0
deprecated: true
description: DEPRECATED - A Helm chart for the Weave Scope cluster visualizer.
home: https://www.weave.works/oss/scope/
icon: https://avatars1.githubusercontent.com/u/9976052?s=64
keywords:
- containers
- dashboard
- monitoring
name: weave-scope
sources:
- https://github.com/weaveworks/scope
version: 1.1.12
# 安装,名字叫 ui
[root@k8smaster ~]# helm install ui stable/weave-scope
NAME: ui
LAST DEPLOYED: Mon Nov 28 13:15:05 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
You should now be able to access the Scope frontend in your web browser, by
using kubectl port-forward:
kubectl -n default port-forward $(kubectl -n default get endpoints \
ui-weave-scope -o jsonpath='{.subsets[0].addresses[0].targetRef.name}') 8080:4040
then browsing to http://localhost:8080/.
For more details on using Weave Scope, see the Weave Scope documentation:
https://www.weave.works/docs/scope/latest/introducing/
# 查看列表
[root@k8smaster ~]# helm list
NAME    NAMESPACE       REVISION        UPDATED                                 STATUS          CHART                   APP VERSION
ui      default         1               2022-11-28 13:15:05.404335352 +0800 CST deployed        weave-scope-1.1.12      1.12.0 # 查看发布状态
[root@k8smaster ~]# helm status ui
NAME: ui
LAST DEPLOYED: Mon Nov 28 13:15:05 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
You should now be able to access the Scope frontend in your web browser, by
using kubectl port-forward:
kubectl -n default port-forward $(kubectl -n default get endpoints \
ui-weave-scope -o jsonpath='{.subsets[0].addresses[0].targetRef.name}') 8080:4040
then browsing to http://localhost:8080/.
For more details on using Weave Scope, see the Weave Scope documentation:
https://www.weave.works/docs/scope/latest/introducing/
# 查看服务 当前是不暴露端口的
[root@k8smaster ~]# kubectl get svc
NAME             TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
javademo1        NodePort    10.106.43.46   <none>        8111:31452/TCP   40d
kubernetes       ClusterIP   10.96.0.1      <none>        443/TCP          45d
nginx            NodePort    10.103.87.81   <none>        80:30339/TCP     45d
nginx-nfs        NodePort    10.99.84.9     <none>        80:30205/TCP     19d
ui-weave-scope   ClusterIP   10.101.4.212   <none>        80/TCP           3m19s
# 修改 ui-weave-scpoe 暴露端口
[root@k8smaster ~]# kubectl edit svc ui-weave-scope
#  type: ClusterIP =>  改成 type: NodePort
service/ui-weave-scope edited
# 再次查看,暴露了 30690 端口
[root@k8smaster ~]# kubectl get svc
NAME             TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
javademo1        NodePort    10.106.43.46   <none>        8111:31452/TCP   40d
kubernetes       ClusterIP   10.96.0.1      <none>        443/TCP          45d
nginx            NodePort    10.103.87.81   <none>        80:30339/TCP     45d
nginx-nfs        NodePort    10.99.84.9     <none>        80:30205/TCP     19d
ui-weave-scope   NodePort    10.101.4.212   <none>        80:30690/TCP     5m26s
# 删除 ui-weave-scope
[root@k8smaster ~]# kubectl delete deployment ui-weave-scope
[root@k8smaster ~]# kubectl delete svc ui-weave-scope

测试

相关实践学习
通过Ingress进行灰度发布
本场景您将运行一个简单的应用,部署一个新的应用用于新的发布,并通过Ingress能力实现灰度发布。
容器应用与集群管理
欢迎来到《容器应用与集群管理》课程,本课程是“云原生容器Clouder认证“系列中的第二阶段。课程将向您介绍与容器集群相关的概念和技术,这些概念和技术可以帮助您了解阿里云容器服务ACK/ACK Serverless的使用。同时,本课程也会向您介绍可以采取的工具、方法和可操作步骤,以帮助您了解如何基于容器服务ACK Serverless构建和管理企业级应用。 学习完本课程后,您将能够: 掌握容器集群、容器编排的基本概念 掌握Kubernetes的基础概念及核心思想 掌握阿里云容器服务ACK/ACK Serverless概念及使用方法 基于容器服务ACK Serverless搭建和管理企业级网站应用
目录
相关文章
|
2月前
|
Kubernetes 应用服务中间件 nginx
Kubernetes 入门指南:快速上手容器编排
【8月更文第29天】Kubernetes(简称 K8s)是一个开源平台,用于自动化容器化应用程序的部署、扩展和管理。它提供了一种便捷的方式来部署和运行应用程序,而无需关心底层基础设施的细节。本指南将带你从零开始学习 Kubernetes 的基础知识,并帮助你部署第一个应用。
154 0
|
3天前
|
存储 Kubernetes 关系型数据库
阿里云ACK备份中心,K8s集群业务应用数据的一站式灾备方案
阿里云ACK备份中心,K8s集群业务应用数据的一站式灾备方案
|
14天前
|
存储 Kubernetes 负载均衡
深入浅出 Kubernetes:掌握容器编排的艺术
在云计算迅速发展的今天,Kubernetes 作为容器编排和管理的事实标准,提供了运行分布式系统的强大框架,支持无缝部署、扩展和管理容器化应用。本文深入探讨 Kubernetes 的核心概念与组件,介绍其自动化部署、负载均衡、存储编排等特性,并演示如何使用 Minikube、kubeadm 及 Kubernetes 服务提供商部署集群,通过 `kubectl` 和 Helm 管理资源,帮助开发者掌握这一关键技术。
|
20天前
|
存储 Kubernetes 持续交付
深入浅出 Kubernetes:掌握容器编排的艺术
Kubernetes作为容器编排领域的领头羊,提供了运行分布式系统的强大框架,支持自动化部署、扩展和管理容器化应用。本文深入浅出地介绍了Kubernetes的核心概念与关键组件,包括服务发现、存储编排及自动部署等特性。通过Minikube、kubeadm及云服务商等多种方式部署集群,并使用`kubectl`、YAML配置文件和Helm进行资源管理。掌握Kubernetes将成为软件开发者的宝贵技能。
|
21天前
|
Kubernetes 应用服务中间件 nginx
Kubernetes上安装Metallb和Ingress并部署应用程序
Kubernetes上安装Metallb和Ingress并部署nginx应用程序,使用LoadBalancer类型的KubernetesService
87 3
|
2月前
|
存储 Kubernetes Cloud Native
探索Python编程的奥秘云原生时代的容器编排:Kubernetes入门与实践
【8月更文挑战第30天】本文以浅显易懂的方式,探讨了Python编程的核心概念和技巧。从基础语法到高级特性,再到实际应用案例,逐步引导读者深入理解Python编程的精髓。通过本文的学习,读者将能够掌握Python编程的基本技能,并激发进一步探索的兴趣。
31 13
|
2月前
|
Kubernetes 数据库 容器
k8s安装seata单机版
k8s安装seata单机版
|
2月前
|
消息中间件 Kubernetes 容器
k8s安装rabbbitmq
k8s安装rabbbitmq
|
2月前
|
Kubernetes NoSQL MongoDB
k8s安装YAPI
k8s安装YAPI
|
2月前
|
Kubernetes 关系型数据库 MySQL
k8s安装并迁移jumpserver
k8s安装并迁移jumpserver
下一篇
无影云桌面