Skip to content

Commit

Permalink
Merge branch 'flatcar-os-compatibility' into 'main'
Browse files Browse the repository at this point in the history
Gitlab setup for publishing helm packages.

See merge request catalystcloud/capi-helm-charts!5
  • Loading branch information
Travis Holton committed Jun 28, 2023
2 parents bd0aa95 + 0a4cc48 commit 7850c89
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 4 deletions.
36 changes: 35 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
charts/*/charts
Chart.lock
.vscode
.vscode

# Created by https://www.toptal.com/developers/gitignore/api/vim,direnv,helm
# Edit at https://www.toptal.com/developers/gitignore?templates=vim,direnv,helm

### direnv ###
.direnv
.envrc

### Helm ###
# Chart dependencies
**/charts/**/*.tgz

### Vim ###
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~

# End of https://www.toptal.com/developers/gitignore/api/vim,direnv,helm
59 changes: 59 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
include:
- remote: https://gitlab.int.catalystcloud.nz/catalystcloud/gitlab-build-tools/raw/main/templates/docker-setup.gitlab-ci.yml

stages:
- template
- package
- publish

.helm_publish_jobs:
image: gitlab.int.catalystcloud.nz:4567/catalystcloud/helm-environment:20230606T015011Z
before_script:
- cd ${CI_PROJECT_DIR}/charts/openstack-cluster
- export CHART_VERSION=$(git describe --tags)
rules:
- if: $CI_COMMIT_TAG && $CI_COMMIT_REF_NAME =~ /^\d+\.\d+\.\d+.*$/


helm_package:
extends: .helm_publish_jobs
stage: package
script:
- helm dependency build ${CI_PROJECT_DIR}/charts/openstack-cluster
- helm package --app-version $(git describe --always) --version ${CHART_VERSION} ${CI_PROJECT_DIR}/charts/openstack-cluster
artifacts:
paths:
- "${CI_PROJECT_DIR}/charts/openstack-cluster/openstack-cluster-*.tgz"

.publish_chart:
extends: .helm_publish_jobs
stage: publish
script:
# NOTE(travis) push to both gitlab helm repo and OCI for now. Since OCI has no search function it might be useful
# to have a place to browse packages.
- >
curl --request POST
--form chart=@${CI_PROJECT_DIR}/charts/openstack-cluster/openstack-cluster-${CHART_VERSION}.tgz
--user gitlab-ci-token:${CI_JOB_TOKEN}
${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/api/${HELM_CHANNEL}/charts
- >
helm push
${CI_PROJECT_DIR}/charts/openstack-cluster/openstack-cluster-${CHART_VERSION}.tgz oci://internal.oci-registry.nz-por-1.catalystcloud.nz/v2/openstack-cluster/${HELM_CHANNEL}
dependencies:
- helm_package
# NOTE(travis) Alternately publish chart to "dev" or "stable" channel depending if commit tag is on the default branch.
publish_chart_dev:
extends: .publish_chart
variables:
HELM_CHANNEL: dev
rules:
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_REF_NAME =~ /^\d+\.\d+\.\d+.*$/


publish_chart_prod:
extends: .publish_chart
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_REF_NAME =~ /^\d+\.\d+\.\d+.*$/
variables:
HELM_CHANNEL: stable
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
## Catalyst cloud


Add dev channel to helm:
```
helm repo add dev-cc-capi-helm-charts \
--username <gitlab user> \
--password <gitlab password or token> \
https://gitlab.int.catalystcloud.nz/api/v4/projects/848/packages/helm/dev
```


Add stable channel:
```
helm repo add cc-capi-helm-charts \
--username <gitlab user> \
--password <gitlab password or token> \
https://gitlab.int.catalystcloud.nz/api/v4/projects/848/packages/helm/stable
```

Update the repo get any recent packages:
```
helm repo update cc-capi-helm-charts
```

Assuming you have all the necessary default values defined in `values.yml`, `clouds.yaml` etc. you can create a cluster as follows:
```
helm install lf-7 -f addons.yaml -f values.yaml -f clouds.yaml cc-capi-helm-charts/openstack-cluster
```


### Creating helm packages

* commits tagged with a semantic version on `${CI_DEFAULT_BRANCH}` (i.e. main) are published in the **stable** channel
* commits tagged with a semantic version on any branch other than the default branch are published to the **dev** channel


# capi-helm-charts
![Lint](https://github.com/stackhpc/capi-helm-charts/actions/workflows/lint.yaml/badge.svg?branch=main)
![Test Helm](https://github.com/stackhpc/capi-helm-charts/actions/workflows/install.yaml/badge.svg?branch=main)
Expand Down
2 changes: 1 addition & 1 deletion charts/openstack-cluster/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: openstack-cluster
description: Helm chart for deploying a cluster on an OpenStack cloud using Cluster API.
type: application
version: 0.1.0
version: 0.1.3
appVersion: main

dependencies:
Expand Down
17 changes: 16 additions & 1 deletion charts/openstack-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ mirrors and additional packages.
*/}}
{{- define "openstack-cluster.kubeadmConfigSpec" -}}
{{- $ctx := index . 0 }}
{{/* WARN(travis) Flatcar is experimental. Do not merge yet! */}}
{{- $flatcarOS := $ctx.Values.flatcarOS }}
{{- $flatcarContainerLinuxConfig := $ctx.Values.flatcarContainerLinuxConfig }}
{{- $registryMirrors := $ctx.Values.registryMirrors }}
{{- $additionalPackages := $ctx.Values.additionalPackages }}
{{- $trustedCAs := $ctx.Values.trustedCAs }}
Expand Down Expand Up @@ -134,7 +137,13 @@ files:
- {{ toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- if or $trustedCAs $additionalPackages $preKubeadmCommands }}
{{- if $flatcarOS }}
{{/* WARN(travis) Flatcar based images. */}}
{{- with $flatcarContainerLinuxConfig }}
{{- toYaml . }}
{{- end }}
{{- end }}
{{- if or $trustedCAs $additionalPackages $preKubeadmCommands $flatcarOS }}
preKubeadmCommands:
{{- if $trustedCAs }}
- update-ca-certificates
Expand All @@ -148,6 +157,12 @@ preKubeadmCommands:
{{- end }}
{{- end }}
{{- end }}
{{/* WARN(travis) Flatcar based images */}}
{{- if .Values.flatcarOS }}
{{- with .Values.flatcarContainerLinuxConfig }}
{{ toYaml . }}
{{- end }}
{{- end}}

{{/*
Produces the image for the cluster autoscaler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ preKubeadmCommands:
{{- if $skipPhases }}
- cat /run/kubeadm/skip-phases.yaml >> /run/kubeadm/kubeadm.yaml
{{- end }}
{{- if not $ctx.Values.flatcarOS }}
{{- if $kubeProxyConfiguration }}
- cat /run/kubeadm/kube-proxy-configuration.yaml >> /run/kubeadm/kubeadm.yaml
{{- end }}
{{- end }}
{{- end }}
{{- end }}

Expand Down
24 changes: 23 additions & 1 deletion charts/openstack-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@ cloudName: openstack
# This should match the version of kubelet and kubeadm in the image
kubernetesVersion:

# WARN(travis) Flatcar based images
flatcarOS: false
flatcarContainerLinuxConfig:
format: ignition
ignition:
containerLinuxConfig:
additionalConfig: |
systemd:
units:
- name: [email protected]
enabled: true
- name: kubeadm.service
enabled: true
dropins:
- name: 10-flatcar.conf
contents: |
[Unit]
Requires=containerd.service coreos-metadata.service
After=containerd.service coreos-metadata.service
[Service]
EnvironmentFile=/run/metadata/flatcar
# The name of the image to use for cluster machines
machineImage:
# OR
Expand All @@ -34,7 +55,7 @@ machineImageId:
machineSSHKeyName:

# The prefix used for project labels and annotations
projectPrefix: capi.stackhpc.com
projectPrefix: capi.catalystcloud.nz

# Any extra annotations to add to the cluster
clusterAnnotations: {}
Expand Down Expand Up @@ -170,6 +191,7 @@ controlPlane:
# etcd metrics, controller-manager, scheduler and kube-proxy to 0.0.0.0 so that Prometheus
# can reach them to collect metrics
clusterConfiguration:
imageRepository: oci-registry.catalystcloud.nz
etcd:
local:
extraArgs:
Expand Down

0 comments on commit 7850c89

Please sign in to comment.