k8s安装kubeapps

0 / 1065
---
title: k8s安装kubeapps
date: 2020-12-29 11:31:22
permalink: /pages/99e4ba/
categories:
  - 安装
  - K8s
tags:
  - K8s
---

Kubeapps是Bitnami公司的一个项目,其目的是为Kubernetes的使用者们提供已经打包好的应用仪表盘,它拥有网页界面可以更方便的部署和管理 k8s 原生应用。
<!-- more -->
## 基于helm
```shell
[root@master home]# helm repo add bitnami https://charts.bitnami.com/bitnami
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config
"bitnami" already exists with the same configuration, skipping
[root@master home]# kubectl create namespace kubeapps
namespace/kubeapps created
[root@master home]# helm install kubeapps --namespace kubeapps bitnami/kubeapps
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config
NAME: kubeapps
LAST DEPLOYED: Tue Dec 29 10:53:57 2020
NAMESPACE: kubeapps
STATUS: deployed
REVISION: 1
NOTES:
** 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.

生成token

[root@master home]# kubectl create serviceaccount kubeapps-operator
serviceaccount/kubeapps-operator created
[root@master home]# kubectl create clusterrolebinding kubeapps-operator --clusterrole=cluster-admin --serviceaccount=default:kubeapps-operator
clusterrolebinding.rbac.authorization.k8s.io/kubeapps-operator created
[root@master home]# kubectl get secret $(kubectl get serviceaccount kubeapps-operator -o jsonpath='{range .secrets[*]}{.name}{"\n"}{end}' | grep kubeapps-operator-token) -o jsonpath='{.data.token}' -o go-template='{{.data.token | base64decode}}' && echo
eyJhbGciOiJSUzI1NiIsImtpZCI6ImFxc1B1SVVOQXRCR2FfRHA2Rk4xQ3ZEcXRIbFNURklZWU05cGpSLWN0T2cifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6Imt1YmVhcHBzLW9wZXJhdG9yLXRva2VuLW02cXE0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6Imt1YmVhcHBzLW9wZXJhdG9yIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQudWlkIjoiOWRkZWI4MzYtNWY3ZC00NGYyLWIzZGItOGU2YmQ4N2I0NzAxIiwic3ViIjoic3lzdGVtOnNlcnZpY2VhY2NvdW50OmRlZmF1bHQ6a3ViZWFwcHMtb3BlcmF0b3IifQ.P0Rr3hOOL8vjFn7cxmi1Dz59X4oaTKsT3aTH_iS0Z6j5KIQ8ZB1pcCOCmMkA97t-1KdLaDEzDkwvuaEQtF0i8BkhvV4gLSNCJPMJg0j6dCCiMhW_yZ0Mk7xfIkZw2VgLLUQqM3T9fgLy5sqMZhNCHTTkYn-qaL0MWf_GTJ9P9Tx1bDlJ6JAD9X36bwYXzq1dd4scZF8Nz8YYWq38U394mQbNnM72XA8ItBBj4Qf5j9YgSvpoq5xrpAxChUnl0hHLizORZWvVYee1RVDIYxYLV-KhkQkKsSduXadxkG2xCQETiaLae2qeu9Q7PFEHNobbgireLEDTOowmIusWhWcoWA

修改访问模式并访问kubeapps

编辑kubeapps服务svc 将连接类型改为NodePort

kubectl edit svc kubeapps -n kubeapps

20210929164100.png

查看nodeport

kubectl get svc -nkubeapps

20210929164101.png

验证

[root@master home]# kubectl get pod -n kubeapps
NAME                                                          READY   STATUS    RESTARTS   AGE
apprepo-kubeapps-sync-bitnami-pjqvv-mzlbr                     1/1     Running   0          117s
kubeapps-5bd76b567c-ppn2t                                     1/1     Running   0          2m2s
kubeapps-5bd76b567c-xv68s                                     1/1     Running   0          2m2s
kubeapps-internal-apprepository-controller-5cd76f5fdb-n8cgd   1/1     Running   0          2m2s
kubeapps-internal-assetsvc-6496dd496c-7vd48                   1/1     Running   0          2m2s
kubeapps-internal-assetsvc-6496dd496c-8p7jm                   1/1     Running   0          2m2s
kubeapps-internal-dashboard-6d57bfb564-7rjzr                  1/1     Running   0          2m2s
kubeapps-internal-dashboard-6d57bfb564-zhkv9                  1/1     Running   0          2m2s
kubeapps-internal-kubeops-859d5d49c4-kvtkv                    1/1     Running   0          2m2s
kubeapps-internal-kubeops-859d5d49c4-rgkcd                    1/1     Running   0          2m2s
kubeapps-postgresql-primary-0                                 1/1     Running   0          2m2s
kubeapps-postgresql-read-0                                    1/1     Running   0          2m2s
[root@master home]#