Skip to content
Merged
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
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Dev teams may of may not be granted permissions to create these objects. In case
A `NamespaceConfig` CRD looks as follows:

```yaml
apiVersion: redhat-cop.redhat.io/v1alpha1
apiVersion: redhatcop.redhat.io/v1alpha1
kind: NamespaceConfig
metadata:
name: small-size
Expand Down Expand Up @@ -50,7 +50,7 @@ oc new-project test-namespace-config
During the provisioning of the projects to dev teams some, organizations start with T-shirt sized quotas. Here is an example of how this can be done with the Namespace Configuration Controller

```yaml
apiVersion: redhat-cop.redhat.io/v1alpha1
apiVersion: redhatcop.redhat.io/v1alpha1
kind: NamespaceConfig
metadata:
name: small-size
Expand All @@ -68,7 +68,7 @@ spec:
requests.cpu: "4"
requests.memory: "2Gi"
---
apiVersion: redhat-cop.redhat.io/v1alpha1
apiVersion: redhatcop.redhat.io/v1alpha1
kind: NamespaceConfig
metadata:
name: large-size
Expand Down Expand Up @@ -104,7 +104,7 @@ In most cases isolating one project from other projects is a good way to start.
The configuration would look as follows:

```yaml
apiVersion: redhat-cop.redhat.io/v1alpha1
apiVersion: redhatcop.redhat.io/v1alpha1
kind: NamespaceConfig
metadata:
name: multitenant
Expand Down Expand Up @@ -150,7 +150,7 @@ That said limit range can still be useful to define the ratio between request an
Here is how it can be done:

```yaml
apiVersion: redhat-cop.redhat.io/v1alpha1
apiVersion: redhatcop.redhat.io/v1alpha1
kind: NamespaceConfig
metadata:
name: overcommit-limitrange
Expand Down Expand Up @@ -184,7 +184,7 @@ oc label namespace overcommit-project overcommit=limited
Another scenario is an application needs to talk to the master API and needs to specific permissions to do that. As an example, we are creating a service account with the `registry-viewer` and `registry-editor` accounts. Here is what we can do:

```yaml
apiVersion: redhat-cop.redhat.io/v1alpha1
apiVersion: redhatcop.redhat.io/v1alpha1
kind: NamespaceConfig
metadata:
name: special-sa
Expand Down Expand Up @@ -266,7 +266,7 @@ rules:
resourceNames:
- forbid-privileged-pods
---
apiVersion: redhat-cop.redhat.io/v1alpha1
apiVersion: redhatcop.redhat.io/v1alpha1
kind: NamespaceConfig
metadata:
name: unprivileged-pods
Expand Down
2 changes: 1 addition & 1 deletion deploy/crds/redhatcop_v1alpha1_namespaceconfig_cr.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: redhat-cop.redhat.io/v1alpha1
apiVersion: redhatcop.redhat.io/v1alpha1
kind: NamespaceConfig
metadata:
name: example-namespaceconfig
Expand Down
17 changes: 13 additions & 4 deletions deploy/crds/redhatcop_v1alpha1_namespaceconfig_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ spec:
plural: namespaceconfigs
singular: namespaceconfig
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
Expand All @@ -32,13 +34,20 @@ spec:
type: object
type: array
selector:
description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Important: Run "operator-sdk generate k8s" to regenerate code after
modifying this file Add custom validation using kubebuilder tags:
https://book.kubebuilder.io/beyond_basics/generating_crd.html'
type: object
type: object
status:
properties:
lastUpdate:
format: date-time
type: string
reason:
type: string
status:
enum:
- Success
- Failure
type: string
type: object
version: v1alpha1
versions:
Expand Down
2 changes: 1 addition & 1 deletion examples/multitenant-networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: redhat-cop.redhat.io/v1alpha1
apiVersion: redhatcop.redhat.io/v1alpha1
kind: NamespaceConfig
metadata:
name: multitenant
Expand Down
2 changes: 1 addition & 1 deletion examples/overcommit-limitrange.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: redhat-cop.redhat.io/v1alpha1
apiVersion: redhatcop.redhat.io/v1alpha1
kind: NamespaceConfig
metadata:
name: overcommit-limitrange
Expand Down
2 changes: 1 addition & 1 deletion examples/serviceaccount-permissions.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: redhat-cop.redhat.io/v1alpha1
apiVersion: redhatcop.redhat.io/v1alpha1
kind: NamespaceConfig
metadata:
name: special-sa
Expand Down
2 changes: 1 addition & 1 deletion examples/special-pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ rules:
resourceNames:
- forbid-privileged-pods
---
apiVersion: redhat-cop.redhat.io/v1alpha1
apiVersion: redhatcop.redhat.io/v1alpha1
kind: NamespaceConfig
metadata:
name: unprivileged-pods
Expand Down
4 changes: 2 additions & 2 deletions examples/tshirt-quotas.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: redhat-cop.redhat.io/v1alpha1
apiVersion: redhatcop.redhat.io/v1alpha1
kind: NamespaceConfig
metadata:
name: small-size
Expand All @@ -16,7 +16,7 @@ spec:
requests.cpu: "4"
requests.memory: "2Gi"
---
apiVersion: redhat-cop.redhat.io/v1alpha1
apiVersion: redhatcop.redhat.io/v1alpha1
kind: NamespaceConfig
metadata:
name: large-size
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/redhatcop/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package v1alpha1 contains API Schema definitions for the redhat-cop v1alpha1 API group
// +k8s:deepcopy-gen=package,register
// +groupName=redhat-cop.redhat.io
// +groupName=redhatcop.redhat.io
package v1alpha1
7 changes: 7 additions & 0 deletions pkg/apis/redhatcop/v1alpha1/namespaceconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type NamespaceConfigSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
// Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html

Selector metav1.LabelSelector `json:"selector,omitempty"`
Resources []runtime.RawExtension `json:"resources,omitempty"`
}
Expand All @@ -24,12 +25,18 @@ type NamespaceConfigStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
// Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html

// +kubebuilder:validation:Enum=Success,Failure
Status string `json:"status,omitempty"`
LastUpdate metav1.Time `json:"lastUpdate,omitempty"`
Reason string `json:"reason,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// NamespaceConfig is the Schema for the namespaceconfigs API
// +k8s:openapi-gen=true
// +kubebuilder:subresource:status
type NamespaceConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/redhatcop/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Package v1alpha1 contains API Schema definitions for the redhat-cop v1alpha1 API group
// +k8s:deepcopy-gen=package,register
// +groupName=redhat-cop.redhat.io
// +groupName=redhatcop.redhat.io
package v1alpha1

import (
Expand All @@ -12,7 +12,7 @@ import (

var (
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: "redhat-cop.redhat.io", Version: "v1alpha1"}
SchemeGroupVersion = schema.GroupVersion{Group: "redhatcop.redhat.io", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/redhatcop/v1alpha1/zz_generated.deepcopy.go

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

26 changes: 22 additions & 4 deletions pkg/apis/redhatcop/v1alpha1/zz_generated.openapi.go

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

Loading