# Kubernetes resources for IoT
###### tags: `IoT over Kubernetes`
source: [1 here](ubuntu.com/blog/five-key-kubernetes-resources-for-iot),
[TOC]
## replicaSets
replica set is a resource that ensures pods are always kept running. if a pod disappear for any reason, the repicaSet notices the missing pod and creates a replacement automatically.
### Implementation
replicaset may be used for backing up missin-critical workload would be backed up with an additional ine running in idle.
### Use case
- Smartcity: this approach can increase the availability of security or surveillance applications. A replicaset would for instance reschedule a camera application on a backup camera node in the event of a failure.
- Energy Management: for battery-powered devices, this approach could double the time between failures.
## daemonSets
daemonSets are used to run a pod on all cluster nodes. This is a contrast to replicaSets that are used for deploying a st number of pods anywhere in a cluster.
Pods run with DaemonSets could contain infrastrycture related workloads that perform system-level operations, such as logging or monitoring. Alternatively, daemonSets can run a pod on a target node in the cluster.
### Implementation of daemonSets
DaemonSets can manage workloads a cluster made of various groups of IoT devices. if a label is attached to each group, daemonSets will run group-specific workloads.
### Possible use cases
- Manufactring on large-scale is possible, such as manufacturing execution systems with kubernetes is quite good idea
- Security workloads need to be executed in a reliable manner on every node. DaemonSets would be the right resource for such cases.
## Jobs
Job is a resouce wich intended for running tasks that terminate after execution. Associated containers won't be restarted when processes within finish successfully.
Job resources run pods immediately after creation. Jobs need to run at a specific time in the future, or repeatedly in a fixed time interval, for instance CronJobs in Linux based operating systems. Kubernetes support CronJobs too.
### Implementation
A job must be created on the master node, to schedule a workload on workers. For single completable tasks, the sequence of execution of workloads can be specified, cronjobs also using specific periodaicity schedule.
### Use cases
- Jobs could be implemented to periodically upload collcted data from edge gateways to a central data center for automotive, especially for deep learning applications for autonomous cars. Data centralisation eases model refinement and transfer learning.
## Deployments
The deplyment resource provides a mechanism to update applications. Deployments can perform rolling updates on pods in a single command. The deployment can delete pods with the old applications, and replicaSets will subsequenly laaunch a pod running the updated application. And the old pods will change into the new pods that had created by replicaSets before.
Availability during updates is especially important in mission-criticl IoT Installations. This is the case because downtime causes lost sales. Deployments enable zero-downtime updates for mission-critical applications.
### Implementation
To implement rolling updates, the label-selector and pod templates will be specified in the manifest. the manifest will contain a field, stating the chosn deployment strategy.
### possible use cases
Maintenance operations can do remotely for each installed IoT devices. Maintenance actions are carried out with simple commands, rathe than manual intervention by physical operators.
## Conclusion #1
The Kubernetes resource can improve availability, reliability, maintainability, and performance of IoT installations. However, advantages obtained with the right software stack chosen. This stack could be upon Ubuntu, CoreOS, micro8s and any other lightweight Kubernetes distribution suitable for IoT.
# Why the IoT needs Kubernetes?
Source: [2 here](https://blog.bosch-si.com/bosch-iot-suite/why-the-iot-needs-kubernetes/)
Kubernetes has become a container orchestration standard for cloud-native deployments microservices.
```flow
st=>start: start
op1=>operation: Many organizations are going
through a digital transformation process.
op2=>operation: Their goal is to chage how
they connect with their customers, suppliers, and partner.
op3=>operation: Using Innovations offered by technologies such as IoT platforms,
Big Data, or machine learning to modernize their enterprise IT and system.
op4=>operation: Complexity of development and deploment of new digital products require new development processes.
They turn to agile development and infrastructure tools such as Kubernetes.
en=>end: end
st->op1->op2->op3->op4->en
```
## Enabling DevOps for IoT
- ability to quickly deploy new features and updates.
- Kubernetes provides a unified deployment model that has capability to automatically test new services.
## Scalability
- able to handle thousands or even millions of device connections,
- able to send huge data in a real-time services
- deployment infrastructure that can scale up and down to meet the demands of an IoT deployment.
- Kubernetes provides scaling on pods across network cluster.
## High availability
- reliable and available at all time operations
- Allow workloads to run independently
- Can be restarted / recreated with no effect to end-users.
## Eficient use of cloud resources
- can handle device connectivity and management, data ingestion, data integraion, a or integration with IT/OT systems
- Run on public cloud providers -> AWS or MS Azure
- Administrator are able to focus on the deployment of the IoT services accross the optimal number of VMs
## Deployment to the IoT edge
- Improve the responsiveness of a predictve maintenance solution: deploy data analytics and machine learning services
- Kubernetes provides a common platform that could be used for deploying IoT services at the edge.