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

support of sub charts for toi helm installer #305

Merged
merged 29 commits into from Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2601570
support of sub charts for toi helm installer
mandelsoft Feb 14, 2023
7c15e9e
unpack chart for subchart handling
mandelsoft Mar 17, 2023
97a4edc
helminstaller path calculation fix
jensh007 Mar 17, 2023
d0502fb
update chart dependencies
mandelsoft Mar 17, 2023
61e2833
fix path calculation for chart adaption in helminstaller
jensh007 Mar 17, 2023
3db1079
add schema extension for subcharts in helminstaller
jensh007 Mar 17, 2023
12d6553
simple exceptions
mandelsoft Mar 19, 2023
55af9de
restructure executor
mandelsoft Mar 19, 2023
43f6667
fix schema definition
jensh007 Mar 20, 2023
c786701
use recursive transfer
mandelsoft Mar 21, 2023
6682664
TOI: forward credentials
mandelsoft Mar 22, 2023
8cc9924
option to keep global access for copy
mandelsoft Mar 23, 2023
04e1f26
TOI: cred forwarding
mandelsoft Mar 24, 2023
2db0ff4
update + align logging
mandelsoft Mar 26, 2023
f7dd6c7
update and improve logging
mandelsoft Mar 26, 2023
4def786
logconfig forwarding to TOI executor
mandelsoft Mar 26, 2023
a0d1c5b
prepare standard TOI logging
mandelsoft Mar 27, 2023
06ca2fd
rework finalizer
mandelsoft Mar 27, 2023
8942a8e
switch to improved logging config
mandelsoft Mar 28, 2023
b063c40
add TOI config+describe command
mandelsoft Mar 28, 2023
d9945aa
conponent build job
mandelsoft Mar 29, 2023
404d518
complete option for component creation
mandelsoft Mar 30, 2023
92d4672
fix github binding
mandelsoft Mar 30, 2023
0fee300
transfer stop option
mandelsoft Mar 30, 2023
8e583ba
make to create ctf as tgz
mandelsoft Mar 31, 2023
12ed834
extend input handling + improve hint generation
mandelsoft Mar 31, 2023
b36ec6a
fix log forwarding and ocm logging
mandelsoft Mar 31, 2023
27df0ec
fix toi logging
mandelsoft Mar 31, 2023
9f5e5c5
fix linter issues
mandelsoft Apr 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/buildcomponents.yaml
@@ -0,0 +1,65 @@
name: BuildComponents

on:
workflow_dispatch:
inputs:
ocm_push:
type: boolean
description: "Push to OCM Repository"
default: false

jobs:
# lint-and-test:
# uses: ./.github/workflows/lint_and_test.yaml
# permissions:
# contents: read
# pull-requests: read
components:
# needs: lint-and-test
name: Trigger component build
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
packages: write
repository-projects: read
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version-file: '${{ github.workspace }}/go.mod'

- name: Cache go-build and mod
uses: actions/cache@v3
with:
path: |
~/.cache/go-build/
~/go/pkg/mod/
key: go-${{ hashFiles('go.sum') }}
restore-keys: |
go-

