Skip to content

Commit

Permalink
Add Phase Skipping for Kubeadm & Relase (#10)
Browse files Browse the repository at this point in the history
Adds a new array of phases to skip during kubeadm cluster creation.  Adds in some new scripting to make things a lot more user friendly to work with, especially with revision bumps.  Finally releases new charts for CAPI and the Openstack cluster.
  • Loading branch information
drew-viles authored Jul 18, 2024
1 parent d347a62 commit ec49678
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 31 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Update this for every tagged release.
CHART_VERSION = v0.2.0
CHART_VERSION = v0.2.1

# Defines the versions to use for cluster API components.
CAPI_VERSION = v1.7.4
Expand All @@ -24,7 +24,7 @@ all: cluster-api

.PHONY: cluster-api
cluster-api: $(CHARTS)
./generate-capi.py $(CHARTS)
./generate-capi.py -v $(CHART_VERSION) -c $(CAPI_VERSION) $(CHARTS)

.PHONY: cluster-api-core
cluster-api-core:
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ There is a top level chart-of-charts that will just install everything as a big
```shell
helm repo add unikorn-cloud-capi https://unikorn-cloud.github.io/helm-cluster-api
helm repo update
helm upgrade --install cluster-api unikorn-cloud-capi/cluster-api -n cluster-api --create-namespace --version v0.2.0
helm upgrade --install cluster-api unikorn-cloud-capi/cluster-api -n cluster-api --create-namespace --version v0.2.1
```
</details>

Expand All @@ -47,7 +47,7 @@ spec:
source:
repoURL: https://unikorn-cloud.github.io/helm-cluster-api
chart: cluster-api
targetRevision: v0.2.0
targetRevision: v0.2.1
destination:
server: https://kubernetes.default.svc
namespace: cluster-api
Expand Down Expand Up @@ -89,7 +89,7 @@ You may want to be a little less gung-ho and deploy the pieces as separate appli
```shell
helm repo add unikorn-cloud-capi https://unikorn-cloud.github.io/helm-cluster-api
helm repo update
helm upgrade --install cluster-api-core unikorn-cloud-capi/cluster-api-core -n cluster-api --create-namespace --version v0.2.0
helm upgrade --install cluster-api-core unikorn-cloud-capi/cluster-api-core -n cluster-api --create-namespace --version v0.2.1
```
</details>

Expand All @@ -108,7 +108,7 @@ spec:
source:
repoURL: https://unikorn-cloud.github.io/helm-cluster-api
chart: cluster-api-core
targetRevision: v0.2.0
targetRevision: v0.2.1
destination:
server: https://kubernetes.default.svc
namespace: cluster-api
Expand Down Expand Up @@ -141,7 +141,7 @@ spec:
```shell
helm repo add unikorn-cloud-capi https://unikorn-cloud.github.io/helm-cluster-api
helm repo update
helm upgrade --install cluster-api-bootstrap-kubeadm unikorn-cloud-capi/cluster-api-bootstrap-kubeadm -n cluster-api --create-namespace --version v0.2.0
helm upgrade --install cluster-api-bootstrap-kubeadm unikorn-cloud-capi/cluster-api-bootstrap-kubeadm -n cluster-api --create-namespace --version v0.2.1
```
</details>

Expand All @@ -160,7 +160,7 @@ spec:
source:
repoURL: https://unikorn-cloud.github.io/helm-cluster-api
chart: cluster-api-bootstrap-kubeadm
targetRevision: v0.2.0
targetRevision: v0.2.1
destination:
server: https://kubernetes.default.svc
namespace: cluster-api
Expand All @@ -186,7 +186,7 @@ spec:
```shell
helm repo add unikorn-cloud-capi https://unikorn-cloud.github.io/helm-cluster-api
helm repo update
helm upgrade --install cluster-api-control-plane-kubeadm unikorn-cloud-capi/cluster-api-control-plane-kubeadm -n cluster-api --create-namespace --version v0.2.0
helm upgrade --install cluster-api-control-plane-kubeadm unikorn-cloud-capi/cluster-api-control-plane-kubeadm -n cluster-api --create-namespace --version v0.2.1
```
</details>

Expand All @@ -205,7 +205,7 @@ spec:
source:
repoURL: https://unikorn-cloud.github.io/helm-cluster-api
chart: cluster-api-control-plane-kubeadm
targetRevision: v0.2.0
targetRevision: v0.2.1
destination:
server: https://kubernetes.default.svc
namespace: cluster-api
Expand Down
4 changes: 2 additions & 2 deletions README.provider-openstack.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
```shell
helm repo add unikorn-cloud-capi https://unikorn-cloud.github.io/helm-cluster-api
helm repo update
helm upgrade --install cluster-api-provider-openstack unikorn-cloud-capi/cluster-api-provider-openstack -n cluster-api --create-namespace --version v0.2.0
helm upgrade --install cluster-api-provider-openstack unikorn-cloud-capi/cluster-api-provider-openstack -n cluster-api --create-namespace --version v0.2.1
```
</details>

Expand All @@ -28,7 +28,7 @@ spec:
source:
repoURL: https://unikorn-cloud.github.io/helm-cluster-api
chart: cluster-api-provider-openstack
targetRevision: v0.2.0
targetRevision: v0.2.1
destination:
server: https://kubernetes.default.svc
namespace: cluster-api
Expand Down
2 changes: 1 addition & 1 deletion charts/cluster-api-bootstrap-kubeadm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ description: A Helm chart for deploying cluster API.
icon: https://assets.unikorn-cloud.org/assets/images/logos/dark-on-light/icon.png
name: cluster-api-bootstrap-kubeadm
type: application
version: v0.2.0
version: v0.2.1
2 changes: 1 addition & 1 deletion charts/cluster-api-cluster-openstack/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: cluster-api-cluster-openstack
description: A Helm chart to deploy a Kubernetes Cluster
type: application
version: v0.4.3
version: v0.4.4
icon: https://raw.githubusercontent.com/unikorn-cloud/helm-cluster-api/main/icons/default.png
2 changes: 1 addition & 1 deletion charts/cluster-api-cluster-openstack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
source:
repoURL: https://unikorn-cloud.github.io/helm-cluster-api
chart: cluster-api-cluster-openstack
targetRevision: v0.4.3
targetRevision: v0.4.4
helm:
releaseName: foo
# Remove the default work queue.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ spec:
node-labels: {{- include "openstack.nodelabels.control-plane" . | nindent 12 }}
taints:
{{- include "openstack.taints.control-plane" . | nindent 8 }}
{{- if .Values.controlPlane.kubeadmSkipPhases }}
skipPhases:
{{- toYaml $.Values.controlPlane.kubeadmSkipPhases | nindent 6 }}
{{- end }}
joinConfiguration:
nodeRegistration:
name: {{ "'{{ local_hostname }}'" }}
Expand Down
6 changes: 6 additions & 0 deletions charts/cluster-api-cluster-openstack/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@
},
"machine": {
"$ref": "#/$defs/machine"
},
"kubeadmSkipPhases": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
Expand Down
22 changes: 16 additions & 6 deletions charts/cluster-api-cluster-openstack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,29 @@ openstack:
# Modifications to this object will trigger a control plane upgrade.
controlPlane:
# Version of Kubernetes, should match that installed on the base images.
version: v1.25.2
version: v1.30.2

