Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/dapr/dashboard
Browse files Browse the repository at this point in the history
# Conflicts:
#	web/package-lock.json

Signed-off-by: HueiFeng <[email protected]>
  • Loading branch information
hueifeng committed Feb 22, 2024
2 parents d7ca84c + 298a16a commit ec87984
Show file tree
Hide file tree
Showing 38 changed files with 7,160 additions and 4,565 deletions.
45 changes: 45 additions & 0 deletions .github/scripts/set_helm_dapr_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
#
# Copyright 2021 The Dapr Authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

replace_all() {
SUBSTRING=$1
CONTENT=$2
FILES=`grep -Hrl $SUBSTRING chart`
for file in $FILES; do
echo "Replacing \"$SUBSTRING\" with \"$CONTENT\" in $file ..."
if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
sed -i '' -e "s/$SUBSTRING/$CONTENT/" "$file"
else
# Linux
sed -e "s/$SUBSTRING/$CONTENT/" -i "$file"
fi
done
}


if [ -z $REL_VERSION ]; then
echo "REL_VERSION is not set. Exiting ..."
exit 1
fi

DAPR_VERSION_HELM="${REL_VERSION}"
DAPR_VERSION_TAG="${REL_VERSION}"
if [[ "$REL_VERSION" == "edge" || "$REL_VERSION" == "nightly"* ]]; then
DAPR_VERSION_HELM="0.0.0"
fi

