Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/publish-helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
name: Publish Ascender Operator Helm chart
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag_name:
description: 'Name for the tag of the release.'
required: true

jobs:
publish-chart:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Set GitHub Env vars for workflow_dispatch event
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV

- name: Set GitHub Env vars if release event
if: ${{ github.event_name == 'release' }}
run: |
echo "TAG_NAME=${{ github.event.release.tag_name }}" >> $GITHUB_ENV

- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0

- name: Package the chart
run: |
make helm-package VERSION="${TAG_NAME}"

- name: Attach the chart to the release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
CHART_NAME=$(make print-CHART_NAME)
gh release upload "${TAG_NAME}" \
".cr-release-packages/${TAG_NAME}/${CHART_NAME}-${TAG_NAME}.tgz" --clobber

# The chart repository is the gh-pages branch of this repository: index.yaml lists
# every release that carries a chart, and each entry points at the tarball attached
# to that release.
- name: Publish the chart index to the gh-pages branch
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
REPO_URL="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"

if git ls-remote --exit-code --heads "${REPO_URL}" gh-pages > /dev/null; then
git clone --branch gh-pages --single-branch "${REPO_URL}" gh-pages
else
git clone --depth 1 "${REPO_URL}" gh-pages
git -C gh-pages switch --orphan gh-pages
fi

# helm repo index merges into an existing index, so seed one the first time
# the chart is published.
if [ ! -f gh-pages/index.yaml ]; then
printf 'apiVersion: v1\nentries: {}\n' > gh-pages/index.yaml
fi

make helm-index CHART_OWNER="${GITHUB_REPOSITORY_OWNER}"

cd gh-pages
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add index.yaml
git commit -m "Update index.yaml for release ${TAG_NAME}"
git push origin gh-pages
18 changes: 9 additions & 9 deletions .helm/starter/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# AWX Operator Helm Chart
# Ascender Operator Helm Chart

