helm v3.x 部署 redis — Jevic

helm v3.x 部署 redis

2020/07/01 Kubernetes

helm v3.0 进行了重构,区别与v2.x 不需要安装tiller;

Installing Helm

Download release

[root@kms ~]# helm version
version.BuildInfo{Version:"v3.2.4", GitCommit:"0ad800ef43d3b826f31a5ad8dfbb4fe05d143688", GitTreeState:"clean", GoVersion:"go1.13.12"}

添加国内源

helm repo remove stable
helm repo add gitlab https://charts.gitlab.io/
helm repo add stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
helm repo add incubator https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/
helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts-incubator/
helm repo update

helm repo list
NAME     	URL                                                                      
stable   	https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts                   
gitlab   	https://charts.gitlab.io/                                                
incubator	https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/
aliyun   	https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts-incubator/   

安装redis

[root@kms ~]# helm list
Error: Kubernetes cluster unreachable

解决方式: 配置 ~/.kube/config

# helm search repo redis
NAME           	CHART VERSION	APP VERSION	DESCRIPTION                                       
stable/redis   	1.1.15       	4.0.8      	Open source, advanced key-value store. It is of...
stable/redis-ha	2.0.1        	           	Highly available Redis cluster with multiple se...
stable/sensu   	0.2.0        	           	Sensu monitoring framework backed by the Redis ...


## 出现报错
[root@kms ~]# helm install redis stable/redis
Error: unable to build kubernetes objects from release manifest: unable to recognize "": no matches for kind "Deployment" in version "extensions/v1beta1"

解决方式:

将 kind “Deployment” version 从”extensions/v1beta1” 修改为 apps/v1

[root@kms helm]# helm pull stable/redis
[root@kms helm]# pwd
/root/helm
[root@kms helm]# ls
redis-1.1.15.tgz
[root@kms helm]# tar zxf redis-1.1.15.tgz
[root@kms helm]# ls
redis  redis-1.1.15.tgz
[root@kms templates]# pwd
/root/helm/redis/templates
[root@kms templates]# ls
deployment.yaml  _helpers.tpl  networkpolicy.yaml  NOTES.txt  pvc.yaml  secrets.yaml  svc.yaml
[root@kms templates]# vim deployment.yaml 
[root@kms templates]# head -n2 deployment.yaml 
apiVersion: apps/v1
kind: Deployment

# helm install redis redis
NAME: redis
LAST DEPLOYED: Wed Jul  8 14:00:29 2020
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Redis can be accessed via port 6379 on the following DNS name from within your cluster:
redis-redis.default.svc.cluster.local
To get your password run:

    REDIS_PASSWORD=$(kubectl get secret --namespace default redis-redis -o jsonpath="{.data.redis-password}" | base64 --decode)

To connect to your Redis server:

1. Run a Redis pod that you can use as a client:

   kubectl run --namespace default redis-redis-client --rm --tty -i \
    --env REDIS_PASSWORD=$REDIS_PASSWORD \
   --image bitnami/redis:4.0.8-r2 -- bash

2. Connect using the Redis CLI:

  redis-cli -h redis-redis -a $REDIS_PASSWORD

Search

    Post Directory