replace_all "'edge'" "'$DAPR_VERSION_TAG'"
replace_all "'0.0.0'" "'$DAPR_VERSION_HELM'"
116 changes: 114 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries
runs-on: ${{ matrix.os }}
env:
GOVER: 1.17
GOLANGCILINT_VER: 1.26.0
GOVER: 1.19
GOLANGCILINT_VER: 1.50.1
GOOS: ${{ matrix.target_os }}
GOARCH: ${{ matrix.target_arch }}
GOPROXY: https://proxy.golang.org
Expand Down Expand Up @@ -214,3 +214,115 @@ jobs:
run: |
echo "Build docker multiarch image manifest and push it"
make docker-publish DAPR_REGISTRY=ghcr.io/${{ github.repository_owner }} DAPR_TAG=${{ env.REL_VERSION }}
helm-build:
name: Builds Helm chart
env:
HELM_PACKAGE_DIR: helm
HELMVER: v3.7.2
DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
ARTIFACT_DIR: ./helm_release
DAPR_VERSION_ARTIFACT: dapr_version
runs-on: ubuntu-latest
steps:
- name: Set up Helm ${{ env.HELMVER }}
uses: azure/setup-helm@v1
with:
version: ${{ env.HELMVER }}
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Parse release version and set REL_VERSION and LATEST_RELEASE
run: python ./.github/scripts/get_release_version.py ${{ github.event_name }}
- name: Set REPO_OWNER
shell: bash
run: |
REPO_OWNER=${{ github.repository_owner }}
# Lowercase the value
echo "REPO_OWNER=${REPO_OWNER,,}" >>${GITHUB_ENV}
- name: Update Helm chart files for release version ${{ env.REL_VERSION }}
run: ./.github/scripts/set_helm_dapr_version.sh
- name: Generate Helm chart manifest
if: env.DOCKER_REGISTRY != ''
env:
DAPR_REGISTRY: ${{ env.DOCKER_REGISTRY }}
DAPR_TAG: ${{ env.REL_VERSION }}
run: |
make manifest-gen
shell: bash
- name: Move Helm chart manifest to artifact
if: env.DOCKER_REGISTRY != ''
run: |
mkdir -p ${{ env.ARTIFACT_DIR }}
mv ./release/install/dapr-dashboard.yaml ${{ env.ARTIFACT_DIR }}/dapr-dashboard.yaml
- name: Save release version
run: |
mkdir -p ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
echo ${REL_VERSION} > ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}/${{ env.DAPR_VERSION_ARTIFACT }}
- name: Package Helm chart
if: ${{ env.LATEST_RELEASE }} == "true" && env.DOCKER_REGISTRY != ''
env:
HELM_CHARTS_DIR: chart/dapr-dashboard
run: |
mkdir -p ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
helm package ${{ env.HELM_CHARTS_DIR }} --destination ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
- name: Upload Helm charts package to artifacts
if: ${{ env.LATEST_RELEASE }} == "true" && env.DOCKER_REGISTRY != ''
uses: actions/upload-artifact@master
with:
name: dapr_helm_charts_package
path: ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
# This job downloads the helm charts package artifact uploaded by the publish job,
# checks out the helm charts git hub pages repo and commits the latest version of
# helm charts package.
# This does not run on forks
helm-publish:
name: Publish Helm charts to Helm github pages repo
needs: helm-build
if: startswith(github.ref, 'refs/tags/v') && github.repository_owner == 'dapr'
env:
ARTIFACT_DIR: ./helm_release
DAPR_VERSION_ARTIFACT: dapr_version
HELM_PACKAGE_DIR: helm
runs-on: ubuntu-latest
steps:
- name: Create Helm charts directory
run: |
mkdir -p ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
- name: download artifacts - dapr_helm_charts_package
uses: actions/download-artifact@master
with:
name: dapr_helm_charts_package
path: ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
- name: Checkout Helm Charts Repo
uses: actions/checkout@v3
env:
DAPR_HELM_REPO: dapr/helm-charts
DAPR_HELM_REPO_CODE_PATH: helm-charts
with:
repository: ${{ env.DAPR_HELM_REPO }}
ref: refs/heads/master
token: ${{ secrets.DAPR_BOT_TOKEN }}
path: ${{ env.DAPR_HELM_REPO_CODE_PATH }}
- name: Upload helm charts to Helm Repo
env:
DAPR_HELM_REPO_CODE_PATH: helm-charts
DAPR_HELM_REPO: https://dapr.github.io/helm-charts/
run: |
daprVersion=`cat ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}/${{ env.DAPR_VERSION_ARTIFACT }}`
cd ${{ env.ARTIFACT_DIR }}/${{ env.HELM_PACKAGE_DIR }}
cp -r `ls -A | grep -v ${{ env.DAPR_VERSION_ARTIFACT }}` $GITHUB_WORKSPACE/${{ env.DAPR_HELM_REPO_CODE_PATH }}
cd $GITHUB_WORKSPACE/${{ env.DAPR_HELM_REPO_CODE_PATH }}
helm repo index --url ${{ env.DAPR_HELM_REPO }} --merge index.yaml .
git config --global user.email "[email protected]"
git config --global user.name "dapr-bot"
git add --all
# Check if the dapr-dashboard-${daprVersion}.tgz file is modified.
if git diff --name-only --staged | grep -q ${daprVersion}; then
# If it is, we update the Helm chart, since this is an intentional update.
git commit -m "Release - $daprVersion"
git push
else
# This check is here because the automation can fail, but the manual step is no longer required.
# If not, this update was accidentally triggered by tagging a release before updating the Helm chart.
echo "::error::There is no change for ${daprVersion} Helm chart. Did you forget to update the chart version before tagging?"
exit -1
fi
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ GIT_VERSION = $(shell git describe --always --abbrev=7 --dirty)
# By default, disable CGO_ENABLED. See the details on https://golang.org/cmd/cgo
CGO ?= 0
BINARIES ?= dashboard
HA_MODE ?= false

# Add latest tag if LATEST_RELEASE is true
LATEST_RELEASE ?=
Expand Down Expand Up @@ -106,6 +107,17 @@ DAPR_ARTIFACTS := $(OUT_DIR)/artifacts
DAPR_OUT_DIR := $(OUT_DIR)/$(GOOS)_$(GOARCH)
DAPR_LINUX_OUT_DIR := $(OUT_DIR)/linux_$(GOARCH)