# Number of control plane machines.
replicas: 3

# kubeadm uses phases to init a node.
# https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-init-phase
# Any phase can be skipped by adding --skip-phase NAME to the kubeadm init command.
# To skip kubeadm phases in Unikorn, you can supply a list below
# WARNING: Skipping phases may cause cluster instability so make sure you know what you're skipping before enabling this!
# List of Phases: https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-init/
kubeadmSkipPhases: []
# - addon/kube-proxy
# - addon/coredns

# Defines the physical properties of a machine.
# Modifications to this object will trigger a control plane upgrade.
machine:
# Openstack image name.
imageID: f810a963-437d-4a24-a972-a0bff942542b

# Control plane machine type.
flavorID: 6ac45c49-3e3b-4cdf-acbc-d98a321a92c0
# Control plane machine type (This is the name of the flavor rather than the actual ID).
flavorID: some-flavor-name

# Ephemeral disk size in GiB. If specified this overrides the default
# size for the flavor.
Expand All @@ -100,7 +110,7 @@ controlPlane:
# default:
# # Version of Kubernetes, should match that installed on the base images
# # in order to improve provisioning and scaling time.
# version: v1.25.2
# version: v1.30.2
#
# # Number of workload machines.
# replicas: 3
Expand All @@ -111,8 +121,8 @@ controlPlane:
# # Openstack image name.
# imageID: f810a963-437d-4a24-a972-a0bff942542b
#
# # Workload machine type.
# flavorID: 6ac45c49-3e3b-4cdf-acbc-d98a321a92c0
# # Workload machine type (This is the name of the flavor rather than the actual ID).
# flavorID: some-flavor-name
#
# # Ephemeral disk size in GiB. If specified this overrides the default
# # size for the flavor.
Expand Down
2 changes: 1 addition & 1 deletion charts/cluster-api-control-plane-kubeadm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ description: A Helm chart for deploying cluster API.
icon: https://assets.unikorn-cloud.org/assets/images/logos/dark-on-light/icon.png
name: cluster-api-control-plane-kubeadm
type: application
version: v0.2.0
version: v0.2.1
2 changes: 1 addition & 1 deletion charts/cluster-api-core/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ description: A Helm chart for deploying cluster API.
icon: https://assets.unikorn-cloud.org/assets/images/logos/dark-on-light/icon.png
name: cluster-api-core
type: application
version: v0.2.0
version: v0.2.1
2 changes: 1 addition & 1 deletion charts/cluster-api-provider-openstack/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ description: A Helm chart for deploying cluster API.
icon: https://assets.unikorn-cloud.org/assets/images/logos/dark-on-light/icon.png
name: cluster-api-provider-openstack
type: application
version: v0.2.0
version: v0.2.1
12 changes: 6 additions & 6 deletions charts/cluster-api/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
apiVersion: v2
appVersion: v1.6.2
appVersion: v1.7.4
name: cluster-api
description: A Helm chart to deploy Cluster API
type: application
version: v0.2.0
version: v0.2.1
icon: https://assets.unikorn-cloud.org/assets/images/logos/dark-on-light/icon.png

