Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Three Web-UI Interface deployments of K8s Cluster

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Blog outline:

Deploy the Web-UI interface of dashboard

Deploy weave-scope to monitor K8s cluster

III. Deploy Prometheus services

Deploy dashboard's Web-UI interface 1, download the yaml file configuration and execute # download the project on github (github search dashboard to find it) [root@master ~] # wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.0/src/deploy/recommended/kubernetes-dashboard.yaml[root@master ~] # vim kubernetes-dashboard.yaml # jump to line 112 and modify the specified image Modify as follows: image: registry.cn-hangzhou.aliyuncs.com/google_containers/kubernetes-dashboard-amd64:v1.10.0# specifies the image of Google by default, which cannot be downloaded from abroad, so change the # of domestic Aliyun to jump to 150th lines, modify its corresponding service, and configure its type to NodePort. Modify as follows: kind: ServiceapiVersion: v1metadata: labels: k8s-app: kubernetes-dashboard name: kubernetes-dashboard namespace: kube-systemspec: type: NodePort # add type NodePort ports:-port: 443 targetPort: 8443 nodePort: 30230 # after the port mapped to the host is 30230 selector: k8s-app: kubernetes-dashboard# Save and exit [root@master ~] # kubectl apply-f kubernetes-dashboard.yaml # execute the yaml file [root@master ~] # kubectl get pod-n kube-system | grep dashboard # confirm its normal operation kubernetes-dashboard-6cfb7d8f54-l6jgj 1 Running 1 Running 0 88s2, and the client can access it through Firefox.

You must use Firefox. Neither Google nor the default edge can be accessed.

1) visit https://192.168.20.6:30230, (192.168.20.6 is the IP of my master, in fact, you can access any node IP+30230 port in the cluster), and then click as follows:

2) create a user on the terminal and view the login token:

[root@master ~] # kubectl create serviceaccount dashboard-admin- n kube-system # create dashboard administrative user # bind user to the administrator of the cluster [root@master ~] # kubectl create clusterrolebinding dashboard-cluster-admin-- clusterrole=cluster-admin-- serviceaccount=kube-system:dashboard-admin [root@master ~] # kubectl get secrets-n kube-system | grep dashboard-admin # get the tokendashboard-admin-token-97g76 kubernetes of the user you just created. Io/service-account-token 3 15s [root@master ~] # kubectl describe secrets-n kube-system dashboard-admin-token-97g76# Note: the last paragraph above depends on the secrets name of the user seen above. Name: dashboard-admin-token-97g76Namespace: kube-system. # omit part of the content Data====token: # copy the value after the token field

3) paste the token value below:

4) at this point, you can monitor the information of cluster nodes and create resource objects in the web interface (generally, resource objects are not created on this interface):

Deploy weave-scope to monitor K8s cluster

The yaml file for this service is not easy to find on github, so attach the process of finding this link. As follows:

1. Github searches for "scope", and then click as follows:

2. After entering, on the drop-down page, click "kubernetes", as follows:

3. After entering, drop down the page again:

4. Download the obtained link:

[root@master ~] # wget https://cloud.weave.works/k8s/scope.yaml

5. Modify the downloaded yaml file and run:

[root@master ~] # vim scope.yaml # Edit yaml file # jump to line 197 Modify the port type of its service spec: type: NodePort # modify the type to NodePort ports:-name: app port: 80 protocol: TCP targetPort: 4040 nodePort: 30231 # Map to the host port 30231 [root@master ~] # kubectl apply-f scope.yaml # execute yaml file # View the operation of the container Confirm that it is in normal operation [root@master ~] # kubectl get pod-o wide-n weave # defaults to weave namespace NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATESweave-scope-agent-b4dwz 1 to 1 Running 0 73s 192.168.20.8 node02 Weave-scope-agent-lksqh 1/1 Running 0 73s 192.168.20.7 node01 weave-scope-agent-mv6mj 1/1 Running 0 73s 192.168.20.6 master weave-scope-app-78cff98cbc-kxp9v 1/1 Running 0 73s 10.244.2.2 node02 weave-scope-cluster-agent-7cc889fbbf-ngf8j 1 Running 0 73s 10.244.1.3 node01 # DaemonSet Resource object: weave-scope-agent (proxy): responsible for collecting node information # deployment resource object: weave-scope-app (application): get data from agent, display it through web UI and interact with users. Compared with deployment, the characteristic of # DaemonSet resource object is that DaemonSet resource object runs on each node and can only run one pod. # because each node needs to be monitored, a resource object such as DaemonSet is used

