Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ __pycache__
.odo/
.odo/env
.odo/odo-file-index.json
venv
2 changes: 1 addition & 1 deletion Containerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/rhpds/python-kopf-s2i:v1.38
FROM quay.io/rhpds/python-kopf-s2i:v1.43

USER root

Expand Down
45 changes: 16 additions & 29 deletions Development.adoc
Original file line number Diff line number Diff line change
@@ -1,55 +1,40 @@
# Poolboy Development

Poolboy development can be performed in the `odo` OpenShift developer CLI or building with OpenShift build configs.
An OpenShift cluster with cluster-admin is required for `odo` development.
https://developers.redhat.com/products/codeready-containers/overview[CodeReady Containers] is recommended for local development.
An Ansible test suite is available for functional testing.

## Development with `odo`

Use of `odo` is recommended for fast iterative development.
`odo` simplifies the build/deploy process and avoids creating unnecessary build artifacts during the development process.

. Install the `odo` developer CLI as described in the OpenShift documentation:
https://docs.openshift.com/container-platform/latest/cli_reference/developer_cli_odo/installing-odo.html[Installing odo]
## Local Development

. Create poolboy local dev resources from the provided helm chart using `poolboy.dev.local` as the operator domain:
+
---------------------------------------------
helm template helm \
helm template helm --include-crds \
--set deploy=false \
--set admin.deploy=false \
--set nameOverride=poolboy-dev \
--set operatorDomain.name=poolboy.dev.local \
| oc apply -f -
---------------------------------------------

. Create a project for development using `odo`:
. Create a project for development and set as active project:
+
------------------------------
oc create namespace poolboy-dev
------------------------------

. Change project to `poolboy-dev` namespace:
+
----------------------
oc project poolboy-dev
----------------------
------------------------------

. Grant privileges for cluster role `poolboy-dev` to default service account:
. Setup virtual environment:
+
-------------------------------------------------------------
oc adm policy add-cluster-role-to-user poolboy-dev -z default
-------------------------------------------------------------
---------------------
python -m venv ./venv
. ./venv/bin/activate
pip install git+https://github.com/rhpds/kopf.git@add-deprecated-finalizer-support
pip install -r dev-requirements.txt
pip install -r requirements.txt
---------------------

. Run odo:
. Run locally:
+
-------
odo dev
./run-local.sh
-------
+
NOTE: The poolboy operator domain is specified in the devfile.
If you are developing with a different operator domain then you will need to update the `devfile.yaml`.

. Run tests with Ansible:
+
Expand Down Expand Up @@ -109,10 +94,12 @@ oc start-build poolboy --from-dir=. --follow
+
--------------------------------------------------------------------------------
helm template helm \
--set enablePrometheusMetrics=false \
--set nameOverride=poolboy-dev \
--set namespace.create=false \
--set manageClaimsInterval=5 \
--set manageHandlesInterval=5 \
--set managePoolsInterval=5 \
--set operatorDomain.name=poolboy.dev.local \
--set resourceHandlerCount=2 \
--set image.tagOverride=- \
Expand Down
3 changes: 3 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ansible==13.4.0
kubernetes==35.0.0
kubernetes-asyncio==35.0.1
37 changes: 0 additions & 37 deletions devfile.yaml

This file was deleted.

