diff --git a/packs/hello-universe-1.2.0/README.md b/packs/hello-universe-1.2.0/README.md new file mode 100644 index 00000000..9d4fee71 --- /dev/null +++ b/packs/hello-universe-1.2.0/README.md @@ -0,0 +1,91 @@ +# Hello Universe + +[Hello Universe](https://github.com/spectrocloud/hello-universe) is a demo web application utilized to help users learn more about [Palette](https://docs.spectrocloud.com/introduction) and its features. + +You can deploy it using two preset configurations: +- A standalone front-end application. It provides a frontend for Spacetastic, a fictional company used as a Spectro Cloud use case. It provides multiple pages with facts about space. +- A three-tier application with a front-end application, API server and PostgreSQL database into a Kubernetes cluster. It provides an events counter that is saved in the deployed database which tracks the activity on the Spacetastic pages provided by the frontend. You can read more about this configuration on the Hello Universe [README](https://github.com/spectrocloud/hello-universe?tab=readme-ov-file#reverse-proxy-with-kubernetes). + +## Prerequisites + +- A Palette account. + +- A cluster profile where the Hello Universe pack can be integrated. + +- A Palette cluster with port `:8080` available. If port 8080 is not available, you can set a different port in the **values.yaml** file. + +- If you are using the **Enable Hello Universe API** preset, you will need the `:3000` port available on your cluster too. Check out the [Usage](#usage) section for further details. + +- Ensure sufficient CPU resources within the cluster to allocate a minimum of 500 milliCPU and a maximum of 500 milliCPU per replica. + +## Parameters + +The following parameters are applied to the **hello-universe.yaml** manifest through the **values.yaml** file. Users do not need to take any additional actions regarding these parameters. + +| **Parameter** | **Description** | **Default Value** | **Required** | +| --------------------------------- | ------------------------------------------------------------------------------ | ------------------------------------------- | ------------ | +| `manifests.namespace` | The namespace in which the application will be deployed. | `hello-universe` | Yes | +| `manifests.images.hellouniverse` | The [`hello-universe`](https://github.com/spectrocloud/hello-universe) application image that will be utilized to create the containers. | `ghcr.io/spectrocloud/hello-universe:1.2.0`/ `ghcr.io/spectrocloud/hello-universe:1.2.0-proxy` | Yes | +| `manifests.images.hellouniverseapi` | The [`hello-universe-api`](https://github.com/spectrocloud/hello-universe-api) application image that will be utilized to create the containers. | `ghcr.io/spectrocloud/hello-universe-api:1.1.0` | No | +| `manifests.images.hellouniversedb` | The [`hello-universe-db`](https://github.com/spectrocloud/hello-universe-db) application image that will be utilized to create the containers. | `ghcr.io/spectrocloud/hello-universe-db:1.1.0` | No | +| `manifests.apiEnabled` | The flag that indicates whether to deploy the UI application as standalone or together with the API server. | `false` | Yes | +| `manifests.port` | The cluster port number on which the service will listen for incoming traffic. | `8080` | Yes | +| `manifests.replicas` | The number of Pods to be created. | `1` | Yes | +| `manifests.dbPassword` | The base64 encoded database password to connect to the API database. | `REPLACE_ME` | No | +| `manifests.authToken` | The base64 encoded auth token for the API connection. | `REPLACE_ME` | No | +| `manifests.hello-universe.ui.useTolerations` | Flag to indicate whether to use tolerations for the UI pods. | `false` | No | +| `manifests.hello-universe.api.useTolerations` | Flag to indicate whether to use tolerations for the API pods. | `false` | No | +| `manifests.hello-universe.postgres.useTolerations` | Flag to indicate whether to use tolerations for the Postgres pods. | `false` | No | +| `manifests.hello-universe.ui.tolerations.effect` | The toleration effect to use for the Hello Universe UI pods. The allowed values are `PreferNoSchedule`, `NoSchedule` and `NoExecute`. | `PreferNoSchedule` | No | +| `manifests.hello-universe.api.tolerations.effect` | The toleration effect to use for the Hello Universe API pods. The allowed values are `PreferNoSchedule`, `NoSchedule` and `NoExecute`. | `PreferNoSchedule` | No | +| `manifests.hello-universe.postgres.tolerations.effect` | The toleration effect to use for the Hello Universe Postgres pods. The allowed values are `PreferNoSchedule`, `NoSchedule` and `NoExecute`. | `PreferNoSchedule` | No | +| `manifests.hello-universe.ui.tolerations.key` | The tolerations key to use for the Hello Universe UI pods. | `app` | No | +| `manifests.hello-universe.api.tolerations.key` | The tolerations key to use for the Hello Universe API pods. | `app` | No | +| `manifests.hello-universe.postgres.tolerations.key` | The tolerations key to use for the Hello Universe Postgres pods. | `app` | No | +| `manifests.hello-universe.ui.tolerations.value` | The tolerations value to use for the Hello Universe UI pods. | `ui` | No | +| `manifests.hello-universe.api.tolerations.value` | The tolerations value to use for the Hello Universe API pods. | `api` | No | +| `manifests.hello-universe.postgres.tolerations.value` | The tolerations value to use for the Hello Universe Postgres pods. | `postgres` | No | + +## Upgrade + +Upgrades from the [hello-universe-1.1.1](../hello-universe-1.1.1/README.md) pack are not supported. If you want to upgrade the pack, you must first remove it from the cluster profile. Then, you can add the upgraded version as a cluster profile layer. + +## Usage + +The Hello Universe pack has two presets that you can select: +- **Disable Hello Universe API** configures Hello Universe as a standalone frontend application. This is the default configuration of the pack. +- **Enable Hello Universe API** configures Hello Universe as a three-tier application with a frontend, API server, and Postgres database. + +To utilize the Hello Universe pack, create either a [full Palette cluster profile](https://docs.spectrocloud.com/profiles/cluster-profiles/create-cluster-profiles/create-full-profile) or an [add-on Palette cluster profile](https://docs.spectrocloud.com/profiles/cluster-profiles/create-cluster-profiles/create-addon-profile/) and add the pack to your profile. You can select the preset you wish to deploy on the cluster profile creation page. + +If your infrastructure provider does not offer a native load balancer solution, such as VMware and MAAS, the [MetalLB](https://docs.spectrocloud.com/integrations/metallb) pack must be included to the cluster profile to help the LoadBalancer service specified in the manifest obtain an IP address. + +After defining the cluster profile, use it to deploy a new cluster or attach it as an add-on profile to an existing cluster. + +Once the cluster status displays **Running** and **Healthy**, access the Hello Universe application through the exposed service URL along with the displayed port number. + +### Tolerations + +The Hello Universe pack provides parameters for providing pod tolerations. These make it possible to provide [Kubernetes Taints](https://docs.spectrocloud.com/clusters/cluster-management/taints/#taints). You can only apply toleration for the UI, API, and Postgres pods. + +The parameters are applied using the `Equal` operator as demonstrated below: + +```yaml + tolerations: + - effect: {{ .Values.ui.tolerations.effect }} + key: {{ .Values.ui.tolerations.key }} + operator: Equal + value: {{ .Values.ui.tolerations.value }} +``` + +## References + +- [Hello Universe GitHub Repository](https://github.com/spectrocloud/hello-universe) + +- [Hello Universe API GitHub Repository](https://github.com/spectrocloud/hello-universe-api) + +- [Deploy a Custom Pack Tutorial](https://docs.spectrocloud.com/registries-and-packs/deploy-pack/) + +- [Registries and Packs](https://docs.spectrocloud.com/registries-and-packs/) + +- [Node Labels and Taints](https://docs.spectrocloud.com/clusters/cluster-management/taints/) diff --git a/packs/hello-universe-1.2.0/logo.png b/packs/hello-universe-1.2.0/logo.png new file mode 100644 index 00000000..eeae3434 Binary files /dev/null and b/packs/hello-universe-1.2.0/logo.png differ diff --git a/packs/hello-universe-1.2.0/manifests/hello-universe.yaml b/packs/hello-universe-1.2.0/manifests/hello-universe.yaml new file mode 100644 index 00000000..cfb34574 --- /dev/null +++ b/packs/hello-universe-1.2.0/manifests/hello-universe.yaml @@ -0,0 +1,329 @@ +{{ if not .Values.apiEnabled }} + +apiVersion: v1 +kind: Namespace +metadata: + name: {{ .Values.namespace }} +--- +apiVersion: v1 +kind: Service +metadata: + name: hello-universe-service + namespace: {{ .Values.namespace }} +spec: + type: LoadBalancer + selector: + app: hello-universe + ports: + - protocol: TCP + port: {{ .Values.port }} + targetPort: 8080 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-universe-deployment + namespace: {{ .Values.namespace }} +spec: + replicas: {{ .Values.replicas }} + selector: + matchLabels: + app: hello-universe + template: + metadata: + labels: + app: hello-universe + spec: + containers: + - name: hello-universe + image: {{ .Values.images.hellouniverse }} + imagePullPolicy: IfNotPresent + ports: + - containerPort: 8080 + resources: + requests: + cpu: "100m" # requesting 100 milliCPU + memory: "512Mi" # requesting 512 MiB of memory + limits: + cpu: "200m" # limiting to 200 milliCPU + memory: "1024Mi" # requesting 1024 MiB of memory + +{{ end }} + +{{ if .Values.apiEnabled }} + +apiVersion: v1 +kind: Namespace +metadata: + name: {{ .Values.namespace }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: service-reader +rules: + - apiGroups: [""] + resources: ["services"] + verbs: ["get", "list", "watch"] +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: hello-universe-role + namespace: {{ .Values.namespace }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: service-reader-binding +subjects: + - kind: ServiceAccount + name: hello-universe-role + namespace: {{ .Values.namespace }} +roleRef: + kind: ClusterRole + name: service-reader + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: v1 +kind: Service +metadata: + name: ui + namespace: {{ .Values.namespace }} +spec: + selector: + app: ui + ports: + - protocol: TCP + name: ui + port: {{ .Values.port }} + targetPort: 8080 + - protocol: TCP + name: api + port: 3000 + targetPort: 3000 + type: LoadBalancer +--- +apiVersion: v1 +kind: Secret +metadata: + name: db-password + namespace: {{ .Values.namespace }} +type: Opaque +data: + db-password: {{ .Values.dbPassword }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: auth-token + namespace: {{ .Values.namespace }} +type: Opaque +data: + auth-token: {{ .Values.authToken }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: postgres + namespace: {{ .Values.namespace }} +spec: + selector: + matchLabels: + app: postgres + replicas: 1 + template: + metadata: + labels: + app: postgres + spec: + containers: + - name: postgres + image: {{ .Values.images.hellouniversedb }} + ports: + - containerPort: 5432 + name: postgres + resources: + limits: + memory: "500Mi" + cpu: "500m" + requests: + memory: "500Mi" + cpu: "500m" + {{ if .Values.postgres.useTolerations -}} + tolerations: + - effect: {{ .Values.postgres.tolerations.effect }} + key: {{ .Values.postgres.tolerations.key }} + operator: Equal + value: {{ .Values.postgres.tolerations.value }} + {{- end }} +--- +apiVersion: v1 +kind: Service +metadata: + name: postgres + namespace: {{ .Values.namespace }} +spec: + selector: + app: postgres + ports: + - protocol: TCP + port: 5432 + targetPort: 5432 + type: ClusterIP +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: api + namespace: {{ .Values.namespace }} +spec: + selector: + matchLabels: + app: api + replicas: 1 + template: + metadata: + labels: + app: api + spec: + serviceAccountName: hello-universe-role + containers: + - name: api + image: {{ .Values.images.hellouniverseapi }} + ports: + - containerPort: 3000 + name: api + env: + - name: db-password + valueFrom: + secretKeyRef: + name: db-password + key: db-password + - name: DB_HOST + value: "postgres.{{ .Values.namespace }}.svc.cluster.local" + - name: PORT + value: "3000" + - name: DB_USER + value: "postgres" + - name: DB_NAME + value: "counter" + - name: DB_ENCRYPTION + value: "disable" + - name: DB_INIT + value: "false" + - name: AUTHORIZATION + value: "true" + resources: + limits: + memory: "500Mi" + cpu: "500m" + requests: + memory: "500Mi" + cpu: "500m" + livenessProbe: + httpGet: + path: /api/v1/health + port: 3000 + initialDelaySeconds: 35 + periodSeconds: 3 + readinessProbe: + httpGet: + path: /api/v1/health + port: 3000 + initialDelaySeconds: 30 + periodSeconds: 3 + {{ if .Values.api.useTolerations -}} + tolerations: + - effect: {{ .Values.api.tolerations.effect }} + key: {{ .Values.api.tolerations.key }} + operator: Equal + value: {{ .Values.api.tolerations.value }} + {{- end }} +--- +apiVersion: v1 +kind: Service +metadata: + name: api + namespace: {{ .Values.namespace }} +spec: + selector: + app: api + ports: + - protocol: TCP + port: 3000 + targetPort: 3000 + type: ClusterIP # If you want to expose the API service, change this value to LoadBalancer. See below for an example. + # type: Loadbalancer +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ui + namespace: {{ .Values.namespace }} +spec: + selector: + matchLabels: + app: ui + replicas: {{ .Values.replicas }} + template: + metadata: + labels: + app: ui + spec: + serviceAccountName: hello-universe-role + initContainers: + - name: init-container + image: busybox + command: + ["/bin/sh", "-c", "echo 'sleeping for 30 seconds' && sleep 30"] + containers: + - name: ui + image: {{ .Values.images.hellouniverse }} + imagePullPolicy: Always + ports: + - containerPort: 8080 + name: ui + env: + - name: TOKEN + valueFrom: + secretKeyRef: + name: auth-token + key: auth-token + - name: API_URI + # Leave empty and set QUERY_K8S_API to true to leverage a single loadbalancer. + # Otherwise, set to the API service's URL and set QUERY_K8S_API to false + value: "" + - name: SVC_URI + value: "api.{{ .Values.namespace }}.svc.cluster.local:3000" + - name: API_VERSION + value: "1" + - name: QUERY_K8S_API + value: "true" + resources: + limits: + memory: "500Mi" + cpu: "500m" + requests: + memory: "500Mi" + cpu: "500m" + livenessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: 40 + periodSeconds: 3 + readinessProbe: + httpGet: + path: / + port: 8080 + initialDelaySeconds: 35 + periodSeconds: 3 + {{ if .Values.ui.useTolerations -}} + tolerations: + - effect: {{ .Values.ui.tolerations.effect }} + key: {{ .Values.ui.tolerations.key }} + operator: Equal + value: {{ .Values.ui.tolerations.value }} + {{- end }} +{{ end }} diff --git a/packs/hello-universe-1.2.0/pack.json b/packs/hello-universe-1.2.0/pack.json new file mode 100644 index 00000000..00c53c88 --- /dev/null +++ b/packs/hello-universe-1.2.0/pack.json @@ -0,0 +1,15 @@ +{ + "addonType": "app services", + "annotations": { + "source": "community", + "contributor": "spectrocloud" + }, + "cloudTypes": ["all"], + "displayName": "Hello Universe", + "kubeManifests": [ + "manifests/hello-universe.yaml" + ], + "layer": "addon", + "name": "hello-universe", + "version": "1.2.0" +} diff --git a/packs/hello-universe-1.2.0/presets.yaml b/packs/hello-universe-1.2.0/presets.yaml new file mode 100644 index 00000000..2ded6575 --- /dev/null +++ b/packs/hello-universe-1.2.0/presets.yaml @@ -0,0 +1,50 @@ +presets: + - name: "disable-api" + displayName: "Disable Hello Universe API" + group: "Backend" + remove: [] + add: | + manifests: + hello-universe: + images: + hellouniverse: ghcr.io/spectrocloud/hello-universe:1.2.0 + apiEnabled: false + namespace: hello-universe + port: 8080 + replicas: 1 + + - name: "enable-api" + displayName: "Enable Hello Universe API" + group: "Backend" + remove: [] + add: | + manifests: + hello-universe: + images: + hellouniverse: ghcr.io/spectrocloud/hello-universe:1.2.0-proxy + hellouniverseapi: ghcr.io/spectrocloud/hello-universe-api:1.1.0 + hellouniversedb: ghcr.io/spectrocloud/hello-universe-db:1.1.0 + apiEnabled: true + namespace: hello-universe + port: 8080 + replicas: 1 + dbPassword: REPLACE_ME # Add base64 encoded password + authToken: REPLACE_ME # Add base64 encoded token + ui: + useTolerations: false + tolerations: + effect: PreferNoSchedule + key: app + value: ui + api: + useTolerations: false + tolerations: + effect: PreferNoSchedule + key: app + value: api + postgres: + useTolerations: false + tolerations: + effect: PreferNoSchedule + key: app + value: postgres diff --git a/packs/hello-universe-1.2.0/schema.yaml b/packs/hello-universe-1.2.0/schema.yaml new file mode 100644 index 00000000..a4609c29 --- /dev/null +++ b/packs/hello-universe-1.2.0/schema.yaml @@ -0,0 +1,104 @@ +manifests.hello-universe.namespace: + # The namespace in which the UI application will be deployed. + # The namespace should be specified as a string. + schema: '{{ required | format "${string}" | hints "Enter the namespace in which the application will be deployed."}}' + +manifests.hello-universe.images.hellouniverse: + # The application image. + # Ensure that the image follows the required format: registry/repository:version. + schema: '{{ required | format "${string}" | hints "Enter the UI application image. Ensure that it follows the required format: registry/repository:version." }}' + +manifests.hello-universe.images.hellouniverseapi: + # The hello-universe-api application image. + # Ensure that the image follows the required format: registry/repository:version. + schema: '{{ format "${string}" | hints "Enter the API application image. Ensure that it follows the required format: registry/repository:version." }}' + +manifests.hello-universe.images.hellouniversedb: + # The hello-universe-db application image. + # Ensure that the image follows the required format: registry/repository:version. + schema: '{{ format "${string}" | hints "Enter the API application image. Ensure that it follows the required format: registry/repository:version." }}' + +manifests.hello-universe.port: + # The cluster port number on which the UI service will listen for incoming traffic. + # The port should be specified as a number. + schema: '{{ required | format "${number}" | hints "Enter the cluster port number on which the UI service will listen for incoming traffic."}}' + +manifests.hello-universe.replicas: + # The number of replicas of the UI application to be created. + # The replicas should be specified as a number. + schema: '{{ required | format "${number}" | hints "Enter the number of replicas of the UI application."}}' + +manifests.hello-universe.dbPassword: + # The database password to connect the hello-universe-api to the hello-universe-db. + # The password should be specified as a base64 encoded string. + schema: '{{ format "${string}" | hints "Enter the base64 encoded database password to connect to."}}' + +manifests.hello-universe.authToken: + # The auth token to connect the hello-universe-api to the hello-universe-db. + # The token should be specified as a base64 encoded string. + schema: '{{ format "${string}" | hints "Enter the base64 encoded auth token to connect to the API with."}}' + +manifests.hello-universe.apiEnabled: + # Flag to indicate whether Hello Universe should be deployed with API server or not. + # The flag should be specified with true or false. + schema: '{{ required | format "${boolean}" | hints "Enter whether to deploy Hello Universe as a three-tier application."}}' + +manifests.hello-universe.ui.useTolerations: + # Flag to indicate whether to use tolerations for the UI pods. + # The flag should be specified with true or false. + schema: '{{ format "${boolean}" | hints "Enter whether to use toleratios for the Hello Universe UI pods."}}' + +manifests.hello-universe.api.useTolerations: + # Flag to indicate whether to use tolerations for the API pods. + # The flag should be specified with true or false. + schema: '{{ format "${boolean}" | hints "Enter whether to use toleratios for the Hello Universe API pods."}}' + +manifests.hello-universe.postgres.useTolerations: + # Flag to indicate whether to use tolerations for the postgres pods. + # The flag should be specified with true or false. + schema: '{{ format "${boolean}" | hints "Enter whether to use toleratios for the Hello Universe API pods."}}' + +manifests.hello-universe.ui.tolerations.effect: + # The toleration effect to use for the Hello Universe UI pods. + # The allowed values are PreferNoSchedule, NoSchedule and NoExecute. + schema: '{{ format "${list:[PreferNoSchedule,NoSchedule,NoExecute]}" | hints "Enter the toleration effect for the UI pods."}}' + +manifests.hello-universe.api.tolerations.effect: + # The effect to use for the Hello Universe API pods. + # The allowed values are PreferNoSchedule, NoSchedule and NoExecute. + schema: '{{ format "${list:[PreferNoSchedule,NoSchedule,NoExecute]}" | hints "Enter the toleration effect for the API pods."}}' + +manifests.hello-universe.postgres.tolerations.effect: + # The effect to use for the Hello Universe API pods. + # The allowed values are PreferNoSchedule, NoSchedule and NoExecute. + schema: '{{ format "${list:[PreferNoSchedule,NoSchedule,NoExecute]}" | hints "Enter the toleration effect for the Postgres pods."}}' + +manifests.hello-universe.ui.tolerations.key: + # The tolerations key to use for the Hello Universe UI pods. + # The key should be specified as a string. + schema: '{{ format "${string}" | hints "Enter the toleration key for the UI pods."}}' + +manifests.hello-universe.api.tolerations.key: + # The tolerations key to use for the Hello Universe API pods. + # The key should be specified as a string. + schema: '{{ format "${string}" | hints "Enter the toleration key for the API pods."}}' + +manifests.hello-universe.postgres.tolerations.key: + # The tolerations key to use for the Hello Universe Postgres pods. + # The key should be specified as a string. + schema: '{{ format "${string}" | hints "Enter the toleration key for the Postgres pods."}}' + +manifests.hello-universe.ui.tolerations.value: + # The tolerations value to use for the Hello Universe UI pods. + # The value should be specified as a string. + schema: '{{ format "${string}" | hints "Enter the toleration value for the UI pods."}}' + +manifests.hello-universe.api.tolerations.value: + # The tolerations value to use for the Hello Universe API pods. + # The value should be specified as a string. + schema: '{{ format "${string}" | hints "Enter the toleration value for the API pods."}}' + +manifests.hello-universe.postgres.tolerations.value: + # The tolerations value to use for the Hello Universe Postgres pods. + # The value should be specified as a string. + schema: '{{ format "${string}" | hints "Enter the toleration value for the Postgres pods."}}' diff --git a/packs/hello-universe-1.2.0/values.yaml b/packs/hello-universe-1.2.0/values.yaml new file mode 100644 index 00000000..dd4e0824 --- /dev/null +++ b/packs/hello-universe-1.2.0/values.yaml @@ -0,0 +1,16 @@ +# spectrocloud.com/enabled-presets: Backend:disable-api + +pack: + content: + images: + - image: ghcr.io/spectrocloud/hello-universe:1.2.0 + + +manifests: + hello-universe: + images: + hellouniverse: ghcr.io/spectrocloud/hello-universe:1.2.0 + apiEnabled: false + namespace: hello-universe + port: 8080 + replicas: 1