Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install update #144

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6f01c37
feat: add support for multiple clusters
vishal-chdhry May 29, 2024
7270616
fix: create index by clusterId in clusterpolicy reports
vishal-chdhry May 29, 2024
3590a1c
Merge branch 'main' into multiple-cluster-support
vishal-chdhry May 29, 2024
195e2c6
feat: update makefile
vishal-chdhry Jun 3, 2024
ec0a2dd
fix: provenance
vishal-chdhry Jun 3, 2024
b709483
feat: migration
vishal-chdhry Jun 4, 2024
da73ac7
feat: fix listing in inmemory
vishal-chdhry Jun 4, 2024
424b724
feat: add compression in inmemory
vishal-chdhry Jun 4, 2024
54da8b1
fix: cpolr not creating inmemory
vishal-chdhry Jun 4, 2024
db6a8a4
fix: ci
vishal-chdhry Jun 5, 2024
7c37982
feat: add install instructions
vishal-chdhry Jun 5, 2024
2ea12e1
feat: update the install docs for testing
vishal-chdhry Jun 7, 2024
4b2e06a
Merge branch 'main' into multiple-cluster-support
vishal-chdhry Jun 7, 2024
e7acdc1
Merge pull request #2 from nirmata/multiple-cluster-support
vishal-chdhry Jun 7, 2024
03f07ea
fix: imports
vishal-chdhry Jun 7, 2024
9abe0b3
feat: add support for multiple clusters
vishal-chdhry May 29, 2024
44dd2e3
fix: create index by clusterId in clusterpolicy reports
vishal-chdhry May 29, 2024
52348aa
feat: update makefile
vishal-chdhry Jun 3, 2024
ba46096
feat rebase
vishal-chdhry Jun 8, 2024
1620d47
fix: rebase
vishal-chdhry Jun 8, 2024
bc11b03
feat: reabase
vishal-chdhry Jun 8, 2024
c206925
feat: add compression in inmemory
vishal-chdhry Jun 4, 2024
d4f37ec
fix: cpolr not creating inmemory
vishal-chdhry Jun 4, 2024
bcb8d33
fix: ci
vishal-chdhry Jun 5, 2024
1027af7
feat: add install instructions
vishal-chdhry Jun 5, 2024
f081a18
feat: update the install docs for testing
vishal-chdhry Jun 7, 2024
dbf58bc
fix: merge
vishal-chdhry Jun 8, 2024
246efd2
fix: add sslmode config to managed postgres install doc
vishal-chdhry Jun 8, 2024
1d94ed3
fix: install incluster
anushkamittal2001 Jun 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# CONFIG #
##########

ORG ?= kyverno
ORG ?= nirmata
PACKAGE ?= github.com/$(ORG)/reports-server
GIT_SHA := $(shell git rev-parse HEAD)
GOOS ?= $(shell go env GOOS)
Expand Down Expand Up @@ -190,7 +190,7 @@ verify-codegen: codegen ## Verify all generated code and docs are up to date
# KIND #
########

KIND_IMAGE ?= kindest/node:v1.28.0
KIND_IMAGE ?= kindest/node:v1.30.0
KIND_NAME ?= kind

.PHONY: kind-create
Expand Down
2 changes: 1 addition & 1 deletion charts/reports-server/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ keywords:
- policy reports storage
- postgresql
sources:
- https://github.com/kyverno/reports-server
- https://github.com/nirmata/reports-server
maintainers:
- name: Nirmata
url: https://kyverno.io/
Expand Down
4 changes: 2 additions & 2 deletions charts/reports-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ helm install reports-server --namespace reports-server --create-namespace report
| fullnameOverride | string | `""` | Full name override |
| replicaCount | int | `1` | Number of pod replicas |
| image.registry | string | `"ghcr.io"` | Image registry |
| image.repository | string | `"kyverno/reports-server"` | Image repository |
| image.repository | string | `"nirmata/reports-server"` | Image repository |
| image.pullPolicy | string | `"IfNotPresent"` | Image pull policy |
| image.tag | string | `nil` | Image tag (will default to app version if not set) |
| imagePullSecrets | list | `[]` | Image pull secrets |
Expand Down Expand Up @@ -73,7 +73,7 @@ helm install reports-server --namespace reports-server --create-namespace report

