View the instructions to install the Smart Village Operator on OpenShift Local here.
Create a directory for the Smart Village Operator source code:
mkdir ~/.local/src
Clone the Smart Village Operator source code:
git clone git@github.com:computate-org/smartvillage-operator.git ~/.local/src/smartvillage-operator
pkcon install -y git
pkcon install -y python3
pkcon install -y python3-pip
pip install virtualenv openshift jmespath
This step might be virtualenv-3 for you.
virtualenv ~/python
source ~/python/bin/activate
echo "source ~/python/bin/activate" | tee -a ~/.bashrc
source ~/.bashrc
pip install setuptools_rust wheel
pip install --upgrade pip
pip install ansible
See the documentation here.
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.18.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/bin/kind
Create a cluster with ingress available on port 8080 and 8043
echo '
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 8080
protocol: TCP
- containerPort: 443
hostPort: 8043
protocol: TCP
' > /tmp/kind-cluster.yaml
Create the cluster on Red Hat Enterprise Linux:
systemd-run --user --scope --property=Delegate=yes kind create cluster --config=/tmp/kind-cluster.yaml
Create the cluster on Microsoft Windows:
kind create cluster --config=/tmp/kind-cluster.yaml
Apply Contour components for Ingress
kubectl apply -f https://projectcontour.io/quickstart/contour.yaml
kubectl patch daemonsets -n projectcontour envoy -p '{"spec":{"template":{"spec":{"nodeSelector":{"ingress-ready":"true"},"tolerations":[{"key":"node-role.kubernetes.io/control-plane","operator":"Equal","effect":"NoSchedule"},{"key":"node-role.kubernetes.io/master","operator":"Equal","effect":"NoSchedule"}]}}}}'
ERROR: failed to create cluster: running kind with rootless provider requires setting systemd property "Delegate=yes"
If you get the error above, follow the instructions here.
You may not need to modify /etc/default/grub
.
After following these instructions, reboot your computer.
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/bin/
Test that you can connect to your kubernetes cluster
kubectl get pod -A
export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)
export OS=$(uname | awk '{print tolower($0)}')
export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.28.1
curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}
gpg --keyserver keyserver.ubuntu.com --recv-keys 052996E2A20B5C7E
curl -LO ${OPERATOR_SDK_DL_URL}/checksums.txt
curl -LO ${OPERATOR_SDK_DL_URL}/checksums.txt.asc
gpg -u "Operator SDK (release) <cncf-operator-sdk@cncf.io>" --verify checksums.txt.asc
grep operator-sdk_${OS}_${ARCH} checksums.txt | sha256sum -c -
sudo chmod +x operator-sdk_${OS}_${ARCH} && sudo mv operator-sdk_${OS}_${ARCH} /usr/bin/operator-sdk
Install operators to cluster
operator-sdk olm install
kubectl create namespace smartvillage
kubectl config set-context --current --namespace=smartvillage
Create a free Red Hat Developer account, and download your Red Hat OpenShift pull secret https://console.redhat.com/openshift/create/local.
kubectl create secret generic redhat-reg --from-file=.dockerconfigjson="$HOME/Downloads/pull-secret" --type=kubernetes.io/dockerconfigjson
cd ~/.local/src/smartvillage-operator
kubectl apply -k kustomize/operators/amq-broker-in-namespace/
kubectl patch serviceaccount amq-broker-controller-manager -p '{"imagePullSecrets": [{"name": "redhat-reg"}]}'
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "redhat-reg"}]}'
cd ~/.local/src/smartvillage-operator
make deploy
This will install the following applications:
- An Edge version of the Red Hat AMQ Broker for AMQP and MQTT protocols
- A FIWARE NGSI-LD Context Broker for smart device entity data
- An IoT Agent JSON for receiving AMQP and MQTT messages and updating the Context Broker
- The Smarta Byar Smart Village Sync microservice, for sending context broker subscription data to the Smart Village application.
cd ~/.local/src/smartvillage-operator
kubectl apply -k kustomize/overlays/kubernetes/
kubectl get events -w
kubectl get pod
kubectl logs -n smartvillage-operator-system deployment/smartvillage-operator-controller-manager -f
oc debug -n smartvillage-operator-system --image quay.io/computateorg/smartvillage-operator
Create an HTTP Proxy with CORS for orion-ld at localhost
echo '
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
name: orion-ld
spec:
virtualhost:
fqdn: localhost
corsPolicy:
allowCredentials: true
allowOrigin:
- "*" # allows any origin
allowMethods:
- GET
- POST
- OPTIONS
allowHeaders:
- authorization
- cache-control
- fiware-service
- fiware-servicepath
exposeHeaders:
- Content-Length
- Content-Range
maxAge: "10m" # preflight requests can be cached for 10 minutes.
routes:
- conditions:
- prefix: /
services:
- name: orion-ld
port: 1026
' > /tmp/contour-cors.yaml
kubectl apply -f /tmp/contour-cors.yaml
Expose an Ingress for orion-ld
echo '
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: orion-ld
spec:
rules:
- host: localhost
http:
paths:
- backend:
service:
name: orion-ld
port:
number: 1026
path: /orion-ld
pathType: Prefix
' > /tmp/ingress.yaml
oc apply -f /tmp/ingress.yaml
Some sample TrafficFlowObserved Smart Data Models are provided, as well as an Orion-LD Smart Village Sync microservice. These will automatically be sent by MQTT to the IoT Agent JSON, and into the Orion-LD Context broker. A subscription is set up that will publish to the Orion-LD Smart Village Sync service. The Orion-LD Smart Village Sync is for publishing securely device entity data to the Smart Village platform in the cloud.
cd ~/.local/src/smartvillage-operator
kubectl apply -k kustomize/samples/kubernetes/
Test the orion-ld entity API to see the smart data models in the Context Broker:
kubectl run --image=registry.access.redhat.com/ubi8/ubi --rm -it -- bash
yum install -y jq
curl http://orion-ld:1026/v2/entities -H "Fiware-Service: smarttrafficlights" -H "Fiware-ServicePath: /Sweden/Veberod/CityCenter" | jq
- Install Red Hat MicroShift following the official documentation here.
- Make sure you have the
oc
command in your terminal after installation of MicroShift. - Make sure microshift is running:
systemctl status microshift
. - Watch the logs for MicroShift if you find any problems:
journalctl -fu microshift
- Make sure your computer has an actual ethernet connection and not WIFI for MicroShift to work.
oc create namespace smartvillage
oc config set-context --current --namespace=smartvillage
cd ~/.local/src/smartvillage-operator
oc apply -k kustomize/operators/amq-broker-in-namespace/
cd ~/.local/src/smartvillage-operator
make deploy
oc logs -n smartvillage-operator-system deployment/smartvillage-operator-controller-manager -f
This will install the following applications:
- An Edge version of the Red Hat AMQ Broker for AMQP and MQTT protocols
- A FIWARE NGSI-LD Context Broker for smart device entity data
- An IoT Agent JSON for receiving AMQP and MQTT messages and updating the Context Broker
- The Smarta Byar Smart Village Sync microservice, for sending context broker subscription data to the Smart Village application.
cd ~/.local/src/smartvillage-operator
oc apply -k kustomize/overlays/microshift/
Some sample TrafficFlowObserved Smart Data Models are provided, as well as an Orion-LD Smart Village Sync microservice. These will automatically be sent by MQTT to the IoT Agent JSON, and into the Orion-LD Context broker. A subscription is set up that will publish to the Orion-LD Smart Village Sync service. The Orion-LD Smart Village Sync is for publishing securely device entity data to the Smart Village platform in the cloud.
cd ~/.local/src/smartvillage-operator
oc apply -k kustomize/samples/microshift/
To connect successfully to the Smart Village platform, you will need a valid CLIENT_ID and CLIENT_SECRET configured to a Red Hat Single Sign On server, which is provided by the Smart Village app.
Create a keycloak-client-secret-smartvillage secret on MicroShift.
kind: Secret
apiVersion: v1
metadata:
name: keycloak-client-secret-smartvillage
stringData:
CLIENT_ID: smartvillage
CLIENT_SECRET: ...
type: Opaque
You can run the same ansible roles that the operator uses without deploying the operator. You will need to set the following ansible variables:
-e crd_path=~/.local/src/smartabyar-smartvillage/openshift/kustomize/overlays/nerc-ocp-prod/smartabyarsmartvillages/smartvillage/smartabyarsmartvillage.yaml
to point to theSmartaByarSmartVillage
instance you wish to deploy.
For example:
ansible-playbook apply-smartabyarsmartvillage.yaml -e crd_path=~/.local/src/smartabyar-smartvillage/openshift/kustomize/overlays/nerc-ocp-prod/smartabyarsmartvillages/smartvillage/smartabyarsmartvillage.yaml -e ansible_operator_meta_namespace=smart-village-faeeb6c
operator-sdk init --plugins=ansible --domain computate.org
oc login ...
make docker-build docker-push deploy && oc -n smartvillage-operator-system delete pod -l 'control-plane=controller-manager'
podman run --rm -it --entrypoint /bin/bash quay.io/computateorg/smartvillage-operator:latest
operator-sdk create api --group smartvillage --version v1 --kind OrionLDContextBroker --generate-role
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=OrionLDContextBroker
operator-sdk create api --group smartvillage --version v1 --kind ScorpioBroker --generate-role
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=ScorpioBroker
operator-sdk create api --group smartvillage --version v1 --kind IoTAgentJson --generate-role
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=IoTAgentJson
operator-sdk create api --group smartvillage --version v1 --kind EdgeAmqBroker --generate-role
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=EdgeAmqBroker
operator-sdk create api --group smartvillage --version v1 --kind SmartaByarSmartVillage --generate-role
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=SmartaByarSmartVillage
operator-sdk create api --group smartvillage --version v1 --kind TrafficSimulation --generate-role
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=TrafficSimulation
operator-sdk create api --group smartvillage --version v1 --kind TrafficFlowObserved --generate-role
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=TrafficFlowObserved
operator-sdk create api --group smartvillage --version v1 --kind CrowdFlowObserved --generate-role
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=CrowdFlowObserved
operator-sdk create api --group smartvillage --version v1 --kind SmartTrafficLight --generate-role
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=SmartTrafficLight
- Edit the newly generated vars values file:
smartvillage-operator/roles/smart-data-model-vars/vars/TrafficSimulation.yaml
. - Re-run the playbook to regenerate the latest model.
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=TrafficSimulation
- Increment the VERSION in the smartvillage-operator/Makefile
- Build and deploy the new version of the operator
make docker-build docker-push deploy && oc -n smartvillage-operator-system delete pod -l 'control-plane=controller-manager'
operator-sdk create api --group smartvillage --version v1 --kind EdgeMongoDB --generate-role
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=EdgeMongoDB
- Edit the newly generated vars values file:
smartvillage-operator/roles/smart-data-model-vars/vars/EdgeMongoDB.yaml
. - Re-run the playbook to regenerate the latest model.
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=EdgeMongoDB
- Increment the VERSION in the smartvillage-operator/Makefile
- Build and deploy the new version of the operator
make docker-build docker-push deploy && oc -n smartvillage-operator-system delete pod -l 'control-plane=controller-manager'
operator-sdk create api --group smartvillage --version v1 --kind EdgePostgres --generate-role
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=EdgePostgres
- Edit the newly generated vars values file:
smartvillage-operator/roles/smart-data-model-vars/vars/EdgePostgres.yaml
. - Re-run the playbook to regenerate the latest model.
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=EdgePostgres
- Increment the VERSION in the smartvillage-operator/Makefile
- Build and deploy the new version of the operator
make docker-build docker-push deploy && oc -n smartvillage-operator-system delete pod -l 'control-plane=controller-manager'
operator-sdk create api --group smartvillage --version v1 --kind EdgeKafka --generate-role
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=EdgeKafka
- Edit the newly generated vars values file:
smartvillage-operator/roles/smart-data-model-vars/vars/EdgeKafka.yaml
. - Re-run the playbook to regenerate the latest model.
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=EdgeKafka
- Increment the VERSION in the smartvillage-operator/Makefile
- Build and deploy the new version of the operator
make docker-build docker-push deploy && oc -n smartvillage-operator-system delete pod -l 'control-plane=controller-manager'
operator-sdk create api --group smartvillage --version v1 --kind EdgeRabbitMQ --generate-role
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=EdgeRabbitMQ
- Edit the newly generated vars values file:
smartvillage-operator/roles/smart-data-model-vars/vars/EdgeRabbitMQ.yaml
. - Re-run the playbook to regenerate the latest model.
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=EdgeRabbitMQ
- Increment the VERSION in the smartvillage-operator/Makefile
- Build and deploy the new version of the operator
make docker-build docker-push deploy && oc -n smartvillage-operator-system delete pod -l 'control-plane=controller-manager'
operator-sdk create api --group smartvillage --version v1 --kind EdgeZookeeper --generate-role
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=EdgeZookeeper
- Edit the newly generated vars values file:
smartvillage-operator/roles/smart-data-model-vars/vars/EdgeZookeeper.yaml
. - Re-run the playbook to regenerate the latest model.
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=EdgeZookeeper
- Increment the VERSION in the smartvillage-operator/Makefile
- Build and deploy the new version of the operator
make docker-build docker-push deploy && oc -n smartvillage-operator-system delete pod -l 'control-plane=controller-manager'
## Initialize EdgeSolr model
```bash
operator-sdk create api --group smartvillage --version v1 --kind EdgeSolr --generate-role
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=EdgeSolr
- Edit the newly generated vars values file:
smartvillage-operator/roles/smart-data-model-vars/vars/EdgeSolr.yaml
. - Re-run the playbook to regenerate the latest model.
ansible-playbook write-smart-data-model-templates.yaml -e ENTITY_TYPE=EdgeSolr
- Increment the VERSION in the smartvillage-operator/Makefile
- Build and deploy the new version of the operator
make docker-build docker-push deploy && oc -n smartvillage-operator-system delete pod -l 'control-plane=controller-manager'
Follow the instructions in the docs Deploying AMQ Broker on OpenShift Container Platform using the AMQ Broker Operator
cd ~/Downloads/amq-broker-operator-7.11.0-ocp-install-examples/deploy/
oc create namespace smartvillage
oc config set-context --current --namespace=smartvillage
oc apply -f service_account.yaml
oc apply -f role.yaml
oc apply -f role_binding.yaml
oc apply -f election_role.yaml
oc apply -f election_role_binding.yaml
oc apply -f crds/broker_activemqartemis_crd.yaml
oc apply -f crds/broker_activemqartemisaddress_crd.yaml
oc apply -f crds/broker_activemqartemisscaledown_crd.yaml
oc apply -f crds/broker_activemqartemissecurity_crd.yaml
oc apply -f operator.yaml
https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
- Install the Edge AMQ Broker for MQTT and AMQP messaging.
oc apply -k ~/.local/src/smartabyar-smartvillage/openshift/kustomize/overlays/local/edgeamqbrokers/
# Finishes in about 32 seconds
- Install the NGSI-LD Context Broker and MongoDB, to receive device entity data and activate NGSI-LD APIs.
oc apply -k ~/.local/src/smartabyar-smartvillage/openshift/kustomize/overlays/local/orionldcontextbrokers/
# Finishes in about 51 seconds
- Install the IoT Agent JSON, to receive MQTT or AMQP device data as JSON.
oc apply -k ~/.local/src/smartabyar-smartvillage/openshift/kustomize/overlays/local/iotagentjsons/
# Finishes in about 15 seconds
- Install the Smarta Byar Smart Village platform, to receive context broker subscription data and enable data science APIs.
oc apply -k ~/.local/src/smartabyar-smartvillage/openshift/kustomize/overlays/local/smartabyarsmartvillages/
# Finishes in about 240 seconds
- Install a TrafficFlowObserved Smart Data Model entity, to integrate it with the Iot Agent, Context Broker, and Smart Village application.
oc apply -k ~/.local/src/smartabyar-smartvillage/openshift/kustomize/overlays/local/trafficflowobserveds/
# Finishes in about 15 seconds
pip3 install kubernetes jmespath paho-mqtt
ansible-galaxy collection install kubernetes.core ansible.utils
ansible-galaxy collection install kubernetes.core -U