- name: Push OCM Components
if: inputs.ocm_push == true
env:
GITHUBORG: ${{ github.repository_owner }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
run: make push

- name: Build OCM Components
if: inputs.ocm_push == false
env:
GITHUBORG: ${{ github.repository_owner }}
run: make ctf

- name: Upload OCM Archive
uses: actions/upload-artifact@v3
with:
name: ocm.ctf
path: gen/ctf
50 changes: 47 additions & 3 deletions Makefile
Expand Up @@ -2,14 +2,19 @@
#
# SPDX-License-Identifier: Apache-2.0

NAME := ocm
REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
VERSION := $(shell go run pkg/version/generate/release_generate.go print-version)
GITHUBORG ?= open-component-model
OCMREPO ?= ghcr.io/$(GITHUBORG)/ocm
EFFECTIVE_VERSION := $(VERSION)+$(shell git rev-parse HEAD)
GIT_TREE_STATE := $(shell [ -z "$$(git status --porcelain 2>/dev/null)" ] && echo clean || echo dirty)
COMMIT := $(shell git rev-parse --verify HEAD)

REGISTRY := ghcr.io/mandelsoft/ocm
COMPONENT_CLI_IMAGE_REPOSITORY := $(REGISTRY)/cli
CREDS := $(shell $(REPO_ROOT)/hack/githubcreds.sh)
OCM := go run $(REPO_ROOT)/cmds/ocm $(CREDS)

GEN := $(REPO_ROOT)/gen

SOURCES := $(shell go list -f '{{$$I:=.Dir}}{{range .GoFiles }}{{$$I}}/{{.}} {{end}}' ./... )
GOPATH := $(shell go env GOPATH)
Expand Down Expand Up @@ -83,4 +88,43 @@ $(LOCALBIN):
generate-license:
for f in $(shell find . -name "*.go" -o -name "*.sh"); do \
reuse addheader -r --copyright="SAP SE or an SAP affiliate company and Open Component Model contributors." --license="Apache-2.0" $$f --skip-unrecognised; \
done
done


$(GEN)/.exists:
@mkdir -p $(GEN)
@touch $@

.PHONY: components
components: $(GEN)/.comps

$(GEN)/.comps:
@echo Helminstaller; cd components/helminstaller; make ctf
@echo HelmDemo; cd components/helmdemo; make ctf
@echo OCMCLI; cd components/ocmcli; make ctf
touch $@

.PHONY: ctf
ctf: $(GEN)/ctf

$(GEN)/ctf: $(GEN)/.exists components
@rm -rf "$(GEN)"/ctf
$(OCM) transfer cv --type tgz -V $(GEN)/helminstaller/ctf $(GEN)/ctf
$(OCM) transfer cv -V $(GEN)/helmdemo/ctf $(GEN)/ctf
$(OCM) transfer cv -V $(GEN)/ocmcli/ctf $(GEN)/ctf
touch $@

.PHONY: push
push: $(GEN)/ctf $(GEN)/.push.$(NAME)

$(GEN)/.push.$(NAME): $(GEN)/ctf
$(OCM) transfer ctf -f $(GEN)/ctf $(OCMREPO)
@touch $@

.PHONY: plain-ctf
plain-ctf: $(GEN)
@rm -rf "$(GEN)"/ctf
$(OCM) transfer cv -V $(GEN)/helminstaller/ctf $(GEN)/ctf
$(OCM) transfer cv -V $(GEN)/helmdemo/ctf $(GEN)/ctf
$(OCM) transfer cv -V $(GEN)/ocmcli/ctf $(GEN)/ctf

1 change: 1 addition & 0 deletions VERSION
@@ -0,0 +1 @@
0.3.0-dev
61 changes: 61 additions & 0 deletions cmds/helminstaller/README.md
@@ -0,0 +1,61 @@
# Helm Installer for the TOI Framework

The helm installer provides an executor plugin for the [TOI framework](../../docs/reference/ocm_toi-bootstrapping.md).
It can be used to install a top level helm chart, which might optionally
by composed of a set of sub charts.

## Component

The helm installer plugin for the TOI framework if provided
by component `ocm.software/toi/installers/helminstaller`.

It provides a single `toiExecutor` resource with the
name `toiexecutor`.

## Configuration

The executor configuration supports the following field:

- `chart` *[ResourceReference](../../docs/reference/ocm_toi-bootstrapping.md#resourcereference)* (**required**) The resource containing the top level hemlm chart to work on.

- `subCharts` *map[string]ResourceReference* (**optional**) A set of resources describing charts used as sub charts for the top level chart. The map key is the name of the folder created for the sub chart.

- `release` *string* (**optional**) The default release name to use for installation.

- `namespace` *string* (**optional**) The default namespace to use for the installation.

- `createNamespace` *boolean* (**optional**) If set to true the namespace will be created.

- `imageMapping` *[]ImageMapping* list of localization rules for images.

- `values` **yaml* The default values used for installation. They will be overwritten by the given installation values (at top-level).

- `kubeConfigName` *string* (**optional** default: `target`) The credential name to lookup for the kubeconfig used to access the target Kubernetes cluster.

### Image Mappings

Image meappings describe the injection of OCI image locations, names and versions
taken from the component version info dedicated properties of the installation
values. The hemlm chart MUST take all image locations used in the templates
from dedicated values. This is required to support the transport of
component versions into local repositories environments, which should be used
on the installation site.

An image mapping consists of resource reference fields to refer to an OCI image resource used to extract the image location plus the following additional fields:

- `tag` *string* (**optional**) The property of the values used to inject the tag/version of the image.

- `repository` *string* (**optional**) The property of the values used to inject the base URL (location+repository) of the image.

- `image` *string* (**optional**) The property of the values used to inject the complete image name.

At least the `image` attribute or the `tag` and `repositories` attributes must be used to provide a complete image location.

### Configuring Subcharts

Subcharts are configured as usual with the values for the parent chart (see https://helm.sh/docs/chart_template_guide/subcharts_and_globals/).

The key of the subchart is used as top-level values key to add settings for the subchart.
Similar to the parent chart, images used by subcharts must be localized via [image mappings](#image-mappings), also. The subchart values must accept tag, repository and/or image value
fields for used images. They are set ny preceeding the name of the value field by the key
of the subchart.
15 changes: 8 additions & 7 deletions cmds/helminstaller/app/config.go
Expand Up @@ -13,13 +13,14 @@ import (
)

type Config struct {
Chart v1.ResourceReference `json:"chart,omitempty"`
Release string `json:"release,omitempty"`
Namespace string `json:"namespace,omitempty"`
CreateNamespace bool `json:"createNamespace,omitempty"`
ImageMapping []ImageMapping `json:"imageMapping"`
Values json.RawMessage `json:"values,omitempty"`
KubeConfigName string `json:"kubeConfigName,omitempty"`
Chart v1.ResourceReference `json:"chart,omitempty"`
SubCharts map[string]v1.ResourceReference `json:"subCharts,omitempty"`
Release string `json:"release,omitempty"`
Namespace string `json:"namespace,omitempty"`
CreateNamespace bool `json:"createNamespace,omitempty"`
ImageMapping []ImageMapping `json:"imageMapping"`
Values json.RawMessage `json:"values,omitempty"`
KubeConfigName string `json:"kubeConfigName,omitempty"`
}

type ImageMapping = localize.ImageMapping
Expand Down