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

Adds support for python helm charts on shared cluster. #105

Merged
merged 4 commits into from
Oct 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ metadata:
template: django-psql
name: {{ .Values.name }}
spec:
{{ if .Values.registry.enabled }}
output:
to:
kind: DockerImage
name: "{{ .Values.registry.name }}/{{ .Values.registry.namespace }}/{{ .Values.name }}:latest"
pushSecret:
name: {{ .Values.registry.push_secret }}
{{ else }}
output:
to:
kind: ImageStreamTag
name: {{ .Values.name }}:latest
{{ end }}
postCommit:
script: ./manage.py test
source:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: Deployment
metadata:
annotations:
description: Defines how to deploy the application server
{{ if not .Values.registry.enabled }}
image.openshift.io/triggers: |-
[
{
Expand All @@ -13,6 +14,7 @@ metadata:
"fieldPath": "spec.template.spec.containers[0].image"
}
]
{{ end }}
template.alpha.openshift.io/wait-for-ready: "true"
labels:
app: django-psql
Expand Down Expand Up @@ -56,7 +58,11 @@ spec:
secretKeyRef:
key: django-secret-key
name: {{ .Values.name }}
image: ' '
{{ if .Values.registry.enabled }}
image: "{{ .Values.registry.name }}/{{ .Values.registry.namespace }}/{{ .Values.name }}:latest"
{{ else }}
image: " "
{{ end }}
livenessProbe:
httpGet:
path: /health
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
{{ if .Values.pvc.netapp_nfs }}
annotations:
trident.netapp.io/reclaimPolicy: Delete
{{ end }}
labels:
app: django-psql
template: django-psql
{{ if .Values.pvc.netapp_nfs }}
paas.redhat.com/appcode: {{ .Values.pvc.app_code }}
{{ end }}
name: {{ .Values.database_service_name }}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.volume_capacity }}
storage: {{ .Values.pvc.volume_capacity }}
{{ if .Values.pvc.netapp_nfs }}
storageClassName: netapp-nfs
volumeMode: Filesystem
{{ end }}
47 changes: 39 additions & 8 deletions charts/redhat/django-psql-persistent/src/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,45 @@
"sliderMax": 65536,
"sliderUnit": "Mi"
},
"volume_capacity": {
"type": "string",
"title": "Persistent Volume Size",
"form": true,
"render": "slider",
"sliderMin": 1,
"sliderMax": 100,
"sliderUnit": "Gi"
"registry": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"name": {
"type": "string",
"description": "The name of registry that will be used for pushing built image."
},
"namespace": {
"type": "string",
"description": "The namespace of registry that will be used for pushing built image."
},
"push_secret": {
"type": "string",
"description": "The push secret to push image to registry."
}
}
},
"pvc": {
"type": "object",
"properties": {
"volume_capacity": {
"type": "string",
"title": "Persistent Volume Size",
"form": true,
"render": "slider",
"sliderMin": 1,
"sliderMax": 100,
"sliderUnit": "Gi"
},
"netapp_nfs": {
"type": "boolean"
},
"app_code": {
"type": "string"
}
}
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions charts/redhat/django-psql-persistent/src/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ memory_postgresql_limit: 512Mi
name: django-psql
namespace: openshift
pip_index_url: "" # TODO: must define a default value for .pip_index_url
postgresql_version: 12-el8
postgresql_version: 15-el8
python_version: 3.11-ubi8
source_repository_ref: 2.2.x # TODO: must define a default value for .source_repository_ref
source_repository_url: https://github.com/sclorg/django-ex.git
volume_capacity: 1Gi
registry:
enabled: false
name: "quay.io"
namespace: "something"
push_secret: ""
pvc:
volume_capacity: 1Gi
app_code: "something"
netapp_nfs: false
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
{{ if .Values.pvc.netapp_nfs }}
annotations:
trident.netapp.io/reclaimPolicy: Delete
{{ end }}
labels:
template: postgresql-persistent-template
{{ if .Values.pvc.netapp_nfs }}
paas.redhat.com/appcode: {{ .Values.pvc.app_code }}
{{ end }}
name: {{ .Values.database_service_name }}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ .Values.volume_capacity }}
storage: {{ .Values.pvc.volume_capacity }}
{{ if .Values.pvc.netapp_nfs }}
storageClassName: netapp-nfs
volumeMode: Filesystem
{{ end }}
29 changes: 20 additions & 9 deletions charts/redhat/postgresql-persistent/src/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@
}
}
},
"volume_capacity": {
"type": "string",
"title": "Persistent Volume Size",
"form": true,
"render": "slider",
"sliderMin": 1,
"sliderMax": 100,
"sliderUnit": "Gi"
},
"memory_limit": {
"type": "string",
"title": "Database memory limit",
Expand All @@ -53,6 +44,26 @@
"enum": ["latest", "13-el9", "13-el8", "12-el8", "12" ]
}
}
},
"pvc": {
"type": "object",
"properties": {
"volume_capacity": {
"type": "string",
"title": "Persistent Volume Size",
"form": true,
"render": "slider",
"sliderMin": 1,
"sliderMax": 100,
"sliderUnit": "Gi"
},
"netapp_nfs": {
"type": "boolean"
},
"app_code": {
"type": "string"
}
}
}
}
}
5 changes: 4 additions & 1 deletion charts/redhat/postgresql-persistent/src/values.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
database_service_name: postgresql-persistent
memory_limit: 512Mi
namespace: postgresql-persistent-testing
volume_capacity: 1Gi
config:
postgresql_database: testdb
postgresql_password: testp
postgresql_user: testu
port: 5432
image:
tag: "13-el8"
pvc:
volume_capacity: 1Gi
app_code: "something"
netapp_nfs: false
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@ metadata:
template: django-example
name: {{ .Values.name }}
spec:
{{ if .Values.registry.enabled }}
output:
to:
kind: DockerImage
name: "{{ .Values.registry.name }}/{{ .Values.registry.namespace }}/{{ .Values.name }}:latest"
pushSecret:
name: {{ .Values.registry.push_secret }}
{{ else }}
output:
to:
kind: ImageStreamTag
name: "{{ .Values.name }}:latest"
name: {{ .Values.name }}:latest
{{ end }}
{{ if not .Values.registry.enabled }}
postCommit:
script: ./manage.py test
{{ end }}
source:
contextDir: {{ .Values.context_dir }}
git:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: Deployment
metadata:
annotations:
description: Defines how to deploy the application server
{{ if not .Values.registry.enabled }}
image.openshift.io/triggers: |-
[
{
Expand All @@ -13,6 +14,7 @@ metadata:
"fieldPath": "spec.template.spec.containers[0].image"
}
]
{{ end }}
template.alpha.openshift.io/wait-for-ready: "true"
labels:
app: django-example
Expand Down Expand Up @@ -40,7 +42,11 @@ spec:
secretKeyRef:
key: django-secret-key
name: {{ .Values.name }}
image: ' '
{{ if .Values.registry.enabled }}
image: "{{ .Values.registry.name }}/{{ .Values.registry.namespace }}/{{ .Values.name }}:latest"
{{ else }}
image: " "
{{ end }}
livenessProbe:
httpGet:
path: /
Expand Down
20 changes: 20 additions & 0 deletions charts/redhat/python-django-application/src/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@
"source_repository_ref": {
"type": "string",
"description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
},
"registry": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"name": {
"type": "string",
"description": "The name of registry that will be used for pushing built image."
},
"namespace": {
"type": "string",
"description": "The namespace of registry that will be used for pushing built image."
},
"push_secret": {
"type": "string",
"description": "The push secret to push image to registry."
}
}
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion charts/redhat/python-django-application/src/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ python_version: 3.11-ubi8
source_repository_ref: 2.2.x # TODO: must define a default value for .source_repository_ref
source_repository_url: https://github.com/sclorg/django-ex.git
app_config: "" # TODO: must define a default value for .app_config

