Skip to content

Commit

Permalink
Merge pull request #437 from alexander-demicev/enablerke2
Browse files Browse the repository at this point in the history
Install RKE2 by default
  • Loading branch information
richardcase authored Apr 4, 2024
2 parents 324418e + bc7de99 commit b2845d6
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 3 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/test_chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.12.1
version: v3.14.3

- uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -82,8 +82,14 @@ jobs:
- name: Wait for core provider rollout
run: sleep 30 && kubectl rollout status deployment capi-controller-manager -n capi-system --timeout=180s

- name: Wait for RKE2 bootstrap provider rollout
run: sleep 30 && kubectl rollout status deployment rke2-bootstrap-controller-manager -n rke2-bootstrap-system --timeout=180s

- name: Wait for RKE2 control plane provider rollout
run: sleep 30 && kubectl rollout status deployment rke2-control-plane-controller-manager -n rke2-control-plane-system --timeout=180s

- name: Run chart-testing (un-install)
run: helm uninstall rancher-turtles -n rancher-turtles-system --cascade foreground --wait --debug
run: helm uninstall rancher-turtles -n rancher-turtles-system --cascade foreground --wait --debug --timeout=10m

- name: Run chart re-install
run: helm install rancher-turtles out/charts/rancher-turtles/ -n rancher-turtles-system --create-namespace --wait --debug
5 changes: 5 additions & 0 deletions charts/rancher-turtles/questions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ questions:
type: boolean
label: Use management v3 cluster manifest
group: "Rancher Turtles Features Settings"
- variable: cluster-api-operator.cluster-api.rke2.enabled
default: "true"
description: "Flag to enable or disable installation of the RKE2 provider for Cluster API. By default this is enabled."
label: "Enable RKE2 Provider"
type: boolean
24 changes: 23 additions & 1 deletion charts/rancher-turtles/templates/post-delete-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ spec:
- capi-mutating-webhook-configuration
- capi-kubeadm-bootstrap-mutating-webhook-configuration
- capi-kubeadm-control-plane-mutating-webhook-configuration
- rke2-bootstrap-mutating-webhook-configuration
- rke2-control-plane-mutating-webhook-configuration
- --ignore-not-found=true
restartPolicy: Never
---
Expand Down Expand Up @@ -98,6 +100,8 @@ spec:
- capi-validating-webhook-configuration
- capi-kubeadm-bootstrap-validating-webhook-configuration
- capi-kubeadm-control-plane-validating-webhook-configuration
- rke2-bootstrap-validating-webhook-configuration
- rke2-control-plane-validating-webhook-configuration
- --ignore-not-found=true
restartPolicy: Never
---
Expand All @@ -124,7 +128,7 @@ spec:
- delete
- deployments.apps/capi-controller-manager
- -n
- capi-system
- {{ index .Values "cluster-api-operator" "cluster-api" "core" "namespace" }}
- --ignore-not-found=true
- name: delete-capi-kubeadm-bootstrap-controller-manager
image: {{ index .Values "rancherTurtles" "features" "cluster-api-operator" "kubectlImage" }}
Expand All @@ -144,4 +148,22 @@ spec:
- -n
- capi-kubeadm-control-plane-system
- --ignore-not-found=true
- name: delete-rke2-kubeadm-bootstrap-controller-manager
image: {{ index .Values "rancherTurtles" "features" "cluster-api-operator" "kubectlImage" }}
command: ["kubectl"]
args:
- delete
- deployments.apps/rke2-bootstrap-controller-manager
- -n
- {{ index .Values "cluster-api-operator" "cluster-api" "rke2" "bootstrap" "namespace" }}
- --ignore-not-found=true
- name: delete-rke2-control-plane-controller-manager
image: {{ index .Values "rancherTurtles" "features" "cluster-api-operator" "kubectlImage" }}
command: ["kubectl"]
args:
- delete
- deployments.apps/rke2-control-plane-controller-manager
- -n
- {{ index .Values "cluster-api-operator" "cluster-api" "rke2" "controlPlane" "namespace" }}
- --ignore-not-found=true
{{- end }}
43 changes: 43 additions & 0 deletions charts/rancher-turtles/templates/rke2-bootstrap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if and (index .Values "cluster-api-operator" "cluster-api" "enabled") (index .Values "cluster-api-operator" "cluster-api" "rke2" "enabled") }}
{{- $namespace := index .Values "cluster-api-operator" "cluster-api" "rke2" "bootstrap" "namespace" }}
{{- if not (lookup "v1" "Namespace" "" $namespace) }}
---
apiVersion: v1
kind: Namespace
metadata:
annotations:
"helm.sh/hook": "post-install, post-upgrade"
"helm.sh/hook-weight": "1"
name: {{ index .Values "cluster-api-operator" "cluster-api" "rke2" "bootstrap" "namespace" }}
{{- end }}
---
apiVersion: turtles-capi.cattle.io/v1alpha1
kind: CAPIProvider
metadata:
name: rke2-bootstrap
namespace: {{ index .Values "cluster-api-operator" "cluster-api" "rke2" "bootstrap" "namespace" }}
annotations:
"helm.sh/hook": "post-install, post-upgrade, pre-delete"
"helm.sh/hook-weight": "2"
spec:
name: rke2
type: bootstrap
{{- if index .Values "cluster-api-operator" "cluster-api" "rke2" "version" }}
version: {{ index .Values "cluster-api-operator" "cluster-api" "rke2" "version" }}
{{- end }}
configSecret:
{{- if index .Values "cluster-api-operator" "cluster-api" "configSecret" "name" }}
name: {{ index .Values "cluster-api-operator" "cluster-api" "configSecret" "name" }}
{{ else }}
name: {{ index .Values "cluster-api-operator" "cluster-api" "configSecret" "defaultName" }}
{{- end }}
{{- if or (index .Values "cluster-api-operator" "cluster-api" "rke2" "bootstrap" "fetchConfig" "url") (index .Values "cluster-api-operator" "cluster-api" "rke2" "bootstrap" "fetchConfig" "selector") }}
fetchConfig:
{{- if index .Values "cluster-api-operator" "cluster-api" "rke2" "bootstrap" "fetchConfig" "url" }}
url: {{ index .Values "cluster-api-operator" "cluster-api" "rke2" "bootstrap" "fetchConfig" "url" }}
{{- end }}
{{- if index .Values "cluster-api-operator" "cluster-api" "rke2" "bootstrap" "fetchConfig" "selector" }}
selector: {{ index .Values "cluster-api-operator" "cluster-api" "rke2" "bootstrap" "fetchConfig" "selector" }}
{{- end }}
{{- end }}
{{- end }}
43 changes: 43 additions & 0 deletions charts/rancher-turtles/templates/rke2-controlplane.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if and (index .Values "cluster-api-operator" "cluster-api" "enabled") (index .Values "cluster-api-operator" "cluster-api" "rke2" "enabled") }}
{{- $namespace := index .Values "cluster-api-operator" "cluster-api" "rke2" "controlPlane" "namespace" }}
{{- if not (lookup "v1" "Namespace" "" $namespace) }}
---
apiVersion: v1
kind: Namespace
metadata:
annotations:
"helm.sh/hook": "post-install, post-upgrade"
"helm.sh/hook-weight": "1"
name: {{ index .Values "cluster-api-operator" "cluster-api" "rke2" "controlPlane" "namespace" }}
{{- end }}
---
apiVersion: turtles-capi.cattle.io/v1alpha1
kind: CAPIProvider
metadata:
name: rke2-control-plane
namespace: {{ index .Values "cluster-api-operator" "cluster-api" "rke2" "controlPlane" "namespace" }}
annotations:
"helm.sh/hook": "post-install, post-upgrade, pre-delete"
"helm.sh/hook-weight": "2"
spec:
name: rke2
type: controlPlane
{{- if index .Values "cluster-api-operator" "cluster-api" "rke2" "version" }}
version: {{ index .Values "cluster-api-operator" "cluster-api" "rke2" "version" }}
{{- end }}
configSecret:
{{- if index .Values "cluster-api-operator" "cluster-api" "configSecret" "name" }}
name: {{ index .Values "cluster-api-operator" "cluster-api" "configSecret" "name" }}
{{ else }}
name: {{ index .Values "cluster-api-operator" "cluster-api" "configSecret" "defaultName" }}
{{- end }}
{{- if or (index .Values "cluster-api-operator" "cluster-api" "rke2" "controlPlane" "fetchConfig" "url") (index .Values "cluster-api-operator" "cluster-api" "rke2" "controlPlane" "fetchConfig" "selector") }}
fetchConfig:
{{- if index .Values "cluster-api-operator" "cluster-api" "rke2" "controlPlane" "fetchConfig" "url" }}
url: {{ index .Values "cluster-api-operator" "cluster-api" "rke2" "controlPlane" "fetchConfig" "url" }}
{{- end }}
{{- if index .Values "cluster-api-operator" "cluster-api" "rke2" "controlPlane" "fetchConfig" "selector" }}
selector: {{ index .Values "cluster-api-operator" "cluster-api" "rke2" "controlPlane" "fetchConfig" "selector" }}
{{- end }}
{{- end }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/rancher-turtles/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,16 @@ cluster-api-operator:
fetchConfig:
url: ""
selector: ""
rke2:
enabled: true
version: ""
bootstrap:
namespace: rke2-bootstrap-system
fetchConfig:
url: ""
selector: ""
controlPlane:
namespace: rke2-control-plane-system
fetchConfig:
url: ""
selector: ""
18 changes: 18 additions & 0 deletions test/testenv/turtles.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,22 @@ func DeployRancherTurtles(ctx context.Context, input DeployRancherTurtlesInput)
Namespace: "capd-system",
}},
}, input.WaitDeploymentsReadyInterval...)

By("Waiting for CAPI RKE2 bootstrap deployment to be available")
framework.WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{
Name: "rke2-bootstrap-controller-manager",
Namespace: "rke2-bootstrap-system",
}},
}, input.WaitDeploymentsReadyInterval...)

By("Waiting for CAPI RKE2 control plane deployment to be available")
framework.WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{
Name: "rke2-control-plane-controller-manager",
Namespace: "rke2-control-plane-system",
}},
}, input.WaitDeploymentsReadyInterval...)
}

0 comments on commit b2845d6

Please sign in to comment.