Skip to content

Commit

Permalink
operator integration-operator (1.0.0)
Browse files Browse the repository at this point in the history
Signed-off-by: Clay Risser <[email protected]>
  • Loading branch information
clayrisser committed Oct 25, 2023
1 parent 09ac1be commit c0552e5
Show file tree
Hide file tree
Showing 5 changed files with 3,844 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
apiVersion: operators.coreos.com/v1alpha1
kind: ClusterServiceVersion
metadata:
name: integration-operator.v1.0.0
namespace: placeholder
annotations:
alm-examples: >-
[{"apiVersion":"integration.rock8s.com/v1beta1","kind":"Plug","metadata":{"name":"postgres","namespace":"app"},"spec":{"socket":{"name":"postgres","namespace":"postgres-namespace"},"config":{"database":"app"}}},{"apiVersion":"integration.rock8s.com/v1beta1","kind":"Socket","metadata":{"name":"postgres","namespace":"postgres-namespace"},"spec":{"interface":{"config":{"socket":{"protocol":{"required":true},"username":{"required":true},"password":{"required":true},"hostname":{"required":true},"port":{"required":true}},"plug":{"database":{"required":true}}}},"config":{"protocol":"psql","username":"postgres","hostname":"postgres-service.postgres-namespace.svc.cluster.local","port":"5432"},"configSecretName":"postgres-secret","resources":[{"when":["coupled","updated"],"do":"recreate","template":{"apiVersion":"batch/v1","kind":"Job","metadata":{"name":"postgres-coupled-or-updated-{% .plug.metadata.namespace %}"},"spec":{"template":{"spec":{"containers":[{"name":"psql","image":"registry.gitlab.com/bitspur/rock8s/images/kube-commands-psql:0.0.1","env":[{"name":"POSTGRES_PROTOCOL","value":"{% .socketConfig.protocol %}"},{"name":"POSTGRES_USERNAME","value":"{% .socketConfig.username %}"},{"name":"POSTGRES_HOSTNAME","value":"{% .socketConfig.hostname %}"},{"name":"POSTGRES_PORT","value":"{% .socketConfig.port %}"},{"name":"POSTGRES_DATABASE","value":"{% .plugConfig.database %}"},{"name":"POSTGRES_PASSWORD","value":"{% .socketConfig.password %}"}],"command":["sh","-c","export PGPASSFILE=\"/tmp/.pgpass\"\nexport STDOUT=\"/tmp/createdb.out\"\necho \"*:*:*:*:$POSTGRES_PASSWORD\" > $PGPASSFILE\nchmod 600 $PGPASSFILE\ncreatedb -h $POSTGRES_HOSTNAME -U $POSTGRES_USERNAME -p $POSTGRES_PORT -w $POSTGRES_DATABASE || true\n"]}]}}}}}]}}]
k8sMinVersion: ""
k8sMaxVersion: ""
categories: Integration & Delivery
certified: "false"
createdAt: ""
description: kubernetes operator to integrate deployments
containerImage: ""
support: ""
capabilities: Full Lifecycle
repository: ""
spec:
displayName: Integration Operator
description: >
This operator takes inspiration from [Juju](https://juju.is) [Charm](https://juju.is/docs/sdk)
[Relations](https://juju.is/docs/sdk/relations) by [Canonical](https://canonical.com).
## Terminology
| Term | Juju Equivalent | Definition |
| --------------- | --------------- | --------------------------------------------------------------------------------------------- |
| Integration | Relation | means to unite and connect applications through mutual communication and shared configuration |
| Plug | Requires | request from an application to integrate with another application |
| Socket | Provides | fulfils requests from applications trying to integrate |
| Interface | Interface | plug and socket schema required to connect |
| Created Event | Created Event | event triggered when plug or socket created |
| Updated Event | Changed Event | event triggered when plug or socket updated |
| Coupled Event | Joined Event | event triggered when applications connected |
| Decoupled Event | Detached Event | event triggered when applications disconnected |
## Architecture
### A simple analogy
The best way to explain the architecture is to think about how plugs and sockets work in the real world.
Let's say I have a laptop purchased in the United States. In order to power my laptop, I need to **integrate** it with the power grid.
Since the laptop was purchased in the United States, the **interface** of the **plug** is Type A as illustrated below.
![Type A](https://gitlab.com/bitspur/rock8s/integration-operator/-/raw/main/images/typea.png)
This means the **socket** I connect to must be also be Type A.
Now, let's say I travel to India and the only **socket** available to me is Type D as illustrated below.
![Type D](https://gitlab.com/bitspur/rock8s/integration-operator/-/raw/main/images/typed.png)
Since the **socket** interface does not match the **plug** interface, I cannot integrate my laptop with the power grid in India. Of course
this can be overcome with converters, but that is beyond the scope of this analogy.
### A real example
Let's say I have an express application that needs to **integrate** with a mongo database. The express deployment will have a **plug** with
a mongo **interface** and the mongo deployment will have a **socket** with a mongo **interface**. If the **interface** of the **socket** is
a postgres **interface** then the integration will fail. In other words, you cannot connect a mongo **plug** to a postgres **socket**. That
would be like trying to plug a US Type A **plug** into an Indian Type D **socket**. You can only connect a mongo **plug** to a mongo **socket**.
maturity: stable
version: 1.0.0
minKubeVersion: 1.26.0
keywords:
- integration
- plug
- socket
maintainers:
- name: Clay Risser
email: [email protected]
provider:
name: BitSpur
labels: {}
selector:
matchLabels: {}
links:
- name: Integration Operator
url: "https://gitlab.com/bitspur/rock8s/integration-operator"
- name: Inspired by Juju Charms
url: "https://juju.is"
icon:
- base64data: >-
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2ZwogICB2ZXJzaW9uPSIxLjEiCiAgIGlkPSJzdmcxIgogICB3aWR0aD0iMTk4LjY0NDgxIgogICBoZWlnaHQ9IjE5OC42NDQ4MiIKICAgdmlld0JveD0iMCAwIDE5OC42NDQ4MSAxOTguNjQ0ODIiCiAgIHNvZGlwb2RpOmRvY25hbWU9ImNsYXlyaXNzZXJfYV9taW5pbWFsaXN0XzItY29sb3JfbG9nb19vZl9hX3BsdWdfYW5kX3NvY2tldF81YmM0MDc3YS1hZDQ5LTRmMjYtOTZjMi1iNDEyOTY5ZTA1OGEuc3ZnIgogICBpbmtzY2FwZTpleHBvcnQtZmlsZW5hbWU9Imljb24uc3ZnIgogICBpbmtzY2FwZTpleHBvcnQteGRwaT0iNzMxLjUxNzciCiAgIGlua3NjYXBlOmV4cG9ydC15ZHBpPSI3MzEuNTE3NyIKICAgaW5rc2NhcGU6dmVyc2lvbj0iMS4zICgwZTE1MGVkLCAyMDIzLTA3LTIxKSIKICAgeG1sbnM6aW5rc2NhcGU9Imh0dHA6Ly93d3cuaW5rc2NhcGUub3JnL25hbWVzcGFjZXMvaW5rc2NhcGUiCiAgIHhtbG5zOnNvZ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W5rc2NhcGU6bGFiZWw9InBhdGgxIiAvPgogIDwvZz4KPC9zdmc+Cg==
mediatype: image/svg+xml
customresourcedefinitions:
owned:
- name: plugs.integration.rock8s.com
displayName: Plug
kind: Plug
version: v1beta1
description: Plug
resources: []
specDescriptors: []
statusDescriptors: []
- name: sockets.integration.rock8s.com
displayName: Socket
kind: Socket
version: v1beta1
description: Socket
resources: []
specDescriptors: []
statusDescriptors: []
required: []
install:
strategy: deployment
spec:
permissions:
- serviceAccountName: integration-operator
rules:
- apiGroups:
- integration.rock8s.com
resources:
- plugs
- sockets
verbs:
- "*"
- apiGroups:
- integration.rock8s.com
resources:
- plugs/status
- sockets/status
verbs:
- get
- update
- patch
- apiGroups:
- integration.rock8s.com
resources:
- plugs/finalizers
- sockets/finalizers
verbs:
- update
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
clusterPermissions: []
deployments:
- name: add-deployment
spec:
replicas: 1
strategy:
type: RollingUpdate
selector:
matchLabels:
app.kubernetes.io/name: integration-operator
template:
metadata:
labels:
app.kubernetes.io/name: integration-operator
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/arch
operator: In
values:
- amd64
serviceAccountName: integration-operator
containers:
- image: registry.gitlab.com/bitspur/rock8s/integration-operator:1.0.0
imagePullPolicy: Always
name: integration-operator
args:
- "--leader-elect"
- "--health-probe-bind-address=:8081"
- "--zap-devel=false"
resources:
limits:
cpu: 200m
memory: 100Mi
requests:
cpu: 100m
memory: 50Mi
env:
- name: WATCH_NAMESPACE
valueFrom:
fieldRef:
fieldPath: "metadata.annotations['olm.targetNamespaces']"
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: OPERATOR_NAME
value: integration-operator
- name: MAX_CONCURRENT_RECONCILES
value: "3"
nodeSelector:
beta.kubernetes.io/os: linux
livenessProbe:
httpGet:
path: /healthz
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
readinessProbe:
httpGet:
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
installModes:
- type: OwnNamespace
supported: true
- type: SingleNamespace
supported: true
- type: MultiNamespace
supported: true
- type: AllNamespaces
supported: true
Loading

0 comments on commit c0552e5

Please sign in to comment.