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

Changed test launch to be self-contained in our desired namespace +… #165

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 configuration/observatorium/tenants.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
oidc: {
clientID: 'test',
clientSecret: 'ZXhhbXBsZS1hcHAtc2VjcmV0',
issuerURL: 'http://dex.dex.svc.cluster.local:5556/dex',
issuerURL: 'http://dex.${TEST_DEX_NAMESPACE}.svc.cluster.local:5556/dex',
usernameClaim: 'email',
},
},
Expand All @@ -16,7 +16,7 @@
oidc: {
clientID: 'test',
clientSecret: 'ZXhhbXBsZS1hcHAtc2VjcmV0',
issuerURL: 'http://dex.dex.svc.cluster.local:5556/dex',
issuerURL: 'http://dex.${TEST_DEX_NAMESPACE}.svc.cluster.local:5556/dex',
usernameClaim: 'email',
},
},
Expand Down
8 changes: 5 additions & 3 deletions resources/services/observatorium-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -284,22 +284,22 @@ objects:
stringData:
client-id: test
client-secret: ZXhhbXBsZS1hcHAtc2VjcmV0
issuer-url: http://dex.dex.svc.cluster.local:5556/dex
issuer-url: http://dex.${TEST_DEX_NAMESPACE}.svc.cluster.local:5556/dex
tenants.yaml: |-
"tenants":
- "id": "770c1124-6ae8-4324-a9d4-9ce08590094b"
"name": "rhobs"
"oidc":
"clientID": "test"
"clientSecret": "ZXhhbXBsZS1hcHAtc2VjcmV0"
"issuerURL": "http://dex.dex.svc.cluster.local:5556/dex"
"issuerURL": "http://dex.${TEST_DEX_NAMESPACE}.svc.cluster.local:5556/dex"
"usernameClaim": "email"
- "id": "FB870BF3-9F3A-44FF-9BF7-D7A047A52F43"
"name": "telemeter"
"oidc":
"clientID": "test"
"clientSecret": "ZXhhbXBsZS1hcHAtc2VjcmV0"
"issuerURL": "http://dex.dex.svc.cluster.local:5556/dex"
"issuerURL": "http://dex.${TEST_DEX_NAMESPACE}.svc.cluster.local:5556/dex"
"usernameClaim": "email"
- apiVersion: v1
kind: Service
Expand Down Expand Up @@ -1040,3 +1040,5 @@ parameters:
value: 1Gi
- name: UP_MEMORY_LIMIT
value: 2Gi
- name: TEST_DEX_NAMESPACE
value: dex
4 changes: 2 additions & 2 deletions services/dex-template.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ local dex = (import 'github.com/observatorium/observatorium/configuration/compon
userID: '08a8684b-db88-4b73-90a9-3cd1661f5466',
},
],
issuer: 'http://${NAMESPACE}.${NAMESPACE}.svc.cluster.local:5556/dex',
issuer: 'http://dex.${NAMESPACE}.svc.cluster.local:5556/dex',
storage: {
type: 'sqlite3',
config: { file: '/storage/dex.db' },
Expand Down Expand Up @@ -81,7 +81,7 @@ local dex = (import 'github.com/observatorium/observatorium/configuration/compon
};

{
apiVersion: 'v1',
apiVersion: 'template.openshift.io/v1',
kind: 'Template',
metadata: {
name: 'dex',
Expand Down
4 changes: 1 addition & 3 deletions services/minio-template.jsonnet
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
local minio = (import 'github.com/observatorium/observatorium/configuration/components/minio.libsonnet')({
name:: 'minio',
namespace:: '${NAMESPACE}',
image:: '${IMAGE}:${IMAGE_TAG}',
version:: '${IMAGE_TAG}',
accessKey:: '${MINIO_ACCESS_KEY}',
Expand Down Expand Up @@ -34,7 +33,7 @@ local minio = (import 'github.com/observatorium/observatorium/configuration/comp
};

{
apiVersion: 'v1',
apiVersion: 'template.openshift.io/v1',
kind: 'Template',
metadata: {
name: 'minio',
Expand All @@ -48,7 +47,6 @@ local minio = (import 'github.com/observatorium/observatorium/configuration/comp
for name in std.objectFields(minio)
],
parameters: [
{ name: 'NAMESPACE', value: 'minio' },
{ name: 'IMAGE', value: 'minio/minio' },
{ name: 'IMAGE_TAG', value: 'RELEASE.2021-09-09T21-37-07Z' },
{ name: 'REPLICAS', value: '1' },
Expand Down
1 change: 1 addition & 0 deletions services/observatorium-template.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,6 @@ local obs = import 'observatorium.libsonnet';
{ name: 'UP_CPU_LIMIT', value: '500m' },
{ name: 'UP_MEMORY_REQUEST', value: '1Gi' },
{ name: 'UP_MEMORY_LIMIT', value: '2Gi' },
{ name: 'TEST_DEX_NAMESPACE', value: 'dex' },
],
}
2 changes: 1 addition & 1 deletion services/observatorium.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ local rulesObjstore = (import 'github.com/observatorium/rules-objstore/jsonnet/l
stringData+: {
'client-id': 'test',
'client-secret': 'ZXhhbXBsZS1hcHAtc2VjcmV0',
'issuer-url': 'http://dex.dex.svc.cluster.local:5556/dex',
'issuer-url': 'http://dex.${TEST_DEX_NAMESPACE}.svc.cluster.local:5556/dex',
},
},
},
Expand Down
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.test.env
28 changes: 22 additions & 6 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,45 @@ This directory includes extra resources that make it possible to deploy RHOBS in
- [Red Hat External SSO](https://sso.redhat.com/auth/realms/redhat-external), which serves as an OIDC provider, is replaced by a local installation of [dex](https://dexidp.io/)
- The object storage, normally provided by S3, is replaced by a local installation of [minio](https://min.io/)

In addition to replacing external dependencies, this directory also includes files to [override default OpenShift template parameters](https://docs.openshift.com/container-platform/4.9/openshift_images/using-templates.html#templates-cli-generating-list-of-objects_using-templates). These files have filename `<namespace>.test.env` and are namespace-specific. The purpose of this is to override parameters in order to make the deployments suitable for testing, in particular:
The deployment is self-contained in single namespace provided as parameter to `launch.sh deploy` script.

In addition to replacing external dependencies, the `launch.sh` script also includes parameters to [override default OpenShift template parameters](https://docs.openshift.com/container-platform/4.9/openshift_images/using-templates.html#templates-cli-generating-list-of-objects_using-templates). The purpose of this is to override parameters in order to make the deployments suitable for testing, in particular:
- The CPU / memory limits / requests are decreased so that RHOBS can be deployed on smaller clusters as well
- The number of replicas for components is decreased as well in order for the deployment to not be too resources heavy
- Some further object names (e.g. service accounts and images) are replaced to work with local alternatives of the external dependencies
- Namespace name changes so all can be deployed in one namespace.

The parameter files can be edited accordingly to accommodate your specific testing scenario.

### Requirements.

The parameter files can be edited accordingly to accomodate your specific testing scenario.
* OpenShift cluster available.
* [oc](https://docs.openshift.com/container-platform/4.7/cli_reference/openshift_cli/getting-started-cli.html) CLI installed.

### How to

To deploy the RHOBS stack on a cluster, use the `launch.sh` script from within this directory. Run:

```bash
./launch.sh deploy
./launch.sh deploy <your testing namespace>
```

This will create all the necessary namespaces and other resources for you.

To tear down the installation, run:

```bash
./launch.sh teardown
./launch.sh teardown <your testing namespace>
```
This will delete all RHOBS namespaces for you.

### Additional information
This will delete all RHOBS resources for you.

### NOTE: Minio, Dex Templates

Some templates like `minio-template.yaml` and `dex-template.yaml` are generated in `make manifests` process. Any manual edition to this will be removed after that command.

### Additional information.

Currently, not every RHOBS OpenShift template is being processed and deployed - only the 'core' parts of RHOBS are included within the testing deployment at the moment. This includes `observatorium`, `observatorium-metrics` and `telemeter` namespaces (each based on its respective template).

The test deployment also does not take care of exposing services. This is left up to the user, to expose the services in a fashion suitable for the given test scenario - whether this done by using the `oc expose` command or by port forwarding to a given service / pod via `oc port-forward`.
8 changes: 8 additions & 0 deletions tests/alertmanager-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: alertmanager-config
data:
# "# Default"
alertmanager.yaml: IyBEZWZhdWx0Cg==
type: Opaque
45 changes: 45 additions & 0 deletions tests/cluster-roles-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: template.openshift.io/v1
kind: Template
metadata:
name: roles
objects:
- apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: ${NAME}
rules:
- apiGroups:
- authentication.k8s.io
resources:
- tokenreviews
verbs:
- create
- apiGroups:
- authorization.k8s.io
resources:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- ""
resourceNames:
- ${{NAME}}
resources:
- namespaces
verbs:
- get
- apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: ${NAME}
subjects:
- kind: ServiceAccount
name: rhobs
namespace: ${NAME}
roleRef:
kind: ClusterRole
name: ${NAME}
apiGroup: rbac.authorization.k8s.io
parameters:
- name: NAME
value: "<CHANGEME>"
4 changes: 2 additions & 2 deletions tests/dex-template.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
apiVersion: template.openshift.io/v1
kind: Template
metadata:
name: dex
Expand Down Expand Up @@ -88,7 +88,7 @@ objects:
stringData:
config.yaml: |-
"enablePasswordDB": true
"issuer": "http://${NAMESPACE}.${NAMESPACE}.svc.cluster.local:5556/dex"
"issuer": "http://dex.${NAMESPACE}.svc.cluster.local:5556/dex"
"logger":
"level": "debug"
"oauth2":
Expand Down
Loading