k8s Weave Scope 部署配置

Weave Scope 安装

在 master 上通过以下命令安装Weave Scope:
kubectl apply -f "https://cloud.weave.works/k8s/scope.yaml?k8s-version=$(kubectl version | base64 | tr -d '\n')"
运行后会发现已经起来几个pod:

[root@k8s-master ~]# kubectl apply -f "https://cloud.weave.works/k8s/scope.yaml?k8s-version=$(kubectl version | base64 | tr -d '\n')"
namespace/weave created
serviceaccount/weave-scope created
clusterrole.rbac.authorization.k8s.io/weave-scope created
clusterrolebinding.rbac.authorization.k8s.io/weave-scope created
deployment.apps/weave-scope-app created
service/weave-scope-app created
deployment.apps/weave-scope-cluster-agent created
daemonset.apps/weave-scope-agent created
[root@k8s-master ~]# kubectl get pod -n weave  -o wide
NAME                                        READY   STATUS    RESTARTS   AGE   IP              NODE         NOMINATED NODE   READINESS GATES
weave-scope-agent-8zzq5                     1/1     Running   0          11s   192.168.1.92    k8s-master   <none>           <none>
weave-scope-agent-jhcff                     1/1     Running   0          11s   192.168.1.85    k8s-node1    <none>           <none>
weave-scope-agent-qs45b                     1/1     Running   0          11s   192.168.1.133   k8s-node2    <none>           <none>
weave-scope-app-848cd4d8b5-4rlnd            1/1     Running   0          11s   10.244.1.4      k8s-node1    <none>           <none>
weave-scope-cluster-agent-b4f45797c-7srs9   1/1     Running   0          11s   10.244.2.4      k8s-node2    <none>           <none>
[root@k8s-master ~]# kubectl get service -n weave -o wide
NAME              TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)   AGE   SELECTOR
weave-scope-app   ClusterIP   10.1.31.163   <none>        80/TCP    57s   app=weave-scope,name=weave-scope-app,weave-cloud-component=scope,weave-scope-component=app

访问配置

k8s-service-type-Kubernetes服务类型(用于以独立模式运行Scope),可以是 LoadBalancerNodePort,默认情况下未指定(仅内部访问)
使用kubectl edit 方式修改 nodeport 的端口

## 首先 get svc 查看服务
[root@k8s-master ~]# kubectl get svc --all-namespaces
NAMESPACE     NAME              TYPE        CLUSTER-IP    EXTERNAL-IP   PORT(S)                  AGE
default       kubernetes        ClusterIP   10.1.0.1      <none>        443/TCP                  28h
kube-system   kube-dns          ClusterIP   10.1.0.10     <none>        53/UDP,53/TCP,9153/TCP   28h
weave         weave-scope-app   ClusterIP   10.1.31.163   <none>        80/TCP                   4m4s

## 修改 weave 服务
[root@k8s-master ~]# kubectl edit svc/weave-scope-app -n weave
## 以下修改标记
spec:
 clusterIP: 10.1.31.163
 ports:
 - name: app
   nodePort: 30001		## 新增 映射外网访问端口 30000-327627
   port: 80		## 默认 80 不能修改,修改后无法获取节点信息
   protocol: TCP
   targetPort: 4040
 selector:
   app: weave-scope
   name: weave-scope-app
   weave-cloud-component: scope
   weave-scope-component: app
 sessionAffinity: None
 type: NodePort		## 修改为 NodePort
status:
 loadBalancer: {}

web 浏览

在能访问 master 主机网络的主机上浏览器访问 master ip:nodePort,如:http://192.168.1.86:30001/

上一篇:Prometheus(普罗米修斯)用户档案:动态化特性加速weaveworks云原生程序的发展


下一篇:Docker网络之Weave