# kubectl get crds NAME CREATED AT clusterobjectsyncs.reliablesyncs.kubeedge.io 2020-03-17T06:45:08Z devicemodels.devices.kubeedge.io 2020-03-17T06:44:50Z devices.devices.kubeedge.io 2020-03-17T06:44:55Z objectsyncs.reliablesyncs.kubeedge.io 2020-03-17T06:45:08Z
释义:deployment + service 组合,副本数为3(因为有3台节点机器),hostNetwork 模式,挂载日期文件是为了输出真实时间。
在主节点创建 deployment:
1
kubectl apply -f webgin-service.yaml
查看 pod:
1 2 3 4 5 6
# kubectl get pod -owide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES webgin-deployment-57cbd68f7f-f8hq4 1/1 Running 0 5m2s 192.168.0.153 edge-node2 <none> <none> webgin-deployment-57cbd68f7f-ktmfq 1/1 Running 0 5m2s 192.168.0.220 latelee.org.ttucon-2142ec <none> <none> webgin-deployment-57cbd68f7f-xt7hf 1/1 Running 0 5m2s <none> edge-node <none> <none>
三个节点均已正常运行。但是最后一台的IP没有看到,下面测试获取信息时,没有看到该节点。
查看服务:
1 2 3 4
# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 9d webgin LoadBalancer 10.97.98.218 <pending> 88:31059/TCP 12m
访问web服务:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
root@ubuntu:mytest# curl 10.97.98.218:88 Hello World v1.1 arch: arm os: linux hostname: latelee.org.ttucon-2142ec uname: Linux latelee.org.ttucon-2142ec 4.14.67 #7 SMP PREEMPT Fri Feb 28 11:35:26 CST 2020 armv7l Now: 2020-03-27 13:13:10
root@ubuntu:mytest# root@ubuntu:mytest# curl 10.97.98.218:88 Hello World v1.1 arch: amd64 os: linux hostname: edge-node2 uname: Linux edge-node2 4.4.0-174-generic #204-Ubuntu SMP Wed Jan 29 06:41:01 UTC 2020 x86_64 Now: 2020-03-27 13:13:21
root@ubuntu:mytest# root@ubuntu:mytest# curl 10.97.98.218:88 Hello World v1.1 arch: arm os: linux hostname: latelee.org.ttucon-2142ec uname: Linux latelee.org.ttucon-2142ec 4.14.67 #7 SMP PREEMPT Fri Feb 28 11:35:26 CST 2020 armv7l Now: 2020-03-27 13:13:29
结果:三台节点,在查看时,可以看到其中2台(平台不同),不同时候访问,其结果不同,理论上三台。
其它测试
对比kubectl describe命令。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
k8s: # kubectl describe pod webgin-deployment-57cbd68f7f-f8hq4 Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 9m3s default-scheduler Successfully assigned default/webgin-deployment-57cbd68f7f-f8hq4 to edge-node2 Normal Pulling 9m3s kubelet, edge-node2 Pulling image "registry.cn-hangzhou.aliyuncs.com/latelee/webgin:v1.1" Normal Pulled 8m57s kubelet, edge-node2 Successfully pulled image "registry.cn-hangzhou.aliyuncs.com/latelee/webgin:v1.1" Normal Created 8m57s kubelet, edge-node2 Created container webgin Normal Started 8m57s kubelet, edge-node2 Started container webgin
KubeEdge: # kubectl describe pod webgin-deployment-57cbd68f7f-ktmfq
Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 9m25s default-scheduler Successfully assigned default/webgin-deployment-57cbd68f7f-ktmfq to latelee.org.ttucon-2142ec
k8s: # kubectl logs webgin-deployment-57cbd68f7f-f8hq4 Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 9m25s default-scheduler Successfully assigned default/webgin-deployment-57cbd68f7f-ktmfq to latelee.org.ttucon-2142ec root@ubuntu:mytest# kubectl describe pod webgin-deployment-57cbd68f7f-ktmfqkubectl logs webgin-deployment-57cbd68f7f-f8hq4^C root@ubuntu:mytest# kubectl logs webgin-deployment-57cbd68f7f-f8hq4 [GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env: export GIN_MODE=release - using code: gin.SetMode(gin.ReleaseMode)
[GIN-debug] GET / --> main.myIndex (3 handlers) gin server start... [GIN-debug] Listening and serving HTTP on :80 [GIN] 2020/03/27 - 13:13:21 | 200 | 171.926µs | 192.168.0.102 | GET "/"
KubeEdge: # kubectl logs webgin-deployment-57cbd68f7f-ktmfq Error from server: Get https://192.168.0.220:10250/containerLogs/default/webgin-deployment-57cbd68f7f-ktmfq/webgin: dial tcp 192.168.0.220:10250: connect: connection refuse
结果:KubeEdge 不支持该命令。
对比kubectl exec命令。
1 2 3 4 5 6 7
k8s: # kubectl exec -it webgin-deployment-57cbd68f7f-f8hq4 -- uname -a Linux edge-node2 4.4.0-174-generic #204-Ubuntu SMP Wed Jan 29 06:41:01 UTC 2020 x86_64 GNU/Linux