diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..2d5a475 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,102 @@ +version: 2.1 + +workflows: + package-helm-chart: + jobs: + - get-version: + filters: + tags: &filter-allow-all + only: /.*/ + + - pre-commit: + filters: + tags: *filter-allow-all + + - helm-package-and-publish: + filters: + tags: *filter-allow-all + branches: &filter-only-main + only: + - main + +jobs: + get-version: + docker: &docker-image + - image: cimg/base:2022.04 + working_directory: &workingdir /tmp/ci + steps: + - checkout + - run: mkdir -p workspace + - run: + name: set version + command: | + echo "export VERSION=$(.circleci/get_version.sh)" >> workspace/env-vars + - run: + name: store version + command: | + cat workspace/env-vars >> $BASH_ENV + - run: + name: echo version + command: | + echo "VERSION=${VERSION}" + - persist_to_workspace: + root: workspace + paths: + - env-vars + + pre-commit: + parameters: + config_file: + default: ./.pre-commit-config.yaml + description: Optional, path to pre-commit config file. + type: string + cache_prefix: + default: '' + description: | + Optional cache prefix to be used on CircleCI. Can be used for cache busting or to ensure multiple jobs use different caches. + type: string + docker: + - image: speckle/pre-commit-runner:latest + resource_class: &docker-resource-class medium + working_directory: *workingdir + steps: + - checkout + - restore_cache: + keys: + - cache-pre-commit-<>-{{ checksum "<>" }} + - run: + name: Install pre-commit hooks + command: pre-commit install-hooks --config <> + - save_cache: + key: cache-pre-commit-<>-{{ checksum "<>" }} + paths: + - ~/.cache/pre-commit + - run: + name: Run pre-commit + command: pre-commit run --all-files --config <> + - run: + command: git --no-pager diff + name: git diff + when: on_fail + + helm-package-and-publish: + docker: + - image: quay.io/helmpack/chart-testing:v3.7.1-amd64 + resource_class: *docker-resource-class + working_directory: *workingdir + steps: + - checkout + - add_ssh_keys: + fingerprints: + - 'TODO: add fingerprint here' + - attach_workspace: + at: /tmp/workspace + - run: + name: populate environment variables + command: | + cat /tmp/workspace/env-vars >> $BASH_ENV + - run: + name: Build and Publish + command: ./.circleci/package_and_publish_helm.sh + environment: + APP_VERSION: '3.0.441-x64' diff --git a/.circleci/package_and_publish_helm.sh b/.circleci/package_and_publish_helm.sh new file mode 100755 index 0000000..88c50c5 --- /dev/null +++ b/.circleci/package_and_publish_helm.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +set -eo pipefail + +TEMP_PACKAGE_DIR="${TEMP_PACKAGE_DIR:-"/tmp/.cr-release-packages"}" +HELM_PACKAGE_BRANCH="${HELM_PACKAGE_BRANCH:-"gh-pages"}" +HELM_STABLE_BRANCH="${HELM_STABLE_BRANCH:-"main"}" +HELM_CHART_DIR_PATH="${HELM_CHART_DIR_PATH:-"charts/seq-input-gelf"}" + +if [[ -z "${VERSION}" ]]; then + echo "VERSION environment variable should be set" + exit 1 +fi + +if [[ -z "${APP_VERSION}" ]]; then + echo "APP_VERSION environment variable should be set" + exit 1 +fi + +if [[ -z "${GIT_EMAIL}" ]]; then + echo "GIT_EMAIL environment variable should be set" + exit 1 +fi +if [[ -z "${GIT_USERNAME}" ]]; then + echo "GIT_USERNAME environment variable should be set" + exit 1 +fi + +echo "๐Ÿงน cleaning temporary directory" +rm -rf "${TEMP_PACKAGE_DIR}" || true +mkdir "${TEMP_PACKAGE_DIR}" + +helm version -c + +echo "๐Ÿ—๏ธ building dependencies" +helm dependency build "${HELM_CHART_DIR_PATH}" +echo "๐ŸŽ packaging ${HELM_CHART_DIR_PATH} with version: ${VERSION}" +helm package "${HELM_CHART_DIR_PATH}" --dependency-update --version "${VERSION}" --app-version "${APP_VERSION}" --destination "${TEMP_PACKAGE_DIR}" + +echo "โฌ checking out git branch '${HELM_PACKAGE_BRANCH}'" +git config user.email "${GIT_EMAIL}" +git config user.name "${GIT_USERNAME}" +git fetch +git switch "${HELM_PACKAGE_BRANCH}" +if [[ -n "${CIRCLE_TAG}" || "${CIRCLE_BRANCH}" == "${HELM_STABLE_BRANCH}" ]]; then + echo "๐Ÿ›ป copying packages to stable directory" + cp -a "${TEMP_PACKAGE_DIR}/." stable/ + pushd stable + helm repo index . + popd +else + cp -a "${TEMP_PACKAGE_DIR}/." incubator/ + echo "๐Ÿ›ป copying packages to incubator directory" + pushd incubator + helm repo index . + popd +fi + +echo "โซ adding, commiting, and pushing to git repository" +git add . +git commit -m "updating helm chart to version ${VERSION}" +git push --set-upstream origin "${HELM_PACKAGE_BRANCH}" diff --git a/.github/workflows/close-issue.yml b/.github/workflows/close-issue.yml index 30e1ebc..ff7c6ef 100644 --- a/.github/workflows/close-issue.yml +++ b/.github/workflows/close-issue.yml @@ -9,4 +9,4 @@ jobs: uses: specklesystems/github-actions/.github/workflows/project-add-issue.yml@main secrets: inherit with: - issue-id: ${{ github.event.issue.node_id }} \ No newline at end of file + issue-id: ${{ github.event.issue.node_id }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..b07461f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,39 @@ +repos: + - repo: https://github.com/pre-commit/mirrors-prettier + rev: 'v3.0.0-alpha.4' + hooks: + - id: prettier + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: 'v4.4.0' + hooks: + - id: check-yaml + exclude: 'deploy/helm' + - id: check-merge-conflict + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + - id: check-symlinks + - id: check-vcs-permalinks + - id: trailing-whitespace + - id: end-of-file-fixer + exclude: 'deploy/helm/README.md' + + - repo: https://github.com/syntaqx/git-hooks + rev: 'v0.0.17' + hooks: + - id: circleci-config-validate + + - repo: https://github.com/Jarmos-san/shellcheck-precommit + rev: 'v0.2.0' + hooks: + - id: shellcheck-system + + - repo: https://github.com/norwoodj/helm-docs + rev: v1.11.0 + hooks: + - id: helm-docs + args: + - --chart-search-root=charts + +ci: + autoupdate_schedule: weekly diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..d3a4e7e --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +.github +charts diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..1a1ea1a --- /dev/null +++ b/.prettierrc @@ -0,0 +1,11 @@ +{ + "trailingComma": "none", + "tabWidth": 2, + "semi": false, + "endOfLine": "auto", + "bracketSpacing": true, + "vueIndentScriptAndStyle": false, + "htmlWhitespaceSensitivity": "ignore", + "printWidth": 88, + "singleQuote": true +} diff --git a/README.md b/README.md index fccc8f6..8161adf 100644 --- a/README.md +++ b/README.md @@ -4,48 +4,64 @@ ## Introduction -This section should hold a quick intro on what this repo's about. For example: +This repository contains a Helm Chart for deploying [DataLust's `seq-input-gelf`](https://docs.datalust.co/docs/using-gelf#enabling-gelf-in-docker) Docker image to a Kubernetes cluster. -This repo holds Speckle's: +If deploying `seq-input-gelf` alongside `seq`, please use DataLust's [official Helm Chart](https://github.com/datalust/helm.datalust.co/tree/main/charts/seq). This Helm Chart allows `seq-input-gelf` to be deployed independently of `seq`. -- Default [Code of Conduct](.github/CODE_OF_CONDUCT.md), -- Default [Contribution Guidelines](.github/CONTRIBUTING.md), -- README template (you're reading it now), -- Default [Issue Template](.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md), -- Default [Pull Request Template](.github/PULL_REQUEST_TEMPLATE/PR_TEMPLATE.md), -- OSS License (Apache 2.0) +You may wish to deploy `seq-input-gelf` if you are exporting logs in Graylog Extended Log Format (GELF). -Either copy paste the parts that are useful in existing repos, or use this as a base when creating a new repository. +You may wish to deploy `seq-input-gelf` independently of `seq` if you have a multiple Kubernetes clusters, and wish to transfer log data from a source cluster to a target cluster, running `seq`. Alternatively, you may have `seq` deployed on a non-Kubernetes environment, and wish to export logs messages from Kubernetes to that external seq instance. ## Documentation Comprehensive developer and user documentation can be found in our: -#### ๐Ÿ“š [Speckle Docs website](https://speckle.guide/dev/) +### Usage -## This Readme Template +1. You will require [Helm](https://helm.sh/docs/intro/install/) and access to a [Kubernetes](https://kubernetes.io/) cluster to which you have appropriate permissions to deploy resources. +1. Clone this repository and in a shell terminal, `cd` in to the root directory of the cloned repository. +1. Run the following command to create a secret containing your deployment key, replacing `YOURAPIKEY` with an [API key generated by your Seq instance](https://docs.datalust.co/docs/api-keys): -Is rather straightforward. It includes several default sections and one section that requires special attention. + ```shell + kubectl create secret generic seq-api-key --from-value=api-key=YOURAPIKEY --namespace seq-input-gelf + ``` -Default sections: +1. Run the following command to install the helm chart in your kubernetes cluster. Note that this will create a new namespace named `seq-input-gelf`: -- Badges: has several default social badges. Feel free to add more. -- Developing & Debugging - needs filling in! -- Community - can be left as is. + ```shell + helm upgrade seq-input-gelf \ + ./charts/seq-input-gelf \ + --create-namespace \ + --namespace seq-input-gelf \ + --install \ + --values ./example/values.yaml + ``` -**License section**: If this is a pure OSS repo, like Core, remove everything after the first phrase. Otherwise, we need to plan ahead before releasing and make sure we're covered. +1. Verify that the deployment has successfully [rolled out](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#deployment-status): -## Developing & Debugging + ```shell + kubectl rollout status deployment/seq-input-gelf --namespace seq-input-gelf + ``` + +### Developing & Debugging This doesn't make sense here, but in general, we should try to provide a small "how to" guide on local development and debugging, as it lowers the barrier to contributions. -## Contributing +### Contributing Please make sure you read the [contribution guidelines](.github/CONTRIBUTING.md) and [code of conduct](.github/CODE_OF_CONDUCT.md) for an overview of the practices we try to follow. -## Community +#### Prerequisites -The Speckle Community hangs out on [the forum](https://discourse.speckle.works), do join and introduce yourself & feel free to ask us questions! +1. Your code must pass our pre-commit checks in order to be accepted. + 1. Install [pre-commit](https://pre-commit.com/#install). + 1. In your shell terminal, `cd` to the root directory of this repository. + 1. Run `pre-commit install`. + 1. Review the output and adjust your contribution as necessary. + +### Community + +This Helm Chart is maintained by Speckle. The Speckle Community hangs out on [the forum](https://discourse.speckle.works), do join and introduce yourself & feel free to ask us questions! ## Security diff --git a/charts/seq-input-gelf/.gitkeep b/charts/seq-input-gelf/.gitkeep new file mode 100644 index 0000000..e69de29