## Source Code

* <https://github.com/kyverno/reports-server>
* <https://github.com/nirmata/reports-server>

## Requirements

Expand Down
7 changes: 7 additions & 0 deletions charts/reports-server/templates/cluster-roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ metadata:
rbac.authorization.k8s.io/aggregate-to-view: 'true'
{{- include "reports-server.labels" . | nindent 4 }}
rules:
- apiGroups:
- ''
resources:
- namespaces
verbs:
- get
- list
- apiGroups:
- reports.kyverno.io
resources:
Expand Down
2 changes: 1 addition & 1 deletion charts/reports-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ image:
# -- Image registry
registry: ghcr.io
# -- Image repository
repository: kyverno/reports-server
repository: nirmata/reports-server
# -- Image pull policy
pullPolicy: IfNotPresent
# -- Image tag (will default to app version if not set)
Expand Down
9 changes: 8 additions & 1 deletion config/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ metadata:
app.kubernetes.io/version: "v0.1.0-alpha.1"
app.kubernetes.io/managed-by: Helm
rules:
- apiGroups:
- ''
resources:
- namespaces
verbs:
- get
- list
- apiGroups:
- reports.kyverno.io
resources:
Expand Down Expand Up @@ -278,7 +285,7 @@ spec:
runAsUser: 1000
seccompProfile:
type: RuntimeDefault
image: "ghcr.io/kyverno/reports-server:v0.1.0-alpha.1"
image: "ghcr.io/nirmata/reports-server:latest"
imagePullPolicy: IfNotPresent
ports:
- name: https
Expand Down
13 changes: 13 additions & 0 deletions config/samples/cnpg-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: reports-server-cluster
namespace: reports-server
spec:
instances: 3
primaryUpdateStrategy: unsupervised
bootstrap:
initdb:
database: reportsdb
storage:
size: 10Gi
129 changes: 112 additions & 17 deletions docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,142 @@ Reports-server has multiple methods for installation: YAML manifest and Helm Cha

