Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added SupervisorSpec CRD #61

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,7 @@ tags
.idea*
.idea/*
# End of https://www.gitignore.io/api/go,vim,emacs,visualstudiocode

# dev files
cluster.yaml
supervisor-spec.yaml
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kubebuilder 3.9.1
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,19 @@ deploy-testjob: ## Run a wikipedia test pod

.PHONY: helm-install-druid-operator
helm-install-druid-operator: ## Helm install to deploy the druid operator
helm upgrade --install \
--namespace zookeeper \
--create-namespace \
zookeeper bitnami/zookeeper
helm upgrade --install \
--namespace ${NAMESPACE_DRUID_OPERATOR} \
--create-namespace \
--set auth.username=druid \
--set auth.password=druid \
--set auth.database=druid \
mysql bitnami/mysql
helm upgrade --install \
--namespace ${NAMESPACE_DRUID_OPERATOR} \
${NAMESPACE_DRUID_OPERATOR} chart/ \
--set image.repository=${IMG_KIND} \
--set image.tag=${IMG_TAG}
Expand Down
4 changes: 4 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ resources:
kind: Druid
path: github.com/datainfrahq/druid-operator/apis/druid/v1alpha1
version: v1alpha1
- group: druid
kind: SupervisorSpec
path: github.com/datainfrahq/druid-operator/apis/supervisorspec/v1alpha1
version: v1alpha1
version: "3"
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Feel free to join Kubernetes slack and join [druid-operator](https://kubernetes.
- The operator supports CR of type ```Druid```.
- ```Druid``` CR belongs to api Group ```druid.apache.org``` and version ```v1alpha1```

- The operator supports CR of type ```SupervisorSpec```.
- ```SupervisorSpec``` CR belongs to api Group ```druid.apache.org``` and version ```v1alpha1```

### Druid Operator Architecture

![Druid Operator](docs/images/druid-operator.png?raw=true "Druid Operator")
Expand Down
45 changes: 45 additions & 0 deletions apis/druid/v1alpha1/supervisorspec_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*

*/

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this and the below unnecessary comments

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does exist for the druid spec types as well, should i remove those too?

// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// SupervisorSpecSpec defines the desired state of SupervisorSpec
type SupervisorSpecSpec 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 SupervisorSpec. Edit supervisorspec_types.go to remove/update
ClusterRef string `json:"clusterRef,omitempty"`
SupervisorSpec string `json:"supervisorSpec,omitempty"`
}

//+kubebuilder:object:root=true

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

Spec SupervisorSpecSpec `json:"spec,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&SupervisorSpec{}, &SupervisorSpecList{})
}
73 changes: 73 additions & 0 deletions apis/druid/v1alpha1/zz_generated.deepcopy.go

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

47 changes: 47 additions & 0 deletions chart/templates/crds/druid.apache.org_supervisorspecs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.2
creationTimestamp: null
name: supervisorspecs.druid.apache.org
spec:
group: druid.apache.org
names:
kind: SupervisorSpec
listKind: SupervisorSpecList
plural: supervisorspecs
singular: supervisorspec
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: SupervisorSpec is the Schema for the supervisorspecs 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: SupervisorSpecSpec defines the desired state of SupervisorSpec
properties:
clusterRef:
description: Foo is an example field of SupervisorSpec. Edit supervisorspec_types.go
to remove/update
type: string
supervisorSpec:
type: string
type: object
type: object
served: true
storage: true
4 changes: 4 additions & 0 deletions chart/templates/rbac_manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ rules:
- druid.apache.org
resources:
- druids
- supervisorspecs
verbs:
- create
- delete
Expand All @@ -122,6 +123,7 @@ rules:
- druid.apache.org
resources:
- druids/status
- supervisorspecs/status
verbs:
- get
- patch
Expand Down Expand Up @@ -268,6 +270,7 @@ rules:
- druid.apache.org
resources:
- druids
- supervisorspecs
verbs:
- create
- delete
Expand All @@ -280,6 +283,7 @@ rules:
- druid.apache.org
resources:
- druids/status
- supervisorspecs/status
verbs:
- get
- patch
Expand Down
47 changes: 47 additions & 0 deletions config/crd/bases/druid.apache.org_supervisorspecs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.2
creationTimestamp: null
name: supervisorspecs.druid.apache.org
spec:
group: druid.apache.org
names:
kind: SupervisorSpec
listKind: SupervisorSpecList
plural: supervisorspecs
singular: supervisorspec
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: SupervisorSpec is the Schema for the supervisorspecs 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: SupervisorSpecSpec defines the desired state of SupervisorSpec
properties:
clusterRef:
description: Foo is an example field of SupervisorSpec. Edit supervisorspec_types.go
to remove/update
type: string
supervisorSpec:
type: string
type: object
type: object
served: true
storage: true
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/druid.apache.org_druids.yaml
- bases/druid.apache.org_supervisorspecs.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_druids.yaml
#- patches/webhook_in_supervisorspecs.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
#- patches/cainjection_in_druids.yaml
#- patches/cainjection_in_supervisorspecs.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_supervisorspecs.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: supervisorspecs.druid.apache.org
17 changes: 17 additions & 0 deletions config/crd/patches/webhook_in_supervisorspecs.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: supervisorspecs.druid.apache.org
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
Loading