This chart installs the AWX Operator resources configured in [this](https://github.com/ansible/awx-operator) repository.
This chart installs the Ascender Operator resources configured in [this](https://github.com/ctrliq/ascender-operator) repository.

## Getting Started
To configure your AWX resource using this chart, create your own `yaml` values file. The name is up to personal preference since it will explicitly be passed into the helm chart. Helm will merge whatever values you specify in your file with the default `values.yaml`, overriding any settings you've changed while allowing you to fall back on defaults. Because of this functionality, `values.yaml` should not be edited directly.

In your values config, enable `AWX.enabled` and add `AWX.spec` values based on the awx operator's [documentation](https://github.com/ansible/awx-operator/blob/devel/README.md). Consult the docs below for additional functionality.
In your values config, enable `AWX.enabled` and add `AWX.spec` values based on the operator's [documentation](https://github.com/ctrliq/ascender-operator/blob/devel/README.md). Consult the docs below for additional functionality.

### Installing

The operator's [helm install](https://ansible.readthedocs.io/projects/awx-operator/en/latest/installation/helm-install-on-existing-cluster.html) guide provides key installation instructions.
The operator's [helm install](https://github.com/ctrliq/ascender-operator/blob/devel/docs/installation/helm-install-on-existing-cluster.md) guide provides key installation instructions.

Example:

```bash
helm install my-awx-operator awx-operator/awx-operator -n awx --create-namespace -f myvalues.yaml
helm install my-ascender-operator ascender-operator/ascender-operator -n ascender --create-namespace -f myvalues.yaml
```

Argument breakdown:
Expand All @@ -33,7 +33,7 @@ There is no support at this time for upgrading or deleting CRDs using Helm. See
When upgrading to releases with CRD changes use the following command to update the CRDs

```bash
kubectl apply --server-side -k github.com/ansible/awx-operator/config/crd?ref=<VERSION>
kubectl apply --server-side -k github.com/ctrliq/ascender-operator/config/crd?ref=<VERSION>
```

If running above command results in an error like below:
Expand All @@ -56,11 +56,11 @@ See https://kubernetes.io/docs/reference/using-api/server-side-apply/#conflicts
Use `--force-conflicts` flag to resolve the conflict.

```bash
kubectl apply --server-side --force-conflicts -k github.com/ansible/awx-operator/config/crd?ref=<VERSION>
kubectl apply --server-side --force-conflicts -k github.com/ctrliq/ascender-operator/config/crd?ref=<VERSION>
```

## Configuration
The goal of adding helm configurations is to abstract out and simplify the creation of multi-resource configs. The `AWX.spec` field maps directly to the spec configs of the `AWX` resource that the operator provides, which are detailed in the [main README](https://github.com/ansible/awx-operator/blob/devel/README.md). Other sub-config can be added with the goal of simplifying more involved setups that require additional resources to be specified.
The goal of adding helm configurations is to abstract out and simplify the creation of multi-resource configs. The `AWX.spec` field maps directly to the spec configs of the `AWX` resource that the operator provides, which are detailed in the [main README](https://github.com/ctrliq/ascender-operator/blob/devel/README.md). Other sub-config can be added with the goal of simplifying more involved setups that require additional resources to be specified.

These sub-headers aim to be a more intuitive entrypoint into customizing your deployment, and are easier to manage in the long-term. By design, the helm templates will defer to the manually defined specs to avoid configuration conflicts. For example, if `AWX.spec.postgres_configuration_secret` is being used, the `AWX.postgres` settings will not be applied, even if enabled.

Expand Down Expand Up @@ -351,7 +351,7 @@ Below the addition variables to customize the secret configuration.
Where possible, defer to `AWX.spec` configs before applying the abstracted configs to avoid collision. This can be facilitated by the `(hasKey .spec what_i_will_abstract)` check.

## Building and Testing
This chart is built using the Makefile in the [awx-operator repo](https://github.com/ansible/awx-operator). Clone the repo and run `make helm-chart`. This will create the awx-operator chart in the `charts/awx-operator` directory. In this process, the contents of the `.helm/starter` directory will be added to the chart.
This chart is built using the Makefile in the [ascender-operator repo](https://github.com/ctrliq/ascender-operator). Clone the repo and run `make helm-chart`. This will create the ascender-operator chart in the `charts/ascender-operator` directory. In this process, the contents of the `.helm/starter` directory will be added to the chart.

## Future Goals
All values under the `AWX` header are focused on configurations that use the operator. Configurations that relate to the Operator itself could be placed under an `Operator` heading, but that may add a layer of complication over current development.
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
NAMESPACE ?= awx

# Helm variables
CHART_NAME ?= awx-operator
CHART_DESCRIPTION ?= A Helm chart for the AWX Operator
CHART_NAME ?= ascender-operator
CHART_DESCRIPTION ?= A Helm chart for the Ascender Operator
CHART_OWNER ?= $(GH_REPO_OWNER)
CHART_REPO ?= awx-operator
CHART_REPO ?= ascender-operator
CHART_BRANCH ?= gh-pages
CHART_DIR ?= gh-pages
CHART_INDEX ?= index.yaml
Expand Down Expand Up @@ -341,7 +341,7 @@ helm-chart-generate: kustomize helm kubectl-slice yq charts
rm -rf charts/$(CHART_NAME)
# create new chart metadata in Chart.yaml
cd charts && \
$(HELM) create awx-operator --starter $(shell pwd)/.helm/starter ;\
$(HELM) create $(CHART_NAME) --starter $(shell pwd)/.helm/starter ;\
$(YQ) -i '.version = "$(VERSION)"' $(CHART_NAME)/Chart.yaml ;\
$(YQ) -i '.appVersion = "$(VERSION)" | .appVersion style="double"' $(CHART_NAME)/Chart.yaml ;\
$(YQ) -i '.description = "$(CHART_DESCRIPTION)"' $(CHART_NAME)/Chart.yaml ;\
Expand Down Expand Up @@ -389,7 +389,7 @@ helm-chart-generate: kustomize helm kubectl-slice yq charts
rm -rf charts/$(CHART_NAME)/raw-files

# create and populate NOTES.txt
@echo "AWX Operator installed with Helm Chart version $(VERSION)" > charts/$(CHART_NAME)/templates/NOTES.txt
@echo "Ascender Operator installed with Helm Chart version $(VERSION)" > charts/$(CHART_NAME)/templates/NOTES.txt

@echo "Helm chart successfully configured for $(CHART_NAME) version $(VERSION)"

Expand All @@ -399,7 +399,7 @@ helm-package: helm-chart
@echo "== Package Current Chart Version =="
mkdir -p .cr-release-packages
# package the chart and put it in .cr-release-packages dir
$(HELM) package ./charts/awx-operator -d .cr-release-packages/$(VERSION)
$(HELM) package ./charts/$(CHART_NAME) -d .cr-release-packages/$(VERSION)

# List all tags oldest to newest.
TAGS := $(shell git ls-remote --tags --sort=version:refname --refs -q | cut -d/ -f3)
Expand All @@ -408,7 +408,7 @@ TAGS := $(shell git ls-remote --tags --sort=version:refname --refs -q | cut -d/
# until https://github.com/helm/chart-releaser/issues/122 happens, chart-releaser is not ideal for a chart
# that is contained within a larger repo, where a tag may not require a new chart version
.PHONY: helm-index
helm-index:
helm-index: helm
# when running in CI the gh-pages branch is checked out by the ansible playbook
# TODO: test if gh-pages directory exists and if not exist

Expand Down
24 changes: 13 additions & 11 deletions docs/installation/helm-install-on-existing-cluster.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
### Helm Install on existing cluster

For those that wish to use [Helm](https://helm.sh/) to install the awx-operator to an existing K8s cluster:
For those that wish to use [Helm](https://helm.sh/) to install the ascender-operator to an existing K8s cluster:

The helm chart is generated from the `helm-chart` Makefile section using the starter files in `.helm/starter`. Consult [the documentation](https://github.com/ansible/awx-operator/blob/devel/.helm/starter/README.md) on how to customize the AWX resource with your own values.
The helm chart is generated from the `helm-chart` Makefile section using the starter files in `.helm/starter`. Consult [the documentation](https://github.com/ctrliq/ascender-operator/blob/devel/.helm/starter/README.md) on how to customize the AWX resource with your own values.

```bash
$ helm repo add awx-operator https://ansible.github.io/awx-operator/
"awx-operator" has been added to your repositories
$ helm repo add ascender-operator https://ctrliq.github.io/ascender-operator/
"ascender-operator" has been added to your repositories

$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "awx-operator" chart repository
...Successfully got an update from the "ascender-operator" chart repository
Update Complete. ⎈Happy Helming!⎈

$ helm search repo awx-operator
NAME CHART VERSION APP VERSION DESCRIPTION
awx-operator/awx-operator 0.17.1 0.17.1 A Helm chart for the AWX Operator
$ helm search repo ascender-operator
NAME CHART VERSION APP VERSION DESCRIPTION
ascender-operator/ascender-operator 25.5.1 25.5.1 A Helm chart for the Ascender Operator

$ helm install -n awx --create-namespace my-awx-operator awx-operator/awx-operator
NAME: my-awx-operator
$ helm install -n ascender --create-namespace my-ascender-operator ascender-operator/ascender-operator
NAME: my-ascender-operator
LAST DEPLOYED: Thu Feb 17 22:09:05 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Helm Chart 0.17.1
Helm Chart 25.5.1
```

Each release publishes the chart as an asset on its GitHub release, and the chart index served from the `gh-pages` branch of this repository points at those assets. A release made before the chart was published is not in the index, so `helm search repo` only lists the versions that carry one.