From 458f75dbaa2a50c904a5aa3977234f5dc4a7f745 Mon Sep 17 00:00:00 2001 From: Bharath Nallapeta Date: Mon, 24 Jun 2024 17:19:20 +0530 Subject: [PATCH] Add Kubernetes Ingress and update AppList component (#414) * Add Kubernetes Ingress and update AppList component * k8s + local changes * revert applist.js * update port to 8080 from 80 * fix tag * testing workflow * Update readme * test workflow - github comment * revert test --------- Co-authored-by: SheryarButt --- .github/workflows/pull_request.yaml | 6 +- README.md | 31 +- deployments/kubernetes/forecastle.yaml | 37 +-- deployments/kubernetes/manifests/service.yaml | 2 +- deployments/openshift/forecastle.yaml | 282 ++++++++++++++++++ deployments/samples/forecastleapp.yaml | 14 + 6 files changed, 328 insertions(+), 44 deletions(-) create mode 100644 deployments/openshift/forecastle.yaml create mode 100644 deployments/samples/forecastleapp.yaml diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 77ce7bfb..92d9a830 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v4 with: ref: ${{github.event.pull_request.head.sha}} - + # Setting up helm binary - name: Set up Helm uses: azure/setup-helm@v3 @@ -135,7 +135,7 @@ jobs: org.opencontainers.image.source=${{ github.event.repository.clone_url }} org.opencontainers.image.created=${{ steps.prep.outputs.created }} org.opencontainers.image.revision=${{ github.sha }} - + - name: Comment on PR uses: mshick/add-pr-comment@v2 env: @@ -148,7 +148,7 @@ jobs: if: failure() uses: mshick/add-pr-comment@v2 env: - GITHUB_TOKEN: ${{ secrets.STAKATER_GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: message: '@${{ github.actor }} Yikes! You better fix it before anyone else finds out! [Build](https://github.com/${{ github.repository }}/commit/${{ github.event.pull_request.head.sha }}/checks) has Failed!' allow-repeats: true diff --git a/README.md b/README.md index 360e3440..e743831f 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,9 @@ Forecastle boasts a range of functionalities designed to streamline the manageme ## Admin Guide -This section is intended for Administrators aiming to deploy Forecastle in Kubernetes environments. Forecastle offers flexible deployment options, accommodating both Kubernetes and OpenShift platforms with ease. +This section is intended for Administrators aiming to deploy Forecastle on their clusters. Forecastle offers flexible deployment options, accommodating both Kubernetes and OpenShift platforms with ease. -You have the choice of deploying Forecastle using traditional Kubernetes manifests or through Helm charts. Detailed instructions for both methods are provided below to guide you through the deployment process. +You have the choice of deploying Forecastle using traditional manifests or through Helm charts. Detailed instructions for both methods are provided below to guide you through the deployment process. ### Vanilla Manifests @@ -80,10 +80,31 @@ You have the choice of deploying Forecastle using traditional Kubernetes manifes You can get Forecastle by running the following command on your cluster: +for Kubernetes: ```bash kubectl apply -f https://raw.githubusercontent.com/stakater/Forecastle/master/deployments/kubernetes/forecastle.yaml ``` +for OpenShift: +```bash +kubectl apply -f https://raw.githubusercontent.com/stakater/Forecastle/master/deployments/openshift/forecastle.yaml +``` + +##### Accessing the Dashboard + +For Kubernetes environments, you can use the following port-foward command to access the Forecastle dashboard: +```bash +kubectl port-forward svc/forecastle 8080:8080 +``` + +Please note that you would need to configure ingress to to access Forecastle from outside the cluster based on your cluster's ingress configuration. + +For OpenShift environments, a default route is created for the Forecastle service. You can access the dashboard using the route URL. + +```bash +oc get route forecastle +``` + #### Step 2: Update configmap Modify the `namespaceSelector` key in the Forecastle ConfigMap to list the namespaces you want Forecastle to monitor. For detailed instructions, see [namespace selector configuration](#namespaceselector) for instructions. @@ -93,7 +114,7 @@ Modify the `namespaceSelector` key in the Forecastle ConfigMap to list the names If you have Helm configured on your Kubernetes cluster, deploy Forecastle using the Helm chart. The chart is located [here.](./deployments/kubernetes/chart/forecastle) Adjust the configuration in values.yaml if required and run the following command: - + ```bash helm install forecastle ./deployments/kubernetes/chart/forecastle ``` @@ -231,9 +252,9 @@ spec: group: dev icon: https://icon-url url: http://app-url - networkRestricted: "false" + networkRestricted: false properties: - Version: 1.0 + Version: "1.0" instance: "" # Optional ``` diff --git a/deployments/kubernetes/forecastle.yaml b/deployments/kubernetes/forecastle.yaml index f154bfeb..2b4e4ef7 100644 --- a/deployments/kubernetes/forecastle.yaml +++ b/deployments/kubernetes/forecastle.yaml @@ -95,14 +95,12 @@ metadata: release: "forecastle" heritage: "Helm" name: forecastle - namespace: default --- # Source: forecastle/templates/configmap.yaml apiVersion: v1 kind: ConfigMap metadata: name: forecastle - namespace: default labels: app: forecastle group: com.stakater.platform @@ -144,9 +142,6 @@ rules: - apiGroups: ["networking.k8s.io"] resources: ["ingresses"] verbs: ["get", "list"] -- apiGroups: ["route.openshift.io"] - resources: ["routes"] - verbs: ["get", "list"] - apiGroups: ["traefik.containo.us"] resources: ["ingressroutes"] verbs: ["get", "list"] @@ -177,7 +172,7 @@ roleRef: subjects: - kind: ServiceAccount name: forecastle - namespace: default + namespace: forecastle --- # Source: forecastle/templates/service.yaml apiVersion: v1 @@ -193,11 +188,10 @@ metadata: heritage: "Helm" expose: "true" name: forecastle - namespace: default spec: ports: - name: http - port: 80 + port: 8080 protocol: TCP targetPort: 3000 selector: @@ -218,7 +212,6 @@ metadata: release: "forecastle" heritage: "Helm" name: forecastle - namespace: default spec: replicas: 1 revisionHistoryLimit: 2 @@ -254,29 +247,3 @@ spec: configMap: name: forecastle serviceAccountName: forecastle ---- -# Source: forecastle/templates/route.yaml -apiVersion: route.openshift.io/v1 -kind: Route -metadata: - name: forecastle - namespace: default - labels: - app: forecastle - group: com.stakater.platform - provider: stakater - version: "v1.0.141" - chart: "forecastle-v1.0.141" - release: "forecastle" - heritage: "Helm" -spec: - port: - targetPort: http - to: - kind: Service - name: forecastle - weight: 100 - wildcardPolicy: None - tls: - termination: reencrypt - insecureEdgeTerminationPolicy: Redirect diff --git a/deployments/kubernetes/manifests/service.yaml b/deployments/kubernetes/manifests/service.yaml index 38bb344f..cf88efa3 100644 --- a/deployments/kubernetes/manifests/service.yaml +++ b/deployments/kubernetes/manifests/service.yaml @@ -17,7 +17,7 @@ metadata: spec: ports: - name: http - port: 80 + port: 8080 protocol: TCP targetPort: 3000 selector: diff --git a/deployments/openshift/forecastle.yaml b/deployments/openshift/forecastle.yaml new file mode 100644 index 00000000..ee49c018 --- /dev/null +++ b/deployments/openshift/forecastle.yaml @@ -0,0 +1,282 @@ +--- +# Source: crds/forecastleApp.yaml +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: forecastleapps.forecastle.stakater.com +spec: + conversion: + strategy: None + group: forecastle.stakater.com + names: + kind: ForecastleApp + listKind: ForecastleAppList + plural: forecastleapps + singular: forecastleapp + preserveUnknownFields: false + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + type: object + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + properties: + group: + type: string + icon: + type: string + instance: + type: string + name: + type: string + networkRestricted: + type: boolean + properties: + additionalProperties: + type: string + type: object + url: + type: string + urlFrom: + properties: + ingressRef: + type: object + properties: + name: + type: string + routeRef: + type: object + properties: + name: + type: string + ingressRouteRef: + type: object + properties: + name: + type: string + type: object + required: + - name + - group + - icon + type: object + status: + type: object + served: true + storage: true + subresources: + status: {} + +--- +# Source: forecastle/templates/rbac.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app: forecastle + group: com.stakater.platform + provider: stakater + version: "v1.0.136" + chart: "forecastle-v1.0.136" + release: "forecastle" + heritage: "Helm" + name: forecastle + namespace: default +--- +# Source: forecastle/templates/configmap.yaml +apiVersion: v1 +kind: ConfigMap +metadata: + name: forecastle + namespace: default + labels: + app: forecastle + group: com.stakater.platform + provider: stakater + version: "v1.0.136" + chart: "forecastle-v1.0.136" + release: "forecastle" + heritage: "Helm" +data: + config.yaml: |- + crdEnabled: true + customApps: {} + headerBackground: null + headerForeground: null + instanceName: null + namespaceSelector: + any: true + matchNames: + - stakater + title: null +--- +# Source: forecastle/templates/rbac.yaml +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: forecastle-cluster-ingress-role + labels: + app: forecastle + group: com.stakater.platform + provider: stakater + version: "v1.0.136" + chart: "forecastle-v1.0.136" + release: "forecastle" + heritage: "Helm" +rules: +- apiGroups: [""] + resources: ["namespaces"] + verbs: ["get", "list"] +- apiGroups: ["networking.k8s.io"] + resources: ["ingresses"] + verbs: ["get", "list"] +- apiGroups: ["route.openshift.io"] + resources: ["routes"] + verbs: ["get", "list"] +- apiGroups: ["traefik.containo.us"] + resources: ["ingressroutes"] + verbs: ["get", "list"] +- apiGroups: ["traefik.io"] + resources: ["ingressroutes"] + verbs: ["get", "list"] +- apiGroups: ["forecastle.stakater.com"] + resources: ["forecastleapps"] + verbs: ["get", "list"] +--- +# Source: forecastle/templates/rbac.yaml +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: forecastle-cluster-ingress-role-binding + labels: + app: forecastle + group: com.stakater.platform + provider: stakater + version: "v1.0.136" + chart: "forecastle-v1.0.136" + release: "forecastle" + heritage: "Helm" +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: forecastle-cluster-ingress-role +subjects: +- kind: ServiceAccount + name: forecastle + namespace: default +--- +# Source: forecastle/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + labels: + app: forecastle + group: com.stakater.platform + provider: stakater + version: "v1.0.136" + chart: "forecastle-v1.0.136" + release: "forecastle" + heritage: "Helm" + expose: "true" + name: forecastle + namespace: default +spec: + ports: + - name: http + port: 8080 + protocol: TCP + targetPort: 3000 + selector: + app: forecastle + group: com.stakater.platform + provider: stakater +--- +# Source: forecastle/templates/deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: forecastle + group: com.stakater.platform + provider: stakater + version: "v1.0.136" + chart: "forecastle-v1.0.136" + release: "forecastle" + heritage: "Helm" + name: forecastle + namespace: default +spec: + replicas: 1 + revisionHistoryLimit: 2 + selector: + matchLabels: + app: forecastle + group: com.stakater.platform + provider: stakater + template: + metadata: + labels: + app: forecastle + group: com.stakater.platform + provider: stakater + annotations: + checksum/api-config: 3ebc5523d8aeee4106b9debcb5033740666262a515fc298b84945cc77a7544d5 + spec: + containers: + - securityContext: + {} + env: + - name: KUBERNETES_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + image: "stakater/forecastle:v1.0.136" + name: forecastle + volumeMounts: + - name: forecastle-config + mountPath: /etc/forecastle + volumes: + - name: forecastle-config + configMap: + name: forecastle + serviceAccountName: forecastle +--- +# Source: forecastle/templates/route.yaml +apiVersion: route.openshift.io/v1 +kind: Route +metadata: + name: forecastle + namespace: default + labels: + app: forecastle + group: com.stakater.platform + provider: stakater + version: "v1.0.136" + chart: "forecastle-v1.0.136" + release: "forecastle" + heritage: "Helm" +spec: + port: + targetPort: http + to: + kind: Service + name: forecastle + weight: 100 + wildcardPolicy: None + tls: + termination: reencrypt + insecureEdgeTerminationPolicy: Redirect diff --git a/deployments/samples/forecastleapp.yaml b/deployments/samples/forecastleapp.yaml new file mode 100644 index 00000000..f4a59a67 --- /dev/null +++ b/deployments/samples/forecastleapp.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: forecastle.stakater.com/v1alpha1 +kind: ForecastleApp +metadata: + name: google +spec: + name: Google + group: test + icon: https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png + url: https://www.google.com/ + networkRestricted: false + properties: + Version: "1.0" + instance: ""