diff --git a/applications/fake-services/.github/workflows/replicated-release-unstable.yaml b/applications/fake-services/.github/workflows/replicated-release-unstable.yaml new file mode 100644 index 00000000..45b0d710 --- /dev/null +++ b/applications/fake-services/.github/workflows/replicated-release-unstable.yaml @@ -0,0 +1,58 @@ +name: replicated-release-unstable + +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + push-to-replicated: + runs-on: ubuntu-22.04 + outputs: + channel-slug: ${{ steps.create-release.outputs.channel-slug }} + release-sequence: ${{ steps.create-release.outputs.release-sequence }} + app-version: ${{ steps.set-release-version.outputs.VERSION }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Get latest tag + id: get-latest-tag + run: | + # Get the latest tag, defaulting to 0.1.0 if none exists + latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.1.0") + echo "LATEST_TAG=${latest_tag}" >> $GITHUB_ENV + + - name: Set release version + id: set-release-version + run: | + VERSION=${{ env.LATEST_TAG }}-$(git rev-parse --short HEAD) + echo "VERSION=${VERSION}" >> $GITHUB_ENV + + - name: Package Helm chart + id: package-helm-chart + run: | + 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 &&\ + chmod +x /usr/local/bin/yq + + - 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 + with: + 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 diff --git a/applications/fake-services/.github/workflows/replicated-release.yaml b/applications/fake-services/.github/workflows/replicated-release.yaml new file mode 100644 index 00000000..95bf9d90 --- /dev/null +++ b/applications/fake-services/.github/workflows/replicated-release.yaml @@ -0,0 +1,173 @@ +name: replicated-release + +on: + push: + tags: + - 'v*.*.*' + workflow_dispatch: + inputs: + tag: + description: 'Version tag (e.g. v1.0.0)' + required: true + type: string + +jobs: + push-to-replicated: + runs-on: ubuntu-22.04 + outputs: + channel-slug: ${{ steps.create-release.outputs.channel-slug }} + release-sequence: ${{ steps.create-release.outputs.release-sequence }} + app-version: ${{ steps.set-release-version.outputs.VERSION }} + steps: + - uses: actions/checkout@v3 + + - name: Set release version + id: set-release-version + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_ENV + echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT + else + echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV + echo "VERSION=${{ github.ref_name }}" >> $GITHUB_OUTPUT + fi + + - name: Package Helm chart + id: package-helm-chart + run: | + 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 &&\ + chmod +x /usr/local/bin/yq + + - name: Update HelmChart kind + run: | + yq -i '.spec.chart.chartVersion = "${{ env.VERSION }}"' replicated/kots-chart.yaml + + - name: Define Channel name + run: echo "CHANNEL_NAME=${{ env.VERSION }}-${GITHUB_RUN_ID}${GITHUB_RUN_ATTEMPT}" >> $GITHUB_ENV + + - name: Create Replicated release + id: create-release + uses: replicatedhq/compatibility-actions/create-release@v1 + with: + app-slug: ${{ secrets.REPLICATED_APP }} + api-token: ${{ secrets.REPLICATED_API_TOKEN }} + yaml-dir: ./replicated + promote-channel: ${{ env.CHANNEL_NAME }} + version: ${{ env.VERSION }} + + compatibility-matrix: + needs: push-to-replicated + strategy: + fail-fast: false + matrix: + cluster: [{distribution: kind, version: v1.31.2}] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + + - name: Set release version + id: set-release-version + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_ENV + echo "VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT + else + echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV + echo "VERSION=${{ github.ref_name }}" >> $GITHUB_OUTPUT + fi + - name: Create Customer + id: create-customer + uses: replicatedhq/replicated-actions/create-customer@v1 + with: + app-slug: ${{ secrets.REPLICATED_APP }} + api-token: ${{ secrets.REPLICATED_API_TOKEN }} + customer-name: ${{ env.VERSION }}-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }} + channel-slug: ${{ needs.push-to-replicated.outputs.channel-slug }} + customer-email: ${{ env.VERSION }}@example.com + expires-in: 14 + license-type: dev + + - name: Create Cluster + id: create-cluster + uses: replicatedhq/replicated-actions/create-cluster@v1 + with: + api-token: ${{ secrets.REPLICATED_API_TOKEN }} + kubernetes-distribution: ${{ matrix.cluster.distribution }} + kubernetes-version: ${{ matrix.cluster.version }} + cluster-name: ${{ env.VERSION }}-${{ matrix.cluster.distribution }}-${{ matrix.cluster.version }} + timeout-minutes: 5 + ttl: 10m + + - name: Deploy the app + uses: replicatedhq/replicated-actions/kots-install@v1 + with: + kubeconfig: ${{ steps.create-cluster.outputs.cluster-kubeconfig }} + app-slug: ${{ secrets.REPLICATED_APP }}/${{ needs.push-to-replicated.outputs.channel-slug }} + license-file: ${{ steps.create-customer.outputs.license-file }} + app-version-label: ${{ env.VERSION }} + config-values: ./replicated/kots-sample-config-values.yaml + + - name: Run a test + # mask the kubeconfig so it doesn't show up in the logs + run: | + echo "Running connectivity test..." + echo "${{ steps.create-cluster.outputs.cluster-kubeconfig }}" > kubeconfig.yaml + sleep 60 + kubectl wait --for=condition=ready pods -l app.kubernetes.io/name=fake-service-frontend --timeout=60s --kubeconfig='./kubeconfig.yaml' + kubectl port-forward svc/frontend-service --pod-running-timeout=2m --kubeconfig='./kubeconfig.yaml' 8080:80 & + sleep 60 + curl -f http://localhost:8080 + echo "Test complete" + + - name: Remove Cluster + id: remove-cluster + uses: replicatedhq/replicated-actions/remove-cluster@v1 + continue-on-error: true # It could be that the cluster is already removed + with: + api-token: ${{ secrets.REPLICATED_API_TOKEN }} + cluster-id: ${{ steps.create-cluster.outputs.cluster-id }} + + - name: Archive Customer + id: archive-customer + if: always() + uses: replicatedhq/replicated-actions/archive-customer@v1 + with: + api-token: ${{ secrets.REPLICATED_API_TOKEN }} + customer-id: ${{ steps.create-customer.outputs.customer-id }} + + promote-to-stable: + needs: + - compatibility-matrix + - push-to-replicated + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + + - name: Promote to Stable channel + uses: replicatedhq/replicated-actions/promote-release@v1 + with: + app-slug: ${{ secrets.REPLICATED_APP }} + api-token: ${{ secrets.REPLICATED_API_TOKEN }} + channel-to: stable + release-sequence: ${{ needs.push-to-replicated.outputs.release-sequence }} + release-version: ${{ needs.push-to-replicated.outputs.app-version }} + + cleanup-channel: + needs: + - compatibility-matrix + - push-to-replicated + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - name: Archive Replicated Channel + uses: replicatedhq/replicated-actions/archive-channel@v1 + with: + app-slug: ${{ secrets.REPLICATED_APP }} + api-token: ${{ secrets.REPLICATED_API_TOKEN }} + channel-slug: ${{ needs.push-to-replicated.outputs.channel-slug }} \ No newline at end of file diff --git a/applications/fake-services/Makefile b/applications/fake-services/Makefile new file mode 100644 index 00000000..aa6734a6 --- /dev/null +++ b/applications/fake-services/Makefile @@ -0,0 +1,50 @@ +REPLICATED_APP=gerard-helm-fake-service +REPLICATED_DIR=$(shell pwd)/replicated +CHART_DIR=$(shell pwd)/app +CHART_VERSION=0.8.0 +CHANNELS=Stable Unstable Beta + +clean-charts: + rm -rf $(REPLICATED_DIR)/*.tgz + +bump-chart-version: + yq -i '.version = "$(CHART_VERSION)"' $(CHART_DIR)/Chart.yaml + yq -i '.spec.chart.chartVersion = "$(CHART_VERSION)"' $(REPLICATED_DIR)/kots-chart.yaml + +helm-dep-up: + helm dep up $(CHART_DIR) + +helm-dep-list: + helm dep list $(CHART_DIR) + +helm-install-dry-run: + helm install $(REPLICATED_APP) --dry-run --debug $(CHART_DIR) + +helm-template: + helm template $(REPLICATED_APP) $(CHART_DIR) + +helm-install: + helm install $(REPLICATED_APP) --debug --wait $(CHART_DIR) + +helm-uninstall: + helm uninstall $(REPLICATED_APP) + +prepare-release: clean-charts helm-dep-up bump-chart-version + helm package --destination $(REPLICATED_DIR) --debug ./app + echo "Packaged Helm chart to $(REPLICATED_DIR)" + +replicated-lint: + replicated release lint --yaml-dir $(REPLICATED_DIR) + +replicated-release: prepare-release replicated-lint + replicated release create --yaml-dir $(REPLICATED_DIR) + +replicated-promote: + $(eval SEQUENCE := $(shell replicated release ls --output json | jq '.[0].sequence')) + @for channel in $(CHANNELS); do \ + echo "Promoting release sequence $(SEQUENCE) to $$channel channel..."; \ + replicated release promote $(SEQUENCE) $$channel; \ + done + +sync-platform-examples: + rsync -av --exclude '.git' --exclude '.gitignore' . /Users/gerard/dev/platform-examples/applications/fake-services/ \ No newline at end of file diff --git a/applications/fake-services/README.md b/applications/fake-services/README.md new file mode 100644 index 00000000..c4e82215 --- /dev/null +++ b/applications/fake-services/README.md @@ -0,0 +1,8 @@ +# helm-fake-service + +This repository contains an example Helm chart that distributed with Replicated Embedded Cluster. + +## 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 diff --git a/applications/fake-services/app/.helmignore b/applications/fake-services/app/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/applications/fake-services/app/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/applications/fake-services/app/Chart.lock b/applications/fake-services/app/Chart.lock new file mode 100644 index 00000000..f50184f6 --- /dev/null +++ b/applications/fake-services/app/Chart.lock @@ -0,0 +1,9 @@ +dependencies: +- name: ingress-nginx + repository: https://kubernetes.github.io/ingress-nginx + version: 4.11.3 +- name: replicated + repository: oci://registry.replicated.com/library + version: 1.0.0-beta.31 +digest: sha256:c349fc2fe99276ed430877ef2a0cf0e05150cd27f6e4eae2d7bfe47733f64846 +generated: "2024-11-27T11:01:55.491515+11:00" diff --git a/applications/fake-services/app/Chart.yaml b/applications/fake-services/app/Chart.yaml new file mode 100644 index 00000000..636e5592 --- /dev/null +++ b/applications/fake-services/app/Chart.yaml @@ -0,0 +1,29 @@ +apiVersion: v2 +name: fake-service +description: A Helm chart for Kubernetes +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +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.8.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" +dependencies: + - name: ingress-nginx + version: 4.11.3 + repository: https://kubernetes.github.io/ingress-nginx + condition: ingress-nginx.enabled + - name: replicated + repository: oci://registry.replicated.com/library + version: 1.0.0-beta.31 diff --git a/applications/fake-services/app/README.md b/applications/fake-services/app/README.md new file mode 100644 index 00000000..33b868b0 --- /dev/null +++ b/applications/fake-services/app/README.md @@ -0,0 +1,10 @@ +# fake-service + +This Helm chart will install: + +- A fake-service frontend +- A fake-service backend + +The `frontend` service will be exposed with an `Ingress`. + +We will not install `ingress-nginx` as part of the Helm chart but install `ingress-nginx` controller separately. E.g. with `k0s` Helm chart (extension)[https://docs.k0sproject.io/head/helm-charts/?h=helm+extension#example] diff --git a/applications/fake-services/app/templates/NOTES.txt b/applications/fake-services/app/templates/NOTES.txt new file mode 100644 index 00000000..e69de29b diff --git a/applications/fake-services/app/templates/_helpers.tpl b/applications/fake-services/app/templates/_helpers.tpl new file mode 100644 index 00000000..429f8b28 --- /dev/null +++ b/applications/fake-services/app/templates/_helpers.tpl @@ -0,0 +1,102 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "fake-service.name" -}} +{{- default .Chart.Name | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "fake-service.fullname" -}} +{{- $name := "fake-service-app" }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "fake-service.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "fake-service.labels" -}} +helm.sh/chart: {{ include "fake-service.chart" . }} +{{ include "fake-service.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "fake-service.selectorLabels" -}} +app.kubernetes.io/name: {{ include "fake-service.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Frontend labels selector +*/}} +{{- define "fake-service.frontend.selectorLabels" -}} +app.kubernetes.io/name: {{ include "fake-service.name" . }}-frontend +{{- end }} + +{{/* +Backend labels selector +*/}} +{{- define "fake-service.backend.selectorLabels" -}} +app.kubernetes.io/name: {{ include "fake-service.name" . }}-backend +{{- end }} + +{{/* +Frontend service name +*/}} +{{- define "fake-service.frontend.name" -}} +frontend-service +{{- end }} + +{{/* +Backend service name +*/}} +{{- define "fake-service.backend.name" -}} +backend-service +{{- end }} + + +{{/* +Image Pull Secrets +*/}} +{{- define "helpers.imagePullSecrets" -}} +{{- $pullSecrets := list -}} + +{{/* Add existing imagePullSecrets if defined */}} +{{- if .Values.image.imagePullSecrets -}} +{{- $pullSecrets = concat $pullSecrets .Values.image.imagePullSecrets -}} +{{- end -}} + +{{/* Add replicated pull secret if global dockerconfigjson is defined */}} +{{- if hasKey .Values "global" -}} +{{- if hasKey .Values.global "replicated" -}} +{{- if .Values.global.replicated.dockerconfigjson -}} +{{- $replicatedSecret := dict "name" "replicated-pull-secret" -}} +{{- $pullSecrets = append $pullSecrets $replicatedSecret -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* Output the imagePullSecrets block only if we have any secrets */}} +{{- if $pullSecrets -}} +imagePullSecrets: +{{- range $pullSecrets }} + - name: {{ .name }} +{{- end -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/applications/fake-services/app/templates/backend-deployment.yaml b/applications/fake-services/app/templates/backend-deployment.yaml new file mode 100644 index 00000000..cccbf10d --- /dev/null +++ b/applications/fake-services/app/templates/backend-deployment.yaml @@ -0,0 +1,36 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: backend + labels: + {{- include "fake-service.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "fake-service.backend.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "fake-service.backend.selectorLabels" . | nindent 8 }} + spec: + {{- include "helpers.imagePullSecrets" . | nindent 6 }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}" + ports: + - name: backend + containerPort: {{ .Values.backend.port }} + protocol: TCP + env: + - name: NAME + value: {{ .Values.backend.name }} + - name: MESSAGE + value: "{{ .Values.backend.message }}" + - name: LISTEN_ADDR + value: "0.0.0.0:{{ .Values.backend.port }}" + - name: SERVER_TYPE + value: "{{ .Values.backend.serverType }}" + - name: LOG_LEVEL + value: "{{ .Values.backend.logLevel }}" + - name: ERROR_RATE + value: "{{ .Values.backend.errorRate }}" diff --git a/applications/fake-services/app/templates/backend-service.yaml b/applications/fake-services/app/templates/backend-service.yaml new file mode 100644 index 00000000..6a71bba2 --- /dev/null +++ b/applications/fake-services/app/templates/backend-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "fake-service.backend.name" . }} + labels: {{- include "fake-service.labels" . | nindent 4 }} +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: backend + protocol: TCP + name: backend + selector: + {{- include "fake-service.backend.selectorLabels" . | nindent 4 }} diff --git a/applications/fake-services/app/templates/custom-metrics-job.yaml b/applications/fake-services/app/templates/custom-metrics-job.yaml new file mode 100644 index 00000000..16b4cfa6 --- /dev/null +++ b/applications/fake-services/app/templates/custom-metrics-job.yaml @@ -0,0 +1,33 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: lucky-number-sender +spec: + schedule: "* * * * *" # Run every minute + successfulJobsHistoryLimit: 3 + failedJobsHistoryLimit: 1 + concurrencyPolicy: Forbid + jobTemplate: + spec: + template: + spec: + containers: + - name: lucky-sender + image: curlimages/curl:latest + command: ["/bin/sh"] + args: + - -c + - | + # Get seconds since epoch and use it as random seed + NUM=$(date +%s) + LUCKY_NUMBER=$(expr $NUM % 35 + 1) + + # Send the metric + curl -v -X POST 'http://replicated:3000/api/v1/app/custom-metrics' \ + -H 'Content-Type: application/json' \ + -d "{ + \"data\": { + \"lucky_number\": $LUCKY_NUMBER + } + }" + restartPolicy: OnFailure \ No newline at end of file diff --git a/applications/fake-services/app/templates/frontend-deployment.yaml b/applications/fake-services/app/templates/frontend-deployment.yaml new file mode 100644 index 00000000..26109390 --- /dev/null +++ b/applications/fake-services/app/templates/frontend-deployment.yaml @@ -0,0 +1,36 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: frontend + labels: + {{- include "fake-service.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "fake-service.frontend.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "fake-service.frontend.selectorLabels" . | nindent 8 }} + spec: + {{- include "helpers.imagePullSecrets" . | nindent 6 }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}" + ports: + - name: frontend + containerPort: {{ .Values.frontend.port }} + protocol: TCP + env: + - name: NAME + value: {{ .Values.frontend.name }} + - name: MESSAGE + value: "{{ .Values.frontend.message }}" + - name: LISTEN_ADDR + value: "0.0.0.0:{{ .Values.frontend.port }}" + - name: SERVER_TYPE + value: "{{ .Values.frontend.serverType }}" + - 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 diff --git a/applications/fake-services/app/templates/frontend-service.yaml b/applications/fake-services/app/templates/frontend-service.yaml new file mode 100644 index 00000000..09a48dfd --- /dev/null +++ b/applications/fake-services/app/templates/frontend-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "fake-service.frontend.name" . }} + labels: {{- include "fake-service.labels" . | nindent 4 }} +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: frontend + protocol: TCP + name: frontend + selector: + {{- include "fake-service.frontend.selectorLabels" . | nindent 4 }} + diff --git a/applications/fake-services/app/templates/ingress.yaml b/applications/fake-services/app/templates/ingress.yaml new file mode 100644 index 00000000..57b97646 --- /dev/null +++ b/applications/fake-services/app/templates/ingress.yaml @@ -0,0 +1,16 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "fake-service.name" . }}-ingress +spec: + ingressClassName: nginx + rules: + - http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "fake-service.frontend.name" . }} + port: + number: 80 diff --git a/applications/fake-services/app/templates/replicated-pull-secret.yaml b/applications/fake-services/app/templates/replicated-pull-secret.yaml new file mode 100644 index 00000000..d6a7cf9a --- /dev/null +++ b/applications/fake-services/app/templates/replicated-pull-secret.yaml @@ -0,0 +1,11 @@ +{{- if and (hasKey .Values "global") (hasKey .Values.global "replicated") (hasKey .Values.global.replicated "dockerconfigjson") -}} +{{- if .Values.global.replicated.dockerconfigjson -}} +apiVersion: v1 +kind: Secret +metadata: + name: replicated-pull-secret +type: kubernetes.io/dockerconfigjson +data: + .dockerconfigjson: {{ .Values.global.replicated.dockerconfigjson | quote }} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/applications/fake-services/app/values.yaml b/applications/fake-services/app/values.yaml new file mode 100644 index 00000000..8d4b595d --- /dev/null +++ b/applications/fake-services/app/values.yaml @@ -0,0 +1,45 @@ +image: + registry: docker.io + repository: nicholasjackson/fake-service + tag: v0.26.2 + pullPolicy: IfNotPresent + imagePullSecrets: [] + +frontend: + name: "frontend" + message: "Hello from frontend!" + serverType: "http" + logLevel: "debug" + port: 9090 + +backend: + name: "backend" + message: "Hello from backend!" + serverType: "http" + logLevel: "debug" + port: 9091 + errorRate: 0 + origin: "*" + +ingress-nginx: + enabled: true + imagePullSecrets: [] + controller: + image: + registry: registry.k8s.io + image: ingress-nginx/controller + tag: v1.11.3 + digest: "" + admissionWebhooks: + patch: + image: + registry: registry.k8s.io + image: ingress-nginx/kube-webhook-certgen + tag: v1.4.4 + digest: "" + service: + type: NodePort + nodePorts: + http: 30080 + ingressClassResource: + default: true diff --git a/applications/fake-services/notes.md b/applications/fake-services/notes.md new file mode 100644 index 00000000..fe5519d3 --- /dev/null +++ b/applications/fake-services/notes.md @@ -0,0 +1,14 @@ +# Development notes + +## Develop the Helm chart + +```bash +helm create app +``` + +- Test with + +```bash +helm template foo ./app +helm install foo ./app --dry-run +``` diff --git a/applications/fake-services/replicated/backup.yaml b/applications/fake-services/replicated/backup.yaml new file mode 100644 index 00000000..b339d22b --- /dev/null +++ b/applications/fake-services/replicated/backup.yaml @@ -0,0 +1,5 @@ +apiVersion: velero.io/v1 +kind: Backup +metadata: + name: backup + spec: {} diff --git a/applications/fake-services/replicated/k8s-app.yaml b/applications/fake-services/replicated/k8s-app.yaml new file mode 100644 index 00000000..df5f0678 --- /dev/null +++ b/applications/fake-services/replicated/k8s-app.yaml @@ -0,0 +1,9 @@ +apiVersion: app.k8s.io/v1beta1 +kind: Application +metadata: + name: fake-service +spec: + descriptor: + links: + - description: Open App + url: https://repl{{ ConfigOption "hostname" }}:30080 diff --git a/applications/fake-services/replicated/kots-app.yaml b/applications/fake-services/replicated/kots-app.yaml new file mode 100644 index 00000000..6622b940 --- /dev/null +++ b/applications/fake-services/replicated/kots-app.yaml @@ -0,0 +1,12 @@ +apiVersion: kots.io/v1beta1 +kind: Application +metadata: + name: fake-service +spec: + title: Fake Services + icon: https://www.shareicon.net/data/256x256/2016/05/16/766096_zoo_512x512.png + statusInformers: + - deployment/frontend + - deployment/backend + additionalImages: + - curlimages/curl:latest \ No newline at end of file diff --git a/applications/fake-services/replicated/kots-chart.yaml b/applications/fake-services/replicated/kots-chart.yaml new file mode 100644 index 00000000..292e65e7 --- /dev/null +++ b/applications/fake-services/replicated/kots-chart.yaml @@ -0,0 +1,38 @@ +apiVersion: kots.io/v1beta2 +kind: HelmChart +metadata: + name: fake-service +spec: + chart: + name: fake-service + chartVersion: 0.8.0 + helmUpgradeFlags: + - --debug + values: + image: + registry: '{{repl HasLocalRegistry | ternary LocalRegistryHost "proxy.replicated.com" }}' + 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 }}" + frontend: + name: repl{{ ConfigOption "frontend_name" }} + message: repl{{ ConfigOption "frontend_message" }} + logLevel: repl{{ ConfigOption "frontend_log_level" }} + backend: + name: repl{{ ConfigOption "backend_name" }} + message: repl{{ ConfigOption "backend_message" }} + logLevel: repl{{ ConfigOption "backend_log_level" }} + errorRate: repl{{ ConfigOption "backend_error_rate" }} + origin: repl{{ ConfigOption "backend_origin" }} + ingress-nginx: + imagePullSecrets: + - name: "{{repl ImagePullSecretName }}" + controller: + image: + registry: '{{repl HasLocalRegistry | ternary LocalRegistryHost "proxy.replicated.com" }}' + 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" }}' + image: '{{repl HasLocalRegistry | ternary LocalRegistryNamespace "proxy/gerard-helm-fake-service/429114214526.dkr.ecr.ap-southeast-2.amazonaws.com/gerard" }}/kube-webhook-certgen' diff --git a/applications/fake-services/replicated/kots-config.yaml b/applications/fake-services/replicated/kots-config.yaml new file mode 100644 index 00000000..da0784fb --- /dev/null +++ b/applications/fake-services/replicated/kots-config.yaml @@ -0,0 +1,86 @@ +apiVersion: kots.io/v1beta1 +kind: Config +metadata: + name: fake-service +spec: + groups: + - name: Global settings + title: Global settings + description: Global settings + items: + - name: hostname + title: Hostname + type: text + required: false + - name: password + title: Password + type: password + required: false + - name: Frontend settings + title: Frontend settings + description: Frontend settings + items: + - name: frontend_name + title: Service Name + type: text + required: true + - name: frontend_message + title: Message + type: text + required: true + default: Hello from frontend! + - name: frontend_log_level + title: Log level + type: radio + default: debug + items: + - name: debug + title: Debug + - name: info + title: Info + - name: warn + title: Warn + - name: error + title: Error + - name: trace + title: Trace + - name: Backend settings + title: Backend settings + description: Backend settings + items: + - name: backend_name + title: Service Name + type: text + required: true + - name: backend_message + title: Message + type: text + required: true + default: Hello from backend! + - name: backend_log_level + title: Log level + type: radio + default: debug + items: + - name: debug + title: Debug + - name: info + title: Info + - name: warn + title: Warn + - name: error + title: Error + - name: trace + title: Trace + - name: backend_error_rate + title: Error rate + type: text + default: "0" + validation: + regex: + pattern: "^(0|1(\\.0)?|0\\.\\d{1,3})$" + message: "Decimal percentage of request where handler will report an error. e.g. 0.1 = 10% of all requests will result in an error" + - name: backend_origin + title: Allowed origins + type: text + default: "\\*" diff --git a/applications/fake-services/replicated/kots-ec.yaml b/applications/fake-services/replicated/kots-ec.yaml new file mode 100644 index 00000000..2b50dd4d --- /dev/null +++ b/applications/fake-services/replicated/kots-ec.yaml @@ -0,0 +1,13 @@ +apiVersion: embeddedcluster.replicated.com/v1beta1 +kind: Config +spec: + version: 1.19.0+k8s-1.30 + roles: + controller: + name: management + labels: + management: "true" + custom: + - name: app + labels: + app: "true" diff --git a/applications/fake-services/replicated/kots-sample-config-values.yaml b/applications/fake-services/replicated/kots-sample-config-values.yaml new file mode 100644 index 00000000..0149aeb7 --- /dev/null +++ b/applications/fake-services/replicated/kots-sample-config-values.yaml @@ -0,0 +1,12 @@ +apiVersion: kots.io/v1beta1 +kind: ConfigValues +spec: + values: + frontend_message: + value: thisistheway + backend_message: + value: thisistheway + backend_name: + value: Payment + frontend_name: + value: Checkout