Skip to content

Commit

Permalink
Creating "CBContainersCluster" api
Browse files Browse the repository at this point in the history
  • Loading branch information
BenRub committed Mar 14, 2021
1 parent 13d838a commit a2ffa69
Show file tree
Hide file tree
Showing 17 changed files with 491 additions and 0 deletions.
4 changes: 4 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ domain: operator.containers.carbonblack.io
layout: go.kubebuilder.io/v3
projectName: rega
repo: github.com/vmware/cbcontainers-operator
resources:
- crdVersion: v1
kind: CBContainersCluster
version: v1
version: 3-alpha
plugins:
manifests.sdk.operatorframework.io/v2: {}
Expand Down
64 changes: 64 additions & 0 deletions api/v1/cbcontainerscluster_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
Copyright 2021.
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 v1

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.

// CBContainersClusterSpec defines the desired state of CBContainersCluster
type CBContainersClusterSpec 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 CBContainersCluster. Edit CBContainersCluster_types.go to remove/update
Foo string `json:"foo,omitempty"`
}

// CBContainersClusterStatus defines the observed state of CBContainersCluster
type CBContainersClusterStatus 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

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

Spec CBContainersClusterSpec `json:"spec,omitempty"`
Status CBContainersClusterStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&CBContainersCluster{}, &CBContainersClusterList{})
}
36 changes: 36 additions & 0 deletions api/v1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2021.
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 v1 contains API Schema definitions for the v1 API group
// +kubebuilder:object:generate=true
// +groupName=operator.containers.carbonblack.io
package v1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "operator.containers.carbonblack.io", Version: "v1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
114 changes: 114 additions & 0 deletions api/v1/zz_generated.deepcopy.go

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

Binary file modified bin/manager
Binary file not shown.
21 changes: 21 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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:
- bases/operator.containers.carbonblack.io_cbcontainersclusters.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_cbcontainersclusters.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_cbcontainersclusters.yaml
# +kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
configurations:
- kustomizeconfig.yaml
19 changes: 19 additions & 0 deletions config/crd/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
7 changes: 7 additions & 0 deletions config/crd/patches/cainjection_in_cbcontainersclusters.yaml
Original file line number Diff line number Diff line change
@@ -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: cbcontainersclusters.operator.containers.carbonblack.io
14 changes: 14 additions & 0 deletions config/crd/patches/webhook_in_cbcontainersclusters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# The following patch enables a conversion webhook for the CRD
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: cbcontainersclusters.operator.containers.carbonblack.io
spec:
conversion:
strategy: Webhook
webhook:
clientConfig:
service:
namespace: system
name: webhook-service
path: /convert
24 changes: 24 additions & 0 deletions config/rbac/cbcontainerscluster_editor_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# permissions for end users to edit cbcontainersclusters.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: cbcontainerscluster-editor-role
rules:
- apiGroups:
- operator.containers.carbonblack.io
resources:
- cbcontainersclusters
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- operator.containers.carbonblack.io
resources:
- cbcontainersclusters/status
verbs:
- get
20 changes: 20 additions & 0 deletions config/rbac/cbcontainerscluster_viewer_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# permissions for end users to view cbcontainersclusters.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: cbcontainerscluster-viewer-role
rules:
- apiGroups:
- operator.containers.carbonblack.io
resources:
- cbcontainersclusters
verbs:
- get
- list
- watch
- apiGroups:
- operator.containers.carbonblack.io
resources:
- cbcontainersclusters/status
verbs:
- get
7 changes: 7 additions & 0 deletions config/samples/_v1_cbcontainerscluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: operator.containers.carbonblack.io/v1
kind: CBContainersCluster
metadata:
name: cbcontainerscluster-sample
spec:
# Add fields here
foo: bar
4 changes: 4 additions & 0 deletions config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Append samples you want in your CSV to this file as resources ##
resources:
- _v1_cbcontainerscluster.yaml
# +kubebuilder:scaffold:manifestskustomizesamples
Loading

0 comments on commit a2ffa69

Please sign in to comment.