96 changes: 96 additions & 0 deletions helm/crds/resourcepoolscalings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: resourcepoolscalings.poolboy.gpte.redhat.com
spec:
group: poolboy.gpte.redhat.com
scope: Namespaced
names:
plural: resourcepoolscalings
singular: resourcepoolscaling
kind: ResourcePoolScaling
versions:
- name: v1
served: true
storage: true
subresources:
status: {}
additionalPrinterColumns:
- name: Pool
type: string
jsonPath: .spec.resourcePool.name
- name: At
type: string
jsonPath: .spec.at
- name: Count
type: integer
jsonPath: .spec.count
- name: Created
type: integer
jsonPath: .status.count
- name: State
type: string
jsonPath: .status.state
schema:
openAPIV3Schema:
description: >-
ResourcePoolScalings configure ResourceHandles to be added to a ResourcePool at a specific time.
type: object
required:
- apiVersion
- kind
- metadata
- spec
properties:
apiVersion:
type: string
kind:
type: string
metadata:
type: object
properties:
name:
type: string
maxLength: 63
pattern: ^[a-z0-9A-Z]([a-z0-9A-Z\-._]*[a-z0-9A-Z])?$
spec:
description: ResourcePoolScaling specification
type: object
properties:
at:
type: string
format: date-time
count:
type: integer
minimum: 0
resourcePool:
type: object
properties:
name:
type: string
required:
- name
required:
- count
- resourcePool
status:
description: ResourcePoolScaling status
type: object
x-kubernetes-preserve-unknown-fields: true
properties:
count:
description: Number of ResourceHandles created
type: integer
diffBase:
description: Kopf diffbase
type: string
kopf:
description: Kopf status
type: object
x-kubernetes-preserve-unknown-fields: true
state:
type: string
enum:
- waiting
- scaling
- done
98 changes: 98 additions & 0 deletions helm/templates/crds/resourcepoolscalings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{{- if .Values.crds.create -}}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: resourcepoolscalings.{{ include "poolboy.operatorDomain" . }}
spec:
group: {{ include "poolboy.operatorDomain" . }}
scope: Namespaced
names:
plural: resourcepoolscalings
singular: resourcepoolscaling
kind: ResourcePoolScaling
versions:
- name: v1
served: true
storage: true
subresources:
status: {}
additionalPrinterColumns:
- name: Pool
type: string
jsonPath: .spec.resourcePool.name
- name: At
type: string
jsonPath: .spec.at
- name: Count
type: integer
jsonPath: .spec.count
- name: Created
type: integer
jsonPath: .status.count
- name: State
type: string
jsonPath: .status.state
schema:
openAPIV3Schema:
description: >-
ResourcePoolScalings configure ResourceHandles to be added to a ResourcePool at a specific time.
type: object
required:
- apiVersion
- kind
- metadata
- spec
properties:
apiVersion:
type: string
kind:
type: string
metadata:
type: object
properties:
name:
type: string
maxLength: 63
pattern: ^[a-z0-9A-Z]([a-z0-9A-Z\-._]*[a-z0-9A-Z])?$
spec:
description: ResourcePoolScaling specification
type: object
properties:
at:
type: string
format: date-time
count:
type: integer
minimum: 0
resourcePool:
type: object
properties:
name:
type: string
required:
- name
required:
- count
- resourcePool
status:
description: ResourcePoolScaling status
type: object
x-kubernetes-preserve-unknown-fields: true
properties:
count:
description: Number of ResourceHandles created
type: integer
diffBase:
description: Kopf diffbase
type: string
kopf:
description: Kopf status
type: object
x-kubernetes-preserve-unknown-fields: true
state:
type: string
enum:
- waiting
- scaling
- done
{{- end -}}
2 changes: 1 addition & 1 deletion helm/templates/metrics-credentials.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.enablePrometheusMetrics -}}
{{- if (and .Values.deploy .Values.enablePrometheusMetrics) -}}
apiVersion: secretgenerator.mittwald.de/v1alpha1
kind: StringSecret
metadata:
Expand Down
2 changes: 2 additions & 0 deletions helm/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ rules:
- resourcehandles/status
- resourcepools
- resourcepools/status
- resourcepoolscalings
- resourcepoolscalings/status
- resourcewatches
- resourcewatches/status
verbs:
Expand Down
2 changes: 1 addition & 1 deletion helm/templates/service-monitor.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.enablePrometheusMetrics -}}
{{- if (and .Values.deploy .Values.enablePrometheusMetrics) -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
Expand Down
Loading
Loading