Microservice Registry and Catalog Management
During the Quickstart and the tutorial, we specified images to be used for each microservice, for each type of Agent.
That was nice and easy, but what if we need to deploy the same code on a lot of Agents? We would need to specify the images for each Microservice. Wouldn't it be nice to have a way to specify the images to be used for each type of Agent once and then reuse this configuration? That's where the Controller Microservice catalog comes into play!
Each ioFog Controller comes with a built-in microservice catalog. You can see the list of preconfigured Microservices images using potctl
:
potctl get catalog
NAMESPACE
default
ID NAME DESCRIPTION REGISTRY X86 ARM
1 NATs NATs server microservice for Datasance PoT remote ghcr.io/datasance/nats:latest ghcr.io/datasance/nats:latest
4 EdgeGuard Security and monitoring component for edge devices running ioFog Agents. remote ghcr.io/datasance/edge-guard:latest ghcr.io/datasance/edge-guard:latest
Instead of specifying the images for each Agent type, we can refer to catalog ID in your Microservice specification. We can see that there is a Hello Web Demo
catalog item that is configured with the iofog/hello-web
image for x86 Agents, and iofog/hello-web-arm
for ARM Agents. So, to deploy a Microservice running those images, we can use the following YAML:
echo "---
apiVersion: 'datasance.com/v3'
kind: Application
metadata:
name: edge-guard
spec:
---
apiVersion: 'datasance.com/v3'
kind: Microservice # Or application, as application uses the same spec for its microservices
metadata:
name: edge-guard
spec:
agent:
name: my-agent-name
config: {}
images:
catalogId: 4
container:
env: []
ports: []
rootHostAccess: false
volumes:
- hostDestination: /etc/iofog-agent/local-api
containerDestination: /local-api
accessMode: ro
type: bind
- hostDestination: hw-id
containerDestination: /id
accessMode: rw
type: volume
commands: []
config: {}
application: edge-guard
" > /tmp/edge-guard.yaml
potctl deploy microservice -f /tmp/edge-guard.yaml
Note that this YAML snippet assumes we have a running ECN in the current Namespace with an Agent called my-agent-name
.
We can check that the expected images have been used by describing our Microservice with potctl:
potctl describe microservice edge-guard/edge-guard
Create our own Catalog Items
We can also use potctl to create our own Catalog Items. The YAML spec reference can be found here.
echo "---
apiVersion: 'datasance.com/v3'
kind: CatalogItem
metadata:
name: 'my-multiplatform-microservice'
spec:
description: 'Alpine Linux'
x86: 'amd64/alpine:latest'
arm: 'arm32v6/alpine:latest'
registry: 'remote'
" > /tmp/my-catalog-item.yaml
potctl deploy -f /tmp/my-catalog-item.yaml
We can verify that our new Catalog Item was added to the Catalog:
potctl get catalog | grep my-multiplatform-microservice
17 my-multiplatform-microservice Alpine Linux remote amd64/alpine:latest arm32v6/alpine:latest
We used grep to filter the ouput, but the columns are the same as above. You can now use the spec.images.catalogId
field on Microservice
kind set to 17 in order to deploy you microservice.
Registries
During the tutorial, we saw that the images are being pulled from a repository specified in the YAML. The two values we have used so far are remote
(public docker hub) and local
(image locally present on the Agent). There is a third value available, which is a repository ID
.
NB: remote
and local
are aliases for values 1
and 2
, which are the repository seeded in your Controller database.
We can list our current registries using potctl get registries
ID URL USERNAME PRIVATE SECURE
1 registry.hub.docker.com false true
2 from_cache false true
We can add a new registry using the Registry
deploy kind
echo "---
apiVersion: datasance.com/v3
kind: Registry
spec:
url: registry.hub.docker.com # This will create a registry that can download your private docker hub images
username: john
password: q1u45ic9kst563art
email: user@domain.com
" > /tmp/my-private-registry.yaml
potctl deploy -f /tmp/my-private-registry.yaml
After running this, you should now have 3 registries and you can use the ID
in the microservice images registry field