mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-06-19 11:44:20 -04:00
[node operator] AutoscalingStrategy API gen
Signed-off-by: Malte Poll <mp@edgeless.systems>
This commit is contained in:
parent
f100febfa2
commit
ac5ddc27f2
14 changed files with 355 additions and 0 deletions
|
@ -15,4 +15,12 @@ resources:
|
||||||
kind: NodeImage
|
kind: NodeImage
|
||||||
path: github.com/edgelesssys/constellation/operators/constellation-node-operator/api/v1alpha1
|
path: github.com/edgelesssys/constellation/operators/constellation-node-operator/api/v1alpha1
|
||||||
version: v1alpha1
|
version: v1alpha1
|
||||||
|
- api:
|
||||||
|
crdVersion: v1
|
||||||
|
controller: true
|
||||||
|
domain: edgeless.systems
|
||||||
|
group: update
|
||||||
|
kind: AutoscalingStrategy
|
||||||
|
path: github.com/edgelesssys/constellation/operators/constellation-node-operator/api/v1alpha1
|
||||||
|
version: v1alpha1
|
||||||
version: "3"
|
version: "3"
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
|
||||||
|
package v1alpha1
|
||||||
|
|
||||||
|
import (
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
|
||||||
|
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
|
||||||
|
|
||||||
|
// AutoscalingStrategySpec defines the desired state of AutoscalingStrategy
|
||||||
|
type AutoscalingStrategySpec struct {
|
||||||
|
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
|
||||||
|
// Important: Run "make" to regenerate code after modifying this file
|
||||||
|
|
||||||
|
// Foo is an example field of AutoscalingStrategy. Edit autoscalingstrategy_types.go to remove/update
|
||||||
|
Foo string `json:"foo,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AutoscalingStrategyStatus defines the observed state of AutoscalingStrategy
|
||||||
|
type AutoscalingStrategyStatus struct {
|
||||||
|
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
|
||||||
|
// Important: Run "make" to regenerate code after modifying this file
|
||||||
|
}
|
||||||
|
|
||||||
|
//+kubebuilder:object:root=true
|
||||||
|
//+kubebuilder:subresource:status
|
||||||
|
//+kubebuilder:resource:scope=Cluster
|
||||||
|
|
||||||
|
// AutoscalingStrategy is the Schema for the autoscalingstrategies API
|
||||||
|
type AutoscalingStrategy struct {
|
||||||
|
metav1.TypeMeta `json:",inline"`
|
||||||
|
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||||
|
|
||||||
|
Spec AutoscalingStrategySpec `json:"spec,omitempty"`
|
||||||
|
Status AutoscalingStrategyStatus `json:"status,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//+kubebuilder:object:root=true
|
||||||
|
|
||||||
|
// AutoscalingStrategyList contains a list of AutoscalingStrategy
|
||||||
|
type AutoscalingStrategyList struct {
|
||||||
|
metav1.TypeMeta `json:",inline"`
|
||||||
|
metav1.ListMeta `json:"metadata,omitempty"`
|
||||||
|
Items []AutoscalingStrategy `json:"items"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
SchemeBuilder.Register(&AutoscalingStrategy{}, &AutoscalingStrategyList{})
|
||||||
|
}
|
|
@ -10,6 +10,95 @@ import (
|
||||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *AutoscalingStrategy) DeepCopyInto(out *AutoscalingStrategy) {
|
||||||
|
*out = *in
|
||||||
|
out.TypeMeta = in.TypeMeta
|
||||||
|
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||||
|
out.Spec = in.Spec
|
||||||
|
out.Status = in.Status
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoscalingStrategy.
|
||||||
|
func (in *AutoscalingStrategy) DeepCopy() *AutoscalingStrategy {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(AutoscalingStrategy)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||||
|
func (in *AutoscalingStrategy) DeepCopyObject() runtime.Object {
|
||||||
|
if c := in.DeepCopy(); c != nil {
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *AutoscalingStrategyList) DeepCopyInto(out *AutoscalingStrategyList) {
|
||||||
|
*out = *in
|
||||||
|
out.TypeMeta = in.TypeMeta
|
||||||
|
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||||
|
if in.Items != nil {
|
||||||
|
in, out := &in.Items, &out.Items
|
||||||
|
*out = make([]AutoscalingStrategy, len(*in))
|
||||||
|
for i := range *in {
|
||||||
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoscalingStrategyList.
|
||||||
|
func (in *AutoscalingStrategyList) DeepCopy() *AutoscalingStrategyList {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(AutoscalingStrategyList)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||||
|
func (in *AutoscalingStrategyList) DeepCopyObject() runtime.Object {
|
||||||
|
if c := in.DeepCopy(); c != nil {
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *AutoscalingStrategySpec) DeepCopyInto(out *AutoscalingStrategySpec) {
|
||||||
|
*out = *in
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoscalingStrategySpec.
|
||||||
|
func (in *AutoscalingStrategySpec) DeepCopy() *AutoscalingStrategySpec {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(AutoscalingStrategySpec)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
|
func (in *AutoscalingStrategyStatus) DeepCopyInto(out *AutoscalingStrategyStatus) {
|
||||||
|
*out = *in
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoscalingStrategyStatus.
|
||||||
|
func (in *AutoscalingStrategyStatus) DeepCopy() *AutoscalingStrategyStatus {
|
||||||
|
if in == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
out := new(AutoscalingStrategyStatus)
|
||||||
|
in.DeepCopyInto(out)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *NodeImage) DeepCopyInto(out *NodeImage) {
|
func (in *NodeImage) DeepCopyInto(out *NodeImage) {
|
||||||
*out = *in
|
*out = *in
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
---
|
||||||
|
apiVersion: apiextensions.k8s.io/v1
|
||||||
|
kind: CustomResourceDefinition
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
controller-gen.kubebuilder.io/version: v0.9.0
|
||||||
|
creationTimestamp: null
|
||||||
|
name: autoscalingstrategies.update.edgeless.systems
|
||||||
|
spec:
|
||||||
|
group: update.edgeless.systems
|
||||||
|
names:
|
||||||
|
kind: AutoscalingStrategy
|
||||||
|
listKind: AutoscalingStrategyList
|
||||||
|
plural: autoscalingstrategies
|
||||||
|
singular: autoscalingstrategy
|
||||||
|
scope: Cluster
|
||||||
|
versions:
|
||||||
|
- name: v1alpha1
|
||||||
|
schema:
|
||||||
|
openAPIV3Schema:
|
||||||
|
description: AutoscalingStrategy is the Schema for the autoscalingstrategies
|
||||||
|
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: AutoscalingStrategySpec defines the desired state of AutoscalingStrategy
|
||||||
|
properties:
|
||||||
|
foo:
|
||||||
|
description: Foo is an example field of AutoscalingStrategy. Edit
|
||||||
|
autoscalingstrategy_types.go to remove/update
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
status:
|
||||||
|
description: AutoscalingStrategyStatus defines the observed state of AutoscalingStrategy
|
||||||
|
type: object
|
||||||
|
type: object
|
||||||
|
served: true
|
||||||
|
storage: true
|
||||||
|
subresources:
|
||||||
|
status: {}
|
|
@ -3,17 +3,20 @@
|
||||||
# It should be run by config/default
|
# It should be run by config/default
|
||||||
resources:
|
resources:
|
||||||
- bases/update.edgeless.systems_nodeimages.yaml
|
- bases/update.edgeless.systems_nodeimages.yaml
|
||||||
|
- bases/update.edgeless.systems_autoscalingstrategies.yaml
|
||||||
#+kubebuilder:scaffold:crdkustomizeresource
|
#+kubebuilder:scaffold:crdkustomizeresource
|
||||||
|
|
||||||
patchesStrategicMerge:
|
patchesStrategicMerge:
|
||||||
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
|
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
|
||||||
# patches here are for enabling the conversion webhook for each CRD
|
# patches here are for enabling the conversion webhook for each CRD
|
||||||
#- patches/webhook_in_nodeimages.yaml
|
#- patches/webhook_in_nodeimages.yaml
|
||||||
|
#- patches/webhook_in_autoscalingstrategies.yaml
|
||||||
#+kubebuilder:scaffold:crdkustomizewebhookpatch
|
#+kubebuilder:scaffold:crdkustomizewebhookpatch
|
||||||
|
|
||||||
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
|
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
|
||||||
# patches here are for enabling the CA injection for each CRD
|
# patches here are for enabling the CA injection for each CRD
|
||||||
#- patches/cainjection_in_nodeimages.yaml
|
#- patches/cainjection_in_nodeimages.yaml
|
||||||
|
#- patches/cainjection_in_autoscalingstrategies.yaml
|
||||||
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
|
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
|
||||||
|
|
||||||
# the following config is for teaching kustomize how to do kustomization for CRDs.
|
# the following config is for teaching kustomize how to do kustomization for CRDs.
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
# The following patch adds a directive for certmanager to inject CA into the CRD
|
||||||
|
apiVersion: apiextensions.k8s.io/v1
|
||||||
|
kind: CustomResourceDefinition
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
|
||||||
|
name: autoscalingstrategies.update.edgeless.systems
|
|
@ -0,0 +1,16 @@
|
||||||
|
# The following patch enables a conversion webhook for the CRD
|
||||||
|
apiVersion: apiextensions.k8s.io/v1
|
||||||
|
kind: CustomResourceDefinition
|
||||||
|
metadata:
|
||||||
|
name: autoscalingstrategies.update.edgeless.systems
|
||||||
|
spec:
|
||||||
|
conversion:
|
||||||
|
strategy: Webhook
|
||||||
|
webhook:
|
||||||
|
clientConfig:
|
||||||
|
service:
|
||||||
|
namespace: system
|
||||||
|
name: webhook-service
|
||||||
|
path: /convert
|
||||||
|
conversionReviewVersions:
|
||||||
|
- v1
|
|
@ -0,0 +1,24 @@
|
||||||
|
# permissions for end users to edit autoscalingstrategies.
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRole
|
||||||
|
metadata:
|
||||||
|
name: autoscalingstrategy-editor-role
|
||||||
|
rules:
|
||||||
|
- apiGroups:
|
||||||
|
- update.edgeless.systems
|
||||||
|
resources:
|
||||||
|
- autoscalingstrategies
|
||||||
|
verbs:
|
||||||
|
- create
|
||||||
|
- delete
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
- patch
|
||||||
|
- update
|
||||||
|
- watch
|
||||||
|
- apiGroups:
|
||||||
|
- update.edgeless.systems
|
||||||
|
resources:
|
||||||
|
- autoscalingstrategies/status
|
||||||
|
verbs:
|
||||||
|
- get
|
|
@ -0,0 +1,20 @@
|
||||||
|
# permissions for end users to view autoscalingstrategies.
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRole
|
||||||
|
metadata:
|
||||||
|
name: autoscalingstrategy-viewer-role
|
||||||
|
rules:
|
||||||
|
- apiGroups:
|
||||||
|
- update.edgeless.systems
|
||||||
|
resources:
|
||||||
|
- autoscalingstrategies
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
- watch
|
||||||
|
- apiGroups:
|
||||||
|
- update.edgeless.systems
|
||||||
|
resources:
|
||||||
|
- autoscalingstrategies/status
|
||||||
|
verbs:
|
||||||
|
- get
|
|
@ -5,6 +5,32 @@ metadata:
|
||||||
creationTimestamp: null
|
creationTimestamp: null
|
||||||
name: manager-role
|
name: manager-role
|
||||||
rules:
|
rules:
|
||||||
|
- apiGroups:
|
||||||
|
- update.edgeless.systems
|
||||||
|
resources:
|
||||||
|
- autoscalingstrategies
|
||||||
|
verbs:
|
||||||
|
- create
|
||||||
|
- delete
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
- patch
|
||||||
|
- update
|
||||||
|
- watch
|
||||||
|
- apiGroups:
|
||||||
|
- update.edgeless.systems
|
||||||
|
resources:
|
||||||
|
- autoscalingstrategies/finalizers
|
||||||
|
verbs:
|
||||||
|
- update
|
||||||
|
- apiGroups:
|
||||||
|
- update.edgeless.systems
|
||||||
|
resources:
|
||||||
|
- autoscalingstrategies/status
|
||||||
|
verbs:
|
||||||
|
- get
|
||||||
|
- patch
|
||||||
|
- update
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
- update.edgeless.systems
|
- update.edgeless.systems
|
||||||
resources:
|
resources:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
## Append samples you want in your CSV to this file as resources ##
|
## Append samples you want in your CSV to this file as resources ##
|
||||||
resources:
|
resources:
|
||||||
- update_v1alpha1_nodeimage.yaml
|
- update_v1alpha1_nodeimage.yaml
|
||||||
|
- update_v1alpha1_autoscalingstrategy.yaml
|
||||||
#+kubebuilder:scaffold:manifestskustomizesamples
|
#+kubebuilder:scaffold:manifestskustomizesamples
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
apiVersion: update.edgeless.systems/v1alpha1
|
||||||
|
kind: AutoscalingStrategy
|
||||||
|
metadata:
|
||||||
|
name: autoscalingstrategy-sample
|
||||||
|
spec:
|
||||||
|
# TODO(user): Add fields here
|
|
@ -0,0 +1,47 @@
|
||||||
|
|
||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
ctrl "sigs.k8s.io/controller-runtime"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
"sigs.k8s.io/controller-runtime/pkg/log"
|
||||||
|
|
||||||
|
updatev1alpha1 "github.com/edgelesssys/constellation/operators/constellation-node-operator/api/v1alpha1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AutoscalingStrategyReconciler reconciles a AutoscalingStrategy object
|
||||||
|
type AutoscalingStrategyReconciler struct {
|
||||||
|
client.Client
|
||||||
|
Scheme *runtime.Scheme
|
||||||
|
}
|
||||||
|
|
||||||
|
//+kubebuilder:rbac:groups=update.edgeless.systems,resources=autoscalingstrategies,verbs=get;list;watch;create;update;patch;delete
|
||||||
|
//+kubebuilder:rbac:groups=update.edgeless.systems,resources=autoscalingstrategies/status,verbs=get;update;patch
|
||||||
|
//+kubebuilder:rbac:groups=update.edgeless.systems,resources=autoscalingstrategies/finalizers,verbs=update
|
||||||
|
|
||||||
|
// Reconcile is part of the main kubernetes reconciliation loop which aims to
|
||||||
|
// move the current state of the cluster closer to the desired state.
|
||||||
|
// TODO(user): Modify the Reconcile function to compare the state specified by
|
||||||
|
// the AutoscalingStrategy object against the actual cluster state, and then
|
||||||
|
// perform operations to make the cluster state reflect the state specified by
|
||||||
|
// the user.
|
||||||
|
//
|
||||||
|
// For more details, check Reconcile and its Result here:
|
||||||
|
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.11.2/pkg/reconcile
|
||||||
|
func (r *AutoscalingStrategyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
||||||
|
_ = log.FromContext(ctx)
|
||||||
|
|
||||||
|
// TODO(user): your logic here
|
||||||
|
|
||||||
|
return ctrl.Result{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetupWithManager sets up the controller with the Manager.
|
||||||
|
func (r *AutoscalingStrategyReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
||||||
|
return ctrl.NewControllerManagedBy(mgr).
|
||||||
|
For(&updatev1alpha1.AutoscalingStrategy{}).
|
||||||
|
Complete(r)
|
||||||
|
}
|
|
@ -70,6 +70,13 @@ func main() {
|
||||||
setupLog.Error(err, "unable to create controller", "controller", "NodeImage")
|
setupLog.Error(err, "unable to create controller", "controller", "NodeImage")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
if err = (&controllers.AutoscalingStrategyReconciler{
|
||||||
|
Client: mgr.GetClient(),
|
||||||
|
Scheme: mgr.GetScheme(),
|
||||||
|
}).SetupWithManager(mgr); err != nil {
|
||||||
|
setupLog.Error(err, "unable to create controller", "controller", "AutoscalingStrategy")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
//+kubebuilder:scaffold:builder
|
//+kubebuilder:scaffold:builder
|
||||||
|
|
||||||
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
|
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue