-
Notifications
You must be signed in to change notification settings - Fork 16
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
✨ Install CAPI using operator after chart is installed #109
Changes from all commits
692aefa
32f8885
d53167b
dd1f53e
952bb8f
a50bfec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{{- if index .Values "cluster-api-operator" "cluster-api" "enabled" }} | ||
--- | ||
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" "core" "namespace" }} | ||
--- | ||
apiVersion: operator.cluster.x-k8s.io/v1alpha1 | ||
kind: CoreProvider | ||
metadata: | ||
name: cluster-api | ||
namespace: {{ index .Values "cluster-api-operator" "cluster-api" "core" "namespace" }} | ||
annotations: | ||
"helm.sh/hook": "post-install, post-upgrade" | ||
"helm.sh/hook-weight": "2" | ||
spec: | ||
version: {{ index .Values "cluster-api-operator" "cluster-api" "version" }} | ||
additionalManifests: | ||
name: capi-additional-rbac-roles | ||
namespace: {{ index .Values "cluster-api-operator" "cluster-api" "core" "namespace" }} | ||
{{- if index .Values "cluster-api-operator" "cluster-api" "configSecret" "name" }} | ||
secretName: {{ index .Values "cluster-api-operator" "cluster-api" "configSecret" "name" }} | ||
{{- if index .Values "cluster-api-operator" "cluster-api" "configSecret" "namespace" }} | ||
secretNamespace: {{ index .Values "cluster-api-operator" "cluster-api" "configSecret" "namespace" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if or (index .Values "cluster-api-operator" "cluster-api" "core" "fetchConfig" "url") (index .Values "cluster-api-operator" "cluster-api" "core" "fetchConfig" "selector") }} | ||
fetchConfig: | ||
{{- if index .Values "cluster-api-operator" "cluster-api" "core" "fetchConfig" "url" }} | ||
url: {{ index .Values "cluster-api-operator" "cluster-api" "core" "fetchConfig" "url" }} | ||
{{- end }} | ||
{{- if index .Values "cluster-api-operator" "cluster-api" "core" "fetchConfig" "selector" }} | ||
selector: {{ index .Values "cluster-api-operator" "cluster-api" "core" "fetchConfig" "selector" }} | ||
{{- end }} | ||
{{- end }} | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: capi-additional-rbac-roles | ||
namespace: {{ index .Values "cluster-api-operator" "cluster-api" "core" "namespace" }} | ||
annotations: | ||
"helm.sh/hook": "post-install, post-upgrade" | ||
"helm.sh/hook-weight": "2" | ||
data: | ||
manifests: |- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: provisioning-rke-cattle-io | ||
labels: | ||
cluster.x-k8s.io/aggregate-to-manager: "true" | ||
rules: | ||
- apiGroups: ["rke.cattle.io"] | ||
resources: ["*"] | ||
verbs: ["*"] | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: provisioning-rke-machine-cattle-io | ||
labels: | ||
cluster.x-k8s.io/aggregate-to-manager: "true" | ||
rules: | ||
- apiGroups: ["rke-machine.cattle.io"] | ||
resources: ["*"] | ||
verbs: ["*"] | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{{- if index .Values "cluster-api-operator" "cluster-api" "enabled" }} | ||
--- | ||
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" "kubeadmBootstrap" "namespace" }} | ||
--- | ||
apiVersion: operator.cluster.x-k8s.io/v1alpha1 | ||
kind: BootstrapProvider | ||
metadata: | ||
name: kubeadm | ||
namespace: {{ index .Values "cluster-api-operator" "cluster-api" "kubeadmBootstrap" "namespace" }} | ||
annotations: | ||
"helm.sh/hook": "post-install, post-upgrade" | ||
"helm.sh/hook-weight": "2" | ||
spec: | ||
version: {{ index .Values "cluster-api-operator" "cluster-api" "version" }} | ||
{{- if index .Values "cluster-api-operator" "cluster-api" "configSecret" "name" }} | ||
secretName: {{ index .Values "cluster-api-operator" "cluster-api" "configSecret" "name" }} | ||
{{- if index .Values "cluster-api-operator" "cluster-api" "configSecret" "namespace" }} | ||
secretNamespace: {{ index .Values "cluster-api-operator" "cluster-api" "configSecret" "namespace" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if or (index .Values "cluster-api-operator" "cluster-api" "kubeadmBootstrap" "fetchConfig" "url") (index .Values "cluster-api-operator" "cluster-api" "kubeadmBootstrap" "fetchConfig" "selector") }} | ||
fetchConfig: | ||
{{- if index .Values "cluster-api-operator" "cluster-api" "kubeadmBootstrap" "fetchConfig" "url" }} | ||
url: {{ index .Values "cluster-api-operator" "cluster-api" "kubeadmBootstrap" "fetchConfig" "url" }} | ||
{{- end }} | ||
{{- if index .Values "cluster-api-operator" "cluster-api" "kubeadmBootstrap" "fetchConfig" "selector" }} | ||
selector: {{ index .Values "cluster-api-operator" "cluster-api" "kubeadmBootstrap" "fetchConfig" "selector" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{{- if index .Values "cluster-api-operator" "cluster-api" "enabled" }} | ||
--- | ||
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" "kubeadmControlPlane" "namespace" }} | ||
--- | ||
apiVersion: operator.cluster.x-k8s.io/v1alpha1 | ||
kind: ControlPlaneProvider | ||
metadata: | ||
name: kubeadm | ||
namespace: {{ index .Values "cluster-api-operator" "cluster-api" "kubeadmControlPlane" "namespace" }} | ||
annotations: | ||
"helm.sh/hook": "post-install, post-upgrade" | ||
"helm.sh/hook-weight": "2" | ||
spec: | ||
version: {{ index .Values "cluster-api-operator" "cluster-api" "version" }} | ||
{{- if index .Values "cluster-api-operator" "cluster-api" "configSecret" "name" }} | ||
secretName: {{ index .Values "cluster-api-operator" "cluster-api" "configSecret" "name" }} | ||
{{- if index .Values "cluster-api-operator" "cluster-api" "configSecret" "namespace" }} | ||
secretNamespace: {{ index .Values "cluster-api-operator" "cluster-api" "configSecret" "namespace" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if or (index .Values "cluster-api-operator" "cluster-api" "kubeadmControlPlane" "fetchConfig" "url") (index .Values "cluster-api-operator" "cluster-api" "kubeadmControlPlane" "fetchConfig" "selector") }} | ||
fetchConfig: | ||
{{- if index .Values "cluster-api-operator" "cluster-api" "kubeadmControlPlane" "fetchConfig" "url" }} | ||
url: {{ index .Values "cluster-api-operator" "cluster-api" "kubeadmControlPlane" "fetchConfig" "url" }} | ||
{{- end }} | ||
{{- if index .Values "cluster-api-operator" "cluster-api" "kubeadmControlPlane" "fetchConfig" "selector" }} | ||
selector: {{ index .Values "cluster-api-operator" "cluster-api" "kubeadmControlPlane" "fetchConfig" "selector" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -246,8 +246,8 @@ func initBootstrapCluster(bootstrapClusterProxy framework.ClusterProxy, config * | |
} | ||
|
||
func initRancherTurtles(clusterProxy framework.ClusterProxy, config *clusterctl.E2EConfig) { | ||
By("Adding docker variables secret") | ||
Expect(clusterProxy.Apply(ctx, dockerVariablesSecret)).To(Succeed()) | ||
By("Adding CAPI variables secret") | ||
Expect(clusterProxy.Apply(ctx, capiProvidersSecret)).To(Succeed()) | ||
|
||
By("Installing rancher-turtles chart") | ||
chart := &HelmChart{ | ||
|
@@ -258,12 +258,50 @@ func initRancherTurtles(clusterProxy framework.ClusterProxy, config *clusterctl. | |
AdditionalFlags: Flags("-n", rancherTurtlesNamespace, "--create-namespace", "--wait"), | ||
} | ||
_, err := chart.Run(map[string]string{ | ||
"cluster-api-operator.cert-manager.enabled": "true", | ||
"cluster-api-operator.infrastructure": config.GetVariable(capiInfrastructure), | ||
"cluster-api-operator.secretName": "variables", | ||
"cluster-api-operator.secretNamespace": "default", | ||
"cluster-api-operator.cluster-api.configSecret.namespace": "default", | ||
"cluster-api-operator.cluster-api.configSecret.name": "variables", | ||
}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO this test case should be added in the CAPI operator repository (nit) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you elaborate? what exactly has to be tested in CAPI operator? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this supposed to be installed together with operator by the users? Why testing kubeadm provider here when it could be tested in the CAPI operator repository? Additionally with helm uninstall issue, this blocks other operations within e2e tests, it surely missing manual uninstall part in this specific test case. It is not scalable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add a manual uninstall until this is fixed in operator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so after some thinking, I don't believe we have to uninstall manually providers in e2e, we tear down the entire management cluster and if we need to debug the test run and skip cleanup it's better to leave the providers running, wdyt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This implementation fixes uninstall process in capi operator - kubernetes-sigs/cluster-api-operator#251 so no need to do some unnessesary cluster teardowns, we just need to merge it. Creating and tearing down management clusters is costly, not scalable and will prolong the e2e test execution. |
||
By("Adding CAPI infrastructure providers") | ||
Expect(clusterProxy.Apply(ctx, capiProviders)).To(Succeed()) | ||
|
||
By("Waiting for CAPI deployment to be available") | ||
framework.WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{ | ||
Getter: bootstrapClusterProxy.GetClient(), | ||
Deployment: &appsv1.Deployment{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "capi-controller-manager", | ||
Namespace: "capi-system", | ||
}}, | ||
}, config.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...) | ||
|
||
By("Waiting for CAPI kubeadm bootstrap deployment to be available") | ||
framework.WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{ | ||
Getter: bootstrapClusterProxy.GetClient(), | ||
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{ | ||
Name: "capi-kubeadm-bootstrap-controller-manager", | ||
Namespace: "capi-kubeadm-bootstrap-system", | ||
}}, | ||
}, config.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...) | ||
|
||
By("Waiting for CAPI kubeadm control plane deployment to be available") | ||
framework.WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{ | ||
Getter: bootstrapClusterProxy.GetClient(), | ||
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{ | ||
Name: "capi-kubeadm-control-plane-controller-manager", | ||
Namespace: "capi-kubeadm-control-plane-system", | ||
}}, | ||
}, config.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...) | ||
|
||
By("Waiting for CAPI docker provider deployment to be available") | ||
framework.WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{ | ||
Getter: bootstrapClusterProxy.GetClient(), | ||
Deployment: &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{ | ||
Name: "capd-controller-manager", | ||
Namespace: "capd-system", | ||
}}, | ||
}, config.GetIntervals(bootstrapClusterProxy.GetName(), "wait-controllers")...) | ||
} | ||
|
||
func initRancher(clusterProxy framework.ClusterProxy, config *clusterctl.E2EConfig) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: capd-system | ||
--- | ||
apiVersion: operator.cluster.x-k8s.io/v1alpha1 | ||
kind: InfrastructureProvider | ||
metadata: | ||
name: docker | ||
namespace: capd-system | ||
spec: | ||
secretName: variables | ||
secretNamespace: default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you can, using infrastructure flag passed to helm values, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, in this case, CAPI operator chart will deploy the core CAPI provider too. We tried to follow the same pattern as clusterctl here, our deployment model is a bit more complicated. What can help here is a clusterctl plugin for operator or alternatively rancher users will get a UI for providers