From 6fafd9b001f11c7f4e5ba5c2977566b5902ac2a9 Mon Sep 17 00:00:00 2001 From: Armin Schlegel Date: Mon, 5 Jun 2023 14:18:15 +0200 Subject: [PATCH] feat: added stakater reloader annotation Signed-off-by: Armin Schlegel --- cue/traits/edgefarm-network-trait.cue | 197 +++++++++--------- .../traits/edgefarm-network-trait.yaml | 167 +++++++-------- 2 files changed, 187 insertions(+), 177 deletions(-) diff --git a/cue/traits/edgefarm-network-trait.cue b/cue/traits/edgefarm-network-trait.cue index 9e1fd8f..9a17c7a 100644 --- a/cue/traits/edgefarm-network-trait.cue +++ b/cue/traits/edgefarm-network-trait.cue @@ -11,103 +11,110 @@ } template: { patch: { - spec: workloadTemplate: deploymentTemplate: spec: template: spec: { - // +patchKey=name - // +patchStrategy=retainKeys - volumes: [ - { - name: "secret-"+parameter.network.name+"-"+parameter.network.user, - secret: - secretName: parameter.network.name+"-"+parameter.network.user - }, - { - name: "config"+parameter.network.name+"-"+parameter.network.user, - emptyDir: {} - }, - { - name: "dapr-resiliency" - configMap: - name: "resiliency-"+parameter.network.name+"-"+parameter.network.user - }, - ] - initContainers: [{ - command: ["sh", "-c", "cp /secret/dapr /config/streams.yaml && sed -i \"s#localhost#$SUBNETWORK_SVC_ADDRESS.$SUBNETWORK_NAMESPACE#g\" /config/streams.yaml && cat /config/streams.yaml && cp /resiliency-config/resiliency.yaml /config/resiliency.yaml"] - env: [{ - name: "SUBNETWORK_SVC_ADDRESS" - value: parameter.network.name+"-"+context.namespace+"-"+parameter.network.subnetwork - }, { - name: "SUBNETWORK_NAMESPACE" - valueFrom: fieldRef: fieldPath: "metadata.namespace" - }] - image: "bash:5.1-alpine3.17" - imagePullPolicy: "IfNotPresent" - name: "init-dapr-network-"+parameter.network.name+"-"+context.namespace+"-"+parameter.network.subnetwork - volumeMounts: [{ - mountPath: "/config/" - name: "config"+parameter.network.name+"-"+parameter.network.user, - }, - { - mountPath: "/secret" - name: "secret-"+parameter.network.name+"-"+parameter.network.user - }, - { - mountPath: "/resiliency-config" - name: "dapr-resiliency" - }] - }] - // +patchKey=name - containers: [{ - name: context.name, - // +patchStrategy=retainKeys - volumeMounts: [{ - name: "secret-"+parameter.network.name+"-"+parameter.network.user - mountPath: "/creds/network.creds" - subPath: "creds" - readOnly: true - }], - env: [ - { - name: "DAPR_GRPC_ADDRESS", - value: "localhost:\(parameter.daprGrpcPort)" - }, - { - name: "DAPR_HTTP_ADDRESS", - value: "localhost:\(parameter.daprHttpPort)" + spec: workloadTemplate: deploymentTemplate: { + metadata: annotations: { + "reloader.stakater.com/auto": "true" + } + spec: template: { + spec: { + // +patchKey=name + // +patchStrategy=retainKeys + volumes: [ + { + name: "secret-"+parameter.network.name+"-"+parameter.network.user, + secret: + secretName: parameter.network.name+"-"+parameter.network.user + }, + { + name: "config"+parameter.network.name+"-"+parameter.network.user, + emptyDir: {} + }, + { + name: "dapr-resiliency" + configMap: + name: "resiliency-"+parameter.network.name+"-"+parameter.network.user + }, + ] + initContainers: [{ + command: ["sh", "-c", "cp /secret/dapr /config/streams.yaml && sed -i \"s#localhost#$SUBNETWORK_SVC_ADDRESS.$SUBNETWORK_NAMESPACE#g\" /config/streams.yaml && cat /config/streams.yaml && cp /resiliency-config/resiliency.yaml /config/resiliency.yaml"] + env: [{ + name: "SUBNETWORK_SVC_ADDRESS" + value: parameter.network.name+"-"+context.namespace+"-"+parameter.network.subnetwork + }, { + name: "SUBNETWORK_NAMESPACE" + valueFrom: fieldRef: fieldPath: "metadata.namespace" + }] + image: "bash:5.1-alpine3.17" + imagePullPolicy: "IfNotPresent" + name: "init-dapr-network-"+parameter.network.name+"-"+context.namespace+"-"+parameter.network.subnetwork + volumeMounts: [{ + mountPath: "/config/" + name: "config"+parameter.network.name+"-"+parameter.network.user, + }, + { + mountPath: "/secret" + name: "secret-"+parameter.network.name+"-"+parameter.network.user + }, + { + mountPath: "/resiliency-config" + name: "dapr-resiliency" + }] + }] + // +patchKey=name + containers: [{ + name: context.name, + // +patchStrategy=retainKeys + volumeMounts: [{ + name: "secret-"+parameter.network.name+"-"+parameter.network.user + mountPath: "/creds/network.creds" + subPath: "creds" + readOnly: true + }], + env: [ + { + name: "DAPR_GRPC_ADDRESS", + value: "localhost:\(parameter.daprGrpcPort)" + }, + { + name: "DAPR_HTTP_ADDRESS", + value: "localhost:\(parameter.daprHttpPort)" + }, + { + name: "NODE_NAME", + valueFrom: + fieldRef: + fieldPath: "spec.nodeName" + }, + ], }, { - name: "NODE_NAME", - valueFrom: - fieldRef: - fieldPath: "spec.nodeName" - }, - ], - }, - { - name: "dapr", - image: "daprio/daprd:1.10.5", - command: [ - "./daprd", - "--dapr-grpc-port", - "\(parameter.daprGrpcPort)", - "--components-path", - "/config", - "--dapr-http-port", - "\(parameter.daprHttpPort)", - "--app-port", - "\(parameter.daprAppPort)", - "--app-protocol", - parameter.daprProtocol, - "--app-id", - context.name - ], - volumeMounts: [ - { - "name": "config"+parameter.network.name+"-"+parameter.network.user, - "mountPath": "/config/" - "readOnly": true - } - ] - }] + name: "dapr", + image: "daprio/daprd:1.10.5", + command: [ + "./daprd", + "--dapr-grpc-port", + "\(parameter.daprGrpcPort)", + "--components-path", + "/config", + "--dapr-http-port", + "\(parameter.daprHttpPort)", + "--app-port", + "\(parameter.daprAppPort)", + "--app-protocol", + parameter.daprProtocol, + "--app-id", + context.name + ], + volumeMounts: [ + { + "name": "config"+parameter.network.name+"-"+parameter.network.user, + "mountPath": "/config/" + "readOnly": true + } + ] + }] + } + } } } outputs: { diff --git a/manifests/vela-caps/traits/edgefarm-network-trait.yaml b/manifests/vela-caps/traits/edgefarm-network-trait.yaml index a8f5d77..6d2e98a 100644 --- a/manifests/vela-caps/traits/edgefarm-network-trait.yaml +++ b/manifests/vela-caps/traits/edgefarm-network-trait.yaml @@ -12,99 +12,102 @@ spec: schematic: cue: template: | - patch: spec: workloadTemplate: deploymentTemplate: spec: template: spec: { - // +patchKey=name - // +patchStrategy=retainKeys - volumes: [ - { - name: "secret-" + parameter.network.name + "-" + parameter.network.user - secret: secretName: parameter.network.name + "-" + parameter.network.user - }, - { - name: "config" + parameter.network.name + "-" + parameter.network.user - emptyDir: {} - }, - { - name: "dapr-resiliency" - configMap: name: "resiliency-" + parameter.network.name + "-" + parameter.network.user - }, - ] - initContainers: [{ - command: ["sh", "-c", "cp /secret/dapr /config/streams.yaml && sed -i \"s#localhost#$SUBNETWORK_SVC_ADDRESS.$SUBNETWORK_NAMESPACE#g\" /config/streams.yaml && cat /config/streams.yaml && cp /resiliency-config/resiliency.yaml /config/resiliency.yaml"] - env: [{ - name: "SUBNETWORK_SVC_ADDRESS" - value: parameter.network.name + "-" + context.namespace + "-" + parameter.network.subnetwork - }, { - name: "SUBNETWORK_NAMESPACE" - valueFrom: fieldRef: fieldPath: "metadata.namespace" - }] - image: "bash:5.1-alpine3.17" - imagePullPolicy: "IfNotPresent" - name: "init-dapr-network-" + parameter.network.name + "-" + context.namespace + "-" + parameter.network.subnetwork - volumeMounts: [{ - mountPath: "/config/" - name: "config" + parameter.network.name + "-" + parameter.network.user - }, - { - mountPath: "/secret" - name: "secret-" + parameter.network.name + "-" + parameter.network.user - }, - { - mountPath: "/resiliency-config" - name: "dapr-resiliency" - }] - }] - // +patchKey=name - containers: [{ - name: context.name + patch: spec: workloadTemplate: deploymentTemplate: { + metadata: annotations: "reloader.stakater.com/auto": "true" + spec: template: spec: { + // +patchKey=name // +patchStrategy=retainKeys - volumeMounts: [{ - name: "secret-" + parameter.network.name + "-" + parameter.network.user - mountPath: "/creds/network.creds" - subPath: "creds" - readOnly: true - }] - env: [ + volumes: [ { - name: "DAPR_GRPC_ADDRESS" - value: "localhost:\(parameter.daprGrpcPort)" + name: "secret-" + parameter.network.name + "-" + parameter.network.user + secret: secretName: parameter.network.name + "-" + parameter.network.user }, { - name: "DAPR_HTTP_ADDRESS" - value: "localhost:\(parameter.daprHttpPort)" + name: "config" + parameter.network.name + "-" + parameter.network.user + emptyDir: {} }, { - name: "NODE_NAME" - valueFrom: fieldRef: fieldPath: "spec.nodeName" + name: "dapr-resiliency" + configMap: name: "resiliency-" + parameter.network.name + "-" + parameter.network.user }, ] - }, - { - name: "dapr" - image: "daprio/daprd:1.10.5" - command: [ - "./daprd", - "--dapr-grpc-port", - "\(parameter.daprGrpcPort)", - "--components-path", - "/config", - "--dapr-http-port", - "\(parameter.daprHttpPort)", - "--app-port", - "\(parameter.daprAppPort)", - "--app-protocol", - parameter.daprProtocol, - "--app-id", - context.name, - ] - volumeMounts: [ + initContainers: [{ + command: ["sh", "-c", "cp /secret/dapr /config/streams.yaml && sed -i \"s#localhost#$SUBNETWORK_SVC_ADDRESS.$SUBNETWORK_NAMESPACE#g\" /config/streams.yaml && cat /config/streams.yaml && cp /resiliency-config/resiliency.yaml /config/resiliency.yaml"] + env: [{ + name: "SUBNETWORK_SVC_ADDRESS" + value: parameter.network.name + "-" + context.namespace + "-" + parameter.network.subnetwork + }, { + name: "SUBNETWORK_NAMESPACE" + valueFrom: fieldRef: fieldPath: "metadata.namespace" + }] + image: "bash:5.1-alpine3.17" + imagePullPolicy: "IfNotPresent" + name: "init-dapr-network-" + parameter.network.name + "-" + context.namespace + "-" + parameter.network.subnetwork + volumeMounts: [{ + mountPath: "/config/" + name: "config" + parameter.network.name + "-" + parameter.network.user + }, { - name: "config" + parameter.network.name + "-" + parameter.network.user - mountPath: "/config/" - readOnly: true + mountPath: "/secret" + name: "secret-" + parameter.network.name + "-" + parameter.network.user }, - ] + { + mountPath: "/resiliency-config" + name: "dapr-resiliency" + }] }] + // +patchKey=name + containers: [{ + name: context.name + // +patchStrategy=retainKeys + volumeMounts: [{ + name: "secret-" + parameter.network.name + "-" + parameter.network.user + mountPath: "/creds/network.creds" + subPath: "creds" + readOnly: true + }] + env: [ + { + name: "DAPR_GRPC_ADDRESS" + value: "localhost:\(parameter.daprGrpcPort)" + }, + { + name: "DAPR_HTTP_ADDRESS" + value: "localhost:\(parameter.daprHttpPort)" + }, + { + name: "NODE_NAME" + valueFrom: fieldRef: fieldPath: "spec.nodeName" + }, + ] + }, + { + name: "dapr" + image: "daprio/daprd:1.10.5" + command: [ + "./daprd", + "--dapr-grpc-port", + "\(parameter.daprGrpcPort)", + "--components-path", + "/config", + "--dapr-http-port", + "\(parameter.daprHttpPort)", + "--app-port", + "\(parameter.daprAppPort)", + "--app-protocol", + parameter.daprProtocol, + "--app-id", + context.name, + ] + volumeMounts: [ + { + name: "config" + parameter.network.name + "-" + parameter.network.user + mountPath: "/config/" + readOnly: true + }, + ] + }] + } } outputs: "resiliency-dapr-component": { apiVersion: "v1"