6. The browser accesses the mapped port 30231 of the cluster, as follows:

In the web interface of scope, you can view a lot of things, such as pod, node nodes and other details, including opening the terminal of the container, viewing its log information and so on.

III. Deploy Prometheus services

Before you deploy, let's take a look at the role of the various components of Prometheus!

MertricServer: aggregator of K8s cluster resource usage, which collects data for use within K8s cluster, such as: kubectl,hpa,schedulerPrometheusOperator: a system detection and alarm toolkit for storing monitoring data; NodeExporter: key metric status data for each node; kubeStateMetrics: collect resource object data in K8s cluster and specify alarm rules; Prometheus: collect apiserver,scheduler,controller-manager,kubelet component data by pull and transmit it through http protocol Grafana: is a visual data statistics and monitoring platform.

1. Before you start, you need to delete the first two monitoring platforms, or they will consume too much system resources, as follows:

[root@master ~] # kubectl delete-f scope.yaml [root@master ~] # kubectl delete-f kubernetes-dashboard.yaml

2. Download the files required for prometheus:

[root@master ~] # mkdir prometheus [root@master ~] # cd prometheus/ [root@master prometheus] # yum-y install git # install git Command # Clone remote github library [root@master prometheus] # git clone https://github.com/coreos/kube-prometheus.git[root@master prometheus] # cd kube-prometheus/manifests/ # enter the directory under the clone

3. Modify the yaml file of each component service

[root@master manifests] # vim grafana-service.yaml # modify grafana's yaml file apiVersion: v1kind: Servicemetadata: labels: app: grafana name: grafana namespace: monitoringspec: type: NodePort # change NodePort type ports:-name: http port: 3000 targetPort: http nodePort: 30100 # Map to host port 30100 selector: app: grafana [root@master manifests] # vim prometheus-service.yaml # modify prometheus yaml file ApiVersion: v1kind: Servicemetadata: labels: prometheus: K8s name: prometheus-k8s namespace: monitoringspec: type: NodePort # changed to NodePort type ports:-name: web port: 9090 targetPort: web nodePort: 30200 # mapped to host port 30200 selector: app: prometheus prometheus: K8s sessionAffinity: ClientIP [root@master manifests] # vim alertmanager-service.yaml # modify alertmanager's yaml file apiVersion: v1kind: Servicemetadata: labels: alertmanager: main Name: alertmanager-main namespace: monitoringspec: type: NodePort # changed to NodePort type ports:-name: web port: 9093 targetPort: web nodePort: 30300 # mapped to host port 30300 selector: alertmanager: main app: alertmanager sessionAffinity: ClientIP

4. Execute the yaml file

When executing the following yaml file, each node will download many images on the Internet. In order to prevent the image from taking too long to download, you can download the image I provided locally, then import it to each node, and then execute the following yaml file, which will save some time. (if you download the image provided by me, it is recommended to write a script to import the image to avoid manual import and cause errors.)

Examples of scripts are as follows:

[root@master ~] # vim a.sh # script is as follows: #! / bin/bashcd / root/image # the only image stored in this directory is the image for i in `ls / root/image/ `do docker load < ${I} done [root@master ~] # sh a.sh # you must execute all yaml files in the setup directory first As follows: [root@master manifests] # pwd # determine the current path / root/prometheus/kube-prometheus/manifests [root@master manifests] # kubectl apply-f setup/ # execute all yaml files in the setup directory # and then execute the yaml file [root@master manifests] # cd in the manifests directory. # return to the directory above [root@master kube-prometheus] # kubectl apply-f manifests/ # execute the yaml file [root@master kube-prometheus] # kubectl get pod-n monitoring # confirm that all pod are running properly # if you choose to download the image online, it may take about half an hour to run normally.

5. When the client accesses the IP+30100 port of any node in the cluster, you can see the following interface (the default user name and password are admin):

Change the password when prompted:

Add a template:

Click "import" to import the following three templates:

Click below to view the monitoring status within the cluster:

-this is the end of this article. Thank you for reading-

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report