Skip to content
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: 3 additions & 1 deletion Dockerfile.kubebuilder
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ARG TARGETOS
ARG TARGETARCH
# Path of our go.mod
ARG GO_MOD_PATH=.
ARG GO_MAIN_PATH=cmd/main.go
ENV GO_MAIN_PATH=${GO_MAIN_PATH}
ARG GOCACHE=/root/.cache/go-build
ENV GOCACHE=${GOCACHE}

Expand All @@ -28,7 +30,7 @@ ENV GOOS=${TARGETOS:-linux}
ENV GOARCH=${TARGETARCH}
RUN --mount=type=cache,target=/go/pkg/mod/ \
--mount=type=cache,target=${GOCACHE} \
go build -a -o manager cmd/main.go
go build -a -o manager ${GO_MAIN_PATH}

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
10 changes: 10 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ def kubebuilder_binary_files(path):
"""
return [path + '/cmd', path + '/api', path + '/internal', path + '/go.mod', path + '/go.sum']

########### Hypervisors kubernetes client demo
docker_build('ghcr.io/cobaltcore-dev/cortex-hypervisors-demo', '.',
dockerfile='Dockerfile.kubebuilder',
build_args={'GO_MOD_PATH': 'hypervisors', 'GO_MAIN_PATH': '.'},
only=['hypervisors/', 'internal/', 'go.mod', 'go.sum'],
)
local('sh helm/sync.sh hypervisors/demo/chart')
k8s_yaml(helm('hypervisors/demo/chart', name='cortex-hypervisors-demo', values=[tilt_values]))
k8s_resource('demo', labels=['Demo'])

########### Reservations Operator & CRDs
docker_build('ghcr.io/cobaltcore-dev/cortex-reservations-operator', '.',
dockerfile='Dockerfile.kubebuilder',
Expand Down
25 changes: 25 additions & 0 deletions hypervisors/demo/chart/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Patterns to ignore when building Helm packages.
# Operating system files
.DS_Store

# Version control directories
.git/
.gitignore
.bzr/
.hg/
.hgignore
.svn/

# Backup and temporary files
*.swp
*.tmp
*.bak
*.orig
*~

# IDE and editor-related files
.idea/
.vscode/

# Helm chart artifacts
dist/chart/*.tgz
6 changes: 6 additions & 0 deletions hypervisors/demo/chart/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: owner-info
repository: oci://ghcr.io/sapcc/helm-charts
version: 1.0.0
digest: sha256:7643f231cc4ebda347fd12ec62fe4445c280e2b71d27eec555f3025290f5038f
generated: "2025-08-26T10:55:05.888651+02:00"
14 changes: 14 additions & 0 deletions hypervisors/demo/chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v2
name: cortex-hypervisors-client-demo
description: A Helm chart to distribute the cortex hypervisors client demo.
type: application
version: 0.1.0
appVersion: "latest"
icon: "https://example.com/icon.png"
dependencies:
# Owner info adds a configmap to the kubernetes cluster with information on
# the service owner. This makes it easier to find out who to contact in case
# of issues. See: https://github.com/sapcc/helm-charts/pkgs/container/helm-charts%2Fowner-info
- name: owner-info
repository: oci://ghcr.io/sapcc/helm-charts
version: 1.0.0
Binary file not shown.
50 changes: 50 additions & 0 deletions hypervisors/demo/chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{{- define "chart.name" -}}
{{- if .Chart }}
{{- if .Chart.Name }}
{{- .Chart.Name | trunc 63 | trimSuffix "-" }}
{{- else if .Values.nameOverride }}
{{ .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
reservations
{{- end }}
{{- else }}
reservations
{{- end }}
{{- end }}


{{- define "chart.labels" -}}
{{- if .Chart.AppVersion -}}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
{{- if .Chart.Version }}
helm.sh/chart: {{ .Chart.Version | quote }}
{{- end }}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}


{{- define "chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}


{{- define "chart.hasMutatingWebhooks" -}}
{{- $hasMutating := false }}
{{- range . }}
{{- if eq .type "mutating" }}
$hasMutating = true }}{{- end }}
{{- end }}
{{ $hasMutating }}}}{{- end }}


{{- define "chart.hasValidatingWebhooks" -}}
{{- $hasValidating := false }}
{{- range . }}
{{- if eq .type "validating" }}
$hasValidating = true }}{{- end }}
{{- end }}
{{ $hasValidating }}}}{{- end }}
63 changes: 63 additions & 0 deletions hypervisors/demo/chart/templates/demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: demo
namespace: {{ .Release.Namespace }}
labels:
{{- include "chart.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "chart.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
kubectl.kubernetes.io/default-container: demo
labels:
{{- include "chart.labels" . | nindent 8 }}
spec:
containers:
- name: demo
command:
# Created by kubebuilder Dockerfile
- /manager
image: {{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}
volumeMounts:
- name: demo-config-volume
mountPath: /etc/config
- name: demo-secrets-volume
mountPath: /etc/secrets
readOnly: true
volumes:
# Custom values to configure the demo.
- name: demo-config-volume
configMap:
name: demo-config
- name: demo-secrets-volume
secret:
secretName: demo-secrets
---
apiVersion: v1
kind: ConfigMap
metadata:
name: demo-config
data:
conf.json: |-
{{- if .Values.demo.conf }}
{{ toJson .Values.demo.conf }}
{{- else }}
{}
{{- end }}
---
apiVersion: v1
kind: Secret
metadata:
name: demo-secrets
type: Opaque
data:
secrets.json: |-
{{- if .Values.demo.secrets }}
{{ toJson .Values.demo.secrets | b64enc }}
{{- else }}
{{ "{}" | b64enc }}
{{- end }}
25 changes: 25 additions & 0 deletions hypervisors/demo/chart/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This file is safe from kubebuilder edit --plugins=helm/v1-alpha
# If you want to re-generate, add the --force flag.

owner-info:
enabled: true
helm-chart-url: "https://github.com/cobaltcore-dev/cortex/hypervisors/demo/dist/chart"
maintainers:
- "[email protected]"
- "[email protected]"
- "[email protected]"
support-group: "workload-management"
service: "cortex-hypervisors-demo"

image:
repository: ghcr.io/cobaltcore-dev/cortex-hypervisors-demo

demo:
# Default configuration.
conf: {}
# Config provided here will override the config provided above.
secrets:
apiservers:
- host:
bearerToken:
caCrt:
54 changes: 54 additions & 0 deletions hypervisors/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
module github.com/cobaltcore-dev/cortex/reservations

go 1.25.0

replace github.com/cobaltcore-dev/cortex => ../

require (
github.com/cobaltcore-dev/cortex v0.0.0-00010101000000-000000000000
github.com/cobaltcore-dev/openstack-hypervisor-operator v0.0.0-20250910084739-09a2101e23e7
github.com/sapcc/go-bits v0.0.0-20250911190512-4d3226a57454
k8s.io/client-go v0.34.0
sigs.k8s.io/controller-runtime v0.22.1
)

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/net v0.43.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/term v0.34.0 // indirect
golang.org/x/text v0.28.0 // indirect
golang.org/x/time v0.12.0 // indirect
google.golang.org/protobuf v1.36.8 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.34.0 // indirect
k8s.io/apimachinery v0.34.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)
Loading
Loading