diff --git a/applications/fake-services/.github/workflows/replicated-release-unstable.yaml b/applications/fake-services/.github/workflows/replicated-release-unstable.yaml index 45b0d710..bdc150fe 100644 --- a/applications/fake-services/.github/workflows/replicated-release-unstable.yaml +++ b/applications/fake-services/.github/workflows/replicated-release-unstable.yaml @@ -2,6 +2,10 @@ name: replicated-release-unstable on: workflow_dispatch: + inputs: + version: + description: "Version tag (e.g. v1.0.0)" + required: false push: branches: - main @@ -17,7 +21,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - + - name: Get latest tag id: get-latest-tag run: | @@ -28,8 +32,14 @@ jobs: - name: Set release version id: set-release-version run: | - VERSION=${{ env.LATEST_TAG }}-$(git rev-parse --short HEAD) - echo "VERSION=${VERSION}" >> $GITHUB_ENV + if [ -z "${{ github.event.inputs.version }}" ]; then + git_hash=$(git rev-parse --short HEAD) + date_version=$(date -u '+%Y.%-m.%-d-%H%M%S') + version="${date_version}-Unstable-${git_hash}" + else + version="${{ github.event.inputs.version }}" + fi + echo "VERSION=${version}" >> $GITHUB_ENV - name: Package Helm chart id: package-helm-chart @@ -37,7 +47,7 @@ jobs: helm package ./app --debug -u -d ./replicated \ --version ${{ env.VERSION }} \ --app-version ${{ env.VERSION }} - + - name: Install yq run: | wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq &&\ @@ -46,7 +56,7 @@ jobs: - name: Update HelmChart kind run: | yq -i '.spec.chart.chartVersion = "${{ env.VERSION }}"' replicated/kots-chart.yaml - + - name: Create Replicated release id: create-release uses: replicatedhq/compatibility-actions/create-release@v1 @@ -54,5 +64,5 @@ jobs: app-slug: ${{ secrets.REPLICATED_APP }} api-token: ${{ secrets.REPLICATED_API_TOKEN }} yaml-dir: ./replicated - promote-channel: unstable - version: ${{ env.VERSION }} \ No newline at end of file + promote-channel: Unstable + version: ${{ env.VERSION }} diff --git a/applications/fake-services/README.md b/applications/fake-services/README.md index c4e82215..ed3dd90d 100644 --- a/applications/fake-services/README.md +++ b/applications/fake-services/README.md @@ -2,7 +2,60 @@ This repository contains an example Helm chart that distributed with Replicated Embedded Cluster. +![app](img/app.png) + ## Components - A Helm chart using [fake-service](https://github.com/nicholasjackson/fake-service) - Replicated [manifests](https://docs.replicated.com/reference/custom-resource-about) to deploy the chart with Replicated + +## Replicated features + +- [x] Packaged as a Helm chart +- [x] Installation works via Helm CLI, as well as KOTS & Embedded Cluster +- [x] Support Online and Airgap install +- [x] Replicated SDK installed +- [x] Custom Metrics implemented +- [x] Github Actions workflow for Replicated test and release +- [x] Support Replicated Proxy Service +- [x] Support Replicated Custom Domain + +## Troubleshooting features for CRE + +We do include utility pods to peek into KOTS Admin Console underlying database and object storage (Minio). + +### rqlite + +For database, to peek into `rqlite` database, you can use the following command: + +```bash +kubectl port-forward svc/rqlite-ui-service 3000:80 +``` + +And go to http://localhost:3000 to browse the database. + +![rqlite-ui](img/rqlite-ui.png) + +### Minio + +For object storage, to peek into `minio` object storage, you can use the following command: + +First, get the WebUI port from `kotsadm-minio-0` pod: + +```log +kubectl logs kotsadm-minio-0 +... +WebUI: http://10.42.0.11:> http://127.0.0.1: +``` + +Next, port forward to the WebUI port: + +```bash +kubectl port-forward svc/kotsadm-minio : +``` + +And go to http://localhost: to browse the object storage. + +The username is `admin` and the password is the secretkey in `kotsadm-minio` secret. + +![minio-ui](img/minio-ui.png) \ No newline at end of file diff --git a/applications/fake-services/app/Chart.lock b/applications/fake-services/app/Chart.lock index f50184f6..13568257 100644 --- a/applications/fake-services/app/Chart.lock +++ b/applications/fake-services/app/Chart.lock @@ -6,4 +6,4 @@ dependencies: repository: oci://registry.replicated.com/library version: 1.0.0-beta.31 digest: sha256:c349fc2fe99276ed430877ef2a0cf0e05150cd27f6e4eae2d7bfe47733f64846 -generated: "2024-11-27T11:01:55.491515+11:00" +generated: "2025-02-04T08:53:26.530341+11:00" diff --git a/applications/fake-services/app/templates/_helpers.tpl b/applications/fake-services/app/templates/_helpers.tpl index 429f8b28..0cd2da7e 100644 --- a/applications/fake-services/app/templates/_helpers.tpl +++ b/applications/fake-services/app/templates/_helpers.tpl @@ -70,6 +70,26 @@ Backend service name backend-service {{- end }} +{{/* +Rqlite UI service name +*/}} +{{- define "fake-service.rqliteui.name" -}} +rqlite-ui-service +{{- end }} + +{{/* +Rqlite UI labels selector +*/}} +{{- define "fake-service.rqliteui.selectorLabels" -}} +app.kubernetes.io/name: {{ include "fake-service.name" . }}-rqliteui +{{- end }} + +{{/* +Minio UI labels selector +*/}} +{{- define "fake-service.minioui.selectorLabels" -}} +app.kubernetes.io/name: {{ include "fake-service.name" . }}-minioui +{{- end }} {{/* Image Pull Secrets diff --git a/applications/fake-services/app/templates/backend-deployment.yaml b/applications/fake-services/app/templates/backend-deployment.yaml index cccbf10d..3ea78536 100644 --- a/applications/fake-services/app/templates/backend-deployment.yaml +++ b/applications/fake-services/app/templates/backend-deployment.yaml @@ -1,7 +1,7 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: backend + name: {{ quote (printf "%s-backend" (include "fake-service.fullname" .)) }} labels: {{- include "fake-service.labels" . | nindent 4 }} spec: diff --git a/applications/fake-services/app/templates/frontend-deployment.yaml b/applications/fake-services/app/templates/frontend-deployment.yaml index 26109390..affa2228 100644 --- a/applications/fake-services/app/templates/frontend-deployment.yaml +++ b/applications/fake-services/app/templates/frontend-deployment.yaml @@ -1,7 +1,7 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: frontend + name: {{ quote (printf "%s-frontend" (include "fake-service.fullname" .)) }} labels: {{- include "fake-service.labels" . | nindent 4 }} spec: @@ -33,4 +33,4 @@ spec: - name: LOG_LEVEL value: "{{ .Values.frontend.logLevel }}" - name: UPSTREAM_URIS - value: "http://{{ include "fake-service.backend.name" . }}.{{ .Release.Namespace }}" \ No newline at end of file + value: "http://{{ include "fake-service.backend.name" . }}.{{ .Release.Namespace }}" diff --git a/applications/fake-services/app/templates/minio-ui-deployment.yaml b/applications/fake-services/app/templates/minio-ui-deployment.yaml new file mode 100644 index 00000000..8dc26448 --- /dev/null +++ b/applications/fake-services/app/templates/minio-ui-deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ quote (printf "%s-minio-ui" (include "fake-service.fullname" .)) }} + labels: + {{- include "fake-service.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + {{- include "fake-service.minioui.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "fake-service.minioui.selectorLabels" . | nindent 8 }} + spec: + initContainers: + - name: setup-minio-ui + image: minio/minio + env: + - name: MINIO_ACCESS_KEY + valueFrom: + secretKeyRef: + name: kotsadm-minio + key: accesskey + - name: MINIO_SECRET_KEY + valueFrom: + secretKeyRef: + name: kotsadm-minio + key: secretkey + command: + - /bin/sh + - -c + - | + mc alias set myminio http://kotsadm-minio:9000 $MINIO_ACCESS_KEY $MINIO_SECRET_KEY + echo "Creating Minio Console Admin User..." + mc admin user add myminio admin $MINIO_SECRET_KEY + echo "Attaching IAM policy..." + mc admin policy attach myminio consoleAdmin --user admin + containers: + - name: minio-ui + image: alpine + command: + - /bin/sh + - -c + - | + echo "Check WebUI port in kotsadm-minio pod logs and port forward to it to browse the Minio UI" + echo "e.g. kubectl port-forward svc/kotsadm-minio 33655:33655" + echo "username: admin, password: set to secretkey in kotsadm-minio secret" + sleep infinity + restartPolicy: Always diff --git a/applications/fake-services/app/templates/rqlite-ui-deployment.yaml b/applications/fake-services/app/templates/rqlite-ui-deployment.yaml new file mode 100644 index 00000000..c1feada0 --- /dev/null +++ b/applications/fake-services/app/templates/rqlite-ui-deployment.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ quote (printf "%s-rqlite-ui" (include "fake-service.fullname" .)) }} + labels: + {{- include "fake-service.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "fake-service.rqliteui.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "fake-service.rqliteui.selectorLabels" . | nindent 8 }} + spec: + {{- include "helpers.imagePullSecrets" . | nindent 6 }} + containers: + - name: rqliteui + image: {{ .Values.rqliteui.image.registry }}/{{ .Values.rqliteui.image.repository }}:{{ .Values.rqliteui.image.tag }} + env: + - name: RQLITE_HOST + valueFrom: + secretKeyRef: + key: uri + name: kotsadm-rqlite + - name: RQLITE_USERNAME + value: kotsadm + - name: RQLITE_PASSWORD + valueFrom: + secretKeyRef: + key: password + name: kotsadm-rqlite + ports: + - name: rqliteui + containerPort: 3000 diff --git a/applications/fake-services/app/templates/rqlite-ui-service.yaml b/applications/fake-services/app/templates/rqlite-ui-service.yaml new file mode 100644 index 00000000..e1eb41c3 --- /dev/null +++ b/applications/fake-services/app/templates/rqlite-ui-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "fake-service.rqliteui.name" . }} + labels: {{- include "fake-service.labels" . | nindent 4 }} +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: rqliteui + protocol: TCP + name: rqliteui + selector: + {{- include "fake-service.rqliteui.selectorLabels" . | nindent 4 }} + diff --git a/applications/fake-services/app/values.yaml b/applications/fake-services/app/values.yaml index 8d4b595d..6aa2c29c 100644 --- a/applications/fake-services/app/values.yaml +++ b/applications/fake-services/app/values.yaml @@ -43,3 +43,14 @@ ingress-nginx: http: 30080 ingressClassResource: default: true + +rqliteui: + image: + registry: docker.io + repository: gerardnguyen/rqman + tag: 0.0.3 + pullPolicy: IfNotPresent + imagePullSecrets: [] + +cert-manager: + enabled: true diff --git a/applications/fake-services/img/app.png b/applications/fake-services/img/app.png new file mode 100644 index 00000000..70da6ec4 Binary files /dev/null and b/applications/fake-services/img/app.png differ diff --git a/applications/fake-services/img/minio-ui.png b/applications/fake-services/img/minio-ui.png new file mode 100644 index 00000000..92522f59 Binary files /dev/null and b/applications/fake-services/img/minio-ui.png differ diff --git a/applications/fake-services/img/rqlite-ui.png b/applications/fake-services/img/rqlite-ui.png new file mode 100644 index 00000000..f55deb68 Binary files /dev/null and b/applications/fake-services/img/rqlite-ui.png differ diff --git a/applications/fake-services/replicated/cert-manager-chart.yaml b/applications/fake-services/replicated/cert-manager-chart.yaml new file mode 100644 index 00000000..cce9da6b --- /dev/null +++ b/applications/fake-services/replicated/cert-manager-chart.yaml @@ -0,0 +1,18 @@ +apiVersion: kots.io/v1beta2 +kind: HelmChart +metadata: + name: cert-manager +spec: + chart: + name: cert-manager + chartVersion: v1.17.0 + releaseName: cert-manager + weight: -4 + helmUpgradeFlags: + - --wait + - --debug + values: + global: + imagePullSecrets: + - name: repl{{ ImagePullSecretName }} + installCRDs: true diff --git a/applications/fake-services/replicated/k8s-app.yaml b/applications/fake-services/replicated/k8s-app.yaml index df5f0678..861b3a7f 100644 --- a/applications/fake-services/replicated/k8s-app.yaml +++ b/applications/fake-services/replicated/k8s-app.yaml @@ -2,6 +2,7 @@ apiVersion: app.k8s.io/v1beta1 kind: Application metadata: name: fake-service + message: thisistheway spec: descriptor: links: diff --git a/applications/fake-services/replicated/kots-chart.yaml b/applications/fake-services/replicated/kots-chart.yaml index 292e65e7..a6fa7e73 100644 --- a/applications/fake-services/replicated/kots-chart.yaml +++ b/applications/fake-services/replicated/kots-chart.yaml @@ -10,7 +10,7 @@ spec: - --debug values: image: - registry: '{{repl HasLocalRegistry | ternary LocalRegistryHost "proxy.replicated.com" }}' + registry: '{{repl HasLocalRegistry | ternary LocalRegistryHost "quirkyquokka.dev" }}' repository: '{{repl HasLocalRegistry | ternary LocalRegistryNamespace "proxy/gerard-helm-fake-service/429114214526.dkr.ecr.ap-southeast-2.amazonaws.com/gerard" }}/fake-service' imagePullSecrets: - name: "{{repl ImagePullSecretName }}" @@ -29,10 +29,16 @@ spec: - name: "{{repl ImagePullSecretName }}" controller: image: - registry: '{{repl HasLocalRegistry | ternary LocalRegistryHost "proxy.replicated.com" }}' + registry: '{{repl HasLocalRegistry | ternary LocalRegistryHost "quirkyquokka.dev" }}' image: '{{repl HasLocalRegistry | ternary LocalRegistryNamespace "proxy/gerard-helm-fake-service/429114214526.dkr.ecr.ap-southeast-2.amazonaws.com/gerard" }}/controller' admissionWebhooks: patch: image: - registry: '{{repl HasLocalRegistry | ternary LocalRegistryHost "proxy.replicated.com" }}' + registry: '{{repl HasLocalRegistry | ternary LocalRegistryHost "quirkyquokka.dev" }}' image: '{{repl HasLocalRegistry | ternary LocalRegistryNamespace "proxy/gerard-helm-fake-service/429114214526.dkr.ecr.ap-southeast-2.amazonaws.com/gerard" }}/kube-webhook-certgen' + rqliteui: + image: + registry: '{{repl HasLocalRegistry | ternary LocalRegistryHost "quirkyquokka.dev" }}' + repository: '{{repl HasLocalRegistry | ternary LocalRegistryNamespace "proxy/gerard-helm-fake-service/429114214526.dkr.ecr.ap-southeast-2.amazonaws.com/gerard" }}/rqman' + imagePullSecrets: + - name: "{{repl ImagePullSecretName }}" diff --git a/applications/fake-services/replicated/kots-config.yaml b/applications/fake-services/replicated/kots-config.yaml index da0784fb..fa566b00 100644 --- a/applications/fake-services/replicated/kots-config.yaml +++ b/applications/fake-services/replicated/kots-config.yaml @@ -28,7 +28,7 @@ spec: title: Message type: text required: true - default: Hello from frontend! + default: Today is Christmas Eve! Ho Ho Ho! DO NOT USE CUSTOM DOMAIN YET! - name: frontend_log_level title: Log level type: radio @@ -56,7 +56,7 @@ spec: title: Message type: text required: true - default: Hello from backend! + default: Hello from backend! Happy New Year! - name: backend_log_level title: Log level type: radio @@ -83,4 +83,30 @@ spec: - name: backend_origin title: Allowed origins type: text - default: "\\*" + default: "\\*" + # For Testing # + - name: storage_settings + title: Storage Settings + items: + - name: show_storage + title: Show Storage Configuration + type: bool + default: "0" + help_text: "Check to enable storage configuration options." + - name: storage_settings_timescale_retention_spacer + when: repl{{ ConfigOptionEquals "show_storage" "1" }} + type: label + title: " " + - name: storage_settings_timescale_retention_description + when: repl{{ ConfigOptionEquals "show_storage" "1" }} + type: heading + title: Timescale Retention Periods + - name: storage_settings_timescale_retention_raw + when: repl{{ ConfigOptionEquals "show_storage" "1" }} + title: Raw Metrics + type: text + value: "7d" + validation: + regex: + pattern: "^((([8-9]|[1-9][0-9]+)h)|([1-9][0-9]*d)|([1-9][0-9]*y))$" + message: "Please enter a valid retention period. The minimum is 8 hours (e.g., 8h). Example formats: 8h, 45d, 1y." \ No newline at end of file diff --git a/applications/fake-services/replicated/kots-ec.yaml b/applications/fake-services/replicated/kots-ec.yaml index 2b50dd4d..39dbb14c 100644 --- a/applications/fake-services/replicated/kots-ec.yaml +++ b/applications/fake-services/replicated/kots-ec.yaml @@ -1,7 +1,7 @@ apiVersion: embeddedcluster.replicated.com/v1beta1 kind: Config spec: - version: 1.19.0+k8s-1.30 + version: 2.0.0+k8s-1.30 roles: controller: name: management