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

RHDHPAI-29: Add yaml formatting validation #41

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
27 changes: 27 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

# Triggers the workflow on push or pull request events but only for the main branch
on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
yaml-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: skip checking conditional syntax
working-directory: ./templates
run: |
find . -regextype egrep -regex '.*ya?ml$'|while read file; do
sed -i 's/: \s*['\''"]\{0\}\([^'\''"]*{{.*}}.*\)\s*$/: '\''\1'\''/' $file
sed -i '/^\(\s*\)\({%-.*\)$/d' $file
done
- name: yaml format
run: |
curl -L -O https://github.com/google/yamlfmt/releases/download/v0.15.0/yamlfmt_0.15.0_Linux_x86_64.tar.gz
tar -xf yamlfmt_0.15.0_Linux_x86_64.tar.gz
chmod +x yamlfmt
./yamlfmt -lint
7 changes: 7 additions & 0 deletions .yamlfmt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
continue_on_error: true
include:
- templates
formatter:
type: basic
eof_newline: true
trim_trailing_whitespace: true
6 changes: 3 additions & 3 deletions templates/app-of-apps/application-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Application
metadata:
name: {{values.name}}-app
namespace: {{values.argoNS}}
finalizers: ["resources-finalizer.argocd.argoproj.io"]
finalizers: ["resources-finalizer.argocd.argoproj.io"]
spec:
project: {{values.argoProject}}
source:
Expand All @@ -15,9 +15,9 @@ spec:
server: https://kubernetes.default.svc
syncPolicy:
managedNamespaceMetadata:
labels:
labels:
argocd.argoproj.io/managed-by: {{values.argoNS}}
automated:
automated:
prune: true
selfHeal: true
syncOptions:
Expand Down
10 changes: 5 additions & 5 deletions templates/app-of-apps/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
commonLabels:
rhtap/gitops: {{values.name}}
commonLabels:
rhtap/gitops: {{values.name}}
janus-idp.io/tekton: {{values.name}}
backstage.io/kubernetes-id: {{values.name}}
backstage.io/kubernetes-namespace: {{values.namespace}}
backstage.io/kubernetes-namespace: {{values.namespace}}
app.kubernetes.io/part-of: {{values.name}}
resources:
- application-dev.yaml
resources:
- application-dev.yaml
6 changes: 3 additions & 3 deletions templates/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Application
metadata:
name: {{values.name}}
namespace: {{values.argoNS}}
finalizers: ["resources-finalizer.argocd.argoproj.io"]
finalizers: ["resources-finalizer.argocd.argoproj.io"]
spec:
project: {{values.argoProject}}
source:
Expand All @@ -15,9 +15,9 @@ spec:
server: https://kubernetes.default.svc
syncPolicy:
managedNamespaceMetadata:
labels:
labels:
argocd.argoproj.io/managed-by: {{values.argoNS}}
automated:
automated:
prune: true
selfHeal: true
syncOptions:
Expand Down
31 changes: 10 additions & 21 deletions templates/http/base/deployment-database.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,27 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
labels:
app.kubernetes.io/instance: {{values.name}}-database
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/name: {{values.name}}-database
app.kubernetes.io/part-of: {{values.name}}
app.kubernetes.io/part-of: {{values.name}}
name: {{values.name}}-database
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: {{values.name}}-database
template:
metadata:
metadata:
labels:
app.kubernetes.io/instance: {{values.name}}-database
spec:
containers:
- image: {{values.dbContainer}}
name: database
args: [
"--workers",
"1",
"--host",
"0.0.0.0",
"--port",
"{{values.dbPort}}",
"--proxy-headers",
"--log-config",
"chromadb/log_config.yml",
"--timeout-keep-alive",
"30"]
ports:
- containerPort: {{values.dbPort}}
securityContext:
runAsNonRoot: true
- image: {{values.dbContainer}}
name: database
args: ["--workers", "1", "--host", "0.0.0.0", "--port", "{{values.dbPort}}", "--proxy-headers", "--log-config", "chromadb/log_config.yml", "--timeout-keep-alive", "30"]
ports:
- containerPort: {{values.dbPort}}
securityContext:
runAsNonRoot: true
109 changes: 50 additions & 59 deletions templates/http/base/deployment-model-server.yaml
Original file line number Diff line number Diff line change
@@ -1,87 +1,78 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
labels:
app.kubernetes.io/instance: {{values.name}}-model-server
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/name: {{values.name}}-model-server
app.kubernetes.io/part-of: {{values.name}}
app.kubernetes.io/name: {{values.name}}-model-server
app.kubernetes.io/part-of: {{values.name}}
name: {{values.name}}-model-server
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: {{values.name}}-model-server
app.kubernetes.io/instance: {{values.name}}-model-server
template:
metadata:
metadata:
labels:
app.kubernetes.io/instance: {{values.name}}-model-server
app.kubernetes.io/instance: {{values.name}}-model-server
spec:
{%- if values.vllmSelected == nil or not(values.vllmSelected) %}
initContainers:
- name: model-file
image: {{values.initContainer}}
command: {{values.modelInitCommand}}
volumeMounts:
- name: model-file
mountPath: /shared
image: {{values.initContainer}}
command: {{values.modelInitCommand}}
volumeMounts:
- name: model-file
mountPath: /shared
{%- endif %}
containers:
{%- if values.vllmSelected %}
- image: {{values.vllmModelServiceContainer}}
args: ["--model", "{{values.modelName}}", "--port", "{{values.modelServicePort}}", "--download-dir", "/models-cache", "--max-model-len", "{{values.maxModelLength}}"]
resources:
limits:
nvidia.com/gpu: '1'
volumeMounts:
- name: dshm
mountPath: /dev/shm
- name: models-cache
mountPath: /models-cache
{%- else %}
- env:
- name: HOST
value: "0.0.0.0"
- name: PORT
value: "{{values.modelServicePort}}"
- name: MODEL_PATH
value: {{values.modelPath}}
- name: CHAT_FORMAT
value: openchat
image: {{values.modelServiceContainer}}
volumeMounts:
- name: model-file
mountPath: /model
{%- endif %}
name: app-model-service
ports:
- containerPort: {{values.modelServicePort}}
securityContext:
runAsNonRoot: true
{%- if values.vllmSelected %}
- image: {{values.vllmModelServiceContainer}}
args: [
"--model",
"{{values.modelName}}",
"--port",
"{{values.modelServicePort}}",
"--download-dir",
"/models-cache",
"--max-model-len",
"{{values.maxModelLength}}"]
resources:
limits:
nvidia.com/gpu: '1'
volumeMounts:
volumes:
- name: dshm
mountPath: /dev/shm
emptyDir:
medium: Memory
sizeLimit: "2Gi"
- name: models-cache
mountPath: /models-cache
{%- else %}
- env:
- name: HOST
value: "0.0.0.0"
- name: PORT
value: "{{values.modelServicePort}}"
- name: MODEL_PATH
value: {{values.modelPath}}
- name: CHAT_FORMAT
value: openchat
image: {{values.modelServiceContainer}}
volumeMounts:
- name: model-file
mountPath: /model
{%- endif %}
name: app-model-service
ports:
- containerPort: {{values.modelServicePort}}
securityContext:
runAsNonRoot: true
{%- if values.vllmSelected %}
volumes:
- name: dshm
emptyDir:
medium: Memory
sizeLimit: "2Gi"
- name: models-cache
persistentVolumeClaim:
claimName: {{values.name}}

