Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy edge drivers #21

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions edge-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{{/*
Define the image for a container.
*/}}
{{- define "edge-agent.image" -}}
image: "{{ .registry }}/{{ .repository }}:{{ .tag }}"
imagePullPolicy: {{ .pullPolicy }}
{{- $root := index . 0 -}}
{{- $key := index . 1 -}}
{{- $image := $root.Values.image -}}
{{- $spec := merge (get $image $key) $image.default -}}
image: "{{ $spec.registry }}/{{ $spec.repository }}:{{ $spec.tag }}"
imagePullPolicy: {{ $spec.pullPolicy }}
{{- end }}

40 changes: 39 additions & 1 deletion edge-agent/templates/edge-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ spec:
{{ end }}
containers:
- name: edge-agent
{{ include "edge-agent.image" .Values.image.edgeAgent | indent 10 }}
{{ list . "edgeAgent" | include "edge-agent.image" | indent 10 }}
env:
- name: DEBUG
value: {{ .Values.debug | quote }}
Expand All @@ -49,6 +49,10 @@ spec:
secretKeyRef:
name: edge-agent-secrets-{{ .Values.uuid }}
key: keytab
- name: EDGE_MQTT
value: "mqtt://localhost"
- name: EDGE_PASSWORDS
value: "/usr/app/driver-passwords"
resources:
limits:
memory: {{ .Values.limits.memory | quote }}
Expand All @@ -61,13 +65,35 @@ spec:
readOnly: true
- mountPath: /home/node/.config
name: local-config
- mountPath: /usr/app/driver-passwords
name: driver-passwords
{{- range $name, $image := .Values.drivers }}
- name: "driver-{{ $name | lower }}"
{{ list $ $image | include "edge-agent.image" | indent 10 }}
env:
- name: EDGE_MQTT
value: "mqtt://localhost"
- name: EDGE_USERNAME
value: "{{ $name }}"
- name: EDGE_PASSWORD
valueFrom:
secretKeyRef:
name: "driver-passwords-{{ $.Values.uuid }}"
key: "{{ $name }}"
- name: VERBOSE
value: "{{ $.Values.verbosity }}"
{{- end }}
volumes:
- name: edge-agent-sensitive-information
secret:
optional: true
secretName: edge-agent-sensitive-information-{{ .Values.uuid }}
- name: local-config
emptyDir:
- name: driver-passwords
secret:
optional: true
secretName: driver-passwords-{{ .Values.uuid }}
---
apiVersion: factoryplus.app.amrc.co.uk/v1
kind: SparkplugNode
Expand All @@ -79,3 +105,15 @@ spec:
edgeAgent: true
secrets:
- edge-agent-sensitive-information-{{ .Values.uuid }}
{{ range $name, $image := .Values.drivers }}
---
apiVersion: factoryplus.app.amrc.co.uk/v1
kind: LocalSecret
metadata:
namespace: {{ $.Release.Namespace }}
name: "driver-passwords-{{ $.Values.uuid }}-{{ $name | lower }}"
spec:
format: Password
secret: "driver-passwords-{{ $.Values.uuid }}"
key: "{{ $name }}"
{{- end }}
16 changes: 16 additions & 0 deletions edge-agent/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
namespace: {{ .Release.Namespace }}
name: edge-agent-{{ .Values.uuid }}
spec:
selector:
factory-plus.app: edge-agent
factory-plus.nodeUuid: {{ .Values.uuid }}
internalTrafficPolicy: Local
ports:
- name: mqtt
port: 1883
{{- if .Values.externalIPs }}
externalIPs: {{ .Values.externalIPs }}
{{- end }}
16 changes: 13 additions & 3 deletions edge-agent/values.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
image:
# Parameters for the Edge Agent image to pull
edgeAgent:
# Default image parameters. These can be overidden per-image.
default:
registry: ghcr.io/amrc-factoryplus
repository: acs-edge
tag: v3.1.2
pullPolicy: IfNotPresent
# Edge Agent image to pull
edgeAgent:
repository: acs-edge
modbus:
repository: edge-modbus
test:
repository: edge-test
# Further image names for drivers as needed
drivers:
# An object mapping connection names to images from the list above.
#Test: test
debug: false
verbosity: ALL,!token,!service,!sparkplug
poll_int: 10
Expand Down
51 changes: 51 additions & 0 deletions edge-cluster/crds/local-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: localsecrets.factoryplus.app.amrc.co.uk
spec:
group: factoryplus.app.amrc.co.uk
names:
kind: LocalSecret
plural: localsecrets
categories:
- all
scope: Namespaced
versions:
- name: v1
served: true
storage: true
additionalPrinterColumns:
- name: Secret
jsonPath: ".spec.secret"
type: string
- name: Key
jsonPath: ".spec.key"
type: string
- name: Format
jsonPath: ".spec.format"
type: string
schema:
openAPIV3Schema:
type: object
required: [spec]
properties:
spec:
type: object
required: [secret, key, format]
properties:
secret:
description: The name of the Secret to edit.
type: string
key:
description: The key to create within the Secret.
type: string
format:
description: >
The format of the secret value. Currently must be Password.
type: string
enum: [Password]
status:
type: object
x-kubernetes-preserve-unknown-fields: true
subresources:
status: {}
4 changes: 2 additions & 2 deletions edge-cluster/templates/krb-keys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ metadata:
name: krb-keys
rules:
- apiGroups: [factoryplus.app.amrc.co.uk]
resources: [kerberos-keys]
resources: [kerberos-keys, localsecrets]
verbs: [list, get, watch, patch]
- apiGroups: [factoryplus.app.amrc.co.uk]
resources: [kerberos-keys/status]
resources: [kerberos-keys/status, localsecrets/status]
verbs: [list, get, create, update, delete, watch, patch]
- apiGroups: [""]
resources: [secrets]
Expand Down