helm和helm3

Helm工作原理
Helm把Kubernetes资源(比如deployments、services或 ingress等) 打包到一个chart中,而chart被保存到chart仓库。通过chart仓库可用来存储和分享chart。Helm使发布可配置,支持发布应用配置的版本管理,简化了Kubernetes部署应用的版本控制、打包、发布、删除、更新等操作。用
helm部署项目到k8s上,下面是github链接,然后用阿里云镜像初始化就行,github链接如下
https://github.com/helm/helm/releases
我下的2.15.0版本
下面有我的helm3教程,现在我主要用helm3了,附送一个helm hub,里面有各种chart,按照官网教程即可,然后密码什么可以输入:
minikube dashboard进入k8s管理页面的secret获取
helm hub

C:\Users\Administrator>helm init --service-account tiller --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.15.0  --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
$HELM_HOME has been configured at C:\Users\Administrator\.helm.

Tiller (the Helm server-side component) has been installed into your Kubernetes Cluster.

Please note: by default, Tiller is deployed with an insecure 'allow unauthenticated users' policy.
To prevent this, run `helm init` with the --tiller-tls-verify flag.
For more information on securing your installation see: https://docs.helm.sh/using_helm/#securing-your-helm-installation

C:\Users\Administrator\windows-amd64>helm version
Client: &version.Version{SemVer:"v2.15.0", GitCommit:"c2440264ca6c078a06e088a838b0476d2fc14750", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.15.0", GitCommit:"c2440264ca6c078a06e088a838b0476d2fc14750", GitTreeState:"clean"}

查看version这个要等tiller建好后,不要着急,先用阿里云镜像下载helm的tiller默认在k8s的kube-system里面,显示要授权,当然这个github的安装包里面也有一个tiller.exe,可以启动一下,我这里用的2.15.0镜像,因为和我的helm版本对应

我这里用阿里云镜像 创建TLS认证地址

C:\Users\Administrator>kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
clusterrolebinding.rbac.authorization.k8s.io/tiller-cluster-rule created

授权,但是这个没奏效,我就用另一个方法了,网上找的方法是这样的

kubectl patch deploy --namespace kube-system tiller-deploy -p 
'{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'

显示字符串读取失败,json格式报错 因为上面命令的goLong型字符串适合linux系统,windows系统这个字符串转换成json格式,可以换成如下json格式

kubectl patch deploy --namespace kube-system tiller-deploy -p "{\"spec\":{\"template\":{\"spec\":{\"serviceAccount\":\"tiller\"}}}}"

用这个就通了哦

C:\Users\Administrator>kubectl -n kube-system get pods
NAME                                    READY   STATUS             RESTARTS   AGE
coredns-67c766df46-jpw7d                1/1     Running            0          22m
coredns-67c766df46-z2lbh                1/1     Running            3          21h
etcd-minikube                           1/1     Running            29         7d19h
kube-addon-manager-minikube             1/1     Running            13         7d19h
kube-apiserver-minikube                 1/1     Running            64         7d19h
kube-controller-manager-minikube        1/1     Running            5          28h
kube-proxy-nn5nt                        1/1     Running            13         7d19h
kube-scheduler-minikube                 1/1     Running            30         7d19h
kubernetes-dashboard-7c54d59f66-p89db   0/1     ImagePullBackOff   0          21h
metrics-server-5d9c56cffd-nqkws         1/1     Running            11         5d21h
storage-provisioner                     1/1     Running            25         7d19h
tiller-deploy-64ddd4864d-hqfwp          1/1     Running            0          11m

查看是否安装成功,这里可以看见最后一行tiller-deploy已经running了,那就是没毛病了。
装好helm后第一件事就是去拉一下chart

进入下面官方网址:
helm的charts官网

在这里插入图片描述
点击stable,里面有很多好东西,人家给你搭建好了,直接用就可以了,我第一个搭建的rabbitmq集群,我在rabbitmq-ha
在这里插入图片描述
点进去有安装教程

也可以在终端输入helm search命令查看可以用的charts


C:\Users\Administrator\windows-amd64>helm install --name my-release stable/rabbitmq-ha
NAME:   my-release
LAST DEPLOYED: Sun Oct 20 22:14:55 2019
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/ConfigMap
NAME                    DATA  AGE
my-release-rabbitmq-ha  2     1s

==> v1/Pod(related)
NAME                      READY  STATUS    RESTARTS  AGE
my-release-rabbitmq-ha-0  0/1    Init:0/1  0         1s

==> v1/Role
NAME                    AGE
my-release-rabbitmq-ha  1s

==> v1/RoleBinding
NAME                    AGE
my-release-rabbitmq-ha  1s

==> v1/Secret
NAME                    TYPE    DATA  AGE
my-release-rabbitmq-ha  Opaque  6     1s

==> v1/Service
NAME                              TYPE       CLUSTER-IP  EXTERNAL-IP  PORT(S)                      AGE
my-release-rabbitmq-ha            ClusterIP  None        <none>       15672/TCP,5672/TCP,4369/TCP  1s
my-release-rabbitmq-ha-discovery  ClusterIP  None        <none>       15672/TCP,5672/TCP,4369/TCP  1s

==> v1/ServiceAccount
NAME                    SECRETS  AGE
my-release-rabbitmq-ha  1        1s

==> v1/StatefulSet
NAME                    READY  AGE
my-release-rabbitmq-ha  0/3    1s


NOTES:
** Please be patient while the chart is being deployed **

  Credentials:

    Username            : guest
    Password            : $(kubectl get secret --namespace default my-release-rabbitmq-ha -o jsonpath="{.data.rabbitmq-password}" | base64 --decode)
    Management username : management
    Management password : $(kubectl get secret --namespace default my-release-rabbitmq-ha -o jsonpath="{.data.rabbitmq-management-password}" | base64 --decode)
    ErLang Cookie       : $(kubectl get secret --namespace default my-release-rabbitmq-ha -o jsonpath="{.data.rabbitmq-erlang-cookie}" | base64 --decode)

  RabbitMQ can be accessed within the cluster on port 5672 at my-release-rabbitmq-ha.default.svc.cluster.local

  To access the cluster externally execute the following commands:

    export POD_NAME=$(kubectl get pods --namespace default -l "app=rabbitmq-ha" -o jsonpath="{.items[0].metadata.name}")
    kubectl port-forward $POD_NAME --namespace default 5672:5672 15672:15672

  To Access the RabbitMQ AMQP port:

    amqp://127.0.0.1:5672/

  To Access the RabbitMQ Management interface:

    URL : http://127.0.0.1:15672

这里的export在windows是用set代替

在这里插入图片描述
![在这里插入图片描述](https://img-blog.csdnimg.cn/20191020221801787.png?x-oss-process=
执行install命令后看见了如上信息
有一行获取password命令改成如下
kubectl get secret --namespace default my-release-rabbitmq-ha -o jsonpath="{.data.rabbitmq-password}"
因为我是在windows上用所以|bash64这个东西不存在的
management的密码也是同理要去掉|base64后面的命令
最后一行端口信息127.0.0.1:15672直接进入浏览器复制该ip和端口就可以访问rabbitmq啦

在这里插入图片描述

输入minikube dashboard命令进入管理页面
在这里插入图片描述
划红线部分,动动你可爱的小手就能看见密码拉,复制进去登录就行,有rabbitmq-management和rabbitmq两种界面哦,都是不一样的
在这里插入图片描述
三个rabbitmq都在哦

helm3取消了tiller,引进其他功能要方便很多
helm3官网
我的命令执行如下

 helm repo add stable https://kubernetes-charts.storage.googleapis.com/
helm search repo stable
helm repo update
D:\k8s\windows-amd64>helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "stable" chart repository
Update Complete. ⎈ Happy Helming!

安装kafka

D:\k8s\windows-amd64>helm install stable/kafka-manager --generate-name
NAME: kafka-manager-1571996561
LAST DEPLOYED: Fri Oct 25 17:42:43 2019
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. Get the application URL by running these commands:
  export POD_NAME=$(kubectl get pods --namespace default -l "app=kafka-manager,release=kafka-manager-1571996561" -o jsonpath="{.items[0].metadata.name}")
  echo "Visit http://127.0.0.1:8080 to use your application"
  kubectl port-forward $POD_NAME 8080:9000

安装redis-ha集群

D:\k8s\windows-amd64>helm install stable/redis-ha --generate-name
NAME: redis-ha-1571996773
LAST DEPLOYED: Fri Oct 25 17:46:15 2019
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
Redis can be accessed via port 6379 and Sentinel can be accessed via port 26379 on the following DNS name from within your cluster:
redis-ha-1571996773.default.svc.cluster.local

To connect to your Redis server:
1. Run a Redis pod that you can use as a client:

   kubectl exec -it redis-ha-1571996773-server-0 sh -n default

2. Connect using the Redis CLI:

  redis-cli -h redis-ha-1571996773.default.svc.cluster.local
F:\windows-amd64>helm install  my-release bitnami/kafka --namespace kafka
NAME: my-release
LAST DEPLOYED: Sat Oct 26 14:00:41 2019
NAMESPACE: kafka
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
** Please be patient while the chart is being deployed **

Kafka can be accessed via port 9092 on the following DNS name from within your cluster:

    my-release-kafka.kafka.svc.cluster.local

To create a topic run the following command:

    export POD_NAME=$(kubectl get pods --namespace kafka -l "app.kubernetes.io/name=kafka,app.kubernetes.io/instance=my-release,app.kubernetes.io/component=kafka" -o jsonpath="{.items[0].metadata.name}")
    kubectl --namespace kafka exec -it $POD_NAME -- kafka-topics.sh --create --zookeeper my-release-zookeeper:2181 --replication-factor 1 --partitions 1 --topic test

To list all the topics run the following command:

    export POD_NAME=$(kubectl get pods --namespace kafka -l "app.kubernetes.io/name=kafka,app.kubernetes.io/instance=my-release,app.kubernetes.io/component=kafka" -o jsonpath="{.items[0].metadata.name}")
    kubectl --namespace kafka exec -it $POD_NAME -- kafka-topics.sh --list --zookeeper my-release-zookeeper:2181

To start a kafka producer run the following command:

    export POD_NAME=$(kubectl get pods --namespace kafka -l "app.kubernetes.io/name=kafka,app.kubernetes.io/instance=my-release,app.kubernetes.io/component=kafka" -o jsonpath="{.items[0].metadata.name}")
    kubectl --namespace kafka exec -it $POD_NAME -- kafka-console-producer.sh --broker-list localhost:9092 --topic test

To start a kafka consumer run the following command:

    export POD_NAME=$(kubectl get pods --namespace kafka -l "app.kubernetes.io/name=kafka,app.kubernetes.io/instance=my-release,app.kubernetes.io/component=kafka" -o jsonpath="{.items[0].metadata.name}")
    kubectl --namespace kafka exec -it $POD_NAME -- kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning

To connect to your Kafka server from outside the cluster execute the following commands:

    kubectl port-forward --namespace kafka svc/my-release-kafka 9092:9092 &
    echo "Kafka Broker Endpoint: 127.0.0.1:9092"

    PRODUCER:
        kafka-console-producer.sh --broker-list 127.0.0.1:9092 --topic test
    CONSUMER:
        kafka-console-consumer.sh --bootstrap-server 127.0.0.1:9092 --topic test --from-beginning

又下载了bitnami家的kafka

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值