Skip to content

Commit

Permalink
Merge pull request #505 from alexander-demicev/etcdsnapshotrestoreapi
Browse files Browse the repository at this point in the history
Add ETCD Snapshot and Restore API skeleton
  • Loading branch information
alexander-demicev authored May 2, 2024
2 parents 13963cf + 8b876f3 commit 6eb7e3b
Show file tree
Hide file tree
Showing 16 changed files with 701 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ generate: vendor ## Run all generators
$(MAKE) vendor
$(MAKE) generate-modules
$(MAKE) generate-manifests-api
$(MAKE) generate-exp-etcdrestore-manifests-api
$(MAKE) generate-manifests-external
$(MAKE) generate-go-deepcopy
$(MAKE) vendor-clean
Expand All @@ -222,6 +223,12 @@ generate-manifests-api: controller-gen ## Generate ClusterRole and CustomResourc
output:crd:artifacts:config=./config/crd/bases \
output:rbac:dir=./config/rbac \

.PHONY: generate-exp-etcdrestore-manifests-api
generate-exp-etcdrestore-manifests-api: controller-gen ## Generate ClusterRole and CustomResourceDefinition objects for experimental API.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd paths="./exp/etcdrestore/api/..." \
output:crd:artifacts:config=./config/exp/etcdrestore/crd/bases \
output:rbac:dir=./config/exp/etcdrestore/rbac \

.PHONY: generate-modules
generate-modules: ## Run go mod tidy to ensure modules are up to date
go mod tidy
Expand All @@ -232,7 +239,8 @@ generate-go-deepcopy: ## Run deepcopy generation
$(CONTROLLER_GEN) \
object:headerFile=./hack/boilerplate.go.txt \
paths=./api/... \
paths=./internal/rancher/...
paths=./internal/rancher/... \
paths=./exp/etcdrestore/api/...

