Skip to content
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
19 changes: 0 additions & 19 deletions .github/workflows/push-charts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,6 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get all changed helm/library/cortex Chart.yaml files
id: changed-chart-yaml-files-core
uses: tj-actions/changed-files@v47
with:
files: |
helm/library/cortex/Chart.yaml
- name: Push cortex core charts to registry
if: steps.changed-chart-yaml-files-core.outputs.all_changed_files != ''
shell: bash
env:
ALL_CHANGED_FILES: ${{ steps.changed-chart-yaml-files-core.outputs.all_changed_files }}
run: |
for CHART_FILE in ${ALL_CHANGED_FILES}; do
CHART_DIR=$(dirname $CHART_FILE)
helm package $CHART_DIR --dependency-update --destination $CHART_DIR
CHART_PACKAGE=$(ls $CHART_DIR/*.tgz)
helm push $CHART_PACKAGE oci://${{ env.REGISTRY }}/${{ github.repository }}/charts/
done

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow step is redundant with the one below. It can be removed.

- name: Get all changed library Chart.yaml files
id: changed-chart-yaml-files-library
uses: tj-actions/changed-files@v47
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/push-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,55 @@ jobs:
subject-digest: ${{ steps.push_cortex_postgres.outputs.digest }}
push-to-registry: true

# Only build and push the cortex-shim image if there are changes related
# to the cortex shims (e.g., in cmd/shim or internal/shim).
- name: Get all changed shim/ files
id: changed_shim_files
uses: tj-actions/changed-files@v47
with:
files: |
cmd/shim/**
internal/shim/**
api/**
pkg/**
go.mod
go.sum
Dockerfile
- name: Docker Meta (Cortex Shim)
if: steps.changed_shim_files.outputs.all_changed_files != ''
id: meta_cortex_shim
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}-shim
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
latest
env:
DOCKER_METADATA_SHORT_SHA_LENGTH: 8
- name: Build and Push Cortex Shim
if: steps.changed_shim_files.outputs.all_changed_files != ''
id: push_cortex_shim
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta_cortex_shim.outputs.tags }}
labels: ${{ steps.meta_cortex_shim.outputs.labels }}
build-args: |
GIT_TAG=${{ github.ref_name }}
GIT_COMMIT=${{ github.sha }}
GOMAIN=cmd/shim/main.go
- name: Generate Artifact Attestation for Cortex Shim
if: steps.changed_shim_files.outputs.all_changed_files != ''
uses: actions/attest-build-provenance@v4
with:
subject-name: ${{ env.REGISTRY }}/${{ github.repository }}-shim
subject-digest: ${{ steps.push_cortex_shim.outputs.digest }}
push-to-registry: true

# Build & push new cortex image
- name: Docker Meta (Cortex)
id: meta_cortex
Expand All @@ -98,6 +147,7 @@ jobs:
build-args: |
GIT_TAG=${{ github.ref_name }}
GIT_COMMIT=${{ github.sha }}
GOMAIN=cmd/manager/main.go
- name: Generate Artifact Attestation for Cortex
uses: actions/attest-build-provenance@v4
with:
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/update-appversion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ jobs:
git commit -m "Bump cortex-postgres chart appVersions to ${{ steps.vars.outputs.sha }} [skip ci]" || echo "No changes to commit"
git push origin HEAD:main

# Only bumped if there are changes in shim-related directories
- name: Get all changed shim files
id: changed_shim_files
uses: tj-actions/changed-files@v47
with:
files: |
internal/shim/**
cmd/shim/**
- name: Update appVersion in cortex-shim Chart.yaml
if: steps.changed_shim_files.outputs.all_changed_files != ''
run: |
sed -i 's/^\([ ]*appVersion:[ ]*\).*/\1"${{ steps.vars.outputs.sha }}"/' helm/library/cortex-shim/Chart.yaml
- name: Commit and push changes for cortex-shim
if: steps.changed_shim_files.outputs.all_changed_files != ''
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add helm/library/cortex-shim/Chart.yaml
git commit -m "Bump cortex-shim chart appVersions to ${{ steps.vars.outputs.sha }} [skip ci]" || echo "No changes to commit"
git push origin HEAD:main

- name: Update appVersion in helm/library/cortex/Chart.yaml
run: |
sed -i 's/^\([ ]*appVersion:[ ]*\).*/\1"${{ steps.vars.outputs.sha }}"/' helm/library/cortex/Chart.yaml
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ cortex.secrets.yaml
!.editorconfig
!.gitignore
!.github
!.gitkeep
!.golangci.yaml
!.license-scan-overrides.jsonl
!.license-scan-rules.json
Expand Down
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ Helm charts:
## Repository Structure

Code:
- `cmd/main.go` is the entry point for the manager, which starts the controllers and webhooks
- `cmd/manager/main.go` is the entry point for the manager, which starts the controllers and webhooks
- `cmd/shim/main.go` is the entry point for cortex shims exposing cortex capabilities over REST endpoints
- `api/v1alpha1` is where the CRD specs of cortex lives
- `api/external` contains messages sent to cortex via http from external openstack services
- `internal/scheduling` contains the logic for scheduling in different cloud domains
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ARG TARGETARCH
ARG GO_MOD_PATH=.
ARG GOCACHE=/root/.cache/go-build
ENV GOCACHE=${GOCACHE}
ARG GOMAIN=cmd/manager/main.go
ENV GOMAIN=${GOMAIN}

# Note: avoid using COPY to /lib which will lead to docker build errors.
WORKDIR /workspace/${GO_MOD_PATH}
Expand All @@ -29,13 +31,13 @@ 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 /main ${GOMAIN}

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /manager .
COPY --from=builder /main .
USER 65532:65532

ENTRYPOINT ["/manager"]
ENTRYPOINT ["/main"]
24 changes: 22 additions & 2 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
analytics_settings(False)

# Use the ACTIVE_DEPLOYMENTS env var to select which Cortex bundles to deploy.
ACTIVE_DEPLOYMENTS_ENV = os.getenv('ACTIVE_DEPLOYMENTS', 'nova,manila,cinder,ironcore,pods')
ACTIVE_DEPLOYMENTS_ENV = os.getenv(
'ACTIVE_DEPLOYMENTS',
'nova,manila,cinder,ironcore,pods,placement',
)
if ACTIVE_DEPLOYMENTS_ENV == "":
ACTIVE_DEPLOYMENTS = [] # Catch "".split(",") = [""]
else:
Expand Down Expand Up @@ -78,13 +81,22 @@ local('kubectl wait --namespace cert-manager --for=condition=available deploymen
url = 'https://raw.githubusercontent.com/cobaltcore-dev/openstack-hypervisor-operator/refs/heads/main/charts/openstack-hypervisor-operator/crds/kvm.cloud.sap_hypervisors.yaml'
local('curl -L ' + url + ' | kubectl apply -f -')

########### Cortex Operator & CRDs
########### Cortex Manager & CRDs
docker_build('ghcr.io/cobaltcore-dev/cortex', '.',
dockerfile='Dockerfile',
build_args={'GOMAIN': 'cmd/manager/main.go'},
only=['internal/', 'cmd/', 'api/', 'pkg', 'go.mod', 'go.sum', 'Dockerfile'],
)
local('sh helm/sync.sh helm/library/cortex')

########### Cortex Shim
docker_build('ghcr.io/cobaltcore-dev/cortex-shim', '.',
dockerfile='Dockerfile',
build_args={'GOMAIN': 'cmd/shim/main.go'},
only=['internal/', 'cmd/', 'api/', 'pkg', 'go.mod', 'go.sum', 'Dockerfile'],
)
local('sh helm/sync.sh helm/library/cortex-shim')

########### Cortex Bundles
docker_build('ghcr.io/cobaltcore-dev/cortex-postgres', 'postgres')

Expand All @@ -98,6 +110,7 @@ bundle_charts = [
('helm/bundles/cortex-cinder', 'cortex-cinder'),
('helm/bundles/cortex-ironcore', 'cortex-ironcore'),
('helm/bundles/cortex-pods', 'cortex-pods'),
('helm/bundles/cortex-placement-shim', 'cortex-placement-shim'),
]
dep_charts = {
'cortex-crds': [
Expand All @@ -123,6 +136,9 @@ dep_charts = {
('helm/library/cortex-postgres', 'cortex-postgres'),
('helm/library/cortex', 'cortex'),
],
'cortex-placement-shim': [
('helm/library/cortex-shim', 'cortex-shim'),
],
}

for (bundle_chart_path, bundle_chart_name) in bundle_charts:
Expand Down Expand Up @@ -255,6 +271,10 @@ if 'pods' in ACTIVE_DEPLOYMENTS:
k8s_yaml('samples/pods/pod.yaml')
k8s_resource('test-pod', labels=['Cortex-Pods'])

if 'placement' in ACTIVE_DEPLOYMENTS:
print("Activating Cortex Placement Shim bundle")
k8s_yaml(helm('./helm/bundles/cortex-placement-shim', name='cortex-placement-shim', values=tilt_values, set=env_set_overrides))

########### Dev Dependencies
local('sh helm/sync.sh helm/dev/cortex-prometheus-operator')
k8s_yaml(helm('./helm/dev/cortex-prometheus-operator', name='cortex-prometheus-operator')) # Operator
Expand Down
File renamed without changes.
Loading
Loading