Skip to content

Commit

Permalink
feat: added stakater reloader annotation
Browse files Browse the repository at this point in the history
Signed-off-by: Armin Schlegel <armin.schlegel@gmx.de>
  • Loading branch information
siredmar committed Jun 5, 2023
1 parent 83ca0d9 commit 6fafd9b
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 177 deletions.
197 changes: 102 additions & 95 deletions cue/traits/edgefarm-network-trait.cue
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
167 changes: 85 additions & 82 deletions manifests/vela-caps/traits/edgefarm-network-trait.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 6fafd9b

Please sign in to comment.