kubernetes部署2.0版本UI页面,以及容器资源使用监控(2)
2021-04-04 06:25
标签:rap second setting scribe use -- replicas binding blog 完整部署文件 Github 地址:https://github.com/my-dlq/blog-example/tree/master/kubernetes/kubernetes-dashboard2.0.0-deploy 接下来开始部署 部署一共分5个步骤: 我吧文件直接都配好了放到了百度网盘,你们可以直接下载解压使用 链接:https://pan.baidu.com/s/1wdp-zJE6FqpuJdGYgyESmg 完成之后就可以通过web页面访问了 这里使用的是kubeadmin部署的,如果是二进制,需要修改api-server的参数不然无法支持metrics-server服务的 apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1 部署 kind: ConfigMap 3、部署 Dashboard Config & Secret 创建 Dashboard Deploy 部署文件 kind: Deployment 部署 Dashboard Deploy 4、创建 Dashboard Metrics 部署文件 cat >k8s-dashboard-metrics.yamlkind: Service kind: Deployment EOF 5、创建 Dashboard ServiceAccount 部署文件 cat > k8s-dashboard-token.yamlkind: ClusterRoleBinding apiVersion: v1 部署访问的 ServiceAccount kubectl apply -f k8s-dashboard-token.yaml 完成之后登陆页面然后看看 看到了数据 好了2版本的web-ui就完成了 kubernetes部署2.0版本UI页面,以及容器资源使用监控(2) 标签:rap second setting scribe use -- replicas binding blog 原文地址:https://blog.51cto.com/xiaorenwutest/2479996
1、创建RBAC
2、创建configmap和secret
3、创建dashboard
4、创建metrics-scraper
5、创建访问的serviceaccount
提取码:stzw 1、创建 Dashboard RBAC 部署文件
cat > k8s-dashboard-rbac.yaml apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
kind: Role
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
rules:
resources: ["secrets"]
resourceNames: ["kubernetes-dashboard-key-holder", "kubernetes-dashboard-certs", "kubernetes-dashboard-csrf"]
verbs: ["get", "update", "delete"]
resources: ["configmaps"]
resourceNames: ["kubernetes-dashboard-settings"]
verbs: ["get", "update"]
resources: ["services"]
resourceNames: ["heapster", "dashboard-metrics-scraper"]
verbs: ["proxy"]apiGroups: [""]
resources: ["services/proxy"]
resourceNames: ["heapster", "http:heapster:", "https:heapster:", "dashboard-metrics-scraper", "http:dashboard-metrics-scraper"]
verbs: ["get"]
kind: ClusterRole
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
rules:apiGroups: ["metrics.k8s.io"]
resources: ["pods", "nodes"]
verbs: ["get", "list", "watch"]
kind: RoleBinding
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: kubernetes-dashboard
subjects:kind: ServiceAccount
name: kubernetes-dashboard
namespace: kube-system
kind: ClusterRoleBinding
metadata:
name: kubernetes-dashboard
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kubernetes-dashboard
subjects:
name: kubernetes-dashboard
namespace: kube-system
EOF
kubectl apply -f k8s-dashboard-rbac.yaml2、创建 ConfigMap、Secret
cat >k8s-dashboard-configmap-secret.yamlapiVersion: v1
kind: Secret
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-certs
namespace: kube-system
type: OpaqueapiVersion: v1
kind: Secret
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-csrf
namespace: kube-system
type: Opaque
data:
csrf: ""apiVersion: v1
kind: Secret
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-key-holder
namespace: kube-system
type: Opaque
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard-settings
namespace: kube-system
EOF
kubectl apply -f k8s-dashboard-configmap-secret.yaml
cat >k8s-dashboard-deploy.yamlkind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
spec:
type: NodePort
ports:
port: 443
targetPort: 8443
nodePort: 31001
selector:
k8s-app: kubernetes-dashboard
apiVersion: apps/v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kube-system
spec:
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
k8s-app: kubernetes-dashboard
template:
metadata:
labels:
k8s-app: kubernetes-dashboard
spec:
containers:
image: kubernetesui/dashboard:v2.0.0-rc3
ports:
protocol: TCP
args:
volumeMounts:
mountPath: /certs
name: tmp-volume
livenessProbe:
httpGet:
scheme: HTTPS
path: /
port: 8443
initialDelaySeconds: 30
timeoutSeconds: 30
volumes:
secret:
secretName: kubernetes-dashboard-certs
emptyDir: {}
serviceAccountName: kubernetes-dashboard
tolerations:
effect: NoSchedule
EOF
kubectl apply -f k8s-dashboard-deploy.yaml
apiVersion: v1
metadata:
labels:
k8s-app: dashboard-metrics-scraper
name: dashboard-metrics-scraper
namespace: kube-system
spec:
ports:
port: 8000
targetPort: 8000
selector:
k8s-app: dashboard-metrics-scraper
apiVersion: apps/v1
metadata:
labels:
k8s-app: dashboard-metrics-scraper
name: dashboard-metrics-scraper
namespace: kube-system
spec:
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
k8s-app: dashboard-metrics-scraper
template:
metadata:
labels:
k8s-app: dashboard-metrics-scraper
annotations:
seccomp.security.alpha.kubernetes.io/pod: ‘runtime/default‘
spec:
containers:
image: kubernetesui/metrics-scraper:v1.0.3
ports:
protocol: TCP
livenessProbe:
httpGet:
scheme: HTTP
path: /
port: 8000
initialDelaySeconds: 30
timeoutSeconds: 30
volumeMounts:
name: tmp-volume
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsUser: 1001
runAsGroup: 2001
serviceAccountName: kubernetes-dashboard
nodeSelector:
"beta.kubernetes.io/os": linux
tolerations:
effect: NoSchedule
volumes:
emptyDir: {}
部署 Dashboard Metrics
kubectl apply -f k8s-dashboard-metrics.yaml
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: admin
annotations:
rbac.authorization.kubernetes.io/autoupdate: "true"
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
subjects:
kind: ServiceAccount
name: admin
namespace: kube-system
kind: ServiceAccount
metadata:
name: admin
namespace: kube-system
labels:
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
EOF
获取 Token
kubectl describe secret/$(kubectl get secret -n kube-system |grep admin|awk ‘{print $1}‘) -n kube-system
有什么问题可以私信我哈
文章标题:kubernetes部署2.0版本UI页面,以及容器资源使用监控(2)
文章链接:http://soscw.com/index.php/essay/71936.html