Skip to content

Commit

Permalink
Merge pull request #72 from mzeevi/ci/addHelm
Browse files Browse the repository at this point in the history
ci: add helm chart to repo with release workflow
  • Loading branch information
fran2810 authored Aug 13, 2024
2 parents 7462c79 + 653aa73 commit f22878b
Show file tree
Hide file tree
Showing 40 changed files with 824 additions and 579 deletions.
60 changes: 59 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,62 @@ jobs:
- name: Upload install.yaml file
uses: softprops/action-gh-release@v2
with:
files: ./build/install.yaml
files: ./build/install.yaml

package-and-push-helm-chart:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9

- name: Set up Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78
with:
version: v3.12.0

- name: Set chart name
id: chart-name
run: echo "value=${{ github.event.repository.name }}" >> "$GITHUB_OUTPUT"

- name: Set OCI registry name
id: oci-registry-name
run: echo "value=ghcr.io/${{ github.repository_owner }}/helm-charts" >> "$GITHUB_OUTPUT"

- name: Set OCI chart name
id: oci-chart-name
run: echo "value=${{ steps.oci-registry-name.outputs.value }}/${{ steps.chart-name.outputs.value }}" >> "$GITHUB_OUTPUT"

- name: Helm lint
run: helm lint charts/${{ steps.chart-name.outputs.value }}

- name: Trim prefix from version
id: version
run: echo "value=$(echo ${{ github.ref_name }} | sed 's/release-//')" >> "$GITHUB_OUTPUT"

- name: Helm package
id: build
run: |
helm package charts/${{ steps.chart-name.outputs.value }} --version ${{ steps.version.outputs.value }} --app-version ${{ steps.version.outputs.value }}
echo "package=${{ steps.chart-name.outputs.value }}-${{ steps.version.outputs.value }}.tgz" >> "$GITHUB_OUTPUT"
- name: Upload chart as artifact
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
with:
name: "[${{ github.job }}] Helm chart"
path: ${{ steps.build.outputs.package }}

- name: Log in to the Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Helm push
run: helm push ${{ steps.build.outputs.package }} oci://${{ steps.oci-registry-name.outputs.value }}
env:
HELM_REGISTRY_CONFIG: ~/.docker/config.json
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ build/install.yaml: manifests kustomize
cd ${CURDIR} && \
$(KUSTOMIZE) build build/kustomize > $@

.PHONY: doc-chart
doc-chart: helm-docs helm
$(HELM_DOCS) charts/

##@ Dependencies

## Location to install dependencies to
Expand All @@ -170,12 +174,15 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen-$(CONTROLLER_TOOLS_VERSION)
ENVTEST ?= $(LOCALBIN)/setup-envtest-$(ENVTEST_VERSION)
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
GINKGO ?= $(LOCALBIN)/ginkgo
HELM_DOCS ?= $(LOCALBIN)/helm-docs-$(HELM_DOCS_VERSION)
HELM_URL ?= https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3

## Tool Versions
KUSTOMIZE_VERSION ?= v5.3.0
CONTROLLER_TOOLS_VERSION ?= v0.14.0
ENVTEST_VERSION ?= release-0.17
GOLANGCI_LINT_VERSION ?= v1.54.2
HELM_DOCS_VERSION ?= v1.14.2

.PHONY: kustomize
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
Expand All @@ -202,6 +209,17 @@ ginkgo: $(GINKGO) ## Download ginkgo locally if necessary.
$(GINKGO): $(LOCALBIN)
test -s $(LOCALBIN)/ginkgo || GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/ginkgo@latest

.PHONY: helm
helm:
wget -O $(LOCALBIN)/get-helm.sh $(HELM_URL)
chmod 700 $(LOCALBIN)/get-helm.sh
$(LOCALBIN)/get-helm.sh

.PHONY: helm-docs
helm-docs: $(HELM_DOCS)
$(HELM_DOCS): $(LOCALBIN)
$(call go-install-tool,$(HELM_DOCS),github.com/norwoodj/helm-docs/cmd/helm-docs,$(HELM_DOCS_VERSION))

# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary (ideally with version)
# $2 - package url which can be installed
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ The `nfspvc-operator` is an operator that reconciles `NfsPvc` CRs.

This is useful when you have an already-created NFS, which you would like to mount in different places (Kubernetes Pod, Virtual Machine, etc...).

## Install with Helm

Helm chart docs are available on `charts/nfspvc-operator` directory.

Make sure `cert-manager` is [installed](https://cert-manager.io/docs/installation/helm/) as a prerequisite.

```
$ helm upgrade --install nfspvc-operator --namespace nfspvc-operator --create-namespace oci://ghcr.io/dana-team/helm-charts/nfspvc-operator --version <release>
```

## How to Use

An example `NfsPvc` CR looks as follows:
Expand Down
23 changes: 0 additions & 23 deletions chart/.helmignore

This file was deleted.

7 changes: 0 additions & 7 deletions chart/Chart.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions chart/templates/configuration-nfspvc.yaml

This file was deleted.

85 changes: 0 additions & 85 deletions chart/templates/deployment.yaml

This file was deleted.

59 changes: 0 additions & 59 deletions chart/templates/leader-election-rbac.yaml

This file was deleted.

73 changes: 0 additions & 73 deletions chart/templates/manager-rbac.yaml

This file was deleted.

Loading

0 comments on commit f22878b

Please sign in to comment.