If kyverno is already installed in the cluster, follow the [migration guide](#migration).

Reports-server comes with a postgreSQL database. It is recommended to bring-your-own postgres database to have finer control of database configurations ([see database configuration guide](#database-configuration)).
There are three configuration to install reports server:
1. Reports server with managed postgres: Use a centralised postgres database outside of the cluster
2. Reports server with incluster postgres: Create a postgres instance in the cluster
3. Reports server with inmemory reports store: Store reports in the memory of reports server pod

## With Managed Postgres

Reports server can be configured to work with any postgres instance in an out of the cluster. You can install reports server with a postgres instance outside of the cluster with helm as follows.

<!-- In order to install reports-server with Helm, first add the Reports-server Helm repository: -->
<!-- ```bash -->
<!-- helm repo add reports-server https://kyverno.github.io/reports-server -->
<!-- ``` -->
<!---->
<!-- Scan the new repository for charts: -->
<!-- ```bash -->
<!-- helm repo update -->
<!-- ``` -->
<!---->
<!-- Optionally, show all available chart versions for reports-server. -->
<!---->
<!-- ```bash -->
<!-- helm search repo reports-server --l -->
<!-- ``` -->
Get the values for hostname, dbname, postgres username and postgres password from managed postgres and fill the values in helm values

### YAML Manifest
It is recommended to install Reports-server using `kubectl apply`, especially when policy reports CRDs are already installed in the cluster ([see migration guide](#migration)). To install reports server using YAML manifest, create a `reports-server` namespace and run the following command:
Create a namespace and install the reports-server chart:

```bash
kubectl apply -f https://raw.githubusercontent.com/kyverno/reports-server/main/config/install.yaml
helm install reports-server -n reports-server --create-namespace --wait ./charts/reports-server/ \
--set image.tag=latest \
--set postgresql.enabled=false \
--set config.db.host=<HOST_NAME> \
--set config.db.name=<DB_NAME> \
--set config.db.user=<POSTGRES_USERNAME> \
--set config.db.password=<POSTGRES_PASSWORD> \
--set config.db.sslmode=<SSL_MODE>
```

### Helm Chart
## With Incluster database

Reports-server can be deployed via a Helm chart for a production install–which is accessible either through the reports-server repository.
Reports server default install creates a postgres instance by default, but for production, it is recommended to use an postgres operator such as [CloudNativePG](https://cloudnative-pg.io/). Reports-server can be installed along side CloudNativePG as follows:

In order to install reports-server with Helm, first add the Reports-server Helm repository:
Create a namespace for reports-server:
```bash
helm repo add reports-server https://kyverno.github.io/reports-server
kubectl create ns reports-server
```

Scan the new repository for charts:
Install CloudNativePG using one of their recommended installation methods:
```bash
helm repo update
kubectl apply -f \
https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-1.18/releases/cnpg-1.18.5.yaml
```

Optionally, show all available chart versions for reports-server.
Wait for cloud native pg controller to start:

```bash
helm search repo reports-server --l
kubectl wait pod --all --for=condition=Ready --namespace=cnpg-system
```

Create a namespace and install the reports-server chart:

Create a CloudNativePG postgres cluster:
```bash
helm install reports-server -n reports-server reports-server/reports-server --create-namespace
kubectl create -f config/samples/cnpg-cluster.yaml
```

To install pre-releases, add the --devel switch to Helm:
<!-- In order to install reports-server with Helm, first add the Reports-server Helm repository: -->
<!-- ```bash -->
<!-- helm repo add reports-server https://kyverno.github.io/reports-server -->
<!-- ``` -->
<!---->
<!-- Scan the new repository for charts: -->
<!-- ```bash -->
<!-- helm repo update -->
<!-- ``` -->
<!---->
<!-- Optionally, show all available chart versions for reports-server. -->
<!---->
<!-- ```bash -->
<!-- helm search repo reports-server --l -->
<!-- ``` -->
Install the reports-server chart:

```bash
helm install reports-server -n reports-server --create-namespace --wait ./charts/reports-server \
--set image.tag=latest \
--set postgresql.enabled=false \
--set config.db.host=reports-server-cluster-rw.reports-server \
--set config.db.name=reportsdb \
--set config.db.user=$(kubectl get secret -n reports-server reports-server-cluster-app --template={{.data.username}} | base64 -d) \
--set config.db.password=$(kubectl get secret -n reports-server reports-server-cluster-app --template={{.data.password}} | base64 -d)
```

To run without cnpg:
```bash
helm install reports-server -n reports-server reports-server/reports-server --create-namespace --devel
helm install reports-server -n reports-server --create-namespace --wait ./charts/reports-server \
--set image.tag=latest \
--set config.db.name=reportsdb
```
NOTE: to check where the reports are stored you can then exec into the postgres pod
```bash
kubectl exec -it reports-server-postgresql-0 -n reports-server -- psql -U postgres
```
then connect to the db
```
\c reportsdb
```
and query for specific data.


## With inmemory storage
Reports server can be installed without any database as well. In this case, reports will be stored in the memory of reports-server pod. You can install reports-server with inmemory configuration as follows:

<!-- In order to install reports-server with Helm, first add the Reports-server Helm repository: -->
<!-- ```bash -->
<!-- helm repo add reports-server https://kyverno.github.io/reports-server -->
<!-- ``` -->
<!---->
<!-- Scan the new repository for charts: -->
<!-- ```bash -->
<!-- helm repo update -->
<!-- ``` -->
<!---->
<!-- Optionally, show all available chart versions for reports-server. -->
<!---->
<!-- ```bash -->
<!-- helm search repo reports-server --l -->
<!-- ``` -->

Install the reports-server chart:

```bash
helm install reports-server --namespace reports-server --create-namespace --wait ./charts/reports-server \
--set image.tag=latest \
--set config.debug=true \
--set postgresql.enabled=false
```
### Testing

To install Reports-server on a kind cluster for testing, run the following commands:
Expand Down
2 changes: 1 addition & 1 deletion docs/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Follow the given methods to migrate to reports server on your existing cluster:

YAML manifest can be installed directly using `kubectl apply` and this will overwrite the existing API services. Run the following command:
```bash
kubectl apply -f https://raw.githubusercontent.com/kyverno/reports-server/main/config/install.yaml
kubectl apply -f https://raw.githubusercontent.com/nirmata/reports-server/main/config/install.yaml
```

## Helm Chart
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/kyverno/reports-server
module github.com/nirmata/reports-server

Check warning

Code scanning / Trivy

golang: net/http, x/net/http2: unlimited number of CONTINUATION frames causes DoS Medium

Package: golang.org/x/net
Installed Version: 0.20.0
Vulnerability CVE-2023-45288
Severity: MEDIUM
Fixed Version: 0.23.0
Link: CVE-2023-45288

Check warning

Code scanning / Trivy

golang-protobuf: encoding/protojson, internal/encoding/json: infinite loop in protojson.Unmarshal when unmarshaling certain forms of invalid JSON Medium

Package: google.golang.org/protobuf
Installed Version: 1.32.0
Vulnerability CVE-2024-24786
Severity: MEDIUM
Fixed Version: 1.33.0
Link: CVE-2024-24786

go 1.21.4

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"os"
"runtime"

"github.com/kyverno/reports-server/pkg/app"
"github.com/nirmata/reports-server/pkg/app"
genericapiserver "k8s.io/apiserver/pkg/server"
"k8s.io/component-base/logs"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/cephr.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"

reportsv1 "github.com/kyverno/kyverno/api/reports/v1"
"github.com/kyverno/reports-server/pkg/storage"
"github.com/nirmata/reports-server/pkg/storage"
errorpkg "github.com/pkg/errors"
"k8s.io/apimachinery/pkg/api/errors"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/cpolr.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"slices"
"strconv"

"github.com/kyverno/reports-server/pkg/storage"
"github.com/nirmata/reports-server/pkg/storage"
errorpkg "github.com/pkg/errors"
"k8s.io/apimachinery/pkg/api/errors"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/ephr.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"

reportsv1 "github.com/kyverno/kyverno/api/reports/v1"
"github.com/kyverno/reports-server/pkg/storage"
"github.com/nirmata/reports-server/pkg/storage"
errorpkg "github.com/pkg/errors"
"k8s.io/apimachinery/pkg/api/errors"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package api

import (
reportsv1 "github.com/kyverno/kyverno/api/reports/v1"
"github.com/kyverno/reports-server/pkg/storage"
"github.com/nirmata/reports-server/pkg/storage"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/polr.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"slices"
"strconv"

"github.com/kyverno/reports-server/pkg/storage"
"github.com/nirmata/reports-server/pkg/storage"
errorpkg "github.com/pkg/errors"
"k8s.io/apimachinery/pkg/api/errors"
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
Expand Down
8 changes: 4 additions & 4 deletions pkg/app/opts/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"net"
"strings"

"github.com/kyverno/reports-server/pkg/api"
generatedopenapi "github.com/kyverno/reports-server/pkg/api/generated/openapi"
"github.com/kyverno/reports-server/pkg/server"
"github.com/kyverno/reports-server/pkg/storage/db"
"github.com/nirmata/reports-server/pkg/api"
generatedopenapi "github.com/nirmata/reports-server/pkg/api/generated/openapi"
"github.com/nirmata/reports-server/pkg/server"
"github.com/nirmata/reports-server/pkg/storage/db"
openapinamer "k8s.io/apiserver/pkg/endpoints/openapi"
genericapiserver "k8s.io/apiserver/pkg/server"
genericoptions "k8s.io/apiserver/pkg/server/options"
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/policyserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"os"

"github.com/kyverno/reports-server/pkg/app/opts"
"github.com/nirmata/reports-server/pkg/app/opts"
"github.com/spf13/cobra"
cliflag "k8s.io/component-base/cli/flag"
"k8s.io/component-base/logs"
Expand Down
Loading
Loading