k8s包管理器helm_一起学习Kubernetes-01-helm安装

本文详细介绍了Helm,一个用于管理Kubernetes应用的包管理器,包括Helm的介绍、客户端安装步骤、添加Chart仓库、安装与测试应用,以及如何将Helm与自建Harbor仓库结合使用。
摘要由CSDN通过智能技术生成

一、helm简介

helm对于k8s来说的重要性相当于centos的yum。

Helm是一个kubernetes应用的包管理工具,用来管理预先配置好的安装包资源。Helm chart是用来封装kubernetes原生应用程序的yaml文件,可以在你部署应用的时候自定义应用程序的一些metadata,便与应用程序的分发。

是一个命令行下的客户端工具。主要用于 Kubernetes 应用程序 Chart 的创建、打包、发布以及创建和管理本地和远程的 Chart 仓库。

a996ca0a67fc3cdeeb1c963dccd16ad9.png

二、Helm 客户端

1、Tar包安装

mkdir /software cd /software

wget https://get.helm.sh/helm-v3.3.0-linux-amd64.tar.gz

tar xf helm-v3.3.0-linux-amd64.tar.gz

cp linux-amd64/helm /usr/local/bin/

2、脚本安装

curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash

3、源码安装:

git clone https://github.com/helm/helm.git

cd helm && make

4、添加helm命令补全

echo "source > ~/.bash_profile

source !$

5、查看版本

# helm version

version.BuildInfo{Version:"v3.3.0", GitCommit:"8a4aeec08d67a7b84472007529e8097ec3742105", GitTreeState:"dirty", GoVersion:"go1.14.7"}

三、添加 Chart 仓库

在 Helm 中默认是不会添加 Chart 仓库,所以这里我们需要手动添加,下面是添加一些常用的 Charts 库。

Chart和我们yum的仓库或者数据源一个道理。

helm repo add stable http://mirror.azure.cn/kubernetes/charts

helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com

helm repo add elastic https://helm.elastic.co

helm repo add gitlab https://charts.gitlab.io

helm repo add harbor https://helm.goharbor.io

helm repo add bitnami https://charts.bitnami.com/bitnami

helm repo add stable https://kubernetes-charts.storage.googleapis.com

52004439c27d683b85703f6be1ada062.png
c4e29c7ab50eed53cb55ffb32c13c4b6.png

helm repo update

ec09725ad963d4304ff3f6d6b3a0d15c.png

helm repo list

872f82884ca1d1d6d702bd25e35fe12a.png

这里也可以移除,命令是

# helm repo remove harbor

"harbor" has been removed from your repositories

# helm repo list 已经移除了

NAME URL

stable http://mirror.azure.cn/kubernetes/charts

aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

incubator https://kubernetes-charts-incubator.storage.googleapis.com

elastic https://helm.elastic.co

gitlab https://charts.gitlab.io

测试完毕还是加上harbor

helm repo add harbor https://helm.goharbor.io

"harbor" has been added to your repositories

# helm repo list

NAME URL

stable http://mirror.azure.cn/kubernetes/charts

aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

incubator https://kubernetes-charts-incubator.storage.googleapis.com

elastic https://helm.elastic.co

gitlab https://charts.gitlab.io

harbor https://helm.goharbor.io

四、安装测试

通过命令查询

# helm search repo tomcat

NAME CHART VERSION APP VERSION DESCRIPTION

stable/tomcat 0.4.1 7.0 Deploy a basic tomcat application server with

直接部署到k8s集群的默认命名空间

# helm install tomcat stable/tomcat -n default

NAME: tomcat

LAST DEPLOYED: Fri Oct 23 14:03:33 2020

NAMESPACE: default

STATUS: deployed

REVISION: 1

TEST SUITE: None

NOTES:

1. Get the application URL by running these commands:

NOTE: It may take a few minutes for the LoadBalancer IP to be available.

You can watch the status of by running 'kubectl get svc -w tomcat'

export SERVICE_IP=$(kubectl get svc --namespace default tomcat -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')

echo http://$SERVICE_IP:

查看一下状态

# kubectl get svc --namespace default tomcat

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE

tomcat LoadBalancer 192.168.56.73 80:9725/TCP 5m31s

Dashboard页面显示也正常

65347d170264b9e6c5b861529fc578ef.png

我们把它删除了

# helm uninstall tomcat

release "tomcat" uninstalled

五、添加我们自己的harbor

helm plugin install

这里报错了

# helm plugin install https://github.com/chartmuseum/helm-push

Error: git is not installed 没装git

安装git

# yum install git

再来

# helm plugin install https://github.com/chartmuseum/helm-push

Downloading and installing helm-push v0.9.0 ...

查看安装插件

# helm plugin list

NAME VERSION DESCRIPTION

push 0.9.0 Push chart package to ChartMuseum

我发现我们harbor上没有helm chart,

[root@node01 harbor]# docker-compose -f docker-compose.yml down

[root@node01 harbor]# ./install.sh --with-chartmuseum 安装一下即可

[root@node01 harbor]# docker-compose -f docker-compose.yml up -d

bd82fc725de799e73d0508f3e4c48011.png

# helm repo add harbor http://harbor.wumart.com/chartrepo/wolf/ --username=admin --password=admin

"harbor" has been added to your repositories

# helm repo list

NAME URL

stable http://mirror.azure.cn/kubernetes/charts

aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

incubator https://kubernetes-charts-incubator.storage.googleapis.com

elastic https://helm.elastic.co

gitlab https://charts.gitlab.io

harbor http://harbor.wumart.com/chartrepo/wolf/

###########################

常用命令

completion 命令补全

create 创建一个给定名称的chart

dependency 管理chart的依赖关系

env helm环境信息

get 获取给定release的扩展信息

help 命令帮助

history 获取release历史

install 部署chart

lint 对chart进行语法检查

list releases列表,list可简写为ls

package 打包chart

plugin install、list、uninstall Helm插件

pull 从repo中下载chart并(可选)将其解压到本地目录

repo add、list、remove、update、index Helm的repo

rollback 回滚release到一个以前的版本

search 查询在charts中的关键字

show 显示chart的信息

status 显示给定release的状态

template 本地渲染模板

test 测试运行release

uninstall 删除release

upgrade 升级release

verify 验证给定路径的chart是否已签名且有效

version 显示helm的版本信息

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值