Skip to content

Commit

Permalink
the update chart
Browse files Browse the repository at this point in the history
  • Loading branch information
rotty3000 committed Jan 17, 2025
1 parent b9dbf70 commit 1a4c9fc
Show file tree
Hide file tree
Showing 24 changed files with 2,197 additions and 232 deletions.
165 changes: 165 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
name: CI

on:
push:
branches-ignore:
- "dependabot/**"
- "gh-pages/**"
paths:
- "**"
- "!docs/**"
tags:
- "v*"
pull_request:
branches-ignore:
- "dependabot/**"
- "gh-pages/**"
paths:
- "**"
- "!docs/**"

env:
CHART_VERSION: "0.0.0"
CHARTS_TMP_DIR: dist
LC_ALL: en_US.UTF-8
PUBLISH: "false"
SOURCE_DIR: "."

defaults:
run:
shell: bash

permissions:
packages: write
contents: write

jobs:
ci:
name: Build, Test, maybe Publish
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4

- name: Install Helm
run: |
curl -sL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- name: Verify Helm Installation
shell: bash
run: |
helm version
- name: Install the latest version of Kind
shell: bash
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
- name: Verify Kind Installation
shell: bash
run: |
kind version
- name: Create Kind Cluster
shell: bash
run: |
kind create cluster
- name: Run Helm Test
id: helm-test
run: |
helm upgrade -i liferay .
helm test liferay && \
echo "PUBLISH=${{ (github.repository == 'LiferayCloud/liferay-helm-chart') && startsWith(github.ref, 'refs/tags/') && (github.event_name != 'pull_request') }}" >> ${GITHUB_ENV}
- name: Calculate Chart Version
if: ${{ env.PUBLISH == 'true' }}
id: calculate-chart-version
run: |
# This is the tag name
echo GITHUB_REF=${{ github.ref }}
# This is the version
CHART_VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && CHART_VERSION=$(echo $CHART_VERSION | sed -e 's/^v//')
[ "$CHART_VERSION" == "main" ] && CHART_VERSION="0.0.0"
echo CHART_VERSION=$CHART_VERSION
echo "CHART_VERSION=${CHART_VERSION}" >> ${GITHUB_ENV}
- name: Package the Helm Chart
if: ${{ env.PUBLISH == 'true' }}
run: |
mkdir ${CHARTS_TMP_DIR}
helm package --version ${CHART_VERSION} -d ${CHARTS_TMP_DIR} .
echo "CHARTS_TMP_DIR=$(realpath $CHARTS_TMP_DIR)" >> ${GITHUB_ENV}
echo "SOURCE_DIR=$(realpath $SOURCE_DIR)" >> ${GITHUB_ENV}
- name: Log in to registry with Helm
if: ${{ env.PUBLISH == 'true' }}
run: |
echo "${{ github.token }}" | helm registry login ghcr.io/${{ github.repository }} --username ${{ github.actor }} --password-stdin
- name: Push Helm Charts to Github Container Registry (OCI)
if: ${{ env.PUBLISH == 'true' }}
working-directory: dist
run: |
for f in *.tgz ; do
echo "$f"
helm push $f oci://ghcr.io/${{ github.repository }}/charts
done
- name: Install YQ
if: ${{ env.PUBLISH == 'true' }}
run: |
curl -sLo ./yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
chmod +x ./yq
sudo mv ./yq /usr/local/bin/yq
- name: Test YQ Installation
if: ${{ env.PUBLISH == 'true' }}
run: |
yq --version
- name: Update and Publish the Helm Index
if: ${{ env.PUBLISH == 'true' }}
run: |
tmpDir=$(mktemp -d)
pushd $tmpDir >& /dev/null
git clone ${REPO_URL}
cd ${REPOSITORY}
git config user.name "${OWNER}"
git config user.email "${OWNER}@users.noreply.github.com"
git remote set-url origin ${REPO_URL}
git checkout ${PUBLISH_BRANCH}
helm repo index ${CHARTS_TMP_DIR} --url ${CHARTS_URL} --merge "${INDEX_DIR}/index.yaml"
mv -f ${CHARTS_TMP_DIR}/index.yaml ${INDEX_DIR}/index.yaml
# Rewrite the urls into the correct OCI format for the index
yq -i '.entries.liferay[].urls[] |= sub("-(\d+\.\d+\.\d+)\.tgz", ":$1")' ${INDEX_DIR}/index.yaml
# Copy the markdown files to the gh-pages branch
find ${SOURCE_DIR} -name "*.md" -exec cp -f '{}' . \;
# Add all changed files to the index
git add --all
# Diff for observability
git diff --cached
git commit -m "Publish $charts"
git push origin ${PUBLISH_BRANCH}
popd >& /dev/null
rm -rf $tmpDir
env:
CHARTS_URL: "oci://ghcr.io/${{ github.actor }}/${{ github.event.repository.name }}/charts"
INDEX_DIR: charts
OWNER: ${{ github.actor }}
PUBLISH_BRANCH: gh-pages
REPO_URL: "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}"
REPOSITORY: ${{ github.event.repository.name }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/

values-*.yaml
2 changes: 2 additions & 0 deletions .helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
.idea/
*.tmproj
.vscode/

dist/
8 changes: 4 additions & 4 deletions Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: liferay-helm
description: A Helm chart for Kubernetes
name: liferay
description: A Liferay DXP Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
Expand All @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 0.0.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
appVersion: "latest"
118 changes: 118 additions & 0 deletions FOR_LOCAL_DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
## For Local Development

Use this approach when you want to deploy Liferay DXP into a local Kubernetes cluster so you can use and explore the features of DXP in a cloud native configuration.

Required tools:

- Kubectl (recommend `brew install kubernetes-cli`)
- Helm (recommend `brew install helm`)
- K3d (recommend `brew install k3d`)
- Stern (recommend `brew install stern`)

#### Setup a local Kubernetes cluster

The simplest and most comprehensive approach is to use K3d because it supports built-in ingress and seamlessly integrates with Docker's hostname resolution for addresses with the suffix `*.docker.localhost`. (not tested on MacOS or Windows yet)

```shell
k3d cluster create playground \
-p "80:80@loadbalancer" \
-p "443:443@loadbalancer" \
```

#### Install the Chart

It is recommended to install the chart into a custom namespace.

```shell
helm upgrade -i liferay -n liferay-system --create-namespace liferay-helm-chart-repo/liferay
```

_Or from a local clone of the repository_:

```shell
helm upgrade -i liferay -n liferay-system --create-namespace .
```

By default the chart will use the `liferay/dxp:latest` docker image.

#### Check the Installation Progress

There are many moving parts (including downloading the Liferay DXP image) and so it will take several seconds (up to several minutes) before the system is fully working.

I recommend using the following command (which you can run immediately after the helm command completes):

```shell
sterm -n liferay-system liferay-0
```

This will log all the output of Liferay DXP (including waiting for it to start).

#### How to Gain Access

There are 3 preset addresses:

- DXP: http://main.dxp.docker.localhost

The default user name and password are `[email protected]` : `test`.

- MinIO (S3 Server):

- Console: http://console.minio.docker.localhost
- API: http://console.minio.docker.localhost

The default user name and password are `minio` : `miniominio`.

#### Specify a version of Liferay DXP

To specify the version of Liferay DXP to deploy supply a value for `image.tag` on the command line

```shell
helm upgrade -i liferay -n liferay-system --create-namespace \
--set image.tag=2024.q3.13 \
.
```

### Additional Virtual Hosts

If you create additional virtual instances in DXP select a hostname deriving from `*.dxp.docker.localhost` and specify that value for each of **WebId**, **Virtual Host** and **Mail Domain**. Once the Virtual Instance is created that host should be reachable without further action.

e.g. create a new host using:

- **WebId**: `two.dxp.docker.localhost`
- **Virtual Host**: `two.dxp.docker.localhost`
- **Mail Domain**: `two.dxp.docker.localhost`
- Wait for completion then access the virtual instance at http://two.dxp.docker.localhost

## Uninstallation

If all you want to do is update the chart, simply execute the install instruction above.

However, to uninstall the chart simply do:

```shell
helm uninstall -n liferay-system liferay
```

### Starting from Scratch

Starting from scratch involves also removing all the storage volumes.

First uninstall the chart as above. Then remove all the persistent volumes (which destroys all the data):

```shell
k delete -n liferay-system persistentvolumeclaims \
liferay-elasticsearch-pvc-liferay-elasticsearch-0 \
liferay-minio-pvc-liferay-minio-0 \
liferay-postgres-pvc-liferay-postgres-0 \
liferay-working-data-pvc-liferay-0
```

## Basic Observation of the Chart

If you want to watch the progress of the chart the following simple command works well:

```shell
watch -n .5 kubectl get -n liferay-system all,svc,cm,pvc,ingress
```

As resources come, go and update their status the output will adjust accordingly.
Loading

0 comments on commit 1a4c9fc

Please sign in to comment.