Skip to content

Commit

Permalink
keep on trucking
Browse files Browse the repository at this point in the history
  • Loading branch information
dmolik committed Jul 29, 2024
1 parent 52555c7 commit 59e477b
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 15 deletions.
54 changes: 54 additions & 0 deletions config/crd/bases/hyperspike.io_valkeys.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.15.0
name: valkeys.hyperspike.io
spec:
group: hyperspike.io
names:
kind: Valkey
listKind: ValkeyList
plural: valkeys
singular: valkey
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
description: Valkey is the Schema for the valkeys 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: ValkeySpec defines the desired state of Valkey
properties:
foo:
description: Foo is an example field of Valkey. Edit valkey_types.go
to remove/update
type: string
type: object
status:
description: ValkeyStatus defines the observed state of Valkey
type: object
type: object
served: true
storage: true
subresources:
status: {}
33 changes: 27 additions & 6 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
app.kubernetes.io/name: valkey-operator
app.kubernetes.io/managed-by: kustomize
name: manager-role
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "list", "watch"]
- apiGroups:
- hyperspike.io
resources:
- valkeys
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- hyperspike.io
resources:
- valkeys/finalizers
verbs:
- update
- apiGroups:
- hyperspike.io
resources:
- valkeys/status
verbs:
- get
- patch
- update
43 changes: 34 additions & 9 deletions internal/controller/valkey_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"

hyperspikeiov1 "hyperspike.io/valkey-operator/api/v1"
hyperv1 "hyperspike.io/valkey-operator/api/v1"
)

// ValkeyReconciler reconciles a Valkey object
Expand All @@ -49,28 +49,53 @@ type ValkeyReconciler struct {
func (r *ValkeyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
_ = log.FromContext(ctx)

valkey := &hyperv1.Valkey{}
if err := r.Get(ctx, req.NamespacedName, valkey); err != nil {
return ctrl.Result{}, client.IgnoreNotFound(err)
}

if err := r.upsertConfigMap(ctx, valkey); err != nil {
return ctrl.Result{}, err
}
if err := r.upsertService(ctx, valkey); err != nil {
return ctrl.Result{}, err
}
if err := r.upsertServiceAccount(ctx, valkey); err != nil {
return ctrl.Result{}, err
}
if err := r.upsertSecret(ctx, valkey); err != nil {
return ctrl.Result{}, err
}
if err := r.upsertStatefulSet(ctx, valkey); err != nil {
return ctrl.Result{}, err
}

return ctrl.Result{}, nil
}

func (r *ValkeyReconciler) upsertConfigMap() {

func (r *ValkeyReconciler) upsertConfigMap(ctx context.Context, valkey *hyperv1.Valkey) error {
return nil
}

func (r *ValkeyReconciler) upsertService() {

func (r *ValkeyReconciler) upsertService(ctx context.Context, valkey *hyperv1.Valkey) error {
return nil
}

func (r *ValkeyReconciler) upsertServiceAccount() {
func (r *ValkeyReconciler) upsertServiceAccount(ctx context.Context, valkey *hyperv1.Valkey) error {
return nil
}

func (r *ValkeyReconciler) upsertStatefulSet() {
func (r *ValkeyReconciler) upsertStatefulSet(ctx context.Context, valkey *hyperv1.Valkey) error {
return nil
}

func (r *ValkeyReconciler) upsertSecret() {}
func (r *ValkeyReconciler) upsertSecret(ctx context.Context, valkey *hyperv1.Valkey) error {
return nil
}

// SetupWithManager sets up the controller with the Manager.
func (r *ValkeyReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&hyperspikeiov1.Valkey{}).
For(&hyperv1.Valkey{}).
Complete(r)
}

0 comments on commit 59e477b

Please sign in to comment.