Skip to content

Commit

Permalink
Merge pull request #2 from 3scale-labs/first-version-limitador-reconc…
Browse files Browse the repository at this point in the history
…iler

First version of the Limitador reconciler
  • Loading branch information
davidor authored Jan 11, 2021
2 parents a9a757e + b9e0f7d commit 8743cc6
Show file tree
Hide file tree
Showing 17 changed files with 836 additions and 0 deletions.
3 changes: 3 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ resources:
- group: limitador
kind: RateLimit
version: v1alpha1
- group: limitador
kind: Limitador
version: v1alpha1
version: 3-alpha
plugins:
go.sdk.operatorframework.io/v2-alpha: {}
67 changes: 67 additions & 0 deletions api/v1alpha1/limitador_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
Copyright 2020 Red Hat.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

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.

// LimitadorSpec defines the desired state of Limitador
type LimitadorSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// +optional
Replicas *int `json:"replicas,omitempty"`

// +optional
Version *string `json:"version,omitempty"`
}

// LimitadorStatus defines the observed state of Limitador
type LimitadorStatus 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

// Limitador is the Schema for the limitadors API
type Limitador struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec LimitadorSpec `json:"spec,omitempty"`
Status LimitadorStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// LimitadorList contains a list of Limitador
type LimitadorList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Limitador `json:"items"`
}

func init() {
SchemeBuilder.Register(&Limitador{}, &LimitadorList{})
}
99 changes: 99 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions config/crd/bases/limitador.3scale.net_limitadors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.3.0
creationTimestamp: null
name: limitadors.limitador.3scale.net
spec:
group: limitador.3scale.net
names:
kind: Limitador
listKind: LimitadorList
plural: limitadors
singular: limitador
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: Limitador is the Schema for the limitadors 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: LimitadorSpec defines the desired state of Limitador
properties:
replicas:
type: integer
version:
type: string
type: object
status:
description: LimitadorStatus defines the observed state of Limitador
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
3 changes: 3 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
# It should be run by config/default
resources:
- bases/limitador.3scale.net_ratelimits.yaml
- bases/limitador.3scale.net_limitadors.yaml
# +kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
#- patches/webhook_in_ratelimits.yaml
#- patches/webhook_in_limitadors.yaml
# +kubebuilder:scaffold:crdkustomizewebhookpatch

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

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
8 changes: 8 additions & 0 deletions config/crd/patches/cainjection_in_limitadors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
# CRD conversion requires k8s 1.13 or later.
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: limitadors.limitador.3scale.net
17 changes: 17 additions & 0 deletions config/crd/patches/webhook_in_limitadors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# The following patch enables conversion webhook for CRD
# CRD conversion requires k8s 1.13 or later.
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: limitadors.limitador.3scale.net
spec:
conversion:
strategy: Webhook
webhookClientConfig:
# this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank,
# but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager)
caBundle: Cg==
service:
namespace: system
name: webhook-service
path: /convert
24 changes: 24 additions & 0 deletions config/rbac/limitador_editor_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# permissions for end users to edit limitadors.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: limitador-editor-role
rules:
- apiGroups:
- limitador.3scale.net
resources:
- limitadors
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- limitador.3scale.net
resources:
- limitadors/status
verbs:
- get
20 changes: 20 additions & 0 deletions config/rbac/limitador_viewer_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# permissions for end users to view limitadors.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: limitador-viewer-role
rules:
- apiGroups:
- limitador.3scale.net
resources:
- limitadors
verbs:
- get
- list
- watch
- apiGroups:
- limitador.3scale.net
resources:
- limitadors/status
verbs:
- get
20 changes: 20 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ metadata:
creationTimestamp: null
name: manager-role
rules:
- apiGroups:
- limitador.3scale.net
resources:
- limitadors
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- limitador.3scale.net
resources:
- limitadors/status
verbs:
- get
- patch
- update
- apiGroups:
- limitador.3scale.net
resources:
Expand Down
1 change: 1 addition & 0 deletions config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Append samples you want in your CSV to this file as resources ##
resources:
- limitador_v1alpha1_ratelimit.yaml
- limitador_v1alpha1_limitador.yaml
# +kubebuilder:scaffold:manifestskustomizesamples
7 changes: 7 additions & 0 deletions config/samples/limitador_v1alpha1_limitador.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: limitador.3scale.net/v1alpha1
kind: Limitador
metadata:
name: limitador-sample
spec:
replicas: 1
version: latest
Loading

0 comments on commit 8743cc6

Please sign in to comment.