Skip to content

Commit 3436702

Browse files
Add operator manifests to turtles API
Signed-off-by: Danil-Grigorev <[email protected]>
1 parent fe0e040 commit 3436702

21 files changed

+43784
-5
lines changed

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,9 @@ manifests: generate
235235

236236
.PHONY: generate-manifests-external
237237
generate-manifests-external: vendor controller-gen ## Generate ClusterRole and CustomResourceDefinition objects.
238-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd paths="./api/rancher/..." output:crd:artifacts:config=hack/crd/bases
239-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd paths="./vendor/sigs.k8s.io/cluster-api/..." output:crd:artifacts:config=hack/crd/bases
238+
$(CONTROLLER_GEN) crd paths="./api/rancher/..." output:crd:artifacts:config=hack/crd/bases
239+
$(CONTROLLER_GEN) crd paths="./vendor/sigs.k8s.io/cluster-api/..." output:crd:artifacts:config=hack/crd/bases
240+
$(CONTROLLER_GEN) crd paths="./vendor/sigs.k8s.io/cluster-api-operator/..." output:crd:artifacts:config=./config/operator/bases
240241
# Vendor is only required for pulling latest CRDs from the dependencies
241242
$(MAKE) vendor-clean
242243

@@ -555,6 +556,11 @@ release: clean-release $(RELEASE_DIR) ## Builds and push container images using
555556
.PHONY: build-chart
556557
build-chart: $(HELM) $(KUSTOMIZE) $(RELEASE_DIR) $(CHART_RELEASE_DIR) $(CHART_PACKAGE_DIR) ## Builds the chart to publish with a release
557558
$(KUSTOMIZE) build ./config/chart > $(CHART_DIR)/templates/rancher-turtles-components.yaml
559+
@{ \
560+
echo '{{- if index .Values "rancher-turtles" "embedded-operator" "enabled"}}'; \
561+
$(KUSTOMIZE) build ./config/operatorchart; \
562+
echo '{{- end }}'; \
563+
} > $(CHART_DIR)/templates/operator-crds.yaml
558564
$(KUSTOMIZE) build ./exp/day2/config/chart > $(CHART_DIR)/templates/rancher-turtles-exp-day2-components.yaml
559565
$(KUSTOMIZE) build ./exp/clusterclass/config/default > $(CHART_DIR)/templates/rancher-turtles-exp-clusterclass-components.yaml
560566
./scripts/process-manifests.sh day2operations $(CHART_DIR)/templates/rancher-turtles-exp-day2-components.yaml

api/v1alpha1/capiprovider_wrapper.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package v1alpha1
1818

