-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
362 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
## From open source cloud to edge computing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
|
||
- Tăng số sclae của deployment lên là 3 | ||
``` | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: nginx-deployment | ||
labels: | ||
app: nginx | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
nodeName: ingress.novalocal | ||
containers: | ||
- name: nginx | ||
image: nginx | ||
ports: | ||
- containerPort: 80 | ||
hostPort: 80 | ||
``` | ||
|
||
- Apply | ||
``` | ||
kubectl apply -f deployment.yaml | ||
``` | ||
|
||
- Xem trạng thái deployment | ||
``` | ||
kubectl get deployment nginx-deployment | ||
NAME READY UP-TO-DATE AVAILABLE AGE | ||
nginx-deployment 1/3 3 1 3h59m | ||
``` | ||
|
||
- Kiểm tra dưới node Edge | ||
``` | ||
Jul 14 13:54:20 ingress dockerd: time="2020-07-14T13:54:20.710098221+07:00" level=warning msg="Failed to allocate and map port 80-80: Bind for 0.0.0.0:80 failed: port is already allocated" | ||
``` | ||
- Do hiện tại các pod trên Edge node sẽ sử dụng mạng cho container sẽ là Edge Node IP + Port. Cho nên hiện tại container có sẵn đã bind vào Port 80, cho nên việc replicate Pod là không thể. |
3 changes: 3 additions & 0 deletions
3
KubeEdge/[Day 07] KubeEdge subordinate-Rolling Update/RollBack.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
|
||
## Không có gì khác biệt trong quá trình rolling một deployment |
11 changes: 11 additions & 0 deletions
11
KubeEdge/[Day 08] KubeEdge deployment-Pod designated Node delivery.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
|
||
## Set lable cho node | ||
|
||
``` | ||
kubectl label node edge-1 disktype=hdd | ||
``` | ||
|
||
|
||
- Việc node Affinity chỉ cần thêm thêm nodeSelector trong Spec. |
Empty file.
4 changes: 4 additions & 0 deletions
4
KubeEdge/[Day 1]-From-open-source-cloud-to-edge-computing-Foreword.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
- Trong điện toán biên, dữ liệu được xử lý gần nhất với nguồn thu nhập dữ liệu, điều này giúp chúng ta không cần chuyển các dữ liệu về trung tâm chính hoặc cloud để phân tích và xử lý. Phương pháp này sẽ giảm thiểu tối đa workload cho network và máy chủ. Do khả năng phản hồi nhanh, giúp xây dựng thành công các ứng dụng realtime, điều này giúp biện toán biên có giá trị trong IOT. Ngoài ra điện toán biên cũng được xử lý trong cái bài toán liên quan đến trí tuệ nhân tạo và học máy. | ||
- Trước khi biết đến điện toán biên, cần phải hiểu thế nào là điện toán đám mây, hay còn được gọi là cloud computing. Đây là một phương pháp dựa trên khả năng của internet, giúp truy cập mọi lúc, mọi mơi, mọi thiết bị thông minh. Trên phương pháp này, chúng ta có thể chia sẻ các tài nguyên vật lý, điều này được quyết định bởi các nhà cung cấp dịch vụ điện toán | ||
- Edge Cloud được sinh ra để giải quyết dịch chuyển các tác vụ từ các máy chủ trung tâm về các máy chủ bản địa. Điện toán biên chia nhỏ hệ thống thành các mảnh nhỏ. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
[Day 2] Introduction to KubeEdge | ||
|
||
|
||
- KubeEdge là một dự án OpenSource, được sử dụng để mở rộng các ứng dụng được đóng trong container và quản lý các device trên các Edge Host. Dự án được phát triển từ Kubernetes and cung cấp khả năng quản lý network, triển khai ứng dụng, đồng bộ metadata giữa cloud và edge. Nó hỗ trợ MQTT và cho phép nhà phát triển custom các flow, và giao tiếp các tài nguyên device trên các Edge. KubeEdge bao gồm Cloud và Edge | ||
|
||
## 1. Lợi ích | ||
- Edge computing | ||
- By running business logic on Edge, a larger amount of data can be protected and processed where the data is generated. Edge nodes can run autonomously, effectively reducing the network bandwidth requirements and consumption between Edge and Cloud. By processing data through Edge, the response speed is significantly improved, and data privacy is protected. | ||
|
||
- Simplified development | ||
- Developers can write regular http or mqtt-based applications, containerize them, and run them anywhere-whether in Edge or in the cloud-in a more suitable way. | ||
|
||
- Support for native Kubernetes | ||
- using KubeEdge, users can coordinate applications on Edge nodes, manage devices and monitor applications and device status just like in traditional Kubernetes clusters. The location of the edge node is transparent to the customer. | ||
|
||
- Rich applications | ||
- It is easy to deploy existing complex machine learning, image recognition, event processing and other advanced applications to Edge. | ||
|
||
|
||
## 2. Tổng quan kiến trúc | ||
|
||
- KubeEdge bao gồm 2 thành phần: Cloud và Edge | ||
|
||
- Cloud Part | ||
- CloudHub: A WebSocket server, responsible for monitoring the status of the cloud and sending messages to EdgeHub. | ||
- EdgeController: Extended kubernetes controller for managing edge nodes and pod metadata in order to locate data to specific edge nodes. | ||
- Edge Part | ||
- EdgeHub: A WebSocket client responsible for edge computing interaction with Cloud Service (such as Edge Controller in KubeEdge architecture). This includes synchronously updating cloud resources to the edge, and reporting the status of edge hosts and devices to the cloud. | ||
- Edged: An agent that runs on an edge node and manages containerized applications. | ||
- EventBus: The MQTT client interacts with the MQTT server to provide publish and subscribe functions for other components. | ||
- DeviceTwin: Responsible for storing device status and syncing device status to the cloud. It also provides a query interface for applications. | ||
- MetaManager: responsible for the messages between edged and edgehub. Also responsible for storing/retrieving metadata in a lightweight database (SQLite). | ||
|
||
|
||
## 3. Kiến trúc | ||
|
||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
|
||
|
||
## 1. Môi trường | ||
|
||
- Trước khi cài đặt cần có một K8S Cluster đang hoạt động. KubeEdge Cloud sẽ được cài trên các máy chủ K8S API Server | ||
Cloud installation | ||
|-- k8s / kubeadm / kubectl / kubelet | ||
|-- Docker | ||
|-- OpenSSL | ||
|
||
- Đồng thời yêu cầu 1 host ngoài cluster để triển khai làm Edge Host | ||
|
||
- Edge installation | ||
|-- Docker | ||
|-- OpenSSL | ||
|
||
|
||
## 2. Cài đặt trên Kube Cloud | ||
|
||
- Thực hiện copy cấu hình | ||
``` | ||
mkdir -p $HOME/.kube | ||
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | ||
chown $(id -u):$(id -g) $HOME/.kube/config | ||
``` | ||
|
||
- Thực hiện tải về keadm và boostrap KubeEdge CloudCore.advertise-address tương ứng với địa chỉ API cho các Edge Host kết nối đến. | ||
``` | ||
wget https://github.com/kubeedge/kubeedge/releases/download/v1.3.1/keadm-v1.3.1-linux-amd64.tar.gz | ||
cd keadm-v1.3.1-linux-amd64 | ||
cd keadm | ||
./keadm init --advertise-address=10.10.204.58 | ||
``` | ||
|
||
- Sau khi boostrap thành công, Kube Cloud sẽ trả về đoạn mã token để cho các Edge Host join vào | ||
``` | ||
./keadm join --cloudcore-ipport=10.10.204.58:10000 --token=038fe72b0a242f67c8a8ec6cf24844a86844d562bf69434fc62d879b0578240e.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTQ3MjAxOTJ9.AglB36uB2_ItTe-lJjfTenbgAmoYqlerQthvnEdhfTo | ||
``` | ||
|
||
## 3. Cài đặt trên Kube Edge hay Edge Host | ||
|
||
- Cài đặt Docker | ||
``` | ||
# Install Docker CE | ||
## Set up the repository: | ||
### Install packages to allow apt to use a repository over HTTPS | ||
apt-get update && apt-get install apt-transport-https ca-certificates curl software-properties-common | ||
### Add Docker’s official GPG key | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | ||
### Add Docker apt repository. | ||
add-apt-repository \ | ||
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \ | ||
$(lsb_release -cs) \ | ||
stable" | ||
## Install Docker CE. | ||
apt-get update && apt-get install docker-ce=18.06.2~ce~3-0~ubuntu | ||
# Setup daemon. | ||
cat > /etc/docker/daemon.json <<EOF | ||
{ | ||
"exec-opts": ["native.cgroupdriver=systemd"], | ||
"log-driver": "json-file", | ||
"log-opts": { | ||
"max-size": "100m" | ||
}, | ||
"storage-driver": "overlay2" | ||
} | ||
EOF | ||
mkdir -p /etc/systemd/system/docker.service.d | ||
# Restart docker. | ||
systemctl daemon-reload | ||
systemctl restart docker | ||
``` | ||
|
||
|
||
- Thực hiện tải về keadm và boostrap KubeEdge CloudCore.advertise-address tương ứng với địa chỉ API cho các Edge Host kết nối đến. | ||
``` | ||
wget https://github.com/kubeedge/kubeedge/releases/download/v1.3.1/keadm-v1.3.1-linux-amd64.tar.gz | ||
cd keadm-v1.3.1-linux-amd64 | ||
cd keadm | ||
``` | ||
|
||
- Sau khi truy cập thư mục thành công, trên node Edge thực hiện join vào cluster | ||
``` | ||
./keadm join --cloudcore-ipport=10.10.204.58:10000 --token=038fe72b0a242f67c8a8ec6cf24844a86844d562bf69434fc62d879b0578240e.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTQ3MjAxOTJ9.AglB36uB2_ItTe-lJjfTenbgAmoYqlerQthvnEdhfTo | ||
``` | ||
|
||
- Xem danh sách node | ||
``` | ||
kubectl get nodes | ||
NAME STATUS ROLES AGE VERSION | ||
ingress.novalocal Ready agent,edge 17h v1.17.1-kubeedge-v1.3.1 | ||
worker1.novalocal Ready master 13d v1.18.5 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
## Khởi tạo Deployment trong KubeEdge | ||
|
||
- Khởi tọa file deployment. Thực hiện chỉ định node chính là edge host vừa tạo | ||
|
||
``` | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: nginx | ||
labels: | ||
app: nginx | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
nodeName: ingress.novalocal | ||
containers: | ||
- name: nginx | ||
image: nginx:1.7.9 | ||
ports: | ||
- containerPort: 80 | ||
hostPort: 80 | ||
``` | ||
|
||
- Khởi tạo deployment | ||
``` | ||
kubectl create -f deployment.yaml | ||
``` | ||
|
||
- Xem danh sách Pod | ||
``` | ||
kubectl get pod | grep nginx | ||
nginx-deployment-59b7775946-sfz5k 1/1 Running 0 69m | ||
``` | ||
|
||
- Xem describe pod | ||
``` | ||
Name: nginx-deployment-59b7775946-sfz5k | ||
Namespace: default | ||
Priority: 0 | ||
Node: ingress.novalocal/10.10.204.60 | ||
Start Time: Tue, 14 Jul 2020 09:55:02 +0700 | ||
Labels: app=nginx | ||
pod-template-hash=59b7775946 | ||
Annotations: <none> | ||
Status: Running | ||
IP: 172.17.0.4 | ||
IPs: | ||
IP: 172.17.0.4 | ||
Controlled By: ReplicaSet/nginx-deployment-59b7775946 | ||
Containers: | ||
nginx: | ||
Container ID: docker://a8ae6bb075ba566770b171a75fd6a44677e6612975a91fdd5cbb9f1f4fb3e13b | ||
Image: nginx | ||
Image ID: docker-pullable://nginx@sha256:a93c8a0b0974c967aebe868a186e5c205f4d3bcb5423a56559f2f9599074bbcd | ||
Port: 80/TCP | ||
Host Port: 80/TCP | ||
State: Running | ||
Started: Tue, 14 Jul 2020 09:55:20 +0700 | ||
Ready: True | ||
Restart Count: 0 | ||
Environment: <none> | ||
Mounts: | ||
/var/run/secrets/kubernetes.io/serviceaccount from default-token-sph8h (ro) | ||
Conditions: | ||
Type Status | ||
Initialized True | ||
Ready True | ||
PodScheduled True | ||
Volumes: | ||
default-token-sph8h: | ||
Type: Secret (a volume populated by a Secret) | ||
SecretName: default-token-sph8h | ||
Optional: false | ||
QoS Class: BestEffort | ||
Node-Selectors: <none> | ||
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s | ||
node.kubernetes.io/unreachable:NoExecute for 300s | ||
Events: <none> | ||
``` | ||
|
||
- Truy cập vào địa chỉ của Edge Host, nếu trả về default của Nginx có nghĩa quá trình setup thành công | ||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
|
||
- Bình thường trong K8S, các Pod không được public trực tiếp mà phải giao tiếp với nhau qua Service. Tuy nhiên network trong KubeEdge sẽ khác | ||
|
||
|
||
- Một service thường có 2 type sau đây | ||
|
||
1. Cluster IP | ||
- Virtual IP cho phép các Pod truy cập | ||
- Địa chỉ intranet trong cụm, ngoài cụm không thể truy cập | ||
|
||
2. NodePort | ||
- Sử dụng port để forword request sang service | ||
- Mở cổng cho phép truy cập vào Service trên tất cả các Node. | ||
- Từ ngoài có thể truy cập ngoài vào bằng Node IP + Port | ||
|
||
|
||
- Thử khởi tạo Service trên Cluster | ||
``` | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: mysvc | ||
spec: | ||
selector: | ||
app: nginx | ||
ports: | ||
- port: 80 | ||
targetPort: 80 | ||
``` | ||
|
||
- Xem sanh sách svc | ||
``` | ||
kubectl get svc | grep mysvc | ||
mysvc ClusterIP 10.103.6.221 <none> 80/TCP 32s | ||
``` | ||
- Xem endpoint của svc đang trỏ về pod trong deployment đã tạo ở day 4 | ||
``` | ||
kubectl describe svc mysvc | ||
``` | ||
|
||
- Từ trong pod đã được tạo từ deployment đang ở trên Edge host, thực hiện curl vào địa chỉ ClusterIP | ||
``` | ||
apt-get update && apt-get install curl -y | ||
curl 10.103.6.221 | ||
``` | ||
- Hoàn toàn không thể ping được vào cluster IP do Pod trên Edge Host sử dụng, do IP và cổng trên Pod đã sử dụng bridge trực tiếp trên host. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: mysvc | ||
spec: | ||
selector: | ||
app: nginx | ||
ports: | ||
- port: 80 | ||
targetPort: 80 |
Empty file.