前言:
kubeapps是Bitnami公司的一个项目,其目的是为Kubernetes的使用者们提供已经打包好的应用仪表盘,它拥有网页界面可以更方便的部署和管理k8s 原生应用。
包含绝大多数的云原生应用管理应用-部署,删除,升级以及修改配置服务目录-(Service Catalog)是一种扩展api,它能让 Kubernetes 集群中运行的应用易于使用外部托管的的软件服务,例如云供应商提供的数据仓库服务。
说了这么多,其实估计很多同学还是云山雾罩的,OK,宝塔面板大家应该都知道的吧,可以把kubeapps想象成这个玩意----kubernetes里的宝塔面板,只是这个“面板”管理的是chart包而已了。
部署安装kubeapps:
一,
kubeapps的部署比较简单,基本也就是几条命令就搞定了。主要是有一些先决条件,例如,helm包管理器这个 不用说肯定要有,如何安装helm就不在这里废话了。
添加helm的官方仓库:
# 添加 kubeapps 仓库 helm repo add bitnami https://charts.bitnami.com/bitnami # 创建 kubeapps 的命名空间 kubectl create namespace kubeapps
此时,可以查询到现有helm仓库一个(名字是bitnami,前面定义的):
[root@k8s-master ~]# helm repo list NAME URL bitnami https://charts.bitnami.com/bitnami
查询此仓库内所有的关于redis的chart(helm search repo 仓库名称/要查询的chart -l 如果没有l,只显示最新的那个chart):
[root@k8s-master kubeapps]# helm search repo bitnami/redis -l NAME CHART VERSION APP VERSION DESCRIPTION bitnami/redis 17.3.5 7.0.5 Redis(R) is an open source, advanced key-value ... bitnami/redis 17.3.4 7.0.5 Redis(R) is an open source, advanced key-value ... bitnami/redis 17.3.2 7.0.5 Redis(R) is an open source, advanced key-value ... bitnami/redis 17.3.1 7.0.5 Redis(R) is an open source, advanced key-value ... bitnami/redis 17.2.0 7.0.5 Redis(R) is an open source, advanced key-value ... 。。。。。。略略略
查询此仓库内所有的关于kubeapps的chart(helm search repo 仓库名称/要查询的chart -l 如果没有l,只显示最新的那个chart):
[root@k8s-master kubeapps]# helm search repo bitnami/kubeapps -l NAME CHART VERSION APP VERSION DESCRIPTION bitnami/kubeapps 11.0.1 2.6.0 Kubeapps is a web-based UI for launching and ma... bitnami/kubeapps 10.3.5 2.5.1 Kubeapps is a web-based UI for launching and ma... bitnami/kubeapps 10.3.4 2.5.1 Kubeapps is a web-based UI for launching and ma... bitnami/kubeapps 10.3.3 2.5.1 Kubeapps is a web-based UI for launching and ma... bitnami/kubeapps 10.3.1 2.5.0 Kubeapps is a web-based UI for launching and ma...
考虑到我的kubernetes集群版本是1.18,因此,挑选了一个不是版本太高的kubeapps---kubeapps-8.0.9,下载此chart包,并进入解压后的目录:
[root@k8s-master kubeapps]# helm pull bitnami/kubeapps --version=8.0.9
查看chart包内的README.MD文件中的先决条件:
kubernetes版本必须大于1.16,安装方式不限定,比如,minikube什么的都支持。
helm版本必须大于3.0.2.。
pgsql需要有pv插件支持,也就是volume插件。因此,需要一个默认的StorageClass,如何部署StorageClass请看我的博客:
kubernetes学习之持久化存储StorageClass(4)_晚风_END的博客-CSDN博客_kubernetes中用于持久化存储的组件
我的kubernetes版本是1.18.3,helm版本是3.2,因此,我可以安装kubeapps-8.0.9版本。
[root@k8s-master ~]# k get no NAME STATUS ROLES AGE VERSION k8s-master Ready <none> 15d v1.18.3 k8s-node1 Ready <none> 15d v1.18.3 k8s-node2 Ready <none> 15d v1.18.3 [root@k8s-master ~]# helm version version.BuildInfo{Version:"v3.2.4", GitCommit:"0ad800ef43d3b826f31a5ad8dfbb4fe05d143688", GitTreeState:"clean", GoVersion:"go1.13.12"}
下面是chart里面的README里的先决条件原文:
## Prerequisites - Kubernetes 1.16+ (tested with both bare-metal and managed clusters, including EKS, AKS, GKE and Tanzu Kubernetes Grid, as well as dev clusters, such as Kind, Minikube and Docker for Desktop Kubernetes) - Helm 3.0.2+ - Administrative access to the cluster to create Custom Resource Definitions (CRDs) - PV provisioner support in the underlying infrastructure (required for PostgreSQL database)
二,
OK,以上的先决条件搞定了就可以安装了,安装命令为:
# 安装 helm install kubeapps --namespace kubeapps kubeapps-8.0.9.tgz --version=8.0.9
安装时间根据网速来,可能会比较长,因为镜像都是从docker.io 官网下载的,安装完毕后的kubeapps相关的pod,service,configMap,serviceaccount,pv,pvc:
相关pods和service
[root@k8s-master ~]# k get po,svc -n kubeapps NAME READY STATUS RESTARTS AGE pod/apprepo-kubeapps-sync-bitnami-1666098000-gr5ql 0/1 Completed 0 24h pod/apprepo-kubeapps-sync-bitnami-1666098600-n5txd 0/1 Completed 0 24h pod/apprepo-kubeapps-sync-bitnami-1666099200-js2nw 0/1 Completed 0 23h pod/apprepo-kubeapps-sync-bitnami-hxm68-pgmk4 0/1 Completed 2 5h28m pod/kubeapps-67887978f5-vcbmh 1/1 Running 1 25h pod/kubeapps-67887978f5-xsx7c 1/1 Running 2 25h pod/kubeapps-internal-apprepository-controller-6d84d4d78-b2cjc 1/1 Running 1 25h pod/kubeapps-internal-dashboard-84875db4c5-jdmmt 1/1 Running 1 25h pod/kubeapps-internal-dashboard-84875db4c5-zsrcl 1/1 Running 1 25h pod/kubeapps-internal-kubeappsapis-65c55c5c86-5kpq6 1/1 Running 1 25h pod/kubeapps-internal-kubeappsapis-65c55c5c86-tjsw7 1/1 Running 1 25h pod/kubeapps-internal-kubeops-bb7899866-kh8vx 1/1 Running 1 25h pod/kubeapps-internal-kubeops-bb7899866-sqk9p 1/1 Running 1 25h pod/kubeapps-postgresql-primary-0 1/1 Running 1 25h pod/kubeapps-postgresql-read-0 1/1 Running 2 25h pod/mydokuwiki-79477dbcf7-hqk74 1/1 Running 0 5h9m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kubeapps NodePort 10.0.214.168 <none> 80:31637/TCP 25h service/kubeapps-internal-dashboard NodePort 10.0.175.52 <none> 8080:31171/TCP 25h service/kubeapps-internal-kubeappsapis ClusterIP 10.0.17.79 <none> 8080/TCP 25h service/kubeapps-internal-kubeops ClusterIP 10.0.80.30 <none> 8080/TCP 25h service/kubeapps-postgresql-primary ClusterIP 10.0.49.36 <none> 5432/TCP 25h service/kubeapps-postgresql-primary-hl ClusterIP None <none> 5432/TCP 25h service/kubeapps-postgresql-read ClusterIP 10.0.126.247 <none> 5432/TCP 25h service/kubeapps-postgresql-read-hl ClusterIP None <none> 5432/TCP 25h service/mydokuwiki LoadBalancer 10.0.184.105 <pending> 80:30403/TCP,443:30783/TCP 5h9m
pv和pvc
[root@k8s-master ~]# k get pv,pvc -n kubeapps NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE persistentvolume/pvc-1e943d44-d92d-4210-a52a-5f9b0143bbc7 8Gi RWO Delete Bound kubeapps/data-kubeapps-postgresql-primary-0 managed-nfs-storage 25h persistentvolume/pvc-c2a706ee-e9a0-4db1-b9e5-3f4d6a0d21ea 8Gi RWO Delete Bound kubeapps/mydokuwiki managed-nfs-storage 5h10m persistentvolume/pvc-e75f653e-cbef-460d-bb68-e791f552bfc7 8Gi RWO Delete Bound kubeapps/data-kubeapps-postgresql-read-0 managed-nfs-storage 25h NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE persistentvolumeclaim/data-kubeapps-postgresql-primary-0 Bound pvc-1e943d44-d92d-4210-a52a-5f9b0143bbc7 8Gi RWO managed-nfs-storage 25h persistentvolumeclaim/data-kubeapps-postgresql-read-0 Bound pvc-e75f653e-cbef-460d-bb68-e791f552bfc7 8Gi RWO managed-nfs-storage 25h persistentvolumeclaim/mydokuwiki Bound pvc-c2a706ee-e9a0-4db1-b9e5-3f4d6a0d21ea 8Gi RWO managed-nfs-storage 5h10m
相关的sa,secret
[root@k8s-master ~]# k get sa,secret -n kubeapps NAME SECRETS AGE serviceaccount/default 1 26h serviceaccount/kubeapps-internal-apprepository-controller 1 25h serviceaccount/kubeapps-internal-kubeappsapis 1 25h serviceaccount/kubeapps-internal-kubeops 1 25h serviceaccount/kubeapps-operator 1 24h NAME TYPE DATA AGE secret/default-token-f4pvj kubernetes.io/service-account-token 3 26h secret/kubeapps-internal-apprepository-controller-token-tpn7j kubernetes.io/service-account-token 3 25h secret/kubeapps-internal-kubeappsapis-token-cgvmg kubernetes.io/service-account-token 3 25h secret/kubeapps-internal-kubeops-token-cq2ql kubernetes.io/service-account-token 3 25h secret/kubeapps-operator-token-qfxsx kubernetes.io/service-account-token 3 24h secret/kubeapps-postgresql Opaque 2 25h secret/mydokuwiki Opaque 1 5h12m secret/sh.helm.release.v1.kubeapps.v1 helm.sh/release.v1 1 25h secret/sh.helm.release.v1.mydokuwiki.v1 helm.sh/release.v1 1 5h12m
相关的configMap
[root@k8s-master ~]# k get cm -n kubeapps NAME DATA AGE kubeapps-clusters-config 1 25h kubeapps-frontend-config 2 25h kubeapps-internal-dashboard-config 5 25h kubeapps-internal-kubeappsapis-configmap 1 25h
相关的控制器,可以看到postgresql是sts控制器,
[root@k8s-master ~]# k get deploy,ds,sts -n kubeapps NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/kubeapps 2/2 2 2 25h deployment.apps/kubeapps-internal-apprepository-controller 1/1 1 1 25h deployment.apps/kubeapps-internal-dashboard 2/2 2 2 25h deployment.apps/kubeapps-internal-kubeappsapis 2/2 2 2 25h deployment.apps/kubeapps-internal-kubeops 2/2 2 2 25h deployment.apps/mydokuwiki 1/1 1 1 5h13m NAME READY AGE statefulset.apps/kubeapps-postgresql-primary 1/1 25h statefulset.apps/kubeapps-postgresql-read 1/1 25h
helm install后的输出,提示要port-forward端口,但,我们这是测试,因此,采用NodePort方式暴露服务端口
[root@k8s-master ~]# helm status kubeapps -n kubeapps NAME: kubeapps LAST DEPLOYED: Tue Oct 18 20:05:10 2022 NAMESPACE: kubeapps STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: CHART NAME: kubeapps CHART VERSION: 8.0.9 APP VERSION: 2.4.4** Please be patient while the chart is being deployed ** Tip: Watch the deployment status using the command: kubectl get pods -w --namespace kubeapps Kubeapps can be accessed via port 80 on the following DNS name from within your cluster: kubeapps.kubeapps.svc.cluster.local To access Kubeapps from outside your K8s cluster, follow the steps below: 1. Get the Kubeapps URL by running these commands: echo "Kubeapps URL: http://127.0.0.1:8080" kubectl port-forward --namespace kubeapps service/kubeapps 8080:80 2. Open a browser and access Kubeapps using the obtained URL.
三,
修改service/kubeapps 为NodePort端口模式,其实也可以不修改,直接使用ingress控制器,但,测试性质,过于麻烦。
k edit svc kubeapps -n kubeapps selector: app.kubernetes.io/component: frontend app.kubernetes.io/instance: kubeapps app.kubernetes.io/name: kubeapps sessionAffinity: None type: NodePort 最后一行ClusterIP 修改为NodePort 保存即可。
暴露的端口为31637,打开浏览器,任意的节点IP+31637即可进入kubeapps
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubeapps NodePort 10.0.214.168 <none> 80:31637/TCP 25h
四,
部署成功后的演示
登录后的界面是这样的,这个界面比较简洁,就两个模块,一个是应用程序---application,一个是目录catalog---这个相当于helm的应用商店,从部署kubeapps成功开始后,再使用helm安装的程序将会显示在application这个组件下了:
例如,在目录这个模块下,选择cms,将可以看到bitnami 这个官方仓库下的所有cms类型,比较熟悉的WordPress,ghost等等都可以看到。
就以安装WordPress为例,介绍一哈web界面急速安装cmd吧:
设置要安装的WordPress的版本和要安装到哪个namespace以及哪个kubernetes集群内:
设置WordPress的账号密码以及资源限制等等信息
就这么简简单单的安装好了WordPress,看一下各种信息:
[root@k8s-master ~]# k get po,svc,cm,deploy,sts,ds,pvc -n web NAME READY STATUS RESTARTS AGE pod/mywordpress-57fc6bbb9-q86jp 2/2 Running 5 49m pod/mywordpress-mariadb-0 1/1 Running 0 49m NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/mywordpress NodePort 10.0.58.85 <none> 80:31292/TCP,443:31469/TCP 49m service/mywordpress-mariadb ClusterIP 10.0.163.97 <none> 3306/TCP 49m service/mywordpress-metrics ClusterIP 10.0.131.36 <none> 9150/TCP 49m NAME DATA AGE configmap/mywordpress-mariadb 1 49m NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/mywordpress 1/1 1 1 49m NAME READY AGE statefulset.apps/mywordpress-mariadb 1/1 49m NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE persistentvolumeclaim/data-mywordpress-mariadb-0 Bound pvc-d373bb9c-3e7a-4593-9d07-328edb5717f0 8Gi RWO managed-nfs-storage 50m persistentvolumeclaim/mywordpress Bound pvc-8f78ab1c-5507-484d-8a6e-40894239184d 10Gi RWO managed-nfs-storage 50m
WordPress的后台页面:
kubeapps的应用展示界面,可以看到多了一个WordPress
要删除此应用也非常简单,一个按钮就搞定了:
总结:
kubeapps安装是比较简单的,看起来比较简单的原因是我这里只是测试,很多功能没有使用,比如ingress-controller插件没有启用。但一个默认的StorageClass存储类还是需要的,可以减少很多不必要的麻烦。如果是生产上使用这个kubeapps,那么,还是需要完善增加很多功能的哦。