TKE Edge provides the ServiceGroup feature, which only needs two YAML files to implement service deployment in hundreds of regions, without application adaptation or transformation. This document describes how to deploy Nginx services separately within multiple node groups.
This step performs logic planning without involving any actual operations. TKE Edge sets the
UniqKey used as the logical flag of the ServiceGroup to be created to
Label the edge nodes in the TKE Edge console or by using kubectl in the TKE Edge console as instructed below:
zone=nodeunit1for nodes 12 and 14 and
zone=nodeunit2for nodes 21 and 23.
keyneeds to be the same as the
UniqKeyof the ServiceGroup. The
valueis a unique key of the NodeUnit. Nodes with the same
valuebelong to the same NodeUnit.
apiVersion: superedge.io/v1 kind: DeploymentGrid metadata: name: deploymentgrid-demo namespace: default spec: gridUniqKey: zone template: selector: matchLabels: appGrid: nginx replicas: 2 template: metadata: labels: appGrid: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80 protocol: TCP
apiVersion: superedge.io/v1 kind: ServiceGrid metadata: name: servicegrid-demo namespace: default spec: gridUniqKey: zone template: selector: appGrid: nginx ports: - protocol: TCP port: 80 targetPort: 80
As shown above, the
gridUniqKeyfield is set to
zone. Therefore, you should also set the label
zonewhen grouping edge nodes by label. If there are three node groups, add three labels respectively:
zone: zone-1, and
At this point, each node group contains the Deployment and corresponding Pod of Nginx. For access to the same
service-name on a node, the requests will be sent to the node in the target group. The verification method is as follows:
[root@VM_1_34_centos ~]# kubectl get deploy NAME READY UP-TO-DATE AVAILABLE AGE deploymentgrid-demo-zone-0 2/2 2 2 85s deploymentgrid-demo-zone-1 2/2 2 2 85s deploymentgrid-demo-zone-2 2/2 2 2 85s [root@VM_1_34_centos ~]# kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 172.19.0.1 <none> 443/TCP 87m servicegrid-demo-svc ClusterIP 172.19.0.177 <none> 80/TCP 80s
For node groups added to a cluster after the deployment of DeploymentGrid and ServiceGrid, this feature will automatically create the specified Deployment and Service in the new node groups.