# Helm template and install setting
HELM:=helm
HELM_RELEASE_NAME?=dapr-dashboard
DAPR_NAMESPACE?=dapr-system
DAPR_MTLS_ENABLED?=true
HELM_CHART_ROOT:=./chart
HELM_CHART_DIR:=$(HELM_CHART_ROOT)/dapr-dashboard
HELM_OUT_DIR:=$(OUT_DIR)/install
HELM_MANIFEST_FILE:=$(HELM_OUT_DIR)/$(HELM_RELEASE_NAME).yaml
HELM_REGISTRY?=daprio.azurecr.io

################################################################################
# Target: build #
################################################################################
Expand Down Expand Up @@ -214,3 +226,26 @@ run-backend-standalone:

run-backend-kubernetes:
DAPR_DASHBOARD_KUBECONFIG=~/.kube/config $(DAPR_OUT_DIR)/dashboard$(BINARY_EXT)

################################################################################
# Target: manifest-gen #
################################################################################

# Generate helm chart manifest
manifest-gen: dapr-dashboard.yaml

dapr-dashboard.yaml: check-docker-env
$(info Generating helm manifest $(HELM_MANIFEST_FILE)...)
@mkdir -p $(HELM_OUT_DIR)
$(HELM) template \
--include-crds=true --set ha.enabled=$(HA_MODE) --set-string tag=$(DAPR_TAG) --set-string registry=$(DAPR_REGISTRY) $(HELM_CHART_DIR) > $(HELM_MANIFEST_FILE)

################################################################################
# Target: upload-helmchart
################################################################################

# Upload helm charts to Helm Registry
upload-helmchart:
export HELM_EXPERIMENTAL_OCI=1; \
$(HELM) chart save ${HELM_CHART_ROOT}/${HELM_RELEASE_NAME} ${HELM_REGISTRY}/${HELM}/${HELM_RELEASE_NAME}:${DAPR_VERSION}; \
$(HELM) chart push ${HELM_REGISTRY}/${HELM}/${HELM_RELEASE_NAME}:${DAPR_VERSION}
112 changes: 107 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,135 @@
[![codecov](https://codecov.io/gh/dapr/dashboard/branch/master/graph/badge.svg)](https://codecov.io/gh/dapr/dashboard)
[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B162%2Fgithub.com%2Fdapr%2Fdashboard.svg?type=shield)](https://app.fossa.com/projects/custom%2B162%2Fgithub.com%2Fdapr%2Fdashboard?ref=badge_shield)

Dapr Dashboard is a web-based UI for Dapr, allowing users to see information, view logs and more for the Dapr applications, components, and configurations running either locally or in a Kubernetes cluster.
Dapr Dashboard is a web-based UI for Dapr, allowing users to see information, view logs and more for the Dapr applications, components, and configurations running on a supported Dapr Dashboard platform.

Supported Dapr Dashboard plaforms are:
- Standalone - running locally via Dapr CLI
- Kubernetes - running inside a Kubernetes cluster
- Docker Compose - running inside a docker compose network

<p style="text-align:center">
<img src="img/img.PNG">
</p>

## Features

Dapr Dashboard provides information about Dapr applications, components, configurations, and control plane services. Users can view metadata, manifests and deployment files, actors, logs, and more on both Kubernetes and self-hosted platforms. For more information, check out the [changelog](docs/development/changelog.md).
Dapr Dashboard provides information about Dapr applications, components, configurations, and control plane services (Kubernetes only). Users can view metadata, manifests and deployment files, actors, logs, and more. For more information, check out the [changelog](docs/development/changelog.md).

## Getting started

### Prerequisites
[Dapr Runtime](https://github.com/dapr/dapr)

[Dapr CLI](https://github.com/dapr/cli)
If you intend to run in the Standalone or Kubernetes platform mode you will need to have the following:

### Installation
- [Dapr Runtime](https://github.com/dapr/dapr)
- [Dapr CLI](https://github.com/dapr/cli)

Dapr Dashboard comes pre-packaged with the Dapr CLI. To learn more about the dashboard command, use the CLI command `dapr dashboard -h`.

If you intend to run in the Docker Compose platform mode, you don't need to install anything. Instead you specify Dapr docker images to use.

### Installation
If you want to install via Helm, run:
```sh
helm repo add dapr https://dapr.github.io/helm-charts/
helm repo update
helm install dapr-dashboard dapr/dapr-dashboard
```

#### Kubernetes
Run `dapr dashboard -k`, or if you installed Dapr in a non-default namespace, `dapr dashboard -k -n <your-namespace>`.

#### Standalone
Run `dapr dashboard`, and navigate to http://localhost:8080.

#### Docker Compose
Construct a docker compose file that references the specific Dapr pieces that you want to use. The following example defines an application and its corresponding daprd sidecar, the Dapr Placement service, and the Dapr Dashboard.

When running inside docker compose, the dashboard needs access to the component and configuration files that are passed to the daprd services. It also needs to know about all daprd services running inside the docker compose network - it retrieves this by parsing the docker-compose.yml file. To achieve this, you define docker bind mounts to these files/directories and pass them as command args to the dashboard process. In addition, you must specify the command arg `--docker-compose=true` to tell the dashboard to use the docker compose platform type.

```yml
version: '3.8'
services:

my-application-webhost:
build:
context: .
dockerfile: src/My.Application.WebHost/Dockerfile
ports:
- "5002:80"
networks:
- my-network

my-application-webhost-dapr:
image: "daprio/daprd:1.8.0"
command: [ "./daprd",
"-app-id", "MyApplication.DaprSidecar",
"-app-port", "80",
"-placement-host-address", "dapr-placement:50000",
"-components-path", "/components",
"-config", "/configuration/config.yaml" ]
volumes:
- "./dockercompose/dapr/components/:/components"
- "./dockercompose/dapr/config/:/configuration"
depends_on:
- my-application-webhost
- dapr-placement
network_mode: "service:my-application-webhost"

dapr-placement:
image: "daprio/dapr:1.8.0"
command: [ "./placement", "-port", "50000" ]
ports:
- "50000:50000"
networks:
- my-network

dapr-dashboard:
image: "daprio/dashboard:latest"
command: [ "--docker-compose=true",
"--components-path=/home/nonroot/components",
"--config-path=/home/nonroot/configuration",
"--docker-compose-path=/home/nonroot/docker-compose.yml" ]
ports:
- "8080:8080"
volumes:
- "./dockercompose/dapr/components/:/home/nonroot/components"
- "./dockercompose/dapr/config/:/home/nonroot/configuration"
- ./docker-compose.yml:/home/nonroot/docker-compose.yml
networks:
- my-network

networks:
my-network:
```
The above example assumes the following file system layout
```
dockercompose
dapr
components
(component yaml files e.g. pubsub.yaml, statestore.yaml etc.)
config
config.yaml
src
My.Application.WebHost
Dockerfile
docker-compose.yml
```

If you have configured your Dapr sidecars to require [API token authentication](https://docs.dapr.io/operations/security/api-token/), you can set the environment variable `DAPR_API_TOKEN: {your token}` on the Dapr Dashboard service declaration as follows
```yml
dapr-dashboard:
image: "daprio/dashboard:latest"
environment:
DAPR_API_TOKEN: {your token}
...
```

For more information about running Dapr with docker compose see [Run using Docker-Compose](https://docs.dapr.io/operations/hosting/self-hosted/self-hosted-with-docker/#run-using-docker-compose)

### Contributing
Anyone is free to open an issue, a feature request, or a pull request.

Expand Down
23 changes: 23 additions & 0 deletions chart/dapr-dashboard/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions chart/dapr-dashboard/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: dapr-dashboard
description: Dapr's dashboard.
type: application
version: '0.0.0'
appVersion: '0.0.0'
Loading

0 comments on commit ec87984

Please sign in to comment.