registry:
enabled: false
name: "quay.io"
namespace: "something"
push_secret: ""
4 changes: 2 additions & 2 deletions tests/test_httpd_imagestreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def setup_method(self):
package_name = "httpd-imagestreams"
path = test_dir / "../charts/redhat"
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir)
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()

def teardown_method(self):
self.hc_api.delete_project()
Expand All @@ -30,4 +28,6 @@ def teardown_method(self):
],
)
def test_httpd_imagestream(self, version, registry, expected):
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
assert self.hc_api.check_imagestreams(version=version, registry=registry) == expected
4 changes: 2 additions & 2 deletions tests/test_mariadb_imagestreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def setup_method(self):
package_name = "mariadb-imagestreams"
path = test_dir / "../charts/redhat"
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir)
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()

def teardown_method(self):
self.hc_api.delete_project()
Expand All @@ -31,4 +29,6 @@ def teardown_method(self):
],
)
def test_package_imagestream(self, version, registry, expected):
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
assert self.hc_api.check_imagestreams(version=version, registry=registry) == expected
4 changes: 2 additions & 2 deletions tests/test_mysql_imagestreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ def setup_method(self):
package_name = "mysql-imagestreams"
path = test_dir / "../charts/redhat"
self.hc_api = HelmChartsAPI(path=path, package_name=package_name, tarball_dir=test_dir)
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()

def teardown_method(self):
self.hc_api.delete_project()
Expand All @@ -28,4 +26,6 @@ def teardown_method(self):
],
)
def test_package_imagestream(self, version, registry, expected):
assert self.hc_api.helm_package()
assert self.hc_api.helm_installation()
assert self.hc_api.check_imagestreams(version=version, registry=registry) == expected
Loading