如何看使用指南
[root@master ~]# cat >> /etc/hosts <<EOF
EOF
172.128.11.159 master
172.128.11.202 kubeedge-node
[root@master ~]# curl -O http://mirrors.douxuedu.com/KubeEdge/kubernetes_kubeedge_allinone.tar.gz
[root@master ~]# tar -zxvf kubernetes_kubeedge_allinone.tar.gz -C /opt/
[root@master ~]# mv /etc/yum.repos.d/* /media/
[root@master ~]# cat > /etc/yum.repos.d/local.repo <<EOF
[docker]
name=docker
baseurl=file:///opt/yum
gpgcheck=0
enabled=1
EOF
[root@master k8simage]# cd /opt/kubeedge/
[root@master kubeedge]# mv keadm /usr/bin/
[root@master kubeedge]# mkdir /etc/kubeedge
[root@master kubeedge]# tar -zxf kubeedge-1.11.1.tar.gz
[root@master kubeedge]# cp -rf kubeedge-1.11.1/build/tools/* /etc/kubeedge/
[root@master kubeedge]# cp -rf kubeedge-1.11.1/build/crds/ /etc/kubeedge/
[root@master kubeedge]# tar -zxf kubeedge-v1.11.1-linux-amd64.tar.gz
[root@master kubeedge]# cp -rf * /etc/kubeedge/
[root@master kubeedge]# cd /etc/kubeedge/
[root@master kubeedge]# keadm deprecated init --kubeedge-version=1.11.1 --advertise-address=172.128.11.159
[root@kubeedge-node ~]# scp root@master:/usr/bin/keadm /usr/local/bin/
[root@kubeedge-node ~]# mkdir /etc/kubeedge
[root@kubeedge-node ~]# cd /etc/kubeedge/
[root@kubeedge-node kubeedge]# scp -r root@master:/etc/kubeedge/* /etc/kubeedge/
[root@master kubeedge]# keadm gettoken
1f0f213568007af1011199f65ca6405811573e44061c903d0f24c7c0379a5f65.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTEwNTc2ODN9.48eiBKuwwL8bFyQcfYyicnFSogra0Eh0IpyaRMg5NvY
[root@kubeedge-node ~]# keadm deprecated join --cloudcore-ipport=172.128.11.159:10000 --kubeedge-version=1.11.1 --token=1f0f213568007af1011199f65ca6405811573e44061c903d0f24c7c0379a5f65.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2OTEwNTc2ODN9.48eiBKuwwL8bFyQcfYyicnFSogra0Eh0IpyaRMg5NvY
[root@kubeedge-node kubeedge]# systemctl status edgecore
[root@master ~]# vi /etc/docker/daemon.json
{
"log-driver": "json-file",
"log-opts": {
"max-size": "200m",
"max-file": "5"
},
"default-ulimits": {
"nofile": {
"Name": "nofile",
"Hard": 655360,
"Soft": 655360
},
"nproc": {
"Name": "nproc",
"Hard": 655360,
"Soft": 655360
}
},
"live-restore": true,
"oom-score-adjust": -1000,
"max-concurrent-downloads": 10,
"max-concurrent-uploads": 10,
"insecure-registries": ["0.0.0.0/0"]
}
[root@master ~]# systemctl daemon-reload
[root@master ~]# systemctl restart docker
[root@kubeedge-node ~]# yum -y install docker-ce
[root@kubeedge-node ~]# vi /etc/docker/daemon.json
{
"log-driver": "json-file",
"log-opts": {
"max-size": "200m",
"max-file": "5"
},
"default-ulimits": {
"nofile": {
"Name": "nofile",
"Hard": 655360,
"Soft": 655360
},
"nproc": {
"Name": "nproc",
"Hard": 655360,
"Soft": 655360
}
},
"live-restore": true,
"oom-score-adjust": -1000,
"max-concurrent-downloads": 10,
"max-concurrent-uploads": 10,
"insecure-registries": ["0.0.0.0/0"]
}
[root@kubeedge-node ~]# systemctl daemon-reload
[root@kubeedge-node ~]# systemctl restart docker
[root@master kubeedge]# export CLOUDCOREIPS="172.128.11.159"
[root@master kubeedge]# cd /etc/kubeedge/
[root@master kubeedge]# ./certgen.sh stream
[root@master kubeedge]# vi /etc/kubeedge/config/cloudcore.yaml
cloudStream:
enable: true #修改为true
streamPort: 10003
router:
address: 0.0.0.0
enable: true #修改为true
port: 9443
restTimeout: 60
[root@kubeedge-node kubeedge]# vi /etc/kubeedge/config/edgecore.yaml
edgeStream:
enable: true #修改为true
handshakeTimeout: 30
serviceBus:
enable: true #修改为true
[root@master kubeedge]# kill -9 $(netstat -lntup |grep cloudcore |awk 'NR==1 {print $7}' |cut -d '/' -f 1)
[root@master kubeedge]# cp -rfv cloudcore.service /usr/lib/systemd/system/
[root@master kubeedge]# systemctl start cloudcore.service
[root@master kubeedge]# netstat -lntup |grep 10003
tcp6 0 0 :::10003 :::* LISTEN 15089/cloudcore
[root@kubeedge-node kubeedge]# systemctl restart edgecore.service
[root@master kubeedge]# kubectl top nodes
[root@master ~]# cd /opt/
[root@master opt]# mv docker-compose-Linux-x86_64 /usr/bin/docker-compose
[root@master opt]# tar -zxvf harbor-offline-installer-v2.5.0.tgz
[root@master opt]# cd harbor && cp harbor.yml.tmpl harbor.yml
[root@master harbor]# vi harbor.yml
hostname: 172.128.11.159 #将hostname修改为云端节点IP
[root@master harbor]# ./install.sh
[root@master harbor]# docker login -u admin -p Harbor12345 master
打开浏览器使用云端master节点IP
curl -k -u "admin:Harbor12345" -X POST -H "content-type:application/json" -d '{"project_name":"k8s","public":true}' http://10.26.17.213/api/v2.0/projects
(命令行方式创建项目)
[root@master harbor]# cd /opt/k8simage/ && sh load.sh
[root@master k8simage]# sh push.sh
[root@master k8simage]# kubectl edit daemonset -n kube-system kube-flannel-ds
- linux
- key: node-role.kubernetes.io/edge #在containers标签前面增加配置
operator: DoesNotExist
[root@master k8simage]# kubectl edit daemonset -n kube-system kube-proxy
spec:
affinity: #在containers标签前面增加配置
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/edge
operator: DoesNotExist
[root@master k8simage]# kubectl get pod -n kube-system
[root@master kubeedge]# cd /opt/kubeedge-counter-demo/crds/
[root@master crds]# vi kubeedge-counter-model.yaml
apiVersion: devices.kubeedge.io/v1alpha2
kind: DeviceModel
metadata:
name: counter-model
namespace: default
spec:
properties:
- name: status
description: counter status
type:
string:
accessMode: ReadWrite
defaultValue: ''
[root@master crds]# kubectl apply -f kubeedge-counter-model.yaml
devicemodel.devices.kubeedge.io/counter-model created
[root@master crds]# kubectl get devicemodel -A
[root@master crds]# vi kubeedge-counter-instance.yaml
apiVersion: devices.kubeedge.io/v1alpha2
kind: Device
metadata:
name: counter
labels:
description: 'counter'
spec:
deviceModelRef:
name: counter-model
nodeSelector:
nodeSelectorTerms:
- matchExpressions:
- key: ' kubernetes.io/hostname '
operator: In
values:
- kubeedge-node
status:
twins:
- propertyName: status
desired:
metadata:
type: string
value: 'OFF'
reported:
metadata:
type: string
value: '0'
[root@master crds]# kubectl apply -f kubeedge-counter-instance.yaml
device.devices.kubeedge.io/counter created
[root@master crds]# kubectl get device -A
[root@master crds]# vi kubeedge-web-controller-app.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
k8s-app: kubeedge-counter-app
name: kubeedge-counter-app
namespace: default
spec:
selector:
matchLabels:
k8s-app: kubeedge-counter-app
template:
metadata:
labels:
k8s-app: kubeedge-counter-app
spec:
hostNetwork: true
nodeSelector:
node-role.kubernetes.io/master: ""
containers:
- name: kubeedge-counter-app
image: 172.128.11.159/k8s/kubeedge-counter-app:v1.0.0
imagePullPolicy: IfNotPresent
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
restartPolicy: Always
┄ #三短横请手打
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: kubeedge-counter
namespace: default
rules:
- apiGroups: ["devices.kubeedge.io"]
resources: ["devices"]
verbs: ["get", "patch"]
┄ #三短横请手打
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: kubeedge-counter-rbac
namespace: default
subjects:
- kind: ServiceAccount
name: default
roleRef:
kind: Role
name: kubeedge-counter
apiGroup: rbac.authorization.k8s.io
[root@master crds]# kubectl apply -f kubeedge-web-controller-app.yaml
deployment.apps/kubeedge-counter-app unchanged
role.rbac.authorization.k8s.io/kubeedge-counter unchanged
rolebinding.rbac.authorization.k8s.io/kubeedge-counter-rbac created
[root@master crds]# kubectl get pod -A |grep counter
default kubeedge-counter-app-7f4dc5bfc6-zbkjs 1/1 Running 0 8m52s
[root@master crds]# netstat -ntpl |grep 8089
[root@master crds]# scp /opt/k8simage/edgepause.tar kubeedge-node:/root
[root@kubeedge-node ~]# docker load -i edgepause.tar
[root@kubeedge-node kubeedge]# docker login -u admin -p Harbor12345 master
[root@master crds]# vi kubeedge-pi-counter-app.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
k8s-app: kubeedge-pi-counter
name: kubeedge-pi-counter
namespace: default
spec:
selector:
matchLabels:
k8s-app: kubeedge-pi-counter
template:
metadata:
labels:
k8s-app: kubeedge-pi-counter
spec:
nodeSelector:
node-role.kubernetes.io/master: ""
hostNetwork: true
containers:
- name: kubeedge-pi-counter
image: 172.128.11.159/k8s/kubeedge-pi-counter:v1.0.0
#地址为实际的镜像地址
imagePullPolicy: IfNotPresent
nodeSelector:
node-role.kubernetes.io/edge: ""
restartPolicy: Always
[root@master ~]# systemctl restart cloudcore
[root@kubeedge-node ~]#systemctl restart edgecore.service
[root@master crds]# kubectl apply -f kubeedge-pi-counter-app.yaml
[root@master crds]# kubectl get pod -o wide |grep pi-counter
[root@kubeedge-node ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
820a0e10830e 172.128.11.159/k8s/kubeedge-pi-counter "/pi-counter-app pi-…" 15 minutes ago Up 15 minutes k8s_kubeedge-pi-counter_kubeedge-pi-counter-54dc4b94f4-49vdg_default_1540c358-f31b-4fca-8a36-0657d9dda0fb_0
5f26046a2135 kubeedge/pause:3.1 "/pause" 15 minutes ago Up 15 minutes
[root@kubeedge-node ~]# docker logs 820a0e10830e -f
带桌面的主机,添加DNS,右击选择"Open Terminal Here"
vi /etc/resolv.conf
nameserver 114.114.114.114
http://masterIP:8089/ 在Web页面上选择ON,并单击“Execute”按钮
[root@kubeedge-node ~]# docker logs 820a0e10830e -f
turn on counter.
Counter value: 1
Counter value: 2
Counter value: 3
选中“OFF”,可以结束计数。在Web页面上选中“STATUS”,并单击“Execute”按钮,会在Web页面上返回counter当前的status状态
- 点赞
- 收藏
- 关注作者
评论(0)