root@k8s-master01:~/linux-amd64# helm repo add prometheus-community https://prometheus-community.github.io/helm-charts "prometheus-community" has been added to your repositories root@k8s-master01:~/linux-amd64# helm repo add kube-state-metrics https://kubernetes.github.io/kube-state-metrics "kube-state-metrics" has been added to your repositories root@k8s-master01:~/linux-amd64# helm repo add bitnami https://charts.bitnami.com/bitnami # bitnami也是常用的仓库之一 "bitnami" has been added to your repositories
# 更新仓库抓取索引信息 root@k8s-master01:~/linux-amd64# helm repo update Hang tight while we grab the latest from your chart repositories... ...Successfully got an update from the "kube-state-metrics" chart repository ...Successfully got an update from the "prometheus-community" chart repository ...Successfully got an update from the "bitnami" chart repository Update Complete. ⎈Happy Helming!⎈
查看仓库
1 2 3 4 5 6 7
root@k8s-master01:~/linux-amd64# helm repo list NAME URL prometheus-community https://prometheus-community.github.io/helm-charts kube-state-metrics https://kubernetes.github.io/kube-state-metrics bitnami https://charts.bitnami.com/bitnami
# 仓库已经添加
查找应用redis
1 2 3 4 5
root@k8s-master01:~/linux-amd64# helm search repo redis NAME CHART VERSION APP VERSION DESCRIPTION bitnami/redis 14.8.11 6.2.5 Open source, advanced key-value store. It is of... bitnami/redis-cluster 6.3.4 6.2.5 Open source, advanced key-value store. It is of... prometheus-community/prometheus-redis-exporter 4.2.0 1.11.1 Prometheus exporter for Redis metrics
# 执行此步骤后会将redis chart中的默认信息渲染成资源清单后部署redis root@k8s-master01:~/linux-amd64# helm install db bitnami/redis # instll 后需要添加release名 NAME: db # release名DB LAST DEPLOYED: Wed Aug 25 05:48:50 2021 # 最近一次部署时间 NAMESPACE: default # 所部署的名称空间 STATUS: deployed # 当前状态 REVISION: 1 # 历史版本 TEST SUITE: None # 是否带有测试套件 NOTES: ** Please be patient while the chart is being deployed **
Redis™ can be accessed on the following DNS names from within your cluster: # 部署了2个svc,一个读写,一个只读 db-redis-master.default.svc.cluster.local forread/write operations (port 6379) db-redis-replicas.default.svc.cluster.local for read-only operations (port 6379)
To get your password run: # 部署时生成了密码,使用以下命令来获取 export REDIS_PASSWORD=$(kubectl get secret --namespace default db-redis -o jsonpath="{.data.redis-password}" | base64 --decode)
To connect to your Redis™ server: # 以下为连接redis的方法 1. Run a Redis™ pod that you can use as a client:
root@k8s-master01:~# helm list NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION db default 1 2021-08-25 05:48:50.961139929 +0000 UTC deployed redis-14.8.11 6.2.5
root@k8s-master01:~# kubectl get pods NAME READY STATUS RESTARTS AGE db-redis-master-0 0/1 Pending 0 6m56s db-redis-replicas-0 0/1 Pending 0 6m56s # 处于pending状态
# 查看原因 root@k8s-master01:~# kubectl describe pod db-redis-master-0 | grep -A5 Events Events: Type Reason Age From Message ---- ------ ---- ---- ------- Warning FailedScheduling 8m12s default-scheduler 0/4 nodes are available: 4 pod has unbound immediate PersistentVolumeClaims. Warning FailedScheduling 8m11s default-scheduler 0/4 nodes are available: 4 pod has unbound immediate PersistentVolumeClaims. # 卷挂载问题,redis chart中默认绑定的存储类系统中没有导致的。 # 下面解决此问题
# 先删除已经部署的db root@k8s-master01:~# helm uninstall db release "db" uninstalled
# 重新部署redis root@k8s-master01:~# helm install db bitnami/redis --set master.persistence.enabled=false --set replica.persistence.enabled=false NAME: db LAST DEPLOYED: Wed Aug 25 06:44:40 2021 NAMESPACE: default STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: ** Please be patient while the chart is being deployed **
Redis™ can be accessed on the following DNS names from within your cluster: