diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4b186b4 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +Dockerfile +*.md +bin +.idea \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug.yaml b/.github/ISSUE_TEMPLATE/bug.yaml new file mode 100644 index 0000000..dbfb34a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yaml @@ -0,0 +1,59 @@ +name: 🐛 Bug + +description: Report an issue to help improve the project. + +labels: ["🛠 goal: fix"] + +body: + + - type: textarea + + id: description + + attributes: + + label: Description + + description: A brief description of the question or issue, also include what you tried and what didn't work + + validations: + + required: true + + - type: textarea + + id: screenshots + + attributes: + + label: Screenshots + + description: Please add screenshots if applicable + + validations: + + required: false + + - type: textarea + + id: extrainfo + + attributes: + + label: Additional information + + description: Is there anything else we should know about this bug? + + validations: + + required: false + + - type: markdown + + attributes: + + value: | + + You can also join our slack community [here](https://join.slack.com/t/komodorkommunity/shared_invite/zt-1dm3cnkue-ov1Yh~_95teA35QNx5yuMg) + + Feel free to check out other cool repositories of the [komodorio](https://github.com/komodorio) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..78b49ef --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,35 @@ + + +## Fixes Issue + + + + + +## Changes proposed + + + + + + +## Check List (Check all the applicable boxes) + +- [ ] My code follows the code style of this project. +- [ ] My change requires changes to the documentation. +- [ ] I have updated the documentation accordingly. +- [ ] All new and existing tests passed. +- [ ] The title of my pull request is a short description of the requested changes. + +## Screenshots + + + +## Note to reviewers + + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bcb2bb5..f8d165d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,9 @@ name: Build on: push: - branches: [ "main" ] + branches: main pull_request: - branches: [ "main" ] + branches: main jobs: build: @@ -40,4 +40,31 @@ jobs: # skip-go-installation: true skip-pkg-cache: true skip-build-cache: true - # args: --timeout=15m \ No newline at end of file + # args: --timeout=15m + + image: + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + outputs: local + build-args: VER=0.0.0-dev + + helm_check: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Helm Template Check For Sanity + uses: igabaydulin/helm-check-action@0.1.4 + env: + CHART_LOCATION: ./charts/helm-dashboard + CHART_VALUES: ./charts/helm-dashboard/values.yaml diff --git a/.github/workflows/publish-chart.yaml b/.github/workflows/publish-chart.yaml new file mode 100644 index 0000000..abbd349 --- /dev/null +++ b/.github/workflows/publish-chart.yaml @@ -0,0 +1,43 @@ +name: publish helm chart + +# for manual running in case we need to update the chart without releasing the dashboard app +on: + workflow_dispatch: + +env: + HELM_REP: helm-charts + GH_OWNER: komodorio + CHART_DIR: charts/helm-dashboard + +jobs: + publish_chart: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Bump versions + run: | + git config user.email komi@komodor.io + git config user.name komodor-bot + git fetch --tags + git checkout main + sh ./ci/bump-versions.sh + git add charts/helm-dashboard/Chart.yaml + git commit -m "Increment chart versions [skip ci]" || echo "Already up-to-date" + git push -f || echo "Nothing to push!" + env: + APP_VERSION: ${{ needs.pre_release.outputs.release_tag }} + - name: Push folder to helm-charts repository + uses: crykn/copy_folder_to_another_repo_action@v1.0.6 + env: + API_TOKEN_GITHUB: ${{ secrets.KOMI_WORKFLOW_TOKEN }} + with: + source_folder: "charts/helm-dashboard" + destination_repo: "komodorio/helm-charts" + destination_folder: "charts/helm-dashboard" + user_email: "komi@komodor.io" + user_name: "komodor-bot" + destination_branch: "master" + commit_msg: "feat(helm-dashboard): update chart" #important!! don't change this commit message unless you change the condition in pipeline.yml on helm-charts repo diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 883b032..811e6c5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,7 +3,12 @@ name: release on: push: tags: - - "*" + - "v*" + +env: + HELM_REP: helm-charts + GH_OWNER: komodorio + CHART_DIR: charts/helm-dashboard jobs: pre_release: @@ -52,3 +57,68 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Test Binary Versions run: "dist/helm-dashboard_linux_amd64_v1/helm-dashboard --help" + + image: + runs-on: ubuntu-latest + needs: [release, pre_release] + timeout-minutes: 60 + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Docker meta + uses: docker/metadata-action@v3 + id: meta + with: + images: komodorio/helm-dashboard + + - name: Login to DockerHub + uses: docker/login-action@v1 + if: github.event_name != 'pull_request' + with: + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_PASS }} + + - name: Build and push + uses: docker/build-push-action@v2 + if: github.event_name != 'pull_request' + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: komodorio/helm-dashboard:${{ needs.pre_release.outputs.release_tag }},komodorio/helm-dashboard:latest + labels: ${{ steps.meta.outputs.labels }} + build-args: VER=${{ needs.pre_release.outputs.release_tag }} + + publish_chart: + runs-on: ubuntu-latest + needs: [image, pre_release] + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Bump versions + run: | + git config user.email komi@komodor.io + git config user.name komodor-bot + git fetch --tags + git checkout main + sh ./ci/bump-versions.sh + git add charts/helm-dashboard/Chart.yaml + git commit -m "Increment chart versions [skip ci]" || echo "Already up-to-date" + git push -f || echo "Nothing to push!" + env: + APP_VERSION: ${{ needs.pre_release.outputs.release_tag }} + - name: Push folder to helm-charts repository + uses: crykn/copy_folder_to_another_repo_action@v1.0.6 + env: + API_TOKEN_GITHUB: ${{ secrets.KOMI_WORKFLOW_TOKEN }} + with: + source_folder: "charts/helm-dashboard" + destination_repo: "komodorio/helm-charts" + destination_folder: "charts/helm-dashboard" + user_email: "komi@komodor.io" + user_name: "komodor-bot" + destination_branch: "master" + commit_msg: "feat(helm-dashboard): ${{ github.event.head_commit.message }}" #important!! don't change this commit message unless you change the condition in pipeline.yml on helm-charts repo diff --git a/.gitignore b/.gitignore index d02d94c..122c627 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,6 @@ go.work /bin /.idea/ + +.DS_Store +.vscode/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..6cd72a0 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,55 @@ +# Contributing to Helm Dashboard + +We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's: + +- Reporting a bug +- Discussing the current state of the code +- Submitting a fix +- Proposing new features + +## We Develop with GitHub + +We use GitHub to host code, to track issues and feature requests, as well as accept pull requests. + +## First-time contributors + +We've tagged some issues to make it easy to get started :smile: +[Good first issues](https://github.com/komodorio/helm-dashboard/labels/good%20first%20issue) + +Add a comment on the issue and wait for the issue to be assigned before you start working on it. This helps to avoid multiple people working on similar issues. + +## All Code Changes Happen Through Pull Requests + +Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests: + +1. Fork the repo and create your branch from `main`. +2. If you've added code that should be tested, add tests. +3. Ensure the test suite passes. +4. Make sure your code lints. +5. Issue that pull request! + +## Any contributions you make will be under the Apache License 2.0 + +In short, when you submit code changes, your submissions are understood to be under the same [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0) that covers the project. + +## Report bugs using GitHub's [issues](https://github.com/komodorio/helm-dashboard/issues) + +We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/komodorio/helm-dashboard/issues/new) and labeling it with the `bug` label. It's that easy! + +**Great Bug Reports** tend to have: + +- A quick summary and/or background +- Steps to reproduce + - Be specific! + - Give sample code if you can. +- What you expected would happen +- What actually happens +- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work) + +## License + +By contributing, you agree that your contributions will be licensed under its Apache License 2.0. + +## Questions? + +Contact us on [Slack](https://join.slack.com/t/komodorkommunity/shared_invite/zt-1dm3cnkue-ov1Yh~_95teA35QNx5yuMg). diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..04424c0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,45 @@ +# Stage - builder +FROM golang as builder + + +ENV GOOS=linux +ENV GOARCH=amd64 +ENV CGO_ENABLED=0 + +WORKDIR /build + +COPY go.mod ./ +COPY go.sum ./ +COPY main.go ./ +RUN go mod download + +ARG VER=0.0.0 +ENV VERSION=${VER} + +ADD . src + +WORKDIR /build/src + +RUN make build + +# Stage - runner +FROM alpine/helm + +# Python +RUN apk add --update --no-cache python3 && python3 -m ensurepip && pip3 install --upgrade pip setuptools + +# kubectl +RUN curl -o /bin/kubectl -vf -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && chmod +x /bin/kubectl && kubectl --help + +# Trivy +RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.18.3 +RUN trivy --version + +# Checkov scanner +RUN pip3 install checkov packaging==21.3 && checkov --version + +COPY --from=builder /build/src/bin/dashboard /bin/helm-dashboard + +ENTRYPOINT ["/bin/helm-dashboard", "--no-browser", "--bind=0.0.0.0"] + +# docker build . -t komodorio/helm-dashboard:0.0.0 && kind load docker-image komodorio/helm-dashboard:0.0.0 \ No newline at end of file diff --git a/README.md b/README.md index a0dec6c..67c7de5 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,22 @@ -# ![Helm Dashboard](pkg/dashboard/static/logo-header.svg) +

