From 1e53bf99e41a2ccb061c81dab7381c3e262bceed Mon Sep 17 00:00:00 2001 From: salaboy Date: Wed, 3 Jan 2024 13:45:58 +0000 Subject: [PATCH 1/2] Update README.md --- README.md | 85 +++++++++++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 38aea3b..5ea1b19 100644 --- a/README.md +++ b/README.md @@ -1,74 +1,73 @@ -# Dapr Ambient +# Dapr Shared -Dapr Ambient allows you to create Dapr Applications using the `daprd` Sidecar as a Kubernetes `Daemonset` or `Deployment`. This enables other use cases where Sidecars are not the best option. +Dapr Shared allows you to create Dapr Applications using the `daprd` Sidecar as a Kubernetes `Daemonset` or `Deployment`. This enables other use cases where Sidecars are not the best option. By running `daprd` as a Kubernetes `DaemonSet` (or as a `Deployment`), the `daprd` container will be running in each Kubernetes Node, reducing the network hops between the applications and Dapr. -If you need multiple Dapr Applications, you can deploy this chart multiple times using different `ambient.appId`s. +If you need multiple Dapr Applications, you can deploy this chart multiple times using different `shared.appId`s. ## Getting Started -Before installing Dapr Ambient, please ensure you have Dapr installed in your cluster. +Before installing Dapr Shared, please ensure you have Dapr installed in your cluster. -If you want to get started with Dapr Ambient, you can easily create a new Dapr Ambient instance by installing the official Helm Chart: +If you want to get started with Dapr Shared, you can easily create a new Dapr Shared instance by installing the official Helm Chart: ``` -helm install my-ambient-dapr-ambient oci://registry-1.docker.io/daprio/dapr-ambient-chart --set ambient.appId= --set ambient.remoteURL= ambient.remotePort= +helm install my-dapr-shared oci://registry-1.docker.io/daprio/dapr-shared-chart --set shared.appId= --set shared.remoteURL= shared.remotePort= ``` If you want to look at a step-by-step tutorial using some applications and interacting with Dapr Components, check out the [step-by-step tutorial using Kubernetes KinD here](tutorial/README.md). ## From Source -To deploy this chart from source you can run from inside the `chart/dapr-ambient` directory: +To deploy this chart from the source you can run from inside the `chart/dapr-shared` directory: ``` -helm install my-ambient . --set ambient.appId= --set ambient.remoteURL= +helm install my-shared . --set shared.appId= --set shared.remoteURL= ``` -Where `` is the Dapr App Id that you can use in your components (for example, for scopes) and `` is a reachable URL where `dapr-ambient` will forward notifications received by the Dapr sidecar. +Where `` is the Dapr App Id that you can use in your components (for example, for scopes) and `` is a reachable URL where `dapr-shared` will forward notifications received by the Dapr sidecar. Future versions include forwarding notifications to multiple remote URLs. -## Customize Dapr Ambient -Is possible to customize Dapr Ambient using custom Helm values. +## Customize Dapr Shared +Customize Dapr Shared using custom Helm values -## Values | Key | Type | Default | Description | |-----|------|---------|-------------| -| ambient.controlPlane.namespace | string | `"dapr-system"` | Namespace where Dapr Control Plane is. | -| ambient.daprd.apiLogging.enabled | bool | `true` | Enables API logging for the daprd. | -| ambient.daprd.app.protocol | string | `"http"` | Dapr which protocol your application is using. Valid options are `http`` and `grpc``. | -| ambient.daprd.grpcPort | int | `50001` | gRPC port for the Dapr Internal API to listen on. | -| ambient.daprd.httpPort | int | `3500` | The HTTP port for the Dapr API. | -| ambient.daprd.image.name | string | `"daprd"` | Daprd image. | -| ambient.daprd.image.pullPolicy | string | `"Always"` | Daprd image pull policy. | -| ambient.daprd.image.registry | string | `"docker.io/daprio"` | Daprd image registry. | -| ambient.daprd.image.tag | string | `"1.11.0"` | Daprd image version. | -| ambient.daprd.internalGrpcPort | int | `50002` | gRPC port for the Dapr Internal API to listen on. | -| ambient.daprd.listenAddresses | string | `"0.0.0.0"` | Comma separated list of IP addresses that daprd will listen to. Defaults to all in standalone mode. Defaults to [::1],127.0.0.1 in Kubernetes. To listen to all IPv4 addresses, use 0.0.0.0. To listen to all IPv6 addresses, use [::]. | -| ambient.daprd.metrics.enabled | bool | `true` | Enable prometheus metric. | -| ambient.daprd.metrics.port | int | `9090` | Sets the port for the sidecar metrics server. | -| ambient.daprd.mtls.enabled | bool | `false` | Enables automatic mTLS for daprd to daprd communication channels. | -| ambient.daprd.publicPort | int | `3501` | The HTTP public port for the Dapr API. | -| ambient.daprd.token | string | `""` | Dapr API token to use for token based API authentication. | -| ambient.deployment.replicas | int | `1` | The quantity of replicas. This property is set only when `ambient.strategy` is equal to `deployment` | -| ambient.initContainer.image.name | string | `"dapr-ambient"` | The dapr-ambient image name. | -| ambient.initContainer.image.pullPolicy | string | `"Always"` | The init container pull policy. | -| ambient.initContainer.image.registry | string | `"docker.io/matheuscruzdev"` | The dapr-ambient image registry. | -| ambient.initContainer.image.tag | string | `"latest"` | The dapr-ambient-init image tag. | -| ambient.initContainer.token | string | `""` | The dapr API token. | -| ambient.log.json | bool | `true` | The daprd log format. | -| ambient.log.level | string | `"info"` | The daprd log level. | -| ambient.remotePort | int | `0` | The remote port. | -| ambient.service.type | string | `"ClusterIP"` | The daprd service type. | -| ambient.serviceAccount.annotations | object | `{}` | | -| ambient.serviceAccount.create | bool | `true` | Allows the option to create or not the service account. | -| ambient.serviceAccount.name | string | `""` | Kubernetes Service Account name. | -| ambient.strategy | string | `"daemonset"` | The default strategy to run dapr in ambient mode. Possible values `daemonset`, `deployment`. | +| shared.controlPlane.namespace | string | `"dapr-system"` | Namespace where Dapr Control Plane is. | +| shared.daprd.apiLogging.enabled | bool | `true` | Enables API logging for the daprd. | +| shared.daprd.app.protocol | string | `"http"` | Dapr which protocol your application is using. Valid options are `http`` and `grpc``. | +| shared.daprd.grpcPort | int | `50001` | gRPC port for the Dapr Internal API to listen on. | +| shared.daprd.httpPort | int | `3500` | The HTTP port for the Dapr API. | +| shared.daprd.image.name | string | `"daprd"` | Daprd image. | +| shared.daprd.image.pullPolicy | string | `"Always"` | Daprd image pull policy. | +| shared.daprd.image.registry | string | `"docker.io/daprio"` | Daprd image registry. | +| shared.daprd.image.tag | string | `"1.11.0"` | Daprd image version. | +| shared.daprd.internalGrpcPort | int | `50002` | gRPC port for the Dapr Internal API to listen on. | +| shared.daprd.listenAddresses | string | `"0.0.0.0"` | Comma separated list of IP addresses that daprd will listen to. Defaults to all in standalone mode. Defaults to [::1],127.0.0.1 in Kubernetes. To listen to all IPv4 addresses, use 0.0.0.0. To listen to all IPv6 addresses, use [::]. | +| shared.daprd.metrics.enabled | bool | `true` | Enable prometheus metric. | +| shared.daprd.metrics.port | int | `9090` | Sets the port for the sidecar metrics server. | +| shared.daprd.mtls.enabled | bool | `false` | Enables automatic mTLS for daprd to daprd communication channels. | +| shared.daprd.publicPort | int | `3501` | The HTTP public port for the Dapr API. | +| shared.daprd.token | string | `""` | Dapr API token to use for token based API authentication. | +| shared.deployment.replicas | int | `1` | The quantity of replicas. This property is set only when `shared.strategy` is equal to `deployment` | +| shared.initContainer.image.name | string | `"dapr-shared"` | The dapr-shared image name. | +| shared.initContainer.image.pullPolicy | string | `"Always"` | The init container pull policy. | +| shared.initContainer.image.registry | string | `"docker.io/matheuscruzdev"` | The dapr-shared image registry. | +| shared.initContainer.image.tag | string | `"latest"` | The dapr-shared-init image tag. | +| shared.initContainer.token | string | `""` | The dapr API token. | +| shared.log.json | bool | `true` | The daprd log format. | +| shared.log.level | string | `"info"` | The daprd log level. | +| shared.remotePort | int | `0` | The remote port. | +| shared.service.type | string | `"ClusterIP"` | The daprd service type. | +| shared.serviceAccount.annotations | object | `{}` | | +| shared.serviceAccount.create | bool | `true` | Allows the option to create or not the service account. | +| shared.serviceAccount.name | string | `""` | Kubernetes Service Account name. | +| shared.strategy | string | `"daemonset"` | The default strategy to run dapr in shared mode. Possible values `daemonset`, `deployment`. | ---------------------------------------------- Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0) @@ -76,7 +75,7 @@ Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/n ### Building from source I've used the [CNCF `ko` project](https://ko.build/) to build multiplatform images for the proxy. -You can run the following command to build containers for the `dapr-ambient` proxy: +You can run the following command to build containers for the `dapr-shared` proxy: ``` ko build --platform=linux/amd64,linux/arm64 From 2c1a52dc05b23cade4e2f2d628fd459366a1def0 Mon Sep 17 00:00:00 2001 From: salaboy Date: Mon, 8 Jan 2024 13:03:21 +0000 Subject: [PATCH 2/2] renaming chart and values --- .github/workflows/dapr-ambient.yaml | 28 +++---- .gitignore | 2 +- Dockerfile | 4 +- Makefile | 4 +- chart/dapr-ambient/Chart.yaml | 5 -- chart/dapr-ambient/README.md | 83 ------------------- chart/dapr-ambient/templates/daemonset.yaml | 13 --- chart/dapr-ambient/templates/deployment.yaml | 11 --- chart/dapr-ambient/templates/secret.yaml | 11 --- .../templates/serviceaccount.yaml | 12 --- chart/dapr-shared/Chart.yaml | 5 ++ chart/dapr-shared/README.md | 83 +++++++++++++++++++ .../README.md.gotmpl | 24 +++--- .../templates/_daemondeployshared.yaml | 66 +++++++-------- .../templates/_helpers.tpl | 24 +++--- chart/dapr-shared/templates/daemonset.yaml | 13 +++ chart/dapr-shared/templates/deployment.yaml | 11 +++ .../templates/helmhooks.yaml | 10 +-- .../templates/rbac.yaml | 20 ++--- chart/dapr-shared/templates/secret.yaml | 11 +++ .../templates/service.yaml | 6 +- .../dapr-shared/templates/serviceaccount.yaml | 12 +++ .../tests/daemonset_test.yaml | 16 ++-- .../tests/deployment_test.yaml | 12 +-- .../tests/service_test.yaml | 6 +- .../tests/values/required.yaml | 2 +- .../{dapr-ambient => dapr-shared}/values.yaml | 16 ++-- cmd/{ambient-init => shared-init}/main.go | 8 +- go.mod | 2 +- tutorial/README.md | 28 +++---- 30 files changed, 274 insertions(+), 274 deletions(-) delete mode 100644 chart/dapr-ambient/Chart.yaml delete mode 100644 chart/dapr-ambient/README.md delete mode 100644 chart/dapr-ambient/templates/daemonset.yaml delete mode 100644 chart/dapr-ambient/templates/deployment.yaml delete mode 100644 chart/dapr-ambient/templates/secret.yaml delete mode 100644 chart/dapr-ambient/templates/serviceaccount.yaml create mode 100644 chart/dapr-shared/Chart.yaml create mode 100644 chart/dapr-shared/README.md rename chart/{dapr-ambient => dapr-shared}/README.md.gotmpl (54%) rename chart/{dapr-ambient => dapr-shared}/templates/_daemondeployshared.yaml (52%) rename chart/{dapr-ambient => dapr-shared}/templates/_helpers.tpl (67%) create mode 100644 chart/dapr-shared/templates/daemonset.yaml create mode 100644 chart/dapr-shared/templates/deployment.yaml rename chart/{dapr-ambient => dapr-shared}/templates/helmhooks.yaml (60%) rename chart/{dapr-ambient => dapr-shared}/templates/rbac.yaml (65%) create mode 100644 chart/dapr-shared/templates/secret.yaml rename chart/{dapr-ambient => dapr-shared}/templates/service.yaml (70%) create mode 100644 chart/dapr-shared/templates/serviceaccount.yaml rename chart/{dapr-ambient => dapr-shared}/tests/daemonset_test.yaml (96%) rename chart/{dapr-ambient => dapr-shared}/tests/deployment_test.yaml (71%) rename chart/{dapr-ambient => dapr-shared}/tests/service_test.yaml (83%) rename chart/{dapr-ambient => dapr-shared}/tests/values/required.yaml (87%) rename chart/{dapr-ambient => dapr-shared}/values.yaml (88%) rename cmd/{ambient-init => shared-init}/main.go (95%) diff --git a/.github/workflows/dapr-ambient.yaml b/.github/workflows/dapr-ambient.yaml index 0cffdd5..9db2314 100644 --- a/.github/workflows/dapr-ambient.yaml +++ b/.github/workflows/dapr-ambient.yaml @@ -11,7 +11,7 @@ # limitations under the License. # -name: dapr-ambient-init +name: dapr-shared-init on: pull_request: @@ -70,12 +70,12 @@ jobs: - name: Copy out file from volume run: | - sudo cp ./ambient-init ${{ env.ARCHIVE_OUTDIR }}/ambient-init + sudo cp ./shared-init ${{ env.ARCHIVE_OUTDIR }}/shared-init - name: upload artifacts uses: actions/upload-artifact@master with: - name: ambient-init + name: shared-init path: ${{ env.ARCHIVE_OUTDIR }} publish: @@ -98,10 +98,10 @@ jobs: REPO_OWNER=${{ github.repository_owner }} # Lowercase the value echo "REPO_OWNER=${REPO_OWNER,,}" >>${GITHUB_ENV} - - name: "download artifact: ambient-init" + - name: "download artifact: shared-init" uses: actions/download-artifact@master with: - name: ambient-init + name: shared-init path: ${{ env.ARCHIVE_OUTDIR }} - name: generate checksum files run: cd ${{ env.ARCHIVE_OUTDIR }} && for i in *; do sha256sum -b $i > "$i.sha256"; done && cd - @@ -121,12 +121,12 @@ jobs: OWNER_NAME="${GITHUB_REPOSITORY%%/*}" REPO_NAME="${GITHUB_REPOSITORY#*/}" export GITHUB_TOKEN=${{ secrets.DAPR_BOT_TOKEN }} - echo "Uploading Dapr-Ambient Runtime Binaries to GitHub Release" + echo "Uploading Dapr-Shared Runtime Binaries to GitHub Release" github-release upload \ --owner $OWNER_NAME \ --repo $REPO_NAME \ --tag "v${REL_VERSION}" \ - --release-name "Dapr-Ambient Runtime v${REL_VERSION}" \ + --release-name "Dapr-Shared Runtime v${REL_VERSION}" \ --body "${RELEASE_BODY}" \ --prerelease true \ ${RELEASE_ARTIFACT[*]} @@ -164,9 +164,9 @@ jobs: - name: Build & Push Images env: - KO_DOCKER_REPO: ${{ vars.DOCKER_DAPRIO_REGISTRY }}/dapr-ambient + KO_DOCKER_REPO: ${{ vars.DOCKER_DAPRIO_REGISTRY }}/dapr-shared run: | - ko build cmd/ambient-init/main.go --platform=linux/amd64,linux/arm64 --tags ${REL_VERSION} --bare + ko build cmd/shared-init/main.go --platform=linux/amd64,linux/arm64 --tags ${REL_VERSION} --bare helm: runs-on: ubuntu-latest @@ -190,12 +190,12 @@ jobs: run: helm plugin install https://github.com/quintush/helm-unittest - name: execute unit tests - run: helm unittest chart/dapr-ambient + run: helm unittest chart/dapr-shared - name: Update init-container tag run: | - sed -i -e "s|tag: latest|tag: ${REL_VERSION}|g" ./chart/dapr-ambient/values.yaml - cat ./chart/dapr-ambient/values.yaml + sed -i -e "s|tag: latest|tag: ${REL_VERSION}|g" ./chart/dapr-shared/values.yaml + cat ./chart/dapr-shared/values.yaml - name: Container Registry login uses: docker/login-action@v2 @@ -208,7 +208,7 @@ jobs: - name: Package & Push Helm Chart run : | helm package \ - ./chart/dapr-ambient \ + ./chart/dapr-shared \ --version ${REL_VERSION} - helm push dapr-ambient-chart-${REL_VERSION}.tgz oci://docker.io/${{ vars.DOCKER_DAPRIO_REGISTRY }} + helm push dapr-shared-chart-${REL_VERSION}.tgz oci://docker.io/${{ vars.DOCKER_DAPRIO_REGISTRY }} shell: bash \ No newline at end of file diff --git a/.gitignore b/.gitignore index fa32a03..ad2e314 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ go.work *.tgz -/dapr-ambient \ No newline at end of file +/dapr-shared \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 36c6fa8..0521b06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM busybox:1.34 -COPY ambient-init ambient-init +COPY shared-init shared-init -ENTRYPOINT [ "./ambient-init" ] \ No newline at end of file +ENTRYPOINT [ "./shared-init" ] \ No newline at end of file diff --git a/Makefile b/Makefile index cc991c9..1d1148c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: init/build init/build: - CGO_ENABLED=0 go build -o ambient-init cmd/ambient-init/main.go + CGO_ENABLED=0 go build -o shared-init cmd/shared-init/main.go # build .PHONY: init/build-image @@ -8,4 +8,4 @@ init/build-image: init/build docker build -t $(image) . release: - CGO_ENABLED=0 go build -o ambient-init cmd/ambient-init/main.go \ No newline at end of file + CGO_ENABLED=0 go build -o shared-init cmd/shared-init/main.go \ No newline at end of file diff --git a/chart/dapr-ambient/Chart.yaml b/chart/dapr-ambient/Chart.yaml deleted file mode 100644 index 34bf717..0000000 --- a/chart/dapr-ambient/Chart.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: v2 -description: Helm Chart For Dapr Ambient Apps -name: dapr-ambient-chart -version: 1.10.0 -icon: https://salaboy.files.wordpress.com/2019/07/avatar.png \ No newline at end of file diff --git a/chart/dapr-ambient/README.md b/chart/dapr-ambient/README.md deleted file mode 100644 index 7bc6d0d..0000000 --- a/chart/dapr-ambient/README.md +++ /dev/null @@ -1,83 +0,0 @@ -# Dapr Ambient - -Dapr Ambient allows you to create Dapr Applications using the `daprd` Sidecar as a Kubernetes `Daemonset` or `Deployment`. This enables other use cases where Sidecars are not the best option. - -By running `daprd` as a Kubernetes `DaemonSet` (or as a `Deployment`) the `daprd` container will be running in each Kubernetes Node, reducing the network hops between the applications and Dapr. - -If you need multiple Dapr Applications you can deploy this chart multiple times using different `ambient.appId`s. - -## Getting Started - -If you want to get started with Dapr Ambient you can easily create a new Dapr Ambient instance by install the oficial Helm Chart: - -``` -helm add repo ambient https://salaboy.github.io/helm/ -helm repo update -helm install my-ambient amabient/dapr-ambient --set ambient.appId= --set ambient.channelAddress= --set ambient.daprd.app.port= -``` - -If you want to take a look at a step by step tutorial using some applications and interacting with Dapr Components check out the [step-by-step tutorial using Kubernetes KinD here](tutorial/README.md). - -## From Source - -To deploy this chart from source you can run from inside the `chart/dapr-ambient` directory: - -``` -helm install my-ambient . --set ambient.appId= --set ambient.channelAddress= - -``` - -Where `` is the Dapr App Id that you can use in your components (for example for scopes) - -and `` is a reachable URL where `dapr-ambient` will forward notifications received by the Dapr sidecar. - -Future versions might include forwarding notifications to multiple remote URLs. - -## Customize Dapr Ambient -Is possible to customize Dapr Ambient using custom Helm values. - -## Values - -| Key | Type | Default | Description | -|-----|------|---------|-------------| -| ambient.controlPlane.namespace | string | `"dapr-system"` | Namespace where Dapr Control Plane is. | -| ambient.daprd.apiLogging.enabled | bool | `true` | Enables API logging for the daprd. | -| ambient.daprd.app.protocol | string | `"http"` | Dapr which protocol your application is using. Valid options are `http`` and `grpc``. | -| ambient.daprd.grpcPort | int | `50001` | gRPC port for the Dapr Internal API to listen on. | -| ambient.daprd.httpPort | int | `3500` | The HTTP port for the Dapr API. | -| ambient.daprd.image.name | string | `"daprd"` | Daprd image. | -| ambient.daprd.image.pullPolicy | string | `"Always"` | Daprd image pull policy. | -| ambient.daprd.image.registry | string | `"docker.io/daprio"` | Daprd image registry. | -| ambient.daprd.image.tag | string | `"1.11.0-rc.7"` | Daprd image version. | -| ambient.daprd.internalGrpcPort | int | `50002` | gRPC port for the Dapr Internal API to listen on. | -| ambient.daprd.listenAddresses | string | `"0.0.0.0"` | Comma separated list of IP addresses that daprd will listen to. Defaults to all in standalone mode. Defaults to [::1],127.0.0.1 in Kubernetes. To listen to all IPv4 addresses, use 0.0.0.0. To listen to all IPv6 addresses, use [::]. | -| ambient.daprd.metrics.enabled | bool | `true` | Enable prometheus metric. | -| ambient.daprd.metrics.port | int | `9090` | Sets the port for the sidecar metrics server. | -| ambient.daprd.mtls.enabled | bool | `false` | Enables automatic mTLS for daprd to daprd communication channels. | -| ambient.daprd.publicPort | int | `3501` | The HTTP public port for the Dapr API. | -| ambient.daprd.token | string | `""` | Dapr API token to use for token based API authentication. | -| ambient.deployment.replicas | int | `1` | The quantity of replicas. This property is set only when `ambient.strategy` is equal to `deployment` | -| ambient.initContainer.image.name | string | `"dapr-ambient"` | The dapr-ambient image name. | -| ambient.initContainer.image.pullPolicy | string | `"Always"` | The init container pull policy. | -| ambient.initContainer.image.registry | string | `"docker.io/matheuscruzdev"` | The dapr-ambient image registry. | -| ambient.initContainer.image.tag | string | `"latest"` | The dapr-ambient-init image tag. | -| ambient.initContainer.token | string | `""` | The dapr API token. | -| ambient.log.json | bool | `true` | The daprd log format. | -| ambient.log.level | string | `"info"` | The daprd log level. | -| ambient.remotePort | int | `0` | The remote port. | -| ambient.service.type | string | `"ClusterIP"` | The daprd service type. | -| ambient.serviceAccount.annotations | object | `{}` | | -| ambient.serviceAccount.create | bool | `true` | | -| ambient.serviceAccount.name | string | `""` | | -| ambient.strategy | string | `"daemonset"` | The default strategy to run dapr in ambient mode. Possible values `daemonset`, `deployment`. | -| tolerations | list | `[]` | | - -### Building from source - -I've used the [CNCF `ko` project](https://ko.build/) to build multiplatform images for the proxy. -You can run the following command to build containers for the `dapr-ambient` proxy: - -``` -ko build --platform=linux/amd64,linux/arm64 -``` - diff --git a/chart/dapr-ambient/templates/daemonset.yaml b/chart/dapr-ambient/templates/daemonset.yaml deleted file mode 100644 index c3831c4..0000000 --- a/chart/dapr-ambient/templates/daemonset.yaml +++ /dev/null @@ -1,13 +0,0 @@ -{{- if eq .Values.ambient.strategy "daemonset" -}} -apiVersion: apps/v1 -kind: "DaemonSet" -metadata: - name: {{ include "dapr-ambient.fullname" . }} - labels: - {{- include "dapr-ambient.labels" . | nindent 4 }} -spec: - selector: - matchLabels: - {{- include "dapr-ambient.selectorLabels" . | nindent 6 }} -{{ include "daemon-deploy-shared" . }} -{{- end -}} \ No newline at end of file diff --git a/chart/dapr-ambient/templates/deployment.yaml b/chart/dapr-ambient/templates/deployment.yaml deleted file mode 100644 index 24d551c..0000000 --- a/chart/dapr-ambient/templates/deployment.yaml +++ /dev/null @@ -1,11 +0,0 @@ -{{- if eq .Values.ambient.strategy "deployment" -}} -apiVersion: apps/v1 -kind: "Deployment" -metadata: - name: {{ include "dapr-ambient.fullname" . }} - labels: - {{- include "dapr-ambient.labels" . | nindent 4 }} -spec: - replicas: {{ .Values.ambient.deployment.replicas | default "1" | int }} -{{ include "daemon-deploy-shared" . }} -{{- end -}} \ No newline at end of file diff --git a/chart/dapr-ambient/templates/secret.yaml b/chart/dapr-ambient/templates/secret.yaml deleted file mode 100644 index 48f02a0..0000000 --- a/chart/dapr-ambient/templates/secret.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: {{ include "dapr-ambient.fullname" . }} - labels: - app: {{ include "dapr-ambient.fullname" . }} -data: - dapr-api-token: {{ .Values.ambient.daprd.token | b64enc | quote }} - {{- if .Values.ambient.initContainer.token }} - app-api-token: {{ .Values.ambient.initContainer.token | b64enc | quote }} - {{- end }} \ No newline at end of file diff --git a/chart/dapr-ambient/templates/serviceaccount.yaml b/chart/dapr-ambient/templates/serviceaccount.yaml deleted file mode 100644 index 75a08b6..0000000 --- a/chart/dapr-ambient/templates/serviceaccount.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{{- if .Values.ambient.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "dapr-ambient.serviceAccountName" . }} - labels: - {{- include "dapr-ambient.labels" . | nindent 4 }} - {{- with .Values.ambient.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} diff --git a/chart/dapr-shared/Chart.yaml b/chart/dapr-shared/Chart.yaml new file mode 100644 index 0000000..f313023 --- /dev/null +++ b/chart/dapr-shared/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +description: Helm Chart For Dapr Shared Apps +name: dapr-shared-chart +version: 1.12.0 +icon: https://salaboy.files.wordpress.com/2019/07/avatar.png \ No newline at end of file diff --git a/chart/dapr-shared/README.md b/chart/dapr-shared/README.md new file mode 100644 index 0000000..eaa1170 --- /dev/null +++ b/chart/dapr-shared/README.md @@ -0,0 +1,83 @@ +# Dapr Shared + +Dapr Shared allows you to create Dapr Applications using the `daprd` Sidecar as a Kubernetes `Daemonset` or `Deployment`. This enables other use cases where Sidecars are not the best option. + +By running `daprd` as a Kubernetes `DaemonSet` (or as a `Deployment`) the `daprd` container will be running in each Kubernetes Node, reducing the network hops between the applications and Dapr. + +If you need multiple Dapr Applications you can deploy this chart multiple times using different `shared.appId`s. + +## Getting Started + +If you want to get started with Dapr Shared you can easily create a new Dapr Shared instance by install the oficial Helm Chart: + +``` +helm add repo shared https://salaboy.github.io/helm/ +helm repo update +helm install my-shard shared/dapr-shared --set shared.appId= --set shared.channelAddress= --set shared.daprd.app.port= +``` + +If you want to take a look at a step by step tutorial using some applications and interacting with Dapr Components check out the [step-by-step tutorial using Kubernetes KinD here](tutorial/README.md). + +## From Source + +To deploy this chart from source you can run from inside the `chart/dapr-shared` directory: + +``` +helm install my-shared . --set shared.appId= --set shared.channelAddress= + +``` + +Where `` is the Dapr App Id that you can use in your components (for example for scopes) + +and `` is a reachable URL where `dapr-shared` will forward notifications received by the Dapr sidecar. + +Future versions might include forwarding notifications to multiple remote URLs. + +## Customize Dapr Shared +Is possible to customize Dapr Shared using custom Helm values. + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| shared.controlPlane.namespace | string | `"dapr-system"` | Namespace where Dapr Control Plane is. | +| shared.daprd.apiLogging.enabled | bool | `true` | Enables API logging for the daprd. | +| shared.daprd.app.protocol | string | `"http"` | Dapr which protocol your application is using. Valid options are `http`` and `grpc``. | +| shared.daprd.grpcPort | int | `50001` | gRPC port for the Dapr Internal API to listen on. | +| shared.daprd.httpPort | int | `3500` | The HTTP port for the Dapr API. | +| shared.daprd.image.name | string | `"daprd"` | Daprd image. | +| shared.daprd.image.pullPolicy | string | `"Always"` | Daprd image pull policy. | +| shared.daprd.image.registry | string | `"docker.io/daprio"` | Daprd image registry. | +| shared.daprd.image.tag | string | `"1.11.0-rc.7"` | Daprd image version. | +| shared.daprd.internalGrpcPort | int | `50002` | gRPC port for the Dapr Internal API to listen on. | +| shared.daprd.listenAddresses | string | `"0.0.0.0"` | Comma separated list of IP addresses that daprd will listen to. Defaults to all in standalone mode. Defaults to [::1],127.0.0.1 in Kubernetes. To listen to all IPv4 addresses, use 0.0.0.0. To listen to all IPv6 addresses, use [::]. | +| shared.daprd.metrics.enabled | bool | `true` | Enable prometheus metric. | +| shared.daprd.metrics.port | int | `9090` | Sets the port for the sidecar metrics server. | +| shared.daprd.mtls.enabled | bool | `false` | Enables automatic mTLS for daprd to daprd communication channels. | +| shared.daprd.publicPort | int | `3501` | The HTTP public port for the Dapr API. | +| shared.daprd.token | string | `""` | Dapr API token to use for token based API authentication. | +| shared.deployment.replicas | int | `1` | The quantity of replicas. This property is set only when `shared.strategy` is equal to `deployment` | +| shared.initContainer.image.name | string | `"dapr-shared"` | The dapr-shared image name. | +| shared.initContainer.image.pullPolicy | string | `"Always"` | The init container pull policy. | +| shared.initContainer.image.registry | string | `"docker.io/matheuscruzdev"` | The dapr-shared image registry. | +| shared.initContainer.image.tag | string | `"latest"` | The dapr-shared-init image tag. | +| shared.initContainer.token | string | `""` | The dapr API token. | +| shared.log.json | bool | `true` | The daprd log format. | +| shared.log.level | string | `"info"` | The daprd log level. | +| shared.remotePort | int | `0` | The remote port. | +| shared.service.type | string | `"ClusterIP"` | The daprd service type. | +| shared.serviceAccount.annotations | object | `{}` | | +| shared.serviceAccount.create | bool | `true` | | +| shared.serviceAccount.name | string | `""` | | +| shared.strategy | string | `"daemonset"` | The default strategy to run dapr in shared mode. Possible values `daemonset`, `deployment`. | +| tolerations | list | `[]` | | + +### Building from source + +I've used the [CNCF `ko` project](https://ko.build/) to build multiplatform images for the proxy. +You can run the following command to build containers for the `dapr-shared` proxy: + +``` +ko build --platform=linux/amd64,linux/arm64 +``` + diff --git a/chart/dapr-ambient/README.md.gotmpl b/chart/dapr-shared/README.md.gotmpl similarity index 54% rename from chart/dapr-ambient/README.md.gotmpl rename to chart/dapr-shared/README.md.gotmpl index 815a01b..1ebfd23 100644 --- a/chart/dapr-ambient/README.md.gotmpl +++ b/chart/dapr-shared/README.md.gotmpl @@ -1,21 +1,21 @@ -# Dapr Ambient +# Dapr Shared -Dapr Ambient allows you to create Dapr Applications using the `daprd` Sidecar as a Kubernetes `Daemonset` or `Deployment`. This enables other use cases where Sidecars are not the best option. +Dapr Shared allows you to create Dapr Applications using the `daprd` Sidecar as a Kubernetes `Daemonset` or `Deployment`. This enables other use cases where Sidecars are not the best option. By running `daprd` as a Kubernetes `DaemonSet` (or as a `Deployment`) the `daprd` container will be running in each Kubernetes Node, reducing the network hops between the applications and Dapr. -If you need multiple Dapr Applications you can deploy this chart multiple times using different `ambient.appId`s. +If you need multiple Dapr Applications you can deploy this chart multiple times using different `shared.appId`s. ## Getting Started -If you want to get started with Dapr Ambient you can easily create a new Dapr Ambient instance by install the oficial Helm Chart: +If you want to get started with Dapr Shared you can easily create a new Dapr Shared instance by install the oficial Helm Chart: ``` -helm add repo ambient https://salaboy.github.io/helm/ +helm add repo shared https://salaboy.github.io/helm/ helm repo update -helm install my-ambient amabient/dapr-ambient --set ambient.appId= --set ambient.channelAddress= --set ambient.daprd.app.port= +helm install my-shared amabient/dapr-shared --set shared.appId= --set shared.channelAddress= --set shared.daprd.app.port= ``` If you want to take a look at a step by step tutorial using some applications and interacting with Dapr Components check out the [step-by-step tutorial using Kubernetes KinD here](tutorial/README.md). @@ -23,22 +23,22 @@ If you want to take a look at a step by step tutorial using some applications an ## From Source -To deploy this chart from source you can run from inside the `chart/dapr-ambient` directory: +To deploy this chart from source you can run from inside the `chart/dapr-shared` directory: ``` -helm install my-ambient . --set ambient.appId= --set ambient.channelAddress= +helm install my-shared . --set shared.appId= --set shared.channelAddress= ``` Where `` is the Dapr App Id that you can use in your components (for example for scopes) -and `` is a reachable URL where `dapr-ambient` will forward notifications received by the Dapr sidecar. +and `` is a reachable URL where `dapr-shared` will forward notifications received by the Dapr sidecar. Future versions might include forwarding notifications to multiple remote URLs. -## Customize Dapr Ambient -Is possible to customize Dapr Ambient using custom Helm values. +## Customize Dapr Shared +Is possible to customize Dapr Shared using custom Helm values. {{ template "chart.requirementsSection" . }} @@ -49,7 +49,7 @@ Is possible to customize Dapr Ambient using custom Helm values. ### Building from source I've used the [CNCF `ko` project](https://ko.build/) to build multiplatform images for the proxy. -You can run the following command to build containers for the `dapr-ambient` proxy: +You can run the following command to build containers for the `dapr-shared` proxy: ``` ko build --platform=linux/amd64,linux/arm64 diff --git a/chart/dapr-ambient/templates/_daemondeployshared.yaml b/chart/dapr-shared/templates/_daemondeployshared.yaml similarity index 52% rename from chart/dapr-ambient/templates/_daemondeployshared.yaml rename to chart/dapr-shared/templates/_daemondeployshared.yaml index b2e6175..0e00319 100644 --- a/chart/dapr-ambient/templates/_daemondeployshared.yaml +++ b/chart/dapr-shared/templates/_daemondeployshared.yaml @@ -6,7 +6,7 @@ {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "dapr-ambient.selectorLabels" . | nindent 8 }} + {{- include "dapr-shared.selectorLabels" . | nindent 8 }} spec: volumes: - name: shared-data @@ -15,12 +15,12 @@ imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} - serviceAccountName: {{ include "dapr-ambient.serviceAccountName" . }} + serviceAccountName: {{ include "dapr-shared.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} initContainers: - - name: ambient-init-container - image: "{{ .Values.ambient.initContainer.image.registry }}/{{ .Values.ambient.initContainer.image.name }}:{{ .Values.ambient.initContainer.image.tag }}" + - name: shared-init-container + image: "{{ .Values.shared.initContainer.image.registry }}/{{ .Values.shared.initContainer.image.name }}:{{ .Values.shared.initContainer.image.tag }}" args: - init - --config-map={{ .Release.Name }}-cm @@ -28,29 +28,29 @@ - name: daprd securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.ambient.daprd.image.registry }}/{{ .Values.ambient.daprd.image.name }}:{{ .Values.ambient.daprd.image.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.ambient.daprd.image.pullPolicy }} + image: "{{ .Values.shared.daprd.image.registry }}/{{ .Values.shared.daprd.image.name }}:{{ .Values.shared.daprd.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.shared.daprd.image.pullPolicy }} args: - /daprd - --mode=kubernetes - - --log-level={{ .Values.ambient.log.level }} - - --log-as-json={{ .Values.ambient.log.json }} - - --dapr-http-port={{ .Values.ambient.daprd.httpPort }} - - --dapr-grpc-port={{ .Values.ambient.daprd.grpcPort }} - - --dapr-internal-grpc-port={{ .Values.ambient.daprd.internalGrpcPort }} - - --dapr-listen-addresses={{ .Values.ambient.daprd.listenAddresses }} - - --dapr-public-port={{ .Values.ambient.daprd.publicPort }} - - --app-id={{ required ".Values.ambient.appId is required" .Values.ambient.appId }} - - --app-port={{ required ".Values.ambient.remotePort is required" .Values.ambient.remotePort }} - - --app-protocol={{ required ".Values.ambient.daprd.app.protocol is required" .Values.ambient.daprd.app.protocol }} - - --control-plane-address={{ default "dapr-api.dapr-system.svc.cluster.local:80" .Values.ambient.controlPlane.operatorAddress }} - - --placement-host-address={{ default "dapr-placement-server.dapr-system.svc.cluster.local:50005" .Values.ambient.controlPlane.placementServerAddress }} - - --sentry-address={{ default "dapr-sentry.dapr-system.svc.cluster.local" .Values.ambient.controlPlane.sentryAddress }} - - --enable-metrics={{ .Values.ambient.daprd.metrics.enabled }} - - --metrics-port={{ .Values.ambient.daprd.metrics.port }} - - --enable-mtls={{ .Values.ambient.daprd.mtls.enabled }} - - --enable-api-logging={{ .Values.ambient.daprd.apiLogging.enabled }} - - --app-channel-address={{ .Values.ambient.remoteURL }} + - --log-level={{ .Values.shared.log.level }} + - --log-as-json={{ .Values.shared.log.json }} + - --dapr-http-port={{ .Values.shared.daprd.httpPort }} + - --dapr-grpc-port={{ .Values.shared.daprd.grpcPort }} + - --dapr-internal-grpc-port={{ .Values.shared.daprd.internalGrpcPort }} + - --dapr-listen-addresses={{ .Values.shared.daprd.listenAddresses }} + - --dapr-public-port={{ .Values.shared.daprd.publicPort }} + - --app-id={{ required ".Values.shared.appId is required" .Values.shared.appId }} + - --app-port={{ required ".Values.shared.remotePort is required" .Values.shared.remotePort }} + - --app-protocol={{ required ".Values.shared.daprd.app.protocol is required" .Values.shared.daprd.app.protocol }} + - --control-plane-address={{ default "dapr-api.dapr-system.svc.cluster.local:80" .Values.shared.controlPlane.operatorAddress }} + - --placement-host-address={{ default "dapr-placement-server.dapr-system.svc.cluster.local:50005" .Values.shared.controlPlane.placementServerAddress }} + - --sentry-address={{ default "dapr-sentry.dapr-system.svc.cluster.local" .Values.shared.controlPlane.sentryAddress }} + - --enable-metrics={{ .Values.shared.daprd.metrics.enabled }} + - --metrics-port={{ .Values.shared.daprd.metrics.port }} + - --enable-mtls={{ .Values.shared.daprd.mtls.enabled }} + - --enable-api-logging={{ .Values.shared.daprd.apiLogging.enabled }} + - --app-channel-address={{ .Values.shared.remoteURL }} env: - name: DAPR_TRUST_ANCHORS valueFrom: @@ -68,17 +68,17 @@ name: {{ .Release.Name }}-cm key: dapr-cert-key - name: DAPR_CONTROL_PLANE_NAMESPACE - value: {{ default "dapr-system" .Values.ambient.controlPlane.namespace }} + value: {{ default "dapr-system" .Values.shared.controlPlane.namespace }} - name: DAPR_API_TOKEN valueFrom: secretKeyRef: - name: {{ include "dapr-ambient.fullname" . }} + name: {{ include "dapr-shared.fullname" . }} key: dapr-api-token - {{- if .Values.ambient.daprd.app.token }} + {{- if .Values.shared.daprd.app.token }} - name: APP_API_TOKEN valueFrom: secretKeyRef: - name: {{ include "dapr-ambient.fullname" . }} + name: {{ include "dapr-shared.fullname" . }} key: app-api-token {{- end }} - name: NAMESPACE @@ -91,19 +91,19 @@ fieldPath: metadata.name ports: - name: http - containerPort: {{ .Values.ambient.daprd.httpPort }} + containerPort: {{ .Values.shared.daprd.httpPort }} protocol: TCP - name: grpc - containerPort: {{ .Values.ambient.daprd.grpcPort }} + containerPort: {{ .Values.shared.daprd.grpcPort }} protocol: TCP - name: internal-grpc - containerPort: {{ .Values.ambient.daprd.internalGrpcPort }} + containerPort: {{ .Values.shared.daprd.internalGrpcPort }} protocol: TCP - name: public-http - containerPort: {{ .Values.ambient.daprd.publicPort }} + containerPort: {{ .Values.shared.daprd.publicPort }} protocol: TCP - name: metrics - containerPort: {{ .Values.ambient.daprd.metrics.port }} + containerPort: {{ .Values.shared.daprd.metrics.port }} protocol: TCP livenessProbe: httpGet: diff --git a/chart/dapr-ambient/templates/_helpers.tpl b/chart/dapr-shared/templates/_helpers.tpl similarity index 67% rename from chart/dapr-ambient/templates/_helpers.tpl rename to chart/dapr-shared/templates/_helpers.tpl index 4874d1b..9cb7900 100644 --- a/chart/dapr-ambient/templates/_helpers.tpl +++ b/chart/dapr-shared/templates/_helpers.tpl @@ -1,7 +1,7 @@ {{/* Expand the name of the chart. */}} -{{- define "dapr-ambient.name" -}} +{{- define "dapr-shared.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} @@ -10,7 +10,7 @@ Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). If release name contains chart name it will be used as a full name. */}} -{{- define "dapr-ambient.fullname" -}} +{{- define "dapr-shared.fullname" -}} {{- if .Values.fullnameOverride }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- else }} @@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name. {{/* Create chart name and version as used by the chart label. */}} -{{- define "dapr-ambient.chart" -}} +{{- define "dapr-shared.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Common labels */}} -{{- define "dapr-ambient.labels" -}} -helm.sh/chart: {{ include "dapr-ambient.chart" . }} -{{ include "dapr-ambient.selectorLabels" . }} +{{- define "dapr-shared.labels" -}} +helm.sh/chart: {{ include "dapr-shared.chart" . }} +{{ include "dapr-shared.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} @@ -45,18 +45,18 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{/* Selector labels */}} -{{- define "dapr-ambient.selectorLabels" -}} -app.kubernetes.io/name: {{ include "dapr-ambient.name" . }} +{{- define "dapr-shared.selectorLabels" -}} +app.kubernetes.io/name: {{ include "dapr-shared.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} {{/* Create the name of the service account to use */}} -{{- define "dapr-ambient.serviceAccountName" -}} -{{- if .Values.ambient.serviceAccount.create }} -{{- default (include "dapr-ambient.fullname" .) .Values.ambient.serviceAccount.name }} +{{- define "dapr-shared.serviceAccountName" -}} +{{- if .Values.shared.serviceAccount.create }} +{{- default (include "dapr-shared.fullname" .) .Values.shared.serviceAccount.name }} {{- else }} -{{- default "default" .Values.ambient.serviceAccount.name }} +{{- default "default" .Values.shared.serviceAccount.name }} {{- end }} {{- end }} diff --git a/chart/dapr-shared/templates/daemonset.yaml b/chart/dapr-shared/templates/daemonset.yaml new file mode 100644 index 0000000..0514513 --- /dev/null +++ b/chart/dapr-shared/templates/daemonset.yaml @@ -0,0 +1,13 @@ +{{- if eq .Values.shared.strategy "daemonset" -}} +apiVersion: apps/v1 +kind: "DaemonSet" +metadata: + name: {{ include "dapr-shared.fullname" . }} + labels: + {{- include "dapr-shared.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "dapr-shared.selectorLabels" . | nindent 6 }} +{{ include "daemon-deploy-shared" . }} +{{- end -}} \ No newline at end of file diff --git a/chart/dapr-shared/templates/deployment.yaml b/chart/dapr-shared/templates/deployment.yaml new file mode 100644 index 0000000..8c06023 --- /dev/null +++ b/chart/dapr-shared/templates/deployment.yaml @@ -0,0 +1,11 @@ +{{- if eq .Values.shared.strategy "deployment" -}} +apiVersion: apps/v1 +kind: "Deployment" +metadata: + name: {{ include "dapr-shared.fullname" . }} + labels: + {{- include "dapr-shared.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.shared.deployment.replicas | default "1" | int }} +{{ include "daemon-deploy-shared" . }} +{{- end -}} \ No newline at end of file diff --git a/chart/dapr-ambient/templates/helmhooks.yaml b/chart/dapr-shared/templates/helmhooks.yaml similarity index 60% rename from chart/dapr-ambient/templates/helmhooks.yaml rename to chart/dapr-shared/templates/helmhooks.yaml index c0d4747..5d2a752 100644 --- a/chart/dapr-ambient/templates/helmhooks.yaml +++ b/chart/dapr-shared/templates/helmhooks.yaml @@ -1,9 +1,9 @@ apiVersion: v1 kind: Pod metadata: - name: {{ include "dapr-ambient.fullname" . }}-hook + name: {{ include "dapr-shared.fullname" . }}-hook labels: - {{- include "dapr-ambient.labels" . | nindent 4 }} + {{- include "dapr-shared.labels" . | nindent 4 }} annotations: "helm.sh/hook": pre-delete "helm.sh/hook-delete-policy": hook-succeeded @@ -13,10 +13,10 @@ spec: # {{default "Never" .restartPolicy}} is a slightly optimized version of the # more conventional syntax: {{.restartPolicy | default "Never"}} restartPolicy: "Never" - serviceAccountName: {{ include "dapr-ambient.serviceAccountName" . }} + serviceAccountName: {{ include "dapr-shared.serviceAccountName" . }} containers: - - name: ambient-remove-hook - image: "{{ .Values.ambient.initContainer.image.registry }}/{{ .Values.ambient.initContainer.image.name }}:{{ .Values.ambient.initContainer.image.tag }}" + - name: shared-remove-hook + image: "{{ .Values.shared.initContainer.image.registry }}/{{ .Values.shared.initContainer.image.name }}:{{ .Values.shared.initContainer.image.tag }}" args: - remove - --config-map={{ .Release.Name }}-cm diff --git a/chart/dapr-ambient/templates/rbac.yaml b/chart/dapr-shared/templates/rbac.yaml similarity index 65% rename from chart/dapr-ambient/templates/rbac.yaml rename to chart/dapr-shared/templates/rbac.yaml index 676406b..67dc5d7 100644 --- a/chart/dapr-ambient/templates/rbac.yaml +++ b/chart/dapr-shared/templates/rbac.yaml @@ -1,8 +1,8 @@ -{{- if not (lookup "rbac.authorization.k8s.io/v1" "ClusterRole" "" "dapr-ambient-secret-reader") }} +{{- if not (lookup "rbac.authorization.k8s.io/v1" "ClusterRole" "" "dapr-shared-secret-reader") }} kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: dapr-ambient-secret-reader + name: dapr-shared-secret-reader rules: - apiGroups: [""] resources: ["secrets"] @@ -12,21 +12,21 @@ rules: kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: {{ include "dapr-ambient.fullname" . }}-secret-reader + name: {{ include "dapr-shared.fullname" . }}-secret-reader subjects: - kind: ServiceAccount - name: {{ include "dapr-ambient.serviceAccountName" . }} + name: {{ include "dapr-shared.serviceAccountName" . }} namespace: {{ .Release.Namespace }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: dapr-ambient-secret-reader + name: dapr-shared-secret-reader --- -{{- if not (lookup "rbac.authorization.k8s.io/v1" "ClusterRole" "" "dapr-ambient-configmap-creator") }} +{{- if not (lookup "rbac.authorization.k8s.io/v1" "ClusterRole" "" "dapr-shared-configmap-creator") }} kind: ClusterRole apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: dapr-ambient-configmap-creator + name: dapr-shared-configmap-creator rules: - apiGroups: [""] resources: ["configmaps"] @@ -36,12 +36,12 @@ rules: kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: {{ include "dapr-ambient.fullname" . }}-configmap-creator + name: {{ include "dapr-shared.fullname" . }}-configmap-creator subjects: - kind: ServiceAccount - name: {{ include "dapr-ambient.serviceAccountName" . }} + name: {{ include "dapr-shared.serviceAccountName" . }} namespace: {{ .Release.Namespace }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: dapr-ambient-configmap-creator \ No newline at end of file + name: dapr-shared-configmap-creator \ No newline at end of file diff --git a/chart/dapr-shared/templates/secret.yaml b/chart/dapr-shared/templates/secret.yaml new file mode 100644 index 0000000..60dfa7e --- /dev/null +++ b/chart/dapr-shared/templates/secret.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "dapr-shared.fullname" . }} + labels: + app: {{ include "dapr-shared.fullname" . }} +data: + dapr-api-token: {{ .Values.shared.daprd.token | b64enc | quote }} + {{- if .Values.shared.initContainer.token }} + app-api-token: {{ .Values.shared.initContainer.token | b64enc | quote }} + {{- end }} \ No newline at end of file diff --git a/chart/dapr-ambient/templates/service.yaml b/chart/dapr-shared/templates/service.yaml similarity index 70% rename from chart/dapr-ambient/templates/service.yaml rename to chart/dapr-shared/templates/service.yaml index 6986457..93c3fdc 100644 --- a/chart/dapr-ambient/templates/service.yaml +++ b/chart/dapr-shared/templates/service.yaml @@ -3,9 +3,9 @@ kind: Service metadata: name: {{ .Release.Name }} labels: - {{- include "dapr-ambient.labels" . | nindent 4 }} + {{- include "dapr-shared.labels" . | nindent 4 }} spec: - type: {{ default "ClusterIP" .Values.ambient.service.type }} + type: {{ default "ClusterIP" .Values.shared.service.type }} ports: - name: dapr-http port: 80 @@ -24,4 +24,4 @@ spec: protocol: TCP targetPort: 9090 selector: - {{- include "dapr-ambient.selectorLabels" . | nindent 4 }} + {{- include "dapr-shared.selectorLabels" . | nindent 4 }} diff --git a/chart/dapr-shared/templates/serviceaccount.yaml b/chart/dapr-shared/templates/serviceaccount.yaml new file mode 100644 index 0000000..9b3181c --- /dev/null +++ b/chart/dapr-shared/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.shared.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "dapr-shared.serviceAccountName" . }} + labels: + {{- include "dapr-shared.labels" . | nindent 4 }} + {{- with .Values.shared.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/chart/dapr-ambient/tests/daemonset_test.yaml b/chart/dapr-shared/tests/daemonset_test.yaml similarity index 96% rename from chart/dapr-ambient/tests/daemonset_test.yaml rename to chart/dapr-shared/tests/daemonset_test.yaml index 8350f78..e882e21 100644 --- a/chart/dapr-ambient/tests/daemonset_test.yaml +++ b/chart/dapr-shared/tests/daemonset_test.yaml @@ -3,26 +3,26 @@ suite: test daemonset templates: - daemonset.yaml tests: - - it: when the ambient.strategy is daemonset should be create the daemonset resource + - it: when the shared.strategy is daemonset should be create the daemonset resource values: - ./values/required.yaml set: - ambient.strategy: daemonset + shared.strategy: daemonset asserts: - isAPIVersion: of: apps/v1 - - it: should fail if ambient.appId is not defined + - it: should fail if shared.appId is not defined set: - ambient.remoteURL: https://local + shared.remoteURL: https://local asserts: - failedTemplate: - errorMessage: .Values.ambient.appId is required + errorMessage: .Values.shared.appId is required - - it: should not fail if ambient.appId is defined + - it: should not fail if shared.appId is defined set: - ambient.remoteURL: https://local - ambient.appId: appId + shared.remoteURL: https://local + shared.appId: appId asserts: - matchRegex: path: spec.template.spec.containers[0].args[9] diff --git a/chart/dapr-ambient/tests/deployment_test.yaml b/chart/dapr-shared/tests/deployment_test.yaml similarity index 71% rename from chart/dapr-ambient/tests/deployment_test.yaml rename to chart/dapr-shared/tests/deployment_test.yaml index 6dd0e61..8af1820 100644 --- a/chart/dapr-ambient/tests/deployment_test.yaml +++ b/chart/dapr-shared/tests/deployment_test.yaml @@ -3,20 +3,20 @@ suite: test deplyment templates: - deployment.yaml tests: - - it: when the ambient.strategy is deployment should not create the daemonset resource + - it: when the shared.strategy is deployment should not create the daemonset resource values: - ./values/required.yaml set: - ambient: + shared: strategy: "deployment" asserts: - isKind: of: "Deployment" - - it: when ambient.deployment.replicas is null the quantity of replicas should be 1 + - it: when shared.deployment.replicas is null the quantity of replicas should be 1 values: - ./values/required.yaml set: - ambient: + shared: strategy: deployment deployment: replicas: @@ -25,12 +25,12 @@ tests: path: spec.replicas value: 1 - it: | - when ambient.deployment.replicas is 3 and ambient.strategy is deployment the + when shared.deployment.replicas is 3 and shared.strategy is deployment the spec.replicas filed should be 3 values: - ./values/required.yaml set: - ambient: + shared: strategy: deployment deployment: replicas: 3 diff --git a/chart/dapr-ambient/tests/service_test.yaml b/chart/dapr-shared/tests/service_test.yaml similarity index 83% rename from chart/dapr-ambient/tests/service_test.yaml rename to chart/dapr-shared/tests/service_test.yaml index 21acb95..05be6c2 100644 --- a/chart/dapr-ambient/tests/service_test.yaml +++ b/chart/dapr-shared/tests/service_test.yaml @@ -7,7 +7,7 @@ tests: values: - ./values/required.yaml set: - ambient: + shared: service: type: "ClusterIP" asserts: @@ -15,11 +15,11 @@ tests: path: spec.type value: "ClusterIP" - - it: should set the service type when the .Values.ambient.service.type is empty + - it: should set the service type when the .Values.shared.service.type is empty values: - ./values/required.yaml set: - ambient: + shared: service: type: asserts: diff --git a/chart/dapr-ambient/tests/values/required.yaml b/chart/dapr-shared/tests/values/required.yaml similarity index 87% rename from chart/dapr-ambient/tests/values/required.yaml rename to chart/dapr-shared/tests/values/required.yaml index 6d6beec..b50aad8 100644 --- a/chart/dapr-ambient/tests/values/required.yaml +++ b/chart/dapr-shared/tests/values/required.yaml @@ -1,4 +1,4 @@ -ambient: +shared: appId: appId strategy: daemonset remoteURL: https://local \ No newline at end of file diff --git a/chart/dapr-ambient/values.yaml b/chart/dapr-shared/values.yaml similarity index 88% rename from chart/dapr-ambient/values.yaml rename to chart/dapr-shared/values.yaml index e41978b..3fea7f2 100644 --- a/chart/dapr-ambient/values.yaml +++ b/chart/dapr-shared/values.yaml @@ -1,11 +1,11 @@ -fullnameOverride: dapr-ambient -ambient: - # -- The default strategy to run dapr in ambient mode. Possible values `daemonset`, `deployment`. +fullnameOverride: dapr-shared +shared: + # -- The default strategy to run dapr in shared mode. Possible values `daemonset`, `deployment`. strategy: daemonset # -- The remote port. remotePort: 0 deployment: - # -- The quantity of replicas. This property is set only when `ambient.strategy` is equal to `deployment` + # -- The quantity of replicas. This property is set only when `shared.strategy` is equal to `deployment` replicas: 1 log: # -- The daprd log level. @@ -29,11 +29,11 @@ ambient: # -- The dapr API token. token: "" image: - # -- The dapr-ambient image registry. + # -- The dapr-shared image registry. registry: "docker.io/daprio" - # -- The dapr-ambient image name. - name: dapr-ambient - # -- The dapr-ambient-init image tag. + # -- The dapr-shared image name. + name: dapr-shared + # -- The dapr-shared-init image tag. tag: latest # -- The init container pull policy. pullPolicy: Always diff --git a/cmd/ambient-init/main.go b/cmd/shared-init/main.go similarity index 95% rename from cmd/ambient-init/main.go rename to cmd/shared-init/main.go index 0a5244c..6ede5d5 100644 --- a/cmd/ambient-init/main.go +++ b/cmd/shared-init/main.go @@ -27,7 +27,7 @@ const ( var configMapName string func main() { - log.Println("executing dapr-ambient-init") + log.Println("executing dapr-shared-init") rootCmd := NewRootCmd() rootCmd.Execute() } @@ -67,7 +67,7 @@ func (s *daprSidecarClient) Get(ctx context.Context, ns string) (string, string, func NewRootCmd() *cobra.Command { rootCmd := &cobra.Command{ - Use: "ambient-init", + Use: "shared-init", } rootCmd.AddCommand(NewInitCmd()) rootCmd.AddCommand(NewRemoveCmd()) @@ -83,7 +83,7 @@ func NewInitCmd() *cobra.Command { }, } - initCmd.PersistentFlags().StringVar(&configMapName, "config-map", "dapr-ambient-configmap", "--config-map=value") + initCmd.PersistentFlags().StringVar(&configMapName, "config-map", "dapr-shared-configmap", "--config-map=value") _ = initCmd.MarkPersistentFlagRequired("config-map") return initCmd @@ -98,7 +98,7 @@ func NewRemoveCmd() *cobra.Command { }, } - removeCmd.PersistentFlags().StringVar(&configMapName, "config-map", "dapr-ambient-configmap", "--config-map=value") + removeCmd.PersistentFlags().StringVar(&configMapName, "config-map", "dapr-shared-configmap", "--config-map=value") _ = removeCmd.MarkPersistentFlagRequired("config-map") return removeCmd diff --git a/go.mod b/go.mod index 79d6c0c..6a222e7 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/salaboy/dapr-ambient +module github.com/salaboy/dapr-shared go 1.19 diff --git a/tutorial/README.md b/tutorial/README.md index 23d4feb..c951d11 100644 --- a/tutorial/README.md +++ b/tutorial/README.md @@ -1,9 +1,9 @@ -# Dapr Ambient with KinD -This tutorial provides step-by-step instructions for installing Dapr Ambient and configuring a set of applications to work with it. +# Dapr Shared with KinD +This tutorial provides step-by-step instructions for installing Dapr Shared and configuring a set of applications to work with it. ## Prerequisites and Installation -Before proceeding, please make sure that you have the necessary tools installed on your system. We will create a local KinD cluster to install Dapr, some applications, and an instance of Dapr Ambient. +Before proceeding, please make sure that you have the necessary tools installed on your system. We will create a local KinD cluster to install Dapr, some applications, and an instance of Dapr Shared. To get started, make sure you have the following CLIs installed: @@ -22,7 +22,7 @@ To get started, make sure you have the following CLIs installed: Here, you will create a simple Kubernetes cluster with KinD defaults running the following command: ```bash - kind create cluster --name dapr-ambient + kind create cluster --name dapr-shared ``` ## Installing Redis into the KinD cluster: @@ -41,7 +41,7 @@ Finally, let's install the Dapr Control Plane: helm repo add dapr https://dapr.github.io/helm-charts/ helm repo update helm upgrade --install dapr dapr/dapr \ - --version=1.11.0 \ + --version=1.12.3 \ --namespace dapr-system \ --create-namespace \ --wait @@ -121,24 +121,24 @@ spec: EOF ``` -## Installing Dapr Ambient and all applications +## Installing Dapr Shared and all applications -Finally, let's install Dapr Ambient and three applications that uses the Dapr StateStore and PubSub components. +Finally, let's install Dapr Shared and three applications that uses the Dapr StateStore and PubSub components. -Install Dapr Ambient Helm Chart running this: +Install Dapr Shared Helm Chart running this: ```sh - helm install my-ambient oci://docker.io/daprio/dapr-ambient-chart --set ambient.appId=my-dapr-app --set ambient.remoteURL=subscriber-svc --set ambient.remotePort=80 + helm install my-dapr-shared oci://docker.io/daprio/dapr-shared-chart --set shared.appId=my-dapr-app --set shared.remoteURL=subscriber-svc --set shared.remotePort=80 ``` -Now that we have the Dapr control plane, Redis, the PubSub and StateStore component, and our Dapr Ambient instance, let's deploy the example apps: +Now that we have the Dapr control plane, Redis, the PubSub and StateStore component, and our Dapr Shared instance, let's deploy the example apps: These are standard Kubernetes applications, using `Deployments` and `Services`. ```sh - kubectl apply -f https://raw.githubusercontent.com/salaboy/dapr-ambient-examples/main/apps.yaml + kubectl apply -f https://raw.githubusercontent.com/salaboy/dapr-shared-examples/main/apps.yaml ``` -If you want to see the implementation's detail, you [can access this repository](https://github.com/salaboy/dapr-ambient-examples). +If you want to see the implementation's detail, you [can access this repository](https://github.com/salaboy/dapr-shared-examples). ### Storing data using the write-values application @@ -157,7 +157,7 @@ Now you can send an HTTP request to the application: You can see the log using `kubectl logs -f ` -At this point the `subscriber` application has received the notification from `dapr-ambient`. You can see this, with the same way, using `kubectl logs -f `. +At this point the `subscriber` application has received the notification from `dapr-shared`. You can see this, with the same way, using `kubectl logs -f `. ### Getting the message on the subscriber application @@ -215,5 +215,5 @@ The response should look like it: ## Get involved -If you want to contribute to Dapr Ambient please get in touch, create an issue, or submit a Pull Request. +If you want to contribute to Dapr Shared please get in touch, create an issue, or submit a Pull Request. You can also check the Project Roadmap to see what is coming or to find out how you can help us to get the next version done.