persistentVolumeClaim:
claimName: {{values.name}}
tolerations:
- key: nvidia.com/gpu
operator: Exists
effect: NoSchedule
{%- else %}
volumes:
- name: model-file
emptyDir: {}
- name: model-file
emptyDir: {}
{%- endif %}
58 changes: 29 additions & 29 deletions templates/http/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
annotations:
tad.gitops.set/image: ".spec.template.spec.containers[0].image"
tad.gitops.get/image: ".spec.template.spec.containers[0].image"
tad.gitops.set/replicas: ".spec.replicas"
tad.gitops.get/replicas: ".spec.replicas"
labels:
tad.gitops.get/replicas: ".spec.replicas"
labels:
app.kubernetes.io/instance: {{values.name}}
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/name: {{values.name}}
app.kubernetes.io/part-of: {{values.name}}
app.kubernetes.io/name: {{values.name}}
app.kubernetes.io/part-of: {{values.name}}
name: {{values.name}}
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: {{values.name}}
app.kubernetes.io/instance: {{values.name}}
template:
metadata:
metadata:
labels:
app.kubernetes.io/instance: {{values.name}}
app.kubernetes.io/instance: {{values.name}}
spec:
containers:
- image: {{values.appContainer}}
name: app-inference
envFrom:
- configMapRef:
name: {{values.name}}-model-config
{%- if values.dbRequired %}
- configMapRef:
name: {{values.name}}-database-config
{%- endif %}
{%- if values.includeModelEndpointSecret %}
env:
- name: MODEL_ENDPOINT_BEARER
valueFrom:
secretKeyRef:
name: {{ values.modelEndpointSecretName }}
key: {{ values.modelEndpointSecretKey }}
{%- endif %}
ports:
- containerPort: {{values.appPort}}
securityContext:
runAsNonRoot: true
- image: {{values.appContainer}}
name: app-inference
envFrom:
- configMapRef:
name: {{values.name}}-model-config
{%- if values.dbRequired %}
- configMapRef:
name: {{values.name}}-database-config
{%- endif %}
{%- if values.includeModelEndpointSecret %}
env:
- name: MODEL_ENDPOINT_BEARER
valueFrom:
secretKeyRef:
name: {{ values.modelEndpointSecretName }}
key: {{ values.modelEndpointSecretKey }}
{%- endif %}
ports:
- containerPort: {{values.appPort}}
securityContext:
runAsNonRoot: true
Loading