dependencies:
- name: cluster-api-core
version: v0.2.0
version: v0.2.1
repository: file://../cluster-api-core
- name: cluster-api-bootstrap-kubeadm
version: v0.2.0
version: v0.2.1
repository: file://../cluster-api-bootstrap-kubeadm
condition: kubeadm.enabled
- name: cluster-api-control-plane-kubeadm
version: v0.2.0
version: v0.2.1
repository: file://../cluster-api-control-plane-kubeadm
condition: kubeadm.enabled
- name: cluster-api-provider-openstack
version: v0.2.0
version: v0.2.1
repository: file://../cluster-api-provider-openstack
condition: openstack.enabled
31 changes: 30 additions & 1 deletion generate-capi.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
#!/usr/bin/env python3

import argparse
import re
import sys

def main():
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--version', help="Chart version")
parser.add_argument('-c', '--capi-version', help='Cluster API version')
parser.add_argument('subcharts', nargs='+', help="Subcharts to include")

args = parser.parse_args()

chunks = []

with open('charts/cluster-api/values.yaml.tmpl') as file:
chunks.append(file.read())

for chart in sys.argv[1:]:
for chart in args.subcharts:
chunk = [f"{chart}:\n"]

with open(f'charts/{chart}/values.yaml') as file:
Expand All @@ -19,5 +28,25 @@ def main():
with open('charts/cluster-api/values.yaml', 'w') as file:
file.write('\n'.join(chunks))

with open(f'charts/cluster-api/Chart.yaml', 'w') as file:
file.write("apiVersion: v2\n")
file.write(f"appVersion: {args.capi_version}\n")
file.write("name: cluster-api\n")
file.write("description: A Helm chart to deploy Cluster API\n")
file.write("type: application\n")
file.write(f"version: {args.version}\n")
file.write("icon: https://assets.unikorn-cloud.org/assets/images/logos/dark-on-light/icon.png\n")
file.write("\n")
file.write("dependencies:\n")

for chart in args.subcharts:
file.write(f"- name: {chart}\n")
file.write(f" version: {args.version}\n")
file.write(f" repository: file://../{chart}\n")
# Oh for want of a better way of doing this...
matches = re.match(r'^cluster-api-(?:bootstrap|control-plane|provider)-(.*)', chart)
if matches:
file.write(f" condition: {matches[1]}.enabled\n")

if __name__ == '__main__':
main()

0 comments on commit ec49678

Please sign in to comment.