Skip to content

Manual kubernetes demo

Stefan Schneider edited this page Jun 25, 2019 · 7 revisions

Demo: Manual Kubernetes deployment

k8s_deployment

Starting point

At the start, microk8s and DNS should be running but with nothing inside:

$ microk8s.status
microk8s is running
...

$ kubectl get pods
No resources found.
$ kubectl get services
NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE
kubernetes   ClusterIP   10.152.183.1   <none>        443/TCP   2d23h

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Starting both services

To simplify starting all containers of both network services, we use the Kubernetes descriptors. By applying the apply command to the whole ns1 and ns2 directory, respectively. This will trigger Kubernetes to create the deployments and services described in the .yml files (one per CDU).

# from project root
$ cd k8s
$ kubectl apply -f ns1
service/ns1-cc-service created
deployment.apps/ns1-cc-deployment created
service/ns1-eae-service created
deployment.apps/ns1-eae-deployment created
$ kubectl apply -f ns2
service/ns2-mdc-service created
deployment.apps/ns2-mdc-deployment created

You can check that all pods with the containers inside and all services are started:

$ kubectl get pods
NAME                                  READY   STATUS    RESTARTS   AGE
ns1-cc-deployment-6cc8d5bf5f-6n6q4    4/4     Running   0          13s
ns1-eae-deployment-8564dc4946-kpw67   1/1     Running   0          13s
ns2-mdc-deployment-c4d5db55c-zjgpv    1/1     Running   0          5s

$ kubectl get svc
NAME              TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                         AGE
kubernetes        ClusterIP      10.152.183.1     <none>        443/TCP                         2d23h
ns1-cc-service    LoadBalancer   10.152.183.136   10.1.1.1      1883:30112/TCP,9090:30090/TCP   15m
ns1-eae-service   LoadBalancer   10.152.183.163   10.1.1.2      3000:30000/TCP                  15m
ns2-mdc-service   LoadBalancer   10.152.183.164   10.1.1.3      139:30790/TCP,445:32638/TCP     15m
# external IP of LB services assigned correctly by MetalLB

Access the Prometheus dashboard

Start the digital twin

The digital twin runs, similar to a real manufacturing machine, outside the Kubernetes deployment. Here, it's deployed as an individual Docker container. It connects to the MDC's Samba file share, which is exposed via a LoadBalancer service:

$ kubectl get svc -l cnf=mdc
NAME              TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                       AGE
ns2-mdc-service   LoadBalancer   10.152.183.192   10.1.1.3      139:31334/TCP,445:30372/TCP   18m

Here, the external IP is 10.1.1.3. This has to be passed to the DT via its variable DT_EM63_SHARE_HOST when starting it (in new terminal):

docker run -d --rm --privileged -p 15001:15001 --name vnf-dt -e DT_EM63_SHARE_HOST='10.1.1.3' sonatanfv/vnf-dt:k8s

Check Prometheus dashboard again

  • Select the DT's em63_actsimpara2 metric -> Execute -> Graph -> reduce time granularity

Accessing the EAE

  • Open the browser at http://schneider-dev.cs.upb.de:30000 (mention port = nodePort)
  • Login with admin/tango
  • Update the CC's Prometheus DB as data source:
    • Click Configuration -> Data sources -> cc_database (default)
    • In the settings, set HTTP URL tohttp://ns1-cc-service:9090 (Kubernetes service name of CC!). Otherwise keep the defaults. Save and test.
  • Dashboards -> Manage -> Manufacturing Edge Analytics

Terminate and clean up

# stop the DT (can take a while)
docker stop vnf-dt

# stop NS1 and NS2 inside Kubernetes (also takes a while)
kubectl delete all -l pilot=sm