# Run go mod
.PHONY: vendor
Expand Down Expand Up @@ -495,6 +503,8 @@ release: clean-release $(RELEASE_DIR) ## Builds and push container images using
.PHONY: build-chart
build-chart: $(HELM) $(KUSTOMIZE) $(RELEASE_DIR) $(CHART_RELEASE_DIR) $(CHART_PACKAGE_DIR) ## Builds the chart to publish with a release
$(KUSTOMIZE) build ./config/chart > $(CHART_DIR)/templates/rancher-turtles-components.yaml
$(KUSTOMIZE) build ./config/exp/etcdrestore > $(CHART_DIR)/templates/rancher-turtles-exp-etcdrestore-components.yaml
./scripts/process-exp-etcdrestore-manifests.sh $(CHART_DIR)/templates/rancher-turtles-exp-etcdrestore-components.yaml
cp -rf $(CHART_DIR)/* $(CHART_RELEASE_DIR)
sed -i'' -e 's@image: .*@image: '"$(CONTROLLER_IMG)"'@' $(CHART_RELEASE_DIR)/values.yaml
sed -i'' -e 's@imageVersion: .*@imageVersion: '"$(CONTROLLER_IMAGE_VERSION)"'@' $(CHART_RELEASE_DIR)/values.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{{- if index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "enabled" }}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
name: etcdmachinesnapshots.turtles-capi.cattle.io
spec:
group: turtles-capi.cattle.io
names:
kind: EtcdMachineSnapshot
listKind: EtcdMachineSnapshotList
plural: etcdmachinesnapshots
singular: etcdmachinesnapshot
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: EtcdMachineSnapshot is the Schema for the EtcdMachineSnapshot
API.
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: EtcdMachineSnapshotSpec defines the desired state of EtcdMachineSnapshot.
properties:
foo:
type: string
required:
- foo
type: object
status:
default: {}
description: EtcdMachineSnapshotStatus defines observed state of EtcdMachineSnapshot.
properties:
bar:
type: string
required:
- bar
type: object
type: object
served: true
storage: true
subresources:
status: {}
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
name: etcdsnapshotrestores.turtles-capi.cattle.io
spec:
group: turtles-capi.cattle.io
names:
kind: EtcdSnapshotRestore
listKind: EtcdSnapshotRestoreList
plural: etcdsnapshotrestores
singular: etcdsnapshotrestore
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: EtcdSnapshotRestore is the schema for the EtcdSnapshotRestore
API.
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: EtcdSnapshotRestoreSpec defines the desired state of EtcdSnapshotRestore.
properties:
foo:
type: string
required:
- foo
type: object
status:
default: {}
description: EtcdSnapshotRestoreStatus defines observed state of EtcdSnapshotRestore.
properties:
bar:
type: string
required:
- bar
type: object
type: object
served: true
storage: true
subresources:
status: {}
{{- end }}
2 changes: 2 additions & 0 deletions charts/rancher-turtles/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ rancherTurtles:
enabled: false
propagate-labels:
enabled: false
etcd-snapshot-restore:
enabled: false
cluster-api-operator:
enabled: true
cert-manager:
Expand Down
1 change: 1 addition & 0 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ bases:
- ../rbac
- ../manager
- ../namespace
- ../exp
#- ../certmanager
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
name: etcdmachinesnapshots.turtles-capi.cattle.io
spec:
group: turtles-capi.cattle.io
names:
kind: EtcdMachineSnapshot
listKind: EtcdMachineSnapshotList
plural: etcdmachinesnapshots
singular: etcdmachinesnapshot
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: EtcdMachineSnapshot is the Schema for the EtcdMachineSnapshot
API.
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: EtcdMachineSnapshotSpec defines the desired state of EtcdMachineSnapshot.
properties:
foo:
type: string
required:
- foo
type: object
status:
description: EtcdMachineSnapshotStatus defines observed state of EtcdMachineSnapshot.
properties:
bar:
type: string
required:
- bar
type: object
type: object
served: true
storage: true
subresources:
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
name: etcdsnapshotrestores.turtles-capi.cattle.io
spec:
group: turtles-capi.cattle.io
names:
kind: EtcdSnapshotRestore
listKind: EtcdSnapshotRestoreList
plural: etcdsnapshotrestores
singular: etcdsnapshotrestore
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: EtcdSnapshotRestore is the schema for the EtcdSnapshotRestore
API.
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: EtcdSnapshotRestoreSpec defines the desired state of EtcdSnapshotRestore.
properties:
foo:
type: string
required:
- foo
type: object
status:
description: EtcdSnapshotRestoreStatus defines observed state of EtcdSnapshotRestore.
properties:
bar:
type: string
required:
- bar
type: object
type: object
served: true
storage: true
subresources:
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- op: add
path: /spec/versions/0/schema/openAPIV3Schema/properties/status/default
value: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- op: add
path: /spec/versions/0/schema/openAPIV3Schema/properties/status/default
value: {}
35 changes: 35 additions & 0 deletions config/exp/etcdrestore/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This kustomization.yaml is not intended to be run by itself,
# since it depends on service name and namespace that are out of this kustomize package.
# It should be run by config/default
resources:
- crd/bases/turtles-capi.cattle.io_etcdmachinesnapshots.yaml
- crd/bases/turtles-capi.cattle.io_etcdsnapshotrestores.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patches:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
- target:
group: apiextensions.k8s.io
version: v1
kind: CustomResourceDefinition
name: etcdmachinesnapshots.turtles-capi.cattle.io
path: crd/patches/turtles-capi.cattle.io_etcdmachinesnapshots.yaml
- target:
group: apiextensions.k8s.io
version: v1
kind: CustomResourceDefinition
name: etcdsnapshotrestores.turtles-capi.cattle.io
path: crd/patches/turtles-capi.cattle.io_etcdsnapshotrestores.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
#- path: patches/cainjection_in_capiproviders.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# [WEBHOOK] To enable webhook, uncomment the following section
# the following config is for teaching kustomize how to do kustomization for CRDs.

configurations:
- kustomizeconfig.yaml
19 changes: 19 additions & 0 deletions config/exp/etcdrestore/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This file is for teaching kustomize how to substitute name and namespace reference in CRD
nameReference:
- kind: Service
version: v1
fieldSpecs:
- kind: CustomResourceDefinition
version: v1
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/name

namespace:
- kind: CustomResourceDefinition
version: v1
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/namespace
create: false

varReference:
- path: metadata/annotations
3 changes: 3 additions & 0 deletions exp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Experimental(Technical Preview)

This is a technical preview of the experimental features that are currently being developed in the project. These features are not yet ready for production use and are subject to change.
Loading

0 comments on commit 6eb7e3b

Please sign in to comment.