+ + + + Helm Dashboard + +

-A simplified way of working with Helm. +

A simplified way of working with Helm.

+ +![GitHub contributors](https://img.shields.io/github/contributors/komodorio/helm-dashboard) [![GitHub issues](https://img.shields.io/github/issues-raw/komodorio/helm-dashboard)](https://github.com/komodorio/helm-dashboard/issues) ![GitHub stars](https://img.shields.io/github/stars/komodorio/helm-dashboard?style=social) ![GitHub closed issues](https://img.shields.io/github/issues-closed-raw/komodorio/helm-dashboard) ![GitHub pull requests](https://img.shields.io/github/issues-pr/komodorio/helm-dashboard) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/komodorio/helm-dashboard) ![GitHub commit activity](https://img.shields.io/github/commit-activity/m/komodorio/helm-dashboard) [![GitHub license](https://img.shields.io/github/license/komodorio/helm-dashboard)](https://github.com/komodorio/helm-dashboard) [Screenshot](screenshot.png) -## What it Does? +## Description -The _Helm Dashboard_ plugin offers a UI-driven way to view the installed Helm charts, see their revision history and +_Helm Dashboard_ is an **open-source project** which offers a UI-driven way to view the installed Helm charts, see their revision history and corresponding k8s resources. Also, you can perform simple actions like roll back to a revision or upgrade to newer version. - This project is part of [Komodor's](https://komodor.com/?utm_campaign=Helm-Dash&utm_source=helm-dash-gh) vision of helping Kubernetes users to navigate and troubleshoot their clusters, the project is **NOT** an offical project by the [helm team](https://helm.sh/). @@ -22,9 +29,11 @@ Some of the key capabilities of the tool: - Integration with popular problem scanners - Easy switch between multiple clusters -## Installing +## Setup -To install it, simply run Helm command: +### Using Helm plugin manager + +To install the plugin, simply run Helm command: ```shell helm plugin install https://github.com/komodorio/helm-dashboard.git @@ -42,10 +51,6 @@ To uninstall, run: helm plugin uninstall dashboard ``` -> In case standard Helm plugin way did not work for you, you can just download the appropriate [release package](https://github.com/komodorio/helm-dashboard/releases) for your platform, unpack it and just run `dashboard` binary from it. - -## Running - To use the plugin, your machine needs to have working `helm` and also `kubectl` commands. Helm version 3.4.0+ is required. After installing, start the UI by running: @@ -62,11 +67,12 @@ You can see the list of available command-line flags by running `helm dashboard By default, the web server is only available locally. You can change that by specifying `HD_BIND` environment variable to the desired value. For example, `0.0.0.0` would bind to all IPv4 addresses or `[::0]` would be all IPv6 addresses. This can also be specified using flag `--bind `, for example `--bind=0.0.0.0` or `--bind 0.0.0.0`. + > Precedence order: flag `--bind=` > env `HD_BIND=` > default value `localhost` If your port 8080 is busy, you can specify a different port to use via `--port ` command-line flag. -If you need to limit the operations to a specific namespace, please use `--namespace=...` in your command-line. +If you need to limit the operations to a specific namespace, please use `--namespace=...` in your command-line. If you don't want browser tab to automatically open, add `--no-browser` flag in your command line. @@ -74,6 +80,14 @@ If you want to increase the logging verbosity and see all the debug info, use th > Disclaimer: For the sake of improving the project quality, there is user analytics collected by the tool. You can disable this collecting with `--no-analytics` option. The collection is done via DataDog RUM and Heap Analytics. Only the anonymous data is collected, no sensitive information is used. +### Deploying Helm Dashboard on Kubernetes + +The official helm chart is [available here](https://github.com/komodorio/helm-charts/blob/master/charts/helm-dashboard) + +### Manual Installation + +Download the appropriate [release package](https://github.com/komodorio/helm-dashboard/releases) for your platform, unpack it and just run `dashboard` binary from it. + ## Scanner Integrations Upon startup, Helm Dashboard detects the presence of [Trivy](https://github.com/aquasecurity/trivy) @@ -93,6 +107,15 @@ We have two main channels for supporting the Helm Dashboard users: [Slack community](https://join.slack.com/t/komodorkommunity/shared_invite/zt-1dm3cnkue-ov1Yh~_95teA35QNx5yuMg) for general conversations and [GitHub issues](https://github.com/komodorio/helm-dashboard/issues) for real bugs. +## Contributing + +Kindly read our [Contributing Guide](CONTRIBUTING.md) to learn and understand about our development process, how to propose bug fixes and improvements, and how to build and test your changes to Helm Dashboard.
+ +## Contributors + + + + ## Local Dev Testing diff --git a/artifacthub-repo.yml b/artifacthub-repo.yml new file mode 100644 index 0000000..249a205 --- /dev/null +++ b/artifacthub-repo.yml @@ -0,0 +1,5 @@ +# Artifact Hub repository metadata file +repositoryID: 9ed6d12d-b3d5-4efd-836e-3ac9fa9dd3d1 +owners: + - name: komodor-bot + email: komi@komodor.io diff --git a/charts/helm-dashboard/.helmignore b/charts/helm-dashboard/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/helm-dashboard/.helmignore @@ -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/ diff --git a/charts/helm-dashboard/Chart.yaml b/charts/helm-dashboard/Chart.yaml new file mode 100644 index 0000000..5ba0bd0 --- /dev/null +++ b/charts/helm-dashboard/Chart.yaml @@ -0,0 +1,9 @@ +apiVersion: v2 +type: application + +name: helm-dashboard +description: A GUI Dashboard for Helm by Komodor +icon: "https://raw.githubusercontent.com/komodorio/helm-dashboard/main/pkg/dashboard/static/logo.svg" + +version: 0.1.2 +appVersion: "0.3.1" diff --git a/charts/helm-dashboard/README.md b/charts/helm-dashboard/README.md new file mode 100644 index 0000000..3b8c238 --- /dev/null +++ b/charts/helm-dashboard/README.md @@ -0,0 +1,76 @@ +# Helm Dashboard + +## TL;DR; + +```bash +helm repo add komodorio https://helm-charts.komodor.io +helm repo update +helm upgrade --install my-release komodorio/helm-dashboard +``` + +## Introduction + +This chart bootstraps a Helm Dashboard deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. + +## Prerequisites + +- Kubernetes 1.16+ +- Helm 3+ + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```bash +helm install my-release . +``` + +The command deploys Helm Dashboard on the Kubernetes cluster in the default configuration. The [Parameters](#parameters) section lists the parameters that can be configured during installation. + +> **Tip**: List all releases using `helm list` + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```bash +helm uninstall my-release +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Parameters + +The following table lists the configurable parameters of the chart and their default values. + +| Parameter | Description | Default | +| ------------------------------------ | ---------------------------------------------------------------------------------------------- | ------------------------------------ | +| `image.repository` | Image registry/name | `docker.io/komodorio/helm-dashboard` | +| `image.tag` | Image tag | | +| `image.pullPolicy` | Image pull policy | `IfNotPresent` | +| `replicaCount` | Number of dashboard Pods to run | `1` | +| `dashboard.allowWriteActions` | Enables write actions. Allow modifying, deleting and creating charts and kubernetes resources. | `true` | +| `resources.requests.cpu` | CPU resource requests | `200m` | +| `resources.limits.cpu` | CPU resource limits | `1` | +| `resources.requests.memory` | Memory resource requests | `256Mi` | +| `resources.limits.memory` | Memory resource limits | `1Gi` | +| `service.type ` | Kubernetes service type | `ClusterIP` | +| `service.port ` | Kubernetes service port | `8080` | +| `serviceAccount.create` | Creates a service account | `true` | +| `serviceAccount.name` | Optional name for the service account | `{RELEASE_FULLNAME}` | +| `nodeSelector` | Node labels for pod assignment | | +| `affinity` | Affinity settings for pod assignment | | +| `tolerations` | Tolerations for pod assignment | | +| `dashboard.persistence.enabled` | Enable helm data persistene using PVC | `true` | +| `dashboard.persistence.accessModes` | Persistent Volume access modes | `["ReadWriteOnce"]` | +| `dashboard.persistence.storageClass` | Persistent Volume storage class | `""` | +| `dashboard.persistence.size` | Persistent Volume size | `100M` | +| `dashboard.persistence.hostPath` | Set path in case you want to use local host path volumes (not recommended in production) | `""` | + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. + +```bash +helm upgrade --install my-release komodorio/helm-dashboard --set dashboard.allowWriteActions=true --set service.port=9090 +``` + +> **Tip**: You can use the default [values.yaml](values.yaml) diff --git a/charts/helm-dashboard/templates/NOTES.txt b/charts/helm-dashboard/templates/NOTES.txt new file mode 100644 index 0000000..1b47ebc --- /dev/null +++ b/charts/helm-dashboard/templates/NOTES.txt @@ -0,0 +1,16 @@ +Thank you for installing Helm Dashboard. +Helm Dashboard can be accessed: + * Within your cluster, at the following DNS name at port {{ .Values.service.port }}: + + {{ template "helm-dashboard.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local + + * From outside the cluster, run these commands in the same shell: + + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "helm-dashboard.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT + +Visit our repo at: +https://github.com/komodorio/helm-dashboard + diff --git a/charts/helm-dashboard/templates/_helpers.tpl b/charts/helm-dashboard/templates/_helpers.tpl new file mode 100644 index 0000000..d7188c3 --- /dev/null +++ b/charts/helm-dashboard/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "helm-dashboard.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +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 "helm-dashboard.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "helm-dashboard.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "helm-dashboard.labels" -}} +helm.sh/chart: {{ include "helm-dashboard.chart" . }} +{{ include "helm-dashboard.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "helm-dashboard.selectorLabels" -}} +app.kubernetes.io/name: {{ include "helm-dashboard.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "helm-dashboard.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "helm-dashboard.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/helm-dashboard/templates/deployment.yaml b/charts/helm-dashboard/templates/deployment.yaml new file mode 100644 index 0000000..5108381 --- /dev/null +++ b/charts/helm-dashboard/templates/deployment.yaml @@ -0,0 +1,81 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "helm-dashboard.fullname" . }} + labels: + {{- include "helm-dashboard.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "helm-dashboard.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "helm-dashboard.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "helm-dashboard.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: HELM_CACHE_HOME + value: /opt/dashboard/helm/cache + - name: HELM_CONFIG_HOME + value: /opt/dashboard/helm/config + - name: HELM_DATA_HOME + value: /opt/dashboard/helm/data + - name: DEBUG + value: {{- ternary " 1" "" .Values.debug }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: /status + port: http + readinessProbe: + httpGet: + path: /status + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: data + mountPath: /opt/dashboard/helm + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: data + {{- if .Values.dashboard.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ include "helm-dashboard.fullname" . }} + {{- else }} + emptyDir: {} + {{- end }} diff --git a/charts/helm-dashboard/templates/ingress.yaml b/charts/helm-dashboard/templates/ingress.yaml new file mode 100644 index 0000000..4ff1d98 --- /dev/null +++ b/charts/helm-dashboard/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "helm-dashboard.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "helm-dashboard.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/helm-dashboard/templates/pvc.yaml b/charts/helm-dashboard/templates/pvc.yaml new file mode 100644 index 0000000..7ab8b98 --- /dev/null +++ b/charts/helm-dashboard/templates/pvc.yaml @@ -0,0 +1,48 @@ +{{- if .Values.dashboard.persistence.enabled -}} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "helm-dashboard.fullname" . }} + namespace: {{ .Release.Namespace | quote }} + labels: + {{- include "helm-dashboard.labels" . | nindent 4 }} + {{- with .Values.dashboard.persistence.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.dashboard.persistence.hostPath }} + storageClassName: "" + {{- end }} + accessModes: + {{- if not (empty .Values.dashboard.persistence.accessModes) }} + {{- range .Values.dashboard.persistence.accessModes }} + - {{ . | quote }} + {{- end }} + {{- end }} + resources: + requests: + storage: {{ .Values.dashboard.persistence.size | quote }} +{{- end }} + +--- +{{- if and .Values.dashboard.persistence.enabled .Values.dashboard.persistence.hostPath -}} +apiVersion: v1 +kind: PersistentVolume +metadata: + name: {{ include "helm-dashboard.fullname" . }} + namespace: {{ .Release.Namespace | quote }} + labels: + {{- include "helm-dashboard.labels" . | nindent 4 }} + {{- with .Values.dashboard.persistence.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + accessModes: + - {{ .Values.dashboard.persistence.accessMode | quote }} + capacity: + storage: {{ .Values.dashboard.persistence.size | quote }} + hostPath: + path: {{ .Values.dashboard.persistence.hostPath | quote }} +{{- end -}} \ No newline at end of file diff --git a/charts/helm-dashboard/templates/service.yaml b/charts/helm-dashboard/templates/service.yaml new file mode 100644 index 0000000..59b039f --- /dev/null +++ b/charts/helm-dashboard/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "helm-dashboard.fullname" . }} + labels: + {{- include "helm-dashboard.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "helm-dashboard.selectorLabels" . | nindent 4 }} diff --git a/charts/helm-dashboard/templates/serviceaccount.yaml b/charts/helm-dashboard/templates/serviceaccount.yaml new file mode 100644 index 0000000..b93502a --- /dev/null +++ b/charts/helm-dashboard/templates/serviceaccount.yaml @@ -0,0 +1,40 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "helm-dashboard.serviceAccountName" . }} + labels: + {{- include "helm-dashboard.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} + +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: {{ include "helm-dashboard.serviceAccountName" . }} +rules: + - apiGroups: ["*"] + resources: ["*"] + verbs: ["get", "list", "watch"] + {{- if .Values.dashboard.allowWriteActions }} + - apiGroups: ["*"] + resources: ["*"] + verbs: ["get", "list", "watch", "create", "delete", "patch", "update"] + {{- end }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "helm-dashboard.serviceAccountName" . }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ include "helm-dashboard.serviceAccountName" . }} +subjects: + - kind: ServiceAccount + namespace: {{ .Release.Namespace }} + name: {{ include "helm-dashboard.serviceAccountName" . }} \ No newline at end of file diff --git a/charts/helm-dashboard/templates/tests/test-connection.yaml b/charts/helm-dashboard/templates/tests/test-connection.yaml new file mode 100644 index 0000000..08efbf5 --- /dev/null +++ b/charts/helm-dashboard/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "helm-dashboard.fullname" . }}-test-connection" + labels: + {{- include "helm-dashboard.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['--timeout=5', '{{ include "helm-dashboard.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/helm-dashboard/values.yaml b/charts/helm-dashboard/values.yaml new file mode 100644 index 0000000..fac4561 --- /dev/null +++ b/charts/helm-dashboard/values.yaml @@ -0,0 +1,98 @@ +replicaCount: 1 + +# Flag for setting environment to debug mode +debug: false + +image: + repository: komodorio/helm-dashboard + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +resources: + requests: + cpu: 200m + memory: 256Mi + limits: + cpu: 1 + memory: 1Gi + +dashboard: + allowWriteActions: true + persistence: + enabled: true + + ## If defined, storageClassName: + ## If set to "-", storageClassName: "", which disables dynamic provisioning + ## If undefined (the default) or set to null, no storageClassName spec is + ## set, choosing the default provisioner. (gp2 on AWS, standard on + ## GKE, AWS & OpenStack) + ## + storageClass: "" + + ## Helm Dashboard Persistent Volume access modes + ## Must match those of existing PV or dynamic provisioner + ## Ref: http://kubernetes.io/docs/user-guide/persistent-volumes/ + ## + accessModes: + - ReadWriteOnce + + ## Helm Dashboard Persistent Volume labels + ## + labels: {} + + ## Helm Dashboard Persistent Volume annotations + ## + annotations: {} + + ## Set path in case you want to use local host path volumes (not recommended in production) + ## + hostPath: "" + + ## Helm Dashboard data Persistent Volume size + ## + size: 100M + +podAnnotations: {} + +podSecurityContext: {} + +securityContext: {} + +service: + type: ClusterIP + port: 8080 + +ingress: + enabled: false + className: "" + annotations: {} + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/ci/bump-versions.sh b/ci/bump-versions.sh new file mode 100755 index 0000000..f41423f --- /dev/null +++ b/ci/bump-versions.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +WORKING_DIRECTORY="$PWD" + +[ -z "$HELM_CHARTS_SOURCE" ] && HELM_CHARTS_SOURCE="$WORKING_DIRECTORY/charts/helm-dashboard" + +[ -z "$APP_VERSION" ] && { + APP_VERSION=$(cat ${HELM_CHARTS_SOURCE}/Chart.yaml | grep 'appVersion:' | awk -F'"' '{print $2}') +} + +sed -i -e "s/appVersion.*/appVersion: \"${APP_VERSION}\" /g" ${HELM_CHARTS_SOURCE}/Chart.yaml +CURRENT_VERSION=$(cat ${HELM_CHARTS_SOURCE}/Chart.yaml | grep 'version:' | awk '{print $2}') +NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g') +sed -i -e "s/${CURRENT_VERSION}/${NEW_VERSION}/g" ${HELM_CHARTS_SOURCE}/Chart.yaml diff --git a/go.mod b/go.mod index dbe1b8d..464d5aa 100644 --- a/go.mod +++ b/go.mod @@ -13,8 +13,8 @@ require ( github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 github.com/sirupsen/logrus v1.9.0 gopkg.in/yaml.v3 v3.0.1 - helm.sh/helm/v3 v3.9.4 - k8s.io/apimachinery v0.25.0-alpha.2 + helm.sh/helm/v3 v3.10.3 + k8s.io/apimachinery v0.25.2 ) require ( @@ -34,7 +34,6 @@ require ( github.com/goccy/go-json v0.9.11 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/google/go-cmp v0.5.8 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/leodido/go-urn v1.2.1 // indirect @@ -55,7 +54,7 @@ require ( golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 // indirect golang.org/x/exp v0.0.0-20220518171630-0b5c67f07fdf // indirect golang.org/x/net v0.0.0-20220906165146-f3363e06e74c // indirect - golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect + golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 // indirect golang.org/x/text v0.3.7 // indirect google.golang.org/appengine v1.6.7 // indirect @@ -64,8 +63,8 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - k8s.io/klog/v2 v2.70.0 // indirect - k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect - sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect + k8s.io/klog/v2 v2.70.1 // indirect + k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect + sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect ) diff --git a/go.sum b/go.sum index c571d57..fe015a9 100644 --- a/go.sum +++ b/go.sum @@ -32,7 +32,7 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= +github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= @@ -175,7 +175,6 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= @@ -263,7 +262,7 @@ github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= +github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pegasus-kv/thrift v0.13.0 h1:4ESwaNoHImfbHa9RUGJiJZ4hrxorihZHk5aarYwY8d4= @@ -444,8 +443,8 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f h1:Ax0t5p6N38Ga0dThY21weqDEyz2oklo4IvDkpigvkD8= -golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -665,8 +664,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -helm.sh/helm/v3 v3.9.4 h1:TCI1QhJUeLVOdccfdw+vnSEO3Td6gNqibptB04QtExY= -helm.sh/helm/v3 v3.9.4/go.mod h1:3eaWAIqzvlRSD06gR9MMwmp2KBKwlu9av1/1BZpjeWY= +helm.sh/helm/v3 v3.10.3 h1:wL7IUZ7Zyukm5Kz0OUmIFZgKHuAgByCrUcJBtY0kDyw= +helm.sh/helm/v3 v3.10.3/go.mod h1:CXOcs02AYvrlPMWARNYNRgf2rNP7gLJQsi/Ubd4EDrI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -675,24 +674,24 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= k8s.io/apimachinery v0.0.0-20191123233150-4c4803ed55e3/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= -k8s.io/apimachinery v0.25.0-alpha.2 h1:y6uTWaiqsPTPRewnXJ15IFyGmBo2qPt6enm4zszG8Z0= -k8s.io/apimachinery v0.25.0-alpha.2/go.mod h1:h34FtK3eCxige6ZIACdBSYExtDaKAUxoc7hVe2LOxzw= +k8s.io/apimachinery v0.25.2 h1:WbxfAjCx+AeN8Ilp9joWnyJ6xu9OMeS/fsfjK/5zaQs= +k8s.io/apimachinery v0.25.2/go.mod h1:hqqA1X0bsgsxI6dXsJ4HnNTBOmJNxyPp8dw3u2fSHwA= k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= -k8s.io/klog/v2 v2.70.0 h1:GMmmjoFOrNepPN0ZeGCzvD2Gh5IKRwdFx8W5PBxVTQU= -k8s.io/klog/v2 v2.70.0/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/klog/v2 v2.70.1 h1:7aaoSdahviPmR+XkS7FyxlkkXs6tHISSG03RxleQAVQ= +k8s.io/klog/v2 v2.70.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= -k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc= -k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= +k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed h1:jAne/RjBTyawwAy0utX5eqigAwz/lQhTmy+Hr/Cpue4= +k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 h1:kDi4JBNAsJWfz1aEXhO8Jg87JJaPNLh5tIzYHgStQ9Y= -sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2/go.mod h1:B+TnT182UBxE84DiCz4CVE26eOSDAeYCpfDnC2kdKMY= +sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= +sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= -sigs.k8s.io/structured-merge-diff/v4 v4.2.1 h1:bKCqE9GvQ5tiVHn5rfn1r+yao3aLQEaLzkkmAkf+A6Y= -sigs.k8s.io/structured-merge-diff/v4 v4.2.1/go.mod h1:j/nl6xW8vLS49O8YvXW1ocPhZawJtm+Yrr7PPRQ0Vg4= +sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= +sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/pkg/dashboard/server.go b/pkg/dashboard/server.go index 5af3bfe..4ba68ab 100644 --- a/pkg/dashboard/server.go +++ b/pkg/dashboard/server.go @@ -113,7 +113,7 @@ func discoverScanners(data *subproc.DataLayer) { } } -func checkUpgrade(d *subproc.StatusInfo) { +func checkUpgrade(d *subproc.StatusInfo) { // TODO: check it once an hour url := "https://api.github.com/repos/komodorio/helm-dashboard/releases/latest" type GHRelease struct { Name string `json:"name"` diff --git a/pkg/dashboard/static/analytics.js b/pkg/dashboard/static/analytics.js index 05219b6..bf360e5 100644 --- a/pkg/dashboard/static/analytics.js +++ b/pkg/dashboard/static/analytics.js @@ -5,7 +5,7 @@ xhr.onload = function () { const version = status.CurVer if (status.Analytics) { enableDD(version) - enableHeap(version) + enableHeap(version, status.ClusterMode) } } } @@ -42,7 +42,7 @@ function enableDD(version) { }) } -function enableHeap(version) { +function enableHeap(version, inCluster) { window.heap = window.heap || [], heap.load = function (e, t) { window.heap.appid = e, window.heap.config = t = t || {}; let r = document.createElement("script"); @@ -56,7 +56,10 @@ function enableHeap(version) { }, p = ["addEventProperties", "addUserProperties", "clearEventProperties", "identify", "resetIdentity", "removeEventProperty", "setEventProperties", "track", "unsetEventProperty"], o = 0; o < p.length; o++) heap[p[o]] = n(p[o]) }; heap.load("4249623943"); - window.heap.addEventProperties({'version': version}); + window.heap.addEventProperties({ + 'version': version, + 'installationMode': inCluster?"cluster":"local" + }); } function sendStats(name, prop){ diff --git a/pkg/dashboard/static/details-view.js b/pkg/dashboard/static/details-view.js index 677871b..82e1c30 100644 --- a/pkg/dashboard/static/details-view.js +++ b/pkg/dashboard/static/details-view.js @@ -162,7 +162,9 @@ function showResources(namespace, chart, revision) { } resBody.empty(); - data = data.sort(function(a, b){return interestingResources.indexOf(a.kind.toUpperCase()) - interestingResources.indexOf(b.kind.toUpperCase())}).reverse(); + data = data.sort(function (a, b) { + return interestingResources.indexOf(a.kind.toUpperCase()) - interestingResources.indexOf(b.kind.toUpperCase()) + }).reverse(); for (let i = 0; i < data.length; i++) { const res = data[i] const resBlock = $(` diff --git a/pkg/dashboard/static/index.html b/pkg/dashboard/static/index.html index 5535d32..e950455 100644 --- a/pkg/dashboard/static/index.html +++ b/pkg/dashboard/static/index.html @@ -75,24 +75,6 @@
- - - @@ -144,9 +126,11 @@
-

Clusters

-
    -
+
+

Clusters

+
    +
+

Namespaces

@@ -165,7 +149,8 @@

Installed ChartsInstalled Charts ()

- +
@@ -182,7 +167,8 @@ - @@ -430,6 +416,21 @@
+ + + + diff --git a/pkg/dashboard/static/logo-header-inverted.svg b/pkg/dashboard/static/logo-header-inverted.svg new file mode 100644 index 0000000..1fdcb67 --- /dev/null +++ b/pkg/dashboard/static/logo-header-inverted.svg @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + diff --git a/pkg/dashboard/static/repo.js b/pkg/dashboard/static/repo.js index a3340f4..52f0b00 100644 --- a/pkg/dashboard/static/repo.js +++ b/pkg/dashboard/static/repo.js @@ -132,7 +132,8 @@ function repoChartClicked() { window.location.reload() } else { const contexts = $("body").data("contexts") - const contextNamespace = contexts.filter(obj => {return obj.Name === getHashParam("context")})[0].Namespace + const ctxFiltered = contexts.filter(obj => {return obj.Name === getHashParam("context")}); + const contextNamespace = ctxFiltered.length?ctxFiltered[0].Namespace:"" popUpUpgrade(elm, contextNamespace) } } \ No newline at end of file diff --git a/pkg/dashboard/static/scripts.js b/pkg/dashboard/static/scripts.js index a18df58..1d00055 100644 --- a/pkg/dashboard/static/scripts.js +++ b/pkg/dashboard/static/scripts.js @@ -3,12 +3,18 @@ $(function () { $.getJSON("/status").fail(function (xhr) { // maybe /options call in the future reportError("Failed to get tool version", xhr) }).done(function (data) { + $("body").data("status", data) fillToolVersion(data) limNS = data.LimitedToNamespace if (limNS) { $("#limitNamespace").show().find("span").text(limNS) } fillClusters(limNS) + + if (data.ClusterMode) { + $(".bi-power").hide() + $("#clusterFilterBlock").hide() + } }) $.getJSON("/api/scanners").fail(function (xhr) { @@ -47,7 +53,7 @@ function fillClusters(limNS) { const context = getHashParam("context") data.sort((a, b) => (getCleanClusterName(a.Name) > getCleanClusterName(b.Name)) - (getCleanClusterName(a.Name) < getCleanClusterName(b.Name))) fillClusterList(data, context); - sendStats('contexts', {'status': 'success', length:data.length}); + sendStats('contexts', {'status': 'success', length: data.length}); $.getJSON("/api/kube/namespaces").fail(function (xhr) { reportError("Failed to get namespaces", xhr) }).done(function (res) { @@ -220,7 +226,7 @@ function fillNamespaceList(data) { if (filteredNamespace.split('+').includes(elm.metadata.name)) { opt.find("input").prop("checked", true) } - } else if (curContextNamespaces && curContextNamespaces[0].Namespace === elm.metadata.name) { + } else if (curContextNamespaces.length && curContextNamespaces[0].Namespace === elm.metadata.name) { opt.find("input").prop("checked", true) setFilteredNamespaces([elm.metadata.name]) } diff --git a/plugin.yaml b/plugin.yaml index d289150..3167967 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,5 +1,5 @@ name: "dashboard" -version: "0.2.8" +version: "0.3.0" usage: "A simplified way of working with Helm" description: "View HELM situation in nice web UI" command: "$HELM_PLUGIN_DIR/bin/helm-dashboard"