1919
import (
2020
"cmp"
21+
"strings"
2122

2223
operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha2"
2324
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
@@ -57,7 +58,7 @@ func (b *CAPIProvider) SetStatus(in operatorv1.ProviderStatus) {
5758

5859
// GetType returns the type of the CAPIProvider.
5960
func (b *CAPIProvider) GetType() string {
60-
return "capiprovider"
61+
return strings.ToLower(string(b.Spec.Type))
6162
}
6263

6364
// GetItems returns the list of GenericProviders for CAPIProviderList.

api/v1alpha1/groupversion_info.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ var (
4848
&operatorv1.IPAMProvider{},
4949
}
5050

51+
// ProvidersMap is a map of registered CAPI Operator resources satisfying Provider interface.
52+
ProvidersMap = map[string]operatorv1.GenericProvider{}
53+
5154
// ProviderLists is a list of registered CAPI Operator resources satisfying ProviderList interface.
5255
ProviderLists = []operatorv1.GenericProviderList{
5356
&operatorv1.CoreProviderList{},
@@ -59,6 +62,12 @@ var (
5962
}
6063
)
6164

65+
func init() {
66+
for _, provider := range Providers {
67+
ProvidersMap[provider.GetType()] = provider
68+
}
69+
}
70+
6271
// AddKnownTypes adds the list of known types to api.Scheme.
6372
func AddKnownTypes(scheme *runtime.Scheme) {
6473
scheme.AddKnownTypes(GroupVersion, &CAPIProvider{}, &CAPIProviderList{})

api/v1alpha1/provider_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,6 @@ const (
6262
// Failed status defines a failed state of provider provisioning.
6363
Failed Phase = "Failed"
6464
)
65+
66+
// ProviderNameAnnotation is the annotation key for the provider name.
67+
const ProviderNameAnnotation = "turtles.cattle.io/provider-name"

charts/rancher-turtles/templates/deployment.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,16 @@ spec:
7171
requests:
7272
cpu: 10m
7373
memory: 128Mi
74+
{{- with .Values.rancherTurtles.volumeMounts.manager }}
75+
volumeMounts:
76+
{{- toYaml . | nindent 12 }}
77+
{{- end }}
7478
serviceAccountName: rancher-turtles-manager
7579
terminationGracePeriodSeconds: 10
80+
{{- with .Values.rancherTurtles.volumes }}
81+
volumes:
82+
{{- toYaml . | nindent 8 }}
83+
{{- end }}
7684
tolerations:
7785
- effect: NoSchedule
7886
key: node-role.kubernetes.io/master

charts/rancher-turtles/templates/operator-crds.yaml

Lines changed: 21813 additions & 0 deletions
Large diffs are not rendered by default.

charts/rancher-turtles/values.schema.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,17 @@
128128
}
129129
}
130130
},
131+
"embedded-operator": {
132+
"type": "object",
133+
"description": "Enable embedded operator controller loops.",
134+
"properties": {
135+
"enabled": {
136+
"type": "boolean",
137+
"default": false,
138+
"description": "Turn on or off."
139+
}
140+
}
141+
},
131142
"clusterclass-operations": {
132143
"type": "object",
133144
"description": "Alpha feature. Not ready for testing yet.",
@@ -155,6 +166,53 @@
155166
}
156167
}
157168
}
169+
},
170+
"volumes": {
171+
"type": "array",
172+
"description": "Volumes for controller pods.",
173+
"items": {
174+
"type": "object",
175+
"required": [
176+
"name",
177+
"configMap"
178+
],
179+
"properties": {
180+
"name": {
181+
"type": "string"
182+
},
183+
"configMap": {
184+
"type": "object",
185+
"properties": {
186+
"name": {
187+
"type": "string",
188+
"default": "clusterctl-config",
189+
"description": "ConfigMap for clusterctl."
190+
}
191+
}
192+
}
193+
}
194+
}
195+
},
196+
"volumeMounts": {
197+
"type": "object",
198+
"properties": {
199+
"manager": {
200+
"type": "array",
201+
"description": "Mount volumes to pods.",
202+
"items": {
203+
"type": "object",
204+
"properties": {
205+
"mountPath": { "type": "string" },
206+
"name": { "type": "string" },
207+
"readOnly": {
208+
"type": "boolean",
209+
"default": true,
210+
"description": "Mount as read-only."
211+
}
212+
}
213+
}
214+
}
215+
}
158216
}
159217
}
160218
},

charts/rancher-turtles/values.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ rancherTurtles:
2525
kubectlImage: registry.k8s.io/kubernetes/kubectl:v1.30.0
2626
# features: Optional and experimental features.
2727
features:
28+
# embedded-operator: Embed operator controller loops.
29+
embedded-operator:
30+
# enabled: Turn on or off.
31+
enabled: false
2832
# day2operations: Alpha feature.
2933
day2operations:
3034
# enabled: Turn on or off.
@@ -53,6 +57,16 @@ rancherTurtles:
5357
imageVersion: v0.0.0
5458
# imagePullPolicy: Pull policy.
5559
imagePullPolicy: IfNotPresent
60+
# volumes: Volumes for controller pods.
61+
volumes:
62+
- name: clusterctl-config
63+
configMap:
64+
name: clusterctl-config
65+
# volumeMounts: Volume mounts for controller pods.
66+
volumeMounts:
67+
manager:
68+
- mountPath: /config
69+
name: clusterctl-config
5670

5771
# cluster-api-operator: Manages Cluster API components.
5872
cluster-api-operator:

0